public class BatchDatabaseCollectionReader extends DatabaseCollectionReader
Modifier and Type | Field and Description |
---|---|
protected String |
baseQuery
Query template that will be filled in with min and max values for each batch .
|
protected int |
batchSize
Size of each batch to pull.
|
protected int |
currentBatch
Current batch number we are executing.
|
protected boolean |
isRandom
True if we are pulling random batches.
|
protected int |
maxRecordNumber
Max record ID.
|
protected int |
minRecordNumber
Min record ID.
|
protected int |
randomBatches
Number of random batches to pull.
|
protected static SecureRandom |
secureRandom
Generates the random batch number if random batches are indicated.
|
protected int |
totalNumberOfBatches
Total number of batches available to be executed in the table.
|
protected HashSet<Integer> |
usedBatches
Store the batch numbers already visited when executing random batches.
|
idColumn, noteColumn, query
dataManager, driver, mRecordList, mRowIndex, password, url, username
filters, textFilters
Constructor and Description |
---|
BatchDatabaseCollectionReader()
Default constructor used during UIMA initialization.
|
BatchDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
DataQueryInformation dataQueryInformation,
int minRecordNumber,
int maxRecordNumber,
int batchSize)
Initialize the reader using the database connection and query information provided, including the size of each
batch and optionally the number of random batches to execute.
|
BatchDatabaseCollectionReader(String driver,
String url,
String username,
String password,
String query,
String idColumn,
String noteColumn,
int minRecordNumber,
int maxRecordNumber,
int batchSize)
Initialize the reader using the provided connection and query information, including the size of each batch and
optionally the number of random batches to execute.
|
Modifier and Type | Method and Description |
---|---|
int |
getBatchSize()
Get the batch size.
|
int |
getMaxRecordNumber()
Return the maximum row number.
|
int |
getMinRecordNumber()
Return the minumum row number.
|
protected int |
getNextRandomBatchNumber()
Get the next unused random batch number to pull.
|
protected String |
getQuery(int batch)
Does a string substitution on the query, replacing {min} and {max} with the appropriate
values for this batch.
|
int |
getRandomBatches()
Get the number of random batches, defaults to zero.
|
boolean |
hasNext() |
void |
initialize()
This method is called during initialization.
|
BatchDatabaseCollectionReader |
setBatchSize(int batchSize)
Set the batch size.
|
BatchDatabaseCollectionReader |
setMaxRecordNumber(int maxRecordNumber)
Set the maximum row number.
|
BatchDatabaseCollectionReader |
setMinRecordNumber(int minRecordNumber)
Set the minimum row number.
|
BatchDatabaseCollectionReader |
setRandomBatches(int randomBatches)
Set the number of random batches.
|
protected void |
validateParams(int minRecordNumber,
int maxRecordNumber,
int batchSize)
Validate the parameters that will initialize this object.
|
getData, getIdColumn, getNext, getNoteColumn, getProgress, getQuery, setIdColumn, setNoteColumn, setQuery, validateParams
getDataManager, getDriver, getPassword, getURL, getUsername, setDriver, setPassword, setURL, setUsername
addFilters, addFilters, close, generateCollectionReaderDescription, getFilters, produceCollectionReader
destroy, getCasInitializer, getProcessingResourceMetaData, initialize, isConsuming, reconfigure, setCasInitializer, typeSystemInit
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
getCasManager, getLogger, getMetaData, getResourceManager, getUimaContext, getUimaContextAdmin, setLogger, setMetaData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
@LeoConfigurationParameter(mandatory=true) protected int minRecordNumber
@LeoConfigurationParameter(mandatory=true) protected int maxRecordNumber
@LeoConfigurationParameter(mandatory=true) protected int batchSize
@LeoConfigurationParameter protected int randomBatches
protected String baseQuery
protected int totalNumberOfBatches
protected int currentBatch
protected boolean isRandom
protected HashSet<Integer> usedBatches
protected static final SecureRandom secureRandom
public BatchDatabaseCollectionReader()
public BatchDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation, DataQueryInformation dataQueryInformation, int minRecordNumber, int maxRecordNumber, int batchSize)
databaseConnectionInformation
- database connection information to use.dataQueryInformation
- database query for retrieving results, assumes one record per row.minRecordNumber
- starting row number for record retrieval.maxRecordNumber
- ending row number for record retrieval.batchSize
- size of each batch to retrieve at a time. Optimal size will vary with the database environment.public BatchDatabaseCollectionReader(String driver, String url, String username, String password, String query, String idColumn, String noteColumn, int minRecordNumber, int maxRecordNumber, int batchSize)
driver
- JDBC driver classurl
- JDBC connection URLusername
- database user name.password
- database user password.query
- SQL query used to retrieve the data, one record per row of results.idColumn
- name of the ID column in the SQL query. Assumes only one column to use as the record ID.
Additional ID fields are propagated through the row results String array of the CSI annotation.noteColumn
- name of the note column in the SQL query. Assumes only one note column.minRecordNumber
- starting row number for record retrieval.maxRecordNumber
- ending row number for record retrieval.batchSize
- size of each batch to retrieve at a time. Optimal size will vary with the database environment.public int getMinRecordNumber()
public BatchDatabaseCollectionReader setMinRecordNumber(int minRecordNumber)
minRecordNumber
- minimum row numberpublic int getMaxRecordNumber()
public BatchDatabaseCollectionReader setMaxRecordNumber(int maxRecordNumber)
maxRecordNumber
- max row numberpublic int getBatchSize()
public BatchDatabaseCollectionReader setBatchSize(int batchSize)
batchSize
- batch sizepublic int getRandomBatches()
public BatchDatabaseCollectionReader setRandomBatches(int randomBatches)
randomBatches
- number of random batchesprotected void validateParams(int minRecordNumber, int maxRecordNumber, int batchSize)
minRecordNumber
- Minimum record ID where processing will startmaxRecordNumber
- Maximum record ID where processing will startbatchSize
- Size of each batch to be executedpublic void initialize() throws org.apache.uima.resource.ResourceInitializationException
initialize
in class BaseLeoCollectionReader
org.apache.uima.resource.ResourceInitializationException
- if a failure occurs during initialization.public boolean hasNext() throws org.apache.uima.collection.CollectionException
hasNext
in interface org.apache.uima.collection.base_cpm.BaseCollectionReader
hasNext
in class DatabaseCollectionReader
org.apache.uima.collection.CollectionException
protected int getNextRandomBatchNumber()
protected String getQuery(int batch)
batch
- the batch number being queried.Copyright © 2018 Department of Veterans Affairs. All Rights Reserved.