Package net.sf.basedb.core
Class MappingBatcher
java.lang.Object
net.sf.basedb.core.AbstractBatcher
net.sf.basedb.core.MappingBatcher
- All Implemented Interfaces:
AutoCloseable
,Batcher
Batcher class for inserting parent mapping information in the
dynamic database. This batcher is used to map data cube spots to
their parent
RawData
.
Code example: Dynamic API - Creating a root bioassayset
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2015-04-21 09:59:42 +0200 (ti, 21 apr 2015) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate long
The number of bytes this batcher has added to the experiment.private final long
The number of bytes used by a single row.private final DataCube
The datacube this batcher inserts data for.private final boolean
If the data cube has already received it's data and no raw data can be linked.private int
The number of queued inserts.private PreparedStatement
The statement that inserts the spot/raw data link.private String
The SQL string for therawMappingSql
statement.private int
The total number of inserts done by this batcher.Fields inherited from class net.sf.basedb.core.AbstractBatcher
debugSqlEnabled, logSql
-
Constructor Summary
ConstructorDescriptionMappingBatcher
(DbControl dc, DataCube dataCube) Create a new position batcher for a data cube. -
Method Summary
Modifier and TypeMethodDescriptionprivate String
buildInsertSelectSql
(String selectSql) Build the INSERT INTO ...private void
Builds the insert SQL statement.void
flush()
Flush the batcher and send all remaining items in memory to the database.int
Get the total number of mappings to raw data create by this mapper.void
Link a spot to a raw data.int
insert
(AbstractSqlQuery query) Insert mapping to raw spots using a query.(package private) void
Update bytes on data cube and close open SQL statements.Methods inherited from class net.sf.basedb.core.AbstractBatcher
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
-
Field Details
-
dataCube
The datacube this batcher inserts data for. -
noRawMapping
private final boolean noRawMappingIf the data cube has already received it's data and no raw data can be linked. -
queuedInsertCount
private int queuedInsertCountThe number of queued inserts. Used to check when a flush is needed. -
totalInsertCount
private int totalInsertCountThe total number of inserts done by this batcher. -
bytes
private long bytesThe number of bytes this batcher has added to the experiment. -
bytesPerRow
private final long bytesPerRowThe number of bytes used by a single row. -
rawMappingSql
The statement that inserts the spot/raw data link.INSERT INTO Dynamic#RawParents (cube, column, position, rawdata_id) VALUES (cube, ?, ?, ?)
-
rawMappingSqlStatement
The SQL string for therawMappingSql
statement.
-
-
Constructor Details
-
MappingBatcher
Create a new position batcher for a data cube. It is assumed that the calling code has checked that the cube is allowed to receive more data (ie. it hasn't been committed to the database).
-
-
Method Details
-
flush
Description copied from interface:Batcher
Flush the batcher and send all remaining items in memory to the database.- Throws:
BaseException
- If there is an error- See Also:
-
onBeforeClose
Update bytes on data cube and close open SQL statements.- Overrides:
onBeforeClose
in classAbstractBatcher
- Throws:
BaseException
-
insert
Link a spot to a raw data. One spot may be linked to several raw data items.- Parameters:
column
- The column coordinate of the spotposition
- The position coordinate of the spotrawData
- The raw data object- Throws:
InvalidDataException
- If the raw data is nullBaseException
- If there is an error
-
insert
Insert mapping to raw spots using a query. The query MUST select data in the following order: column, position, rawDataIdInternally 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.- Parameters:
query
- The query that selects the data to be inserted- Returns:
- int The number of rows inserted
- Throws:
BaseException
- If there is an error
-
getTotalInsertCount
public int getTotalInsertCount()Get the total number of mappings to raw data create by this mapper.- Since:
- 2.2
-
buildRawMappingSql
Builds the insert SQL statement. Also creates the Dynamic#RawParents table if it doesn't exists. -
buildInsertSelectSql
Build the INSERT INTO ... SELECT ... statment. Also creates the Dynamic#RawParents table if it doesn't exists.- Parameters:
selectSql
- The SELECT part of the query- Throws:
BaseException
- See Also:
-