|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.sql.writebatch.Batch
public class Batch
A class representing a collection of writes to an SQL database. This class is intended for the purpose of improving the performance of systems that write to an SQL database, by bunching all the writes into a large batch, and then using tricks to speed up the batch commit. One should create one of these objects with a BatchWriter, which will perform the writes. BatchWriters are database-specific, in that they use different tricks to speed up the write, some of which depend on a certain database product.
| Constructor Summary | |
|---|---|
Batch(BatchWriter batchWriter)
Constructs an empty Batch, with no tables. |
|
| Method Summary | |
|---|---|
void |
addRow(java.sql.Connection con,
java.lang.String name,
java.lang.Object idValue,
java.lang.String[] colNames,
java.lang.Object[] values)
Adds a row to the batch for a given table. |
void |
addRow(java.sql.Connection con,
java.lang.String name,
java.lang.String leftColName,
java.lang.String rightColName,
int left,
int right)
Adds a row to the batch for a given indirection table. |
void |
backgroundFlush(java.sql.Connection con,
java.util.Set<java.lang.String> filter)
Flushes the batch out to the database server, but does not guarantee that the operation is finished when this method returns. |
void |
backgroundFlush(java.sql.Connection con,
java.util.Set<java.lang.String> filter,
boolean needBatchCommit)
Flushes the batch out to the database server, but does not guarantee that the operation is finished when this method returns. |
void |
batchCommit(java.sql.Connection con)
Flushes the batch out to the database server, then commits and re-opens the transaction, but does not guarantee that the operation is finished when this method returns. |
void |
clear()
Clears the batch without writing it to the database. |
void |
clearProblem()
Clears the problem with the Batch. |
void |
close(java.sql.Connection con)
Closes this BatchWriter. |
void |
deleteRow(java.sql.Connection con,
java.lang.String name,
java.lang.String idField,
java.lang.Object idValue)
Deletes a row from the batch for a given table. |
void |
deleteRow(java.sql.Connection con,
java.lang.String name,
java.lang.String leftColName,
java.lang.String rightColName,
int left,
int right)
Deletes a row from the batch for a given indirection table. |
void |
flush(java.sql.Connection con)
Flushes the batch out to the database server. |
void |
flush(java.sql.Connection con,
java.util.Set<java.lang.String> filter)
Flushes the batch out to the database server. |
void |
setBatchWriter(BatchWriter batchWriter)
Changes the BatchWriter for a new one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Batch(BatchWriter batchWriter)
batchWriter - the BatchWriter to use| Method Detail |
|---|
public void addRow(java.sql.Connection con,
java.lang.String name,
java.lang.Object idValue,
java.lang.String[] colNames,
java.lang.Object[] values)
throws java.sql.SQLException
con - a Connection for writing to the databasename - the name of the tableidValue - the value of the id field for this rowcolNames - an array of names of fields that are in the tablevalues - an array of Objects to be put in the row, in the same order as colNames
java.sql.SQLException - if a flush occurs, and an error occurs while flushing
public void addRow(java.sql.Connection con,
java.lang.String name,
java.lang.String leftColName,
java.lang.String rightColName,
int left,
int right)
throws java.sql.SQLException
con - a Connection for writing to the databasename - the name of the indirection tableleftColName - the name of the left-hand fieldrightColName - the name of the right-hand fieldleft - the int value of the left fieldright - the int value of the right field
java.sql.SQLException - if a flush occurs, and an error occurs while flushing
public void deleteRow(java.sql.Connection con,
java.lang.String name,
java.lang.String idField,
java.lang.Object idValue)
throws java.sql.SQLException
con - a Connection for writing to the databasename - the name of the tableidField - the name of the field that you wish to use as a unique primary keyidValue - the value of the id field for the row to be deleted
java.sql.SQLException - if a flush occurs, and an error occurs while flushing
public void deleteRow(java.sql.Connection con,
java.lang.String name,
java.lang.String leftColName,
java.lang.String rightColName,
int left,
int right)
throws java.sql.SQLException
con - a Connection for writing to the databasename - the name of the indirection tableleftColName - the name of the left-hand fieldrightColName - the name of the right-hand fieldleft - the int value of the left fieldright - the int value of the right field
java.sql.SQLException - if a flush occurs, and an error occurs while flushing
public void flush(java.sql.Connection con)
throws java.sql.SQLException
con - a Connection for writing to the database
java.sql.SQLException - if an error occurs while flushing
public void flush(java.sql.Connection con,
java.util.Set<java.lang.String> filter)
throws java.sql.SQLException
con - a Connection for writing to the databasefilter - a Set of table names to write, or null to write all of them
java.sql.SQLException - if an error occurs while flushing
public void batchCommit(java.sql.Connection con)
throws java.sql.SQLException
con - a Connection for writing to the database
java.sql.SQLException - if an error occurs while flushing
public void backgroundFlush(java.sql.Connection con,
java.util.Set<java.lang.String> filter)
throws java.sql.SQLException
con - a Connection for writing to the databasefilter - a Set of the table names to write, or null to write all of them
java.sql.SQLException - if an error occurs while flushing
public void backgroundFlush(java.sql.Connection con,
java.util.Set<java.lang.String> filter,
boolean needBatchCommit)
throws java.sql.SQLException
con - a Connection for writing to the databasefilter - a Set of the table names to write, or null to write all of themneedBatchCommit - true to add a FlushJobBatchCommit at the end
java.sql.SQLException - if an error occurs while flushing
public void close(java.sql.Connection con)
throws java.sql.SQLException
con - a Connection for writing to the database
java.sql.SQLException - if an error occurs while flushing.public void clear()
public void setBatchWriter(BatchWriter batchWriter)
batchWriter - the new BatchWriterpublic void clearProblem()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||