public class PositionBatcher extends AbstractBatcher
Normally this means linking a position to a reporter.
Code example: Dynamic API - Creating a root bioassayset
BioAssaySet.getPositionBatcher()
Modifier and Type | Field and Description |
---|---|
private long |
bytes
The number of bytes this batcher has added to the data cube and
experiment.
|
private long |
bytesPerRow
The number of bytes used by a single row.
|
private DataCube |
dataCube
The datacube this batcher inserts data for.
|
private int |
maxPosition
The maximum position number inserted by the batcher.
|
private java.sql.PreparedStatement |
positionSql
The statement that inserts the position/reporter link.
|
private java.lang.String |
positionSqlStatement
The SQL string for the
positionSql statement. |
private int |
queuedInsertCount
The number of queued inserts.
|
private int |
totalInsertCount
The total number of inserts done by this batcher.
|
debugSqlEnabled, logSql
Constructor and Description |
---|
PositionBatcher(DbControl dc,
DataCube dataCube)
Create a new position batcher for a data cube.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
buildInsertSelectSql(java.lang.String selectSql)
Build the INSERT INTO ...
|
private void |
buildPositionSql()
Builds the insert SQL statement.
|
void |
flush()
Flush the batcher and send all remaining items in memory to the
database.
|
int |
insert(AbstractSqlQuery query)
Insert position/reporter links using a query.
|
void |
insert(int position,
ReporterData reporter)
Link a position to a reporter.
|
(package private) void |
onBeforeClose()
Update bytes and max position on the datacube and close
open SQL statements.
|
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
private final DataCube dataCube
private int queuedInsertCount
private int totalInsertCount
private int maxPosition
private long bytes
private final long bytesPerRow
private java.sql.PreparedStatement positionSql
INSERT INTO Dynamic#PerPosition (cube, position, reporter_id) VALUES (cube, ?, ?)
private java.lang.String positionSqlStatement
positionSql
statement.public void flush() throws BaseException
Batcher
BaseException
- If there is an errorBatcher.close()
void onBeforeClose() throws BaseException
onBeforeClose
in class AbstractBatcher
BaseException
public void insert(int position, ReporterData reporter) throws BaseException
position
- The position coordinatereporter
- The reporter or null if no reporter is knownBaseException
- If there is an errorpublic int insert(AbstractSqlQuery query) throws BaseException
Internally this method converts the query into a
INSERT INTO ... SELECT ...
query, making it very fast,
since the data for each position doesn't have to be retreived, processed and
then inserted one row at a time. It is possible to call
this method multiple times with the same or different query.
query
- The query that selects the data to be insertedBaseException
- If there is an errorprivate void buildPositionSql() throws java.sql.SQLException, BaseException
java.sql.SQLException
BaseException
BatchUtil.buildInsertSql(VirtualDb, VirtualTable, VirtualColumn[], Object[])
private java.lang.String buildInsertSelectSql(java.lang.String selectSql) throws BaseException
selectSql
- The SELECT part of the queryBaseException
BatchUtil.buildInsertSelectSql(VirtualDb, VirtualTable, VirtualColumn[], String)