public class RdbStoreAsyncHandler extends EventHandler
This class provides two threads, a work thread and a callback thread. The work thread implements data operations; the callback thread processes data operation results.
SystemCapability.Data#DATA_APPDATAMGREventHandler.Priority| 构造器 | 说明 |
|---|---|
RdbStoreAsyncHandler(RdbStore rdbStore) |
Creates an
RdbStoreAsyncHandler instance using an RdbStore. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addDeleteJob(JobParams jobParams,
RdbPredicates rdbPredicates,
DeleteCallback deleteCallback) |
Deletes data from the database asynchronously and processes the deletion result.
|
void |
addInsertJob(JobParams jobParams,
String tableName,
ValuesBucket valuesBucket,
InsertCallback insertCallback) |
Inserts data into the database asynchronously and processes the insertion result.
|
void |
addQueryJob(JobParams jobParams,
String[] columns,
RdbPredicates rdbPredicates,
QueryCallback queryCallback) |
Queries data in the database asynchronously and processes the query result.
|
void |
addUpdateJob(JobParams jobParams,
ValuesBucket valuesBucket,
RdbPredicates rdbPredicates,
UpdateCallback updateCallback) |
Updates data in the database asynchronously and processes the update result.
|
void |
cancelJob(int token) |
Cancels asynchronous tasks with the same token.
|
current, distributeEvent, dump, getEventName, getEventRunner, hasInnerEvent, hasInnerEvent, hasInnerEvent, hasInnerEvent, hasInnerEvent, isIdle, postSyncTask, postSyncTask, postTask, postTask, postTask, postTask, postTask, postTimingTask, postTimingTask, postTimingTask, processEvent, removeAllEvent, removeEvent, removeEvent, removeEvent, removeEvent, removeTask, removeTask, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendSyncEvent, sendSyncEvent, sendSyncEvent, sendSyncEvent, sendTimingEvent, sendTimingEvent, sendTimingEvent, sendTimingEvent, toStringpublic RdbStoreAsyncHandler(RdbStore rdbStore)
RdbStoreAsyncHandler instance using an RdbStore.rdbStore - Indicates the RdbStore used to create the RdbStoreAsyncHandler instance.public final void addQueryJob(JobParams jobParams, String[] columns, RdbPredicates rdbPredicates, QueryCallback queryCallback)
Use this method when querying a large amount of data in the database in the intra-process scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.columns - Indicates the columns where the data to be queried resides. If it is null,
data in all the columns will be queried.rdbPredicates - Indicates the RdbPredicates. It is mandatory and cannot be null.queryCallback - Indicates the QueryCallback used to process the query result. It is mandatory
and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addInsertJob(JobParams jobParams, String tableName, ValuesBucket valuesBucket, InsertCallback insertCallback)
Use this method when inserting a large amount of data into the database in the intra-process scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.tableName - Indicates the name of the table into which the data is to be inserted.valuesBucket - Indicates a bucket that stores and manages values. It is mandatory and cannot
be null. For details, see ValuesBucket.insertCallback - Indicates the InsertCallback used to process the insertion result. It is mandatory
and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addUpdateJob(JobParams jobParams, ValuesBucket valuesBucket, RdbPredicates rdbPredicates, UpdateCallback updateCallback)
Use this method when updating a large amount of data in the database in the intra-process scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.valuesBucket - Indicates a bucket that stores and manages values. It is mandatory and
cannot be null. For details, see ValuesBucket.rdbPredicates - Indicates the RdbPredicates. It is mandatory and cannot be null.updateCallback - Indicates the UpdateCallback used to process the update result. It is mandatory
and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addDeleteJob(JobParams jobParams, RdbPredicates rdbPredicates, DeleteCallback deleteCallback)
Use this method when deleting a large amount of data from the database in the intra-process scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.rdbPredicates - Indicates the RdbPredicates. It is mandatory and cannot be null.deleteCallback - Indicates the DeleteCallback used to process the deletion result. It is mandatory
and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void cancelJob(int token)
If different tasks share a token, use this method to cancel these tasks.
token - Indicates the token shared by the tasks. It must be consistent with that in the
input parameter jobParams of the addDeleteJob, addInsertJob,
addQueryJob, and addUpdateJob methods.