Search Results

Search found 214 results on 9 pages for 'kai wang'.

Page 6/9 | < Previous Page | 2 3 4 5 6 7 8 9  | Next Page >

  • What is the "task" in twitter Storm parallelism

    - by John Wang
    I'm trying to learn twitter storm by following the great article "Understanding the parallelism of a Storm topology" However I'm a bit confused by the concept of "task". Is a task an running instance of the component(spout or bolt) ? A executor having multiple tasks actually is saying the same component is executed for multiple times by the executor, am I correct ? Moreover in a general parallelism sense, Storm will spawn a dedicated thread(executor) for a spout or bolt, but what is contributed to the parallelism by an executor(thread) having multiple tasks ? I think having multiple tasks in a thread, since a thread executes sequentially, only make the thread a kind of "cached" resource, which avoids spawning new thread for next task run. Am I correct? I may clear those confusion by myself after taking more time to investigate, but you know, we both love stackoverflow ;-) Thanks in advance.

    Read the article

  • What (tf) are the secrets behind PDF memory allocation (CGPDFDocumentRef)

    - by Kai
    For a PDF reader I want to prepare a document by taking 'screenshots' of each page and save them to disc. First approach is CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef) someURL); for (int i = 1; i<=pageCount; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; CGPDFPageRef page = CGPDFDocumentGetPage(document, i); ...//getting + manipulating graphics context etc. ... CGContextDrawPDFPage(context, page); ... UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); ...//saving the image to disc [pool drain]; } CGPDFDocumentRelease(document); This results in a lot of memory which seems not to be released after the first run of the loop (preparing the 1st document), but no more unreleased memory in additional runs: MEMORY BEFORE: 6 MB MEMORY DURING 1ST DOC: 40 MB MEMORY AFTER 1ST DOC: 25 MB MEMORY DURING 2ND DOC: 40 MB MEMORY AFTER 2ND DOC: 25 MB .... Changing the code to for (int i = 1; i<=pageCount; i++) { CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef) someURL); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; CGPDFPageRef page = CGPDFDocumentGetPage(document, i); ...//getting + manipulating graphics context etc. ... CGContextDrawPDFPage(context, page); ... UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); ...//saving the image to disc CGPDFDocumentRelease(document); [pool drain]; } changes the memory usage to MEMORY BEFORE: 6 MB MEMORY DURING 1ST DOC: 9 MB MEMORY AFTER 1ST DOC: 7 MB MEMORY DURING 2ND DOC: 9 MB MEMORY AFTER 2ND DOC: 7 MB .... but is obviously a step backwards in performance. When I start reading a PDF (later in time, different thread) in the first case no more memory is allocated (staying at 25 MB), while in the second case memory goes up to 20 MB (from 7). In both cases, when I remove the CGContextDrawPDFPage(context, page); line memory is (nearly) constant at 6 MB during and after all preparations of documents. Can anybody explain whats going on there?

    Read the article

  • Release an object without a pointer?

    - by Kai Friis
    I’ve just started developing for iPhone and am trying to get my head around memory management. I made a small program that shows a map and an annotation on the map. For the annotation I made a simple class that implements the MKAnnotation protocol. To create and add the annotation I wrote this: [self.myMapView addAnnotation:[[MyAnnotation alloc] init]]; It worked fine until I tried to release the object. Nothing to release. This is what I would have done in C#, I guess it doesn’t work without garbage collection? So is this the only way to do it? MyAnnotation *myAnnotation = [[MyAnnotation alloc] init]; [self.myMapView addAnnotation: myAnnotation]; [myAnnotation release];

    Read the article

  • Can I force WPF rendering tier?

    - by Kai Wang
    Is there any way I can force WPF rendering tiers mentioned here? http://msdn.microsoft.com/en-us/library/ms742196.aspx For example I am on tier 2, but I want to simulate the application in tier 1 or 0 scenario.

    Read the article

  • How to save event handlers, when we set new html for element?

    - by Kai
    I have simple html markup: <div id="cont">Some text here <div class="wrap" style="border: 1px solid black;display: inline;"> block element here </div> and another text</div> And jQuery code: $(function(){ $(".wrap").click(function(){ $("#cont").html($("#cont").html().replace(/text/g, "letter")); alert("Click!"); }); $("#d1").click(function(){ alert("#d1 clicked!"); }); }); I expect that click event will be fire any time you clicked by the #d1 div, but when we clicked by .wrap it neve fire again. I understand why it has such behavior, but how to solve it? In my code I can't set click event for #d1 after $("#cont").html($("#cont").html().replace(/text/g, "letter")) because I don't now at execution time if event was set. You can try example on JSBin

    Read the article

  • (Weak) ETags and Last-Modified

    - by Kai Moritz
    As far as I understand the specs, the ETag, which was introduced in RFC 2616 (HTTP/1.1) is a predecessor of the Last-Modified-Header, which is proposet to give the software-architect more controll over the cache-revalidating process. If both Cache-Validation-Headers (If-None-Match and If-Modified-Since) are present, according to RFC 2616, the client (i.e. the browser) should use the ETag when checking, if a resource has changed. According to section 14.26 of RFC 2616, the server MUST NOT respond with a 304 Not Modified, if the ETag presented in a If-None-Match-Header has changed, and the server has to ignore an additional If-Modified-Since-Header, if present. If the presented ETag matches, he MUST NOT perform the request, unless the Date in the Last-Modified-Header says so. (If the presented ETag matches, the server should respond with a 304 Not Modified in case of a GET- or HEAD-request...) This section leaves room for some speculations: A strong ETag is supposed to change ''everytime'', the resource changes. So, having to responde with something else as 304 Not Modified to a request with an unchanged ETag and an If-Modified-Since-Header, which dose not match is a bit of a contradiction, because the strong ETag says, that the resource was not modified. (Though, this is not that fatal, because the server can send the same unchanged resource again.) ... ... o.k. While I was writing this, the question was boiling down to this answer: The (small) contradiction stated above, was made because of Weak ETags. A resource marked with a Weak ETag may have changed, although the ETag has not. So, in case of a Weak ETag it would be wrong, to answer with 304 Not Modified, when the ETag has not changed, but the date presented in the If-Modified-Since does not match, right?

    Read the article

  • Listfield layout question - blackberry

    - by Kai
    I'm having an interesting anomaly when displaying a listfield on the blackberry simulator: The top item is the height of a single line of text (about 12 pixels) while the rest are fine. Does anyone know why only the top item is being drawn this way? Also, when I add an empty venue in position 0, it still displays the first actual venue this way (item in position 1). Not sure what to do. Thanks for any help. The layout looks like this: ----------------------------------- | *part of image* | title | ----------------------------------- | | title | | * full image * | address | | | city, zip | ----------------------------------- The object is called like so: listField = new ListField( venueList.size() ); listField.setCallback( this ); listField.setSelectedIndex(-1); _middle.add( listField ); Here is the drawListRow code: public void drawListRow( ListField listField, Graphics graphics, int index, int y, int width ) { listField.setRowHeight(90); Hashtable item = (Hashtable) venueList.elementAt( index ); String venue_name = (String) item.get("name"); String image_url = (String) item.get("image_url"); String address = (String) item.get("address"); String city = (String) item.get("city"); String zip = (String) item.get("zip"); EncodedImage img = null; try { String filename = image_url.substring( image_url.indexOf("crop/") + 5, image_url.length() ); FileConnection fconn = (FileConnection) Connector.open( "file:///SDCard/Blackberry/project1/" + filename, Connector.READ); if ( !fconn.exists() ) { } else { InputStream input = fconn.openInputStream(); byte[] data = new byte[(int)fconn.fileSize()]; input.read(data); input.close(); if(data.length > 0) { EncodedImage rawimg = EncodedImage.createEncodedImage(data, 0, data.length); int dw = Fixed32.toFP(Display.getWidth()); int iw = Fixed32.toFP(rawimg.getWidth()); int sf = Fixed32.div(iw, dw); img = rawimg.scaleImage32(sf * 4, sf * 4); } else { } } } catch(IOException ef) { } graphics.drawText( venue_name, 140, y, 0, width ); graphics.drawText( address, 140, y + 15, 0, width ); graphics.drawText( city + ", " + zip, 140, y + 30, 0, width ); if(img != null) { graphics.drawImage(0, y, img.getWidth(), img.getHeight(), img, 0, 0, 0); } }

    Read the article

  • idiomatic way to take groups of n items from a list in Python?

    - by Wang
    Given a list A = [1 2 3 4 5 6] Is there any idiomatic (Pythonic) way to iterate over it as though it were B = [(1, 2) (3, 4) (5, 6)] other than indexing? That feels like a holdover from C: for a1,a2 in [ (A[i], A[i+1]) for i in range(0, len(A), 2) ]: I can't help but feel there should be some clever hack using itertools or slicing or something. (Of course, two at a time is just an example; I'd like a solution that works for any n.) Edit: related http://stackoverflow.com/questions/1162592/iterate-over-a-string-2-or-n-characters-at-a-time-in-python but even the cleanest solution (accepted, using zip) doesn't generalize well to higher n without a list comprehension and *-notation.

    Read the article

  • simple proof that GUID is not unique

    - by Kai
    I'd like to prove that a GUID is not unique in a simple test program. I expected this to run for hours but it's not working. How can I make it work? BigInteger begin = new BigInteger((long)0); BigInteger end = new BigInteger("340282366920938463463374607431768211456",10); //2^128 for(begin; begin<end; begin++) Console.WriteLine(System.Guid.NewGuid().ToString()); I'm using C#

    Read the article

  • Can no longer debug ActiveX controls in Visual Studio 2008

    - by Phenglei Kai
    For a long time I would throw up a DebugBreak() or ASSERT(false) in the startup code of my ActiveX control, load up IE, go to a localhost page hosting my control, wait for the dialog to show up, then debug my application. I could also launch it under the debugger by setting IE as the container. I tried again for the first time in 2 months and now this no longer works. If I use the ASSERT(false) method, when I get the Visual C++ Debug dialog and click "retry", IE simply closes without any debugger activity. When I try launching from VS2008 and hoping the DebugBreak() will kick in after I load the page, VS2008 does break, but it says either the "RPC Server is Unavailable" or the "RPC Client Call failed." I am never allowed to have my application in the debugger and it doesn't show up in the modules list of VS. The stack trace in VS2008 only contains Microsoft DLLs and modules and not a hint of my code. I assume it's something I've picked up through Windows Update that broke this. Has anyone else ever seen this issue and know how to make it go away? As it stands, I'm now completely unable to debug my ActiveX control.

    Read the article

  • Threads are blocked in malloc and free, virtual size

    - by Albert Wang
    Hi, I'm running a 64-bit multi-threaded program on the windows server 2003 server (X64), It run into a case that some of the threads seem to be blocked in the malloc or free function forever. The stack trace is like follows: ntdll.dll!NtWaitForSingleObject() + 0xa bytes ntdll.dll!RtlpWaitOnCriticalSection() - 0x1aa bytes ntdll.dll!RtlEnterCriticalSection() + 0xb040 bytes ntdll.dll!RtlpDebugPageHeapAllocate() + 0x2f6 bytes ntdll.dll!RtlDebugAllocateHeap() + 0x40 bytes ntdll.dll!RtlAllocateHeapSlowly() + 0x5e898 bytes ntdll.dll!RtlAllocateHeap() - 0x1711a bytes MyProg.exe!malloc(unsigned __int64 size=0) Line 168 C MyProg.exe!operator new(unsigned __int64 size=1) Line 59 + 0x5 bytes C++ ntdll.dll!NtWaitForSingleObject() ntdll.dll!RtlpWaitOnCriticalSection() ntdll.dll!RtlEnterCriticalSection() ntdll.dll!RtlpDebugPageHeapFree() ntdll.dll!RtlDebugFreeHeap() ntdll.dll!RtlFreeHeapSlowly() ntdll.dll!RtlFreeHeap() MyProg.exe!free(void * pBlock=0x000000007e8e4fe0) C BTW, the param values passed to the new operator is not correct here maybe due to optimization. Also, at the same time, I found in the process Explorer, the virtual size of this program is 10GB, but the private bytes and working set is very small (<2GB). We did have some threads using virtualalloc but in a way that commit the memory in the call, and these threads are not blocked. m_pBuf = VirtualAlloc(NULL, m_size, MEM_COMMIT, PAGE_READWRITE); ...... VirtualFree(m_pBuf, 0, MEM_RELEASE); This looks strange to me, seems a lot of virtual space is reserved but not committed, and malloc/free is blocked by lock. I'm guessing if there's any corruptions in the memory/object, so plan to turn on gflag with pageheap to troubleshoot this. Does anyone has similar experience on this before? Could you share with me so I may get more hints? Thanks a lot!

    Read the article

  • Testing on blackberry device - adding and removing app multiple times

    - by Kai
    It would be useful for many people to know how to completely remove an application from your device when testing. I have downloaded my app many times now, and likewise have deleted it many times. The problem is when deleting the app, it does not remove things like the persistent object related to my app, or the images downloaded through the app. So, when I download the next build, I have no idea if something broke that is related to building the persistent object or fetching the images since those elements already exist from the last build. I don't know if this is a cache thing. I don't know if this is expected and I have to use some utility to wipe this data after deleting the app. I can't really find much info through basic web searches. Any information would be appreciated. Blackberry Bold 9000. 4.6 OS. tested with both SD card and no SD card.

    Read the article

  • How can I split the suckerfish Menu into two pieces so that I can put it in two frame?

    - by Kai
    I found a tutorial for developing multi-level drop down menu here.Its demo can be checked at www.kriesi.at/wp-content/extra_data/suckerfish_tutorial/step4.html#. I would like to enhance it to support cross-frames . It means, the horizontal part of the whole menu (html,css,javascript etc..in demo page) will exist in the upper frame and the rest will be put in the lower frame. Edit: There will be only one menu item in the horizontal part. It will be still ok if I can click that menu_item rather than mouse-hovering to show the lower part of the menu . Any idea will be appreciated. Thanks.

    Read the article

  • what changes when your input is giga/terabyte sized?

    - by Wang
    I just took my first baby step today into real scientific computing today when I was shown a data set where the smallest file is 48000 fields by 1600 rows (haplotypes for several people, for chromosome 22). And this is considered tiny. I write Python, so I've spent the last few hours reading about HDF5, and Numpy, and PyTable, but I still feel like I'm not really grokking what a terabyte-sized data set actually means for me as a programmer. For example, someone pointed out that with larger data sets, it becomes impossible to read the whole thing into memory, not because the machine has insufficient RAM, but because the architecture has insufficient address space! It blew my mind. What other assumptions have I been relying in the classroom that just don't work with input this big? What kinds of things do I need to start doing or thinking about differently? (This doesn't have to be Python specific.)

    Read the article

  • Does it mean JVM Suspended?

    - by Joe.wang
    When my application run . I got a message says : Ping: Timed out waiting for signal from JVM. The JVM was launched with debug options so this may be because the JVM is currently suspended by a debugger. Any future timeouts during this JVM invocation will be silently ignored. What does that mean? It seems it will block any web request from outside? because when I upload a file to it, it failed. help me .

    Read the article

  • Proper usage of Java Weak Reference in case of nested collections

    - by Tong Wang
    I need to define a weak reference Map, whose value is a Set. I use Google collections' MapMaker, like this: Map<Class<? extends Object>, Set<Foo>> map = new MapMaker().weakKeys().weakValues().makeMap(); So, for Set<Foo>, can I use a normal HashSet? Or, do I have to create a weak HashSet, like this: Collections.newSetFromMap(new WeakHashMap<Foo, Boolean>()); And why? Another question, the key of my map is Class objects, when will a Class object become weakly reachable? In other words, what is the lifetime of a Class object? Thanks.

    Read the article

  • Remove trailing letters at the end of string

    - by wang
    I have some strings like below: ffffffffcfdeee^dddcdeffffffffdddcecffffc^cbcb^cb`cdaba`eeeeeefeba[NNZZcccYccaccBBBBBBBBBBBBBBBBBBBBBB eedeedffcc^bb^bccccbadddba^cc^e`eeedddda`deca_^^\```a```^b^`I^aa^bb^`_b\a^b```Y_\`b^`aba`cM[SS\ZY^BBB Each string MAY (or may not) end with a stretch of trailing "B" of varied length. I'm just wondering if we can simply use bash code to remove the "B" stretch? thx

    Read the article

  • How to build where clause in MS SQL??

    - by Kai
    I would like to build the where clase of sql statement dynamatically from hashtable in C#. The key of the hash_table will be the column's name to be inserted and the value of hash_table will be value. string sql_1="SELECT COL_1,COL_2 FROM MY_TABLE"; string sql_2="SELECT * FROM MY_TABLE WHERE COL_3='ABC'"; //note: some statment have where clause while some do NOT have. string sql= ToSql(sql_1,myHashTable); // the actual sql statment will be returned from ToSql //execute sql sql= ToSql(sql_2,myHashTable); // //execute sql My Question is, how can I create function ToSql() function in LINQ? NOTE: The data type of the value of hashtable will be taken into consideration. Thanks in advance.

    Read the article

  • Flex: Scale an Image so that its width matches contentWidth?

    - by Tong Wang
    I have a dynamic layout, where an image is loaded into an HBox: <mx:HBox ...> <mx:Image height="100%" .../> </mx:HBox> only the image's height is set on the image, so that it can take all the vertical space available, while its width is left undefined and I expect the width to scale accordingly with its height. It turns out that the image's height is equal to its contentHeight, i.e. height scales properly; however, the image's width is still the same as measuredWidth (the image's original width), and is not scaled accordingly. For example, if the image's original size is 800x600 and if the HBox is 300 in height, then image height will scale down to 300, however its width doesn't scale down to 400, instead it stays at 800. I tried to add an event listener to explicitly set the image width: <mx:Image id="img" height="100%" updateComplete="img.width=img.contentWidth;" .../> It works only the first time the image is loaded, after that, if I use Image.load() to dynamically load different images, it stops working - the image width is set to 0. Any help/advice will be highly appreciated.

    Read the article

  • how is a macro expanded in clojure?

    - by john wang
    In the book Programming Clojure(Stuart), when read how macros are expanded I got confused. user=> (defmacro chain ([x form] (list '. x form)) ([x form & more] (concat (list 'chain (list '. x form)) more))) #'user/chain The above macro can be expanded as: user=> (macroexpand '(chain a b c)) (. (. a b) c) But the following is only expanded to the first level: user=> (macroexpand '(and a b c)) (let* [and__3822__auto__ a] (if and__3822__auto__ (clojure.core/and b c) and__3822__auto__)) The and macro source: user=> (source and) (defmacro and([] true) ([x] x) ([x & next] `(let [and# ~x] (if and# (and ~@next) and#)))) Why is the chain macro expanded all the way but the and not ? Why is it not expanded to something like the following: user=> (macroexpand '(chain a b c d)) (. (chain a b c) d)

    Read the article

  • What is the best way to use Unicode in C++ on iPhone?

    - by Olli Wang
    Hi, I want to create my C++ libraries with Unicode support so they can be reused on other platforms. I have found the ICU (International Components for Unicode) project but I also found a discuss about Apple rejecting for using ICU (see http://tinyurl.com/y86phfb). So how do you guys use Unicode in C++ on iPhone? Thanks.

    Read the article

  • Problem with index server talking to remote server names with dashes or dots in them

    - by Aim Kai
    Hi I am having a problem, accessing a remote index server catalog. The name of the server has - in it, so i put the index catalog name as: i.e num.num.num.num\name of catalog or an-example-server I get the following error when using an ole data connection to pull results from the index: "Format of the initialization string does not conform to specification starting at index 39" I tried putting single quotes and &qoute; with no luck - anyone have idea? PS. This Microsoft Index Server Question!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9  | Next Page >