@Test public void testBatchProcessing() throws Exception{ BatchDatabaseCollectionReader reader = (BatchDatabaseCollectionReader) new BatchDatabaseCollectionReader(dbConnectionInfo, new DataQueryInformation(query, "note", "id"), MIN_RECORD_NUMBER, TEST_CORPUS_SIZE, BATCH_SIZE) .produceCollectionReader(); assertNotNull(reader); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine( SampleService.simpleServiceDefinition() .getAnalysisEngineDescription() ); CAS mockCas; FSIterator<AnnotationFS> csiIterator; CSI csi; for(int i = 10; i < (TEST_CORPUS_SIZE+10); i++) { mockCas = ae.newCAS(); if(reader.hasNext()) { reader.getNext(mockCas); csiIterator = mockCas.getAnnotationIndex(mockCas.getTypeSystem().getType(CSI.class.getCanonicalName())).iterator(); assertTrue(csiIterator.hasNext()); csi = (CSI) csiIterator.next(); assertEquals("Expected : " + i + ", but got: " + csi.getID(), csi.getID(), "" + i); } } }
@Override public boolean hasNext() throws CollectionException { while(mRecordList == null || !super.hasNext()) { if(isRandom && randomBatches > 0) { this.query = getQuery(getNextRandomBatchNumber()); randomBatches--; } else if(currentBatch < totalNumberOfBatches) { this.query = getQuery(currentBatch); currentBatch++; } else { return false; } getData(query); } return true; }
BatchDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { while(mRecordList == null || !super.hasNext()) { if(isRandom && randomBatches > 0) { this.query = getQuery(getNextRandomBatchNumber()); randomBatches--; } else if(currentBatch < totalNumberOfBatches) { this.query = getQuery(currentBatch); currentBatch++; } else { return false; } getData(query); } return true; } }
BatchDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { while(mRecordList == null || !super.hasNext()) { if(isRandom && randomBatches > 0) { this.query = getQuery(getNextRandomBatchNumber()); randomBatches--; } else if(currentBatch < totalNumberOfBatches) { this.query = getQuery(currentBatch); currentBatch++; } else { return false; } getData(query); } return true; } BatchDatabaseCollectionReader();  BatchDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                         DataQueryInformation dataQueryInformation,
                                         int minRecordNumber,
                                         int maxRecordNumber,
                                         int batchSize);  BatchDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                         String idColumn, String noteColumn,
                                         int minRecordNumber, int maxRecordNumber, int batchSize); }
BatchDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { while(mRecordList == null || !super.hasNext()) { if(isRandom && randomBatches > 0) { this.query = getQuery(getNextRandomBatchNumber()); randomBatches--; } else if(currentBatch < totalNumberOfBatches) { this.query = getQuery(currentBatch); currentBatch++; } else { return false; } getData(query); } return true; } BatchDatabaseCollectionReader();  BatchDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                         DataQueryInformation dataQueryInformation,
                                         int minRecordNumber,
                                         int maxRecordNumber,
                                         int batchSize);  BatchDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                         String idColumn, String noteColumn,
                                         int minRecordNumber, int maxRecordNumber, int batchSize); int getMinRecordNumber(); BatchDatabaseCollectionReader setMinRecordNumber(int minRecordNumber); int getMaxRecordNumber(); BatchDatabaseCollectionReader setMaxRecordNumber(int maxRecordNumber); int getBatchSize(); BatchDatabaseCollectionReader setBatchSize(int batchSize); int getRandomBatches(); BatchDatabaseCollectionReader setRandomBatches(int randomBatches); @Override void initialize(); @Override boolean hasNext(); }
BatchDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { while(mRecordList == null || !super.hasNext()) { if(isRandom && randomBatches > 0) { this.query = getQuery(getNextRandomBatchNumber()); randomBatches--; } else if(currentBatch < totalNumberOfBatches) { this.query = getQuery(currentBatch); currentBatch++; } else { return false; } getData(query); } return true; } BatchDatabaseCollectionReader();  BatchDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                         DataQueryInformation dataQueryInformation,
                                         int minRecordNumber,
                                         int maxRecordNumber,
                                         int batchSize);  BatchDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                         String idColumn, String noteColumn,
                                         int minRecordNumber, int maxRecordNumber, int batchSize); int getMinRecordNumber(); BatchDatabaseCollectionReader setMinRecordNumber(int minRecordNumber); int getMaxRecordNumber(); BatchDatabaseCollectionReader setMaxRecordNumber(int maxRecordNumber); int getBatchSize(); BatchDatabaseCollectionReader setBatchSize(int batchSize); int getRandomBatches(); BatchDatabaseCollectionReader setRandomBatches(int randomBatches); @Override void initialize(); @Override boolean hasNext();  }