public static interface BatchUpdateAssistant.BatchUpdate
BatchUpdateAssistant
for an upgrade action.Modifier and Type | Field and Description |
---|---|
static String |
FILTER_FALSE
The value, when returned by
getRowChangeInsertFilter , getRowChangeUpdateFilter , or getRowChangeDeleteFilter causes INSERT ed,
UPDATE d, or DELETE d rows (respectively)
to not be processed by the batch update. |
Modifier and Type | Method and Description |
---|---|
void |
addDeletedRowToBatch(long id)
Called by BatchUpdateAssistant for each deleted row to be processed
in the batch.
|
void |
addToBatch(long id)
Called by the BatchUpdateAssistant for each row to be processed in the
batch.
|
void |
beginBatch(IfsConnection conn)
Called by the BatchUpdateAssistant at the start of each batch.
|
void |
completeBatch()
Called by the BatchUpdateAssistant at the end of each batch.
|
void |
executeBatch()
Called by the BatchUpdateAssistant to write all pending updates in the
batch.
|
String |
getCountExpression()
Gets a SQL expression that, when evaluated during the analysis phase,
is true for rows in the
base table to be processed
by this batch update. |
String |
getPrimaryKeyColumnName()
Gets the name of the primary key column in the
base table . |
String |
getRowChangeDeleteFilter()
Gets a PL/SQL expression that, when evaluated by a
DELETE
trigger on the base table , is true if the deleted
row is to be processed by the batch update. |
String |
getRowChangeInsertFilter()
Gets a PL/SQL expression that, when evaluated by an
INSERT
trigger on the base table , is true if the new row
is to be processed by the batch update. |
String |
getRowChangeUpdateFilter()
Gets a PL/SQL expression that, when evaluated by an
UPDATE
trigger on the base table , is true if the updated
row is to be processed by the batch update. |
int |
getSelectBatchSize()
Gets the
SELECT batch size, in rows. |
String |
getSelectExpression()
Gets a SQL expression that, when evaluated during the pre-upgrade and
upgrade phases, is true only for a row in the
base
table to be processed by this batch update. |
LibrarySession |
getSession()
Gets the session used to perform the batch update.
|
String |
getTableName()
Gets the name of the base table.
|
int |
getUpdateBatchSize()
Gets the
UPDATE batch size, in rows. |
void |
setProgress(int phase,
long rowsToUpdate,
long rowsUpdated)
Called by the BatchUpdateAssistant to update the progress of the batch
update.
|
static final String FILTER_FALSE
getRowChangeInsertFilter
, getRowChangeUpdateFilter
, or getRowChangeDeleteFilter
causes INSERT
ed,
UPDATE
d, or DELETE
d rows (respectively)
to not be processed by the batch update.LibrarySession getSession() throws IfsException
The session must be authorized to enter administration mode.
IfsException
- if the operation failsString getTableName() throws IfsException
IfsException
- if the operation failsString getPrimaryKeyColumnName() throws IfsException
base table
.
The column must be convertible, using JDBC, to a Java long
.
IfsException
- if the operation failsString getCountExpression() throws IfsException
base table
to be processed
by this batch update.
The expression is injected into a SQL statement of form "SELECT
count(*) FROM tableName WHERE countExpression
",
where tableName is the value returned by getTableName
and countExpression is the value returned by this
method.
Unlike getSelectExpression
, the expression
returned by this method may estimate the number of rows to be processed.
During the analysis phase, it may not be possible to evaluate the
getSelectExpression
expression (for example, certain
columns in the select expression may not yet exist), so an approximation
may be necessary.
IfsException
- if the operation failsString getSelectExpression() throws IfsException
base
table
to be processed by this batch update.
The expression is injected into a SQL statement of form
"SELECT primaryKeyColumnName FROM tableName
WHERE selectExpression AND primaryKeyColumnName > ?
",
where tableName is the value returned by getTableName
, primaryKeyColumnName is the value returned by
getPrimaryKeyColumnName
, and
selectExpression is the value returned by this method.
IfsException
- if the operation failsString getRowChangeInsertFilter() throws IfsException
INSERT
trigger on the base table
, is true if the new row
is to be processed
by the batch update.
This expression can evaluate true for a superset of the rows to be
processed. For each candidate row, getSelectExpression
will be evaluated to determine whether that row
is actually processed.
FILTER_FALSE
to indicate no
new rows are to be processed by this batch
updateIfsException
- if the operation failsString getRowChangeUpdateFilter() throws IfsException
UPDATE
trigger on the base table
, is true if the updated
row is to be processed
by the batch update.
This expression can evaluate true for a superset of the rows to be
processed. For each candidate row, getSelectExpression
will be evaluated to determine whether that row
is actually processed.
Although this expression may be true for an update performed by an end-user, it should evaluate to false for an update performed on the base table by the batch update itself, otherwise the row may be endlessly updated by this batch update. For this reason, although returning null is allowed, it is generally unwise to do so.
FILTER_FALSE
to indicate no
updated rows are to be processed by this batch
updateIfsException
- if the operation failsString getRowChangeDeleteFilter() throws IfsException
DELETE
trigger on the base table
, is true if the deleted
row is to be processed
by the batch update.
Unlike the insert
and update
filters, this expression alone
determines whether a deleted row is processed by the batch update;
getSelectExpression
is not evaluated.
FILTER_FALSE
to indicate no
deleted rows are to be processed by this batch
updateIfsException
- if the operation failsint getSelectBatchSize() throws IfsException
SELECT
batch size, in rows.
In each batch, up to this number of rows are SELECT
ed from
the base table for processing by the batch update. To maximize update
throughput, this value should be as large as possible without resulting
in "snapshot too old" errors.
IfsException
- if the operation failsint getUpdateBatchSize() throws IfsException
UPDATE
batch size, in rows.
In each batch, updates are written and committed after no more than this number of rows. This value therefore determines the maximum number of row-level locks held by the batch update. To maximize update throughput, this value should be as large as possible without causing excessive lock contention with end-users.
Regardless of this value, updates are written and committed after no
more than the select batch size
.
IfsException
- if the operation failsvoid beginBatch(IfsConnection conn) throws SQLException, IfsException
This method allows the BatchUpdate to amortize certain processing over
the batch, instead of repeating it for each row in the batch. A common
use is to prepare an IfsPreparedStatement
that is executed for each row in the batch.
conn
- an IfsConnectionSQLException
- if the operation failsIfsException
- if the operation failsvoid addToBatch(long id) throws SQLException, IfsException
id
- the primary key of the row to be processedSQLException
- if the operation failsIfsException
- if the operation failsvoid addDeletedRowToBatch(long id) throws SQLException, IfsException
Whereas addToBatch
is called for each row that
requires processing by the batch update, this method is called for
each row deleted subsequent to the start of the batch update that
satisfies the delete filter
.
Because the row no longer exists, it can't be "updated"; however an
upgrade action can perform other processing, such as updating an
ancillary table.
id
- the primary key of the row to be processedSQLException
- if the operation failsIfsException
- if the operation failsvoid executeBatch() throws SQLException, IfsException
As a batch of rows is processed, this method is invoked one or more
times, as specified by the update batch
size
. At minimum, it is always called after the last row in the
batch.
This method must cause all pending updates to be applied to the database. After calling this method, the BatchUpdateAssistant will commit those changes.
A common strategy is for each call to addToBatch
(and similarly, addDeletedRowToBatch
)
to add changes to a JDBC batch, and for this method to execute that
JDBC batch. This approach minimizes database round trips.
SQLException
- if the operation failsIfsException
- if the operation failsvoid completeBatch() throws SQLException, IfsException
This method allows resources acquired by beginBatch
to be released.
SQLException
- if the operation failsIfsException
- if the operation failsvoid setProgress(int phase, long rowsToUpdate, long rowsUpdated) throws IfsException
The values of the arguments may be estimates of overall progress. A
common implementation of this method is to call methods on the ProgressAssistant
to record progress.
phase
- one of STATUS_ANALYZING
if called from analyze
,STATUS_PREUPGRADING
if called from preUpgrade
,STATUS_UPGRADING
if called from upgrade
, orSTATUS_ROLLINGBACK
if called from rollback
rowsToUpdate
- an estimate of the total number of rows to processrowsUpdated
- an estimate of the number or rows processed so farIfsException
- if the operation failsCopyright © 2023. All rights reserved.