base class for bulk DML upsert operations
More...
|
| | BulkUpsertOperation (AbstractTable target, Map< String, Object > opts) throws Throwable |
| | creates the object from the supplied arguments
|
| |
| | BulkUpsertOperation (AbstractTable target) throws Throwable |
| | creates the object from the supplied arguments
|
| |
|
| AbstractBulkOperation (QoreObject obj) throws Throwable |
| | creates a new AbstractBulkOperation object wrapping the Qore object
|
| |
| void | queueData (Map< String, Object > data) throws Throwable |
| | queues row data in the block buffer; the block buffer is flushed to the DB if the buffer size reaches the limit defined by the block_size option; does not commit the transaction
|
| |
| void | queueData (Map< String, Object >[] l) throws Throwable |
| | queues row data in the block buffer; the block buffer is flushed to the DB if the buffer size reaches the limit defined by the block_size option; does not commit the transaction
|
| |
| void | flush () throws Throwable |
| | flushes any remaining batched data to the database; this method should always be called before committing the transaction or destroying the object
|
| |
| void | discard () throws Throwable |
| | discards any buffered batched data; this method should be called before destroying the object if an error occurs
|
| |
|
void | commit () throws Throwable |
| | flushes any queued data and commits the transaction
|
| |
|
void | rollback () throws Throwable |
| | discards any queued data and rolls back the transaction
|
| |
|
String | getTableName () throws Throwable |
| | returns the table name
|
| |
|
AbstractTable | getTable () throws Throwable |
| | returns the underlying SqlUtil::AbstractTable object
|
| |
|
AbstractDatasource | getDatasource () throws Throwable |
| | returns the AbstractDatasource object associated with this object
|
| |
|
int | getRowCount () throws Throwable |
| | returns the affected row count
|
| |
base class for bulk DML upsert operations
This class assists with bulk upsert (SQL merge) operations into a target table.
- Submitting Data
- To use this class, queue data in the form of a hash (a single row or a set of rows) or a list of rows by calling the queueData() method.
The queueData() method queues data to be written to the database; the queue is flush()ed automatically when block_size rows have been queued.
- Flushing and Discarding Data
- Each call to flush() (whether implicit or explicit) will cause a single call to be made to the dataserver; all queued rows are sent in a single bulk DML call, which allows for efficient processing of large amounts of data.
A call to flush() must be made before committing the transaction to ensure that any remaining rows in the internal queue have been written to the database. Because the destructor() will throw an exception if any data is left in the internal queue when the object is destroyed, a call to discard() must be made prior to the destruction of the object in case of errors.
try {
for (Map<String, Object> i : data1) {
}
for (Map<String, Object> i : data2) {
}
ds.commit();
} catch (Throwable e) {
ds.rollback();
throw e;
}
void discard()
discards any buffered batched data; this method should be called before destroying the object if an e...
Definition AbstractBulkOperation.java:240
void flush()
flushes any remaining batched data to the database; this method should always be called before commit...
Definition AbstractBulkOperation.java:203
void queueData(Map< String, Object > data)
queues row data in the block buffer; the block buffer is flushed to the DB if the buffer size reaches...
Definition AbstractBulkOperation.java:129
base class for bulk DML upsert operations
Definition BulkUpsertOperation.java:70
- Note
- Each bulk DML object must be manually flush()ed before committing or manually discard()ed before rolling back to ensure that all data is managed properly in the same transaction and to ensure that no exception is thrown in Qore destructor. See the example above for more information.
- Deprecated:
- Use dynamic imports instead:
import qoremod.BulkSqlUtil.BulkUpsertOperation;
◆ BulkUpsertOperation() [1/2]
| org.qore.lang.bulksqlutil.BulkUpsertOperation.BulkUpsertOperation |
( |
AbstractTable |
target, |
|
|
Map< String, Object > |
opts |
|
) |
| throws Throwable |
|
inline |
creates the object from the supplied arguments
- Parameters
-
| target | the target table object |
| opts | an optional hash of options for the object as follows:
"block_size": the number of rows executed at once (default: 1000)
"info_log": an optional info logging callback of type LogCallback
"upsert_strategy": the upsert strategy to use; default AbstractTable.UpsertAuto; see Upsert Strategy Codes for possible values for the upsert strategy
|
◆ BulkUpsertOperation() [2/2]
| org.qore.lang.bulksqlutil.BulkUpsertOperation.BulkUpsertOperation |
( |
AbstractTable |
target | ) |
throws Throwable |
|
inline |
creates the object from the supplied arguments
- Parameters
-
| target | the target table object |
The documentation for this class was generated from the following file:
- /tmp/module-jni/src/java/org/qore/lang/bulksqlutil/BulkUpsertOperation.java