protected void processFile(Reader r, int maxSample) throws Exception {
        JsonArrayChunker chunker = new JsonArrayChunker(r, executor);
        chunker.initialize();

        int counter = 0;

        Reader jsonObj = chunker.nextChunk();
        while(jsonObj != null && counter < maxSample) {

            final Reader currentObject = jsonObj;

            executor.execute(new Runnable() {
                public void run() {
                    try {
                        JsonFactory factory = new JsonFactory();
                        JsonParser parser = factory.createParser(currentObject);
                        processRecord(parser);
                    } catch(Exception e){
                        throw new RuntimeException(e);
                    }
                }
            });

            while(executor.getQueue().size() > maxWorkQueue) {
                Thread.sleep(5);
            }

            counter++;

            jsonObj.close();
            jsonObj = chunker.nextChunk();
        }

        executor.awaitSuccessfulCompletion();
    }
protected void processFile(Reader r, int maxSample) throws Exception {
        JsonArrayChunker chunker = new JsonArrayChunker(r, executor);
        chunker.initialize();

        int counter = 0;

        Reader jsonObj = chunker.nextChunk();
        while(jsonObj != null && counter < maxSample) {

            final Reader currentObject = jsonObj;

            executor.execute(new Runnable() {
                public void run() {
                    try {
                        JsonFactory factory = new JsonFactory();
                        JsonParser parser = factory.createParser(currentObject);
                        processRecord(parser);
                    } catch(Exception e){
                        throw new RuntimeException(e);
                    }
                }
            });

            while(executor.getQueue().size() > maxWorkQueue) {
                Thread.sleep(5);
            }

            counter++;

            jsonObj.close();
            jsonObj = chunker.nextChunk();
        }

        executor.awaitSuccessfulCompletion();
    }
protected void processFile ( Reader r , int maxSample ) throws Exception { JsonArrayChunker chunker = new JsonArrayChunker ( r , executor ) ; chunker . initialize ( ) ; int counter = 0 ; Reader jsonObj = chunker . nextChunk ( ) ; while ( jsonObj != null && counter < maxSample ) { final Reader currentObject = jsonObj ; executor . execute ( new Runnable ( ) { public void run ( ) { try { JsonFactory factory = new JsonFactory ( ) ; JsonParser parser = factory . createParser ( currentObject ) ; processRecord ( parser ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ) ; while ( executor . getQueue ( ) . size ( ) > maxWorkQueue ) { Thread . sleep ( 5 ) ; } counter ++ ; jsonObj . close ( ) ; jsonObj = chunker . nextChunk ( ) ; } executor . awaitSuccessfulCompletion ( ) ; }
/TODO: Many parse failures can cause out of memory errors.
/ TODO : Many parse failures can cause out of memory errors .