|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.sql.writebatch.BatchWriterSimpleImpl
public class BatchWriterSimpleImpl
An implementation of the BatchWriter interface that uses simple JDBC addBatch() and executeBatch() methods.
| Field Summary | |
|---|---|
protected java.util.List<FlushJob> |
addBatches
|
protected java.sql.Connection |
con
|
protected java.util.List<FlushJob> |
deleteBatches
|
protected int |
deleteTempTableSize
|
protected java.sql.Statement |
lastBatch
|
protected java.sql.Statement |
postDeleteBatch
|
protected java.sql.Statement |
preDeleteBatch
|
protected java.util.Map<java.lang.String,org.intermine.sql.writebatch.BatchWriterSimpleImpl.Statistic> |
stats
|
| Constructor Summary | |
|---|---|
BatchWriterSimpleImpl()
|
|
| Method Summary | |
|---|---|
protected void |
addToLastBatch(java.lang.String sql)
Adds a statement to the lastBatch. |
protected void |
addToPostDeleteBatch(java.lang.String sql)
Adds a statement to the postDeleteBatch. |
protected void |
addToPreDeleteBatch(java.lang.String sql)
Adds a statement to the preDeleteBatch. |
protected void |
doAnalyse(java.lang.String name,
java.sql.Connection conn)
Performs an ANALYSE of a table. |
protected int |
doDeletes(java.lang.String name,
TableBatch table)
Performs all the deletes for the given table name and table batch. |
protected int |
doIndirectionDeletes(java.lang.String name,
IndirectionTableBatch table)
Performs all the delete operations for the given IndirectionTableBatch and name. |
protected int |
doIndirectionInserts(java.lang.String name,
IndirectionTableBatch table,
java.util.List<FlushJob> batches)
Performs all the insert operations for the given IndirectionTableBatch and name. |
protected int |
doInserts(java.lang.String name,
TableBatch table,
java.util.List<FlushJob> batches)
Performs all the inserts for the given table name and table batch. |
protected int |
getTableSize(java.lang.String name,
java.sql.Connection conn)
Returns the approximate number of rows in a table. |
void |
setThreshold(int deleteTempTableSize)
This sets the threshold above which a temp table will be used for deletes. |
void |
updateStatistics(java.util.Map<java.lang.String,java.lang.Integer> activity,
java.sql.Connection conn)
Updates the per-table statistics held in this object, and may tell the SQL database to update its statistics using the supplied Connection. |
java.util.List<FlushJob> |
write(java.sql.Connection con,
java.util.Map<java.lang.String,? extends Table> tables,
java.util.Set<java.lang.String> filter)
Performs all the processing for flushing a few tables to the connection, and returns a List of jobs to do the actual flushing. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int deleteTempTableSize
protected java.sql.Connection con
protected java.sql.Statement preDeleteBatch
protected java.util.List<FlushJob> deleteBatches
protected java.sql.Statement postDeleteBatch
protected java.util.List<FlushJob> addBatches
protected java.sql.Statement lastBatch
protected java.util.Map<java.lang.String,org.intermine.sql.writebatch.BatchWriterSimpleImpl.Statistic> stats
| Constructor Detail |
|---|
public BatchWriterSimpleImpl()
| Method Detail |
|---|
public void setThreshold(int deleteTempTableSize)
deleteTempTableSize - the threshold
public java.util.List<FlushJob> write(java.sql.Connection con,
java.util.Map<java.lang.String,? extends Table> tables,
java.util.Set<java.lang.String> filter)
throws java.sql.SQLException
write in interface BatchWritercon - the SQL connectiontables - a Map from table name to Tablefilter - a Set of table names to write, or null to write all tables
java.sql.SQLException - if there is an underlying DB problem
protected int doInserts(java.lang.String name,
TableBatch table,
java.util.List<FlushJob> batches)
throws java.sql.SQLException
name - the name of the tabletable - the table batchbatches - the List of batches into which new flushjobs should be placed
java.sql.SQLException - if an error occurs
protected int doDeletes(java.lang.String name,
TableBatch table)
throws java.sql.SQLException
name - the name of the tabletable - the table batch
java.sql.SQLException - if an error occurs
protected int doIndirectionDeletes(java.lang.String name,
IndirectionTableBatch table)
throws java.sql.SQLException
name - the name of the tabletable - the IndirectionTableBatch
java.sql.SQLException - if an error occurs
protected int doIndirectionInserts(java.lang.String name,
IndirectionTableBatch table,
java.util.List<FlushJob> batches)
throws java.sql.SQLException
name - the name of the tabletable - the IndirectionTableBatchbatches - the List of flushjobs to add further actions to
java.sql.SQLException - if an error occurs
protected void addToPreDeleteBatch(java.lang.String sql)
throws java.sql.SQLException
sql - the statement
java.sql.SQLException - if an error occurs
protected void addToPostDeleteBatch(java.lang.String sql)
throws java.sql.SQLException
sql - the statement
java.sql.SQLException - if an error occurs
protected void addToLastBatch(java.lang.String sql)
throws java.sql.SQLException
sql - the statement
java.sql.SQLException - if an error occurs
public void updateStatistics(java.util.Map<java.lang.String,java.lang.Integer> activity,
java.sql.Connection conn)
throws java.sql.SQLException
updateStatistics in interface BatchWriteractivity - a Map from table name to the amount of activity (in rows) as an Integerconn - a Connection, over which to talk to the database
java.sql.SQLException - if there is an underlying DB problem
protected int getTableSize(java.lang.String name,
java.sql.Connection conn)
throws java.sql.SQLException
name - the name of the tableconn - a Connection to use
java.sql.SQLException - if there is a problem
protected void doAnalyse(java.lang.String name,
java.sql.Connection conn)
throws java.sql.SQLException
name - the name of the tableconn - a Connection to use
java.sql.SQLException - if something goes wrong
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||