Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IterateExecuteAndCommitInBatch ¶
func IterateExecuteAndCommitInBatch( iter module.BlockIterator, executor IterationExecutor, db storage.DB, isBatchFull IsBatchFull, sleeper Sleeper, ) error
IterateExecuteAndCommitInBatch iterates over blocks and execute tasks with data that was indexed by the block. the update to the storage database is done in batch, and the batch is committed when it's full. the iteration progress is saved after batch is committed, so that the iteration progress can be resumed after restart. it sleeps after each batch is committed in order to minimizing the impact on the system.
Types ¶
type IsBatchFull ¶
IsBatchFull decides the batch size for each commit. it takes the number of blocks iterated in the current batch, and returns whether the batch is full.
type IterationExecutor ¶
type IterationExecutor interface { // ExecuteByBlockID executes the task for the block indexed by the blockID ExecuteByBlockID(blockID flow.Identifier, batch storage.ReaderBatchWriter) (exception error) }
IterationExecutor allows the caller to customize the task to be executed for each block. for instance, the executor can prune data indexed by the block, or build another index for each iterated block.