github.com/chain5j/chain5j-pkg@v1.0.7/database/kvstore/batch.go (about) 1 // Package kvstore 批量处理 2 // 3 // @author: xwc1125 4 package kvstore 5 6 // IdealBatchSize defines the size of the data batches should ideally add in one 7 // write. 8 const IdealBatchSize = 100 * 1024 9 10 // Batch is a write-only database that commits changes to its host database 11 // when Write is called. A batch cannot be used concurrently. 12 type Batch interface { 13 KeyValueWriter 14 15 // ValueSize retrieves the amount of data queued up for writing. 16 ValueSize() int 17 18 // Write flushes any accumulated data to disk. 19 Write() error 20 21 // Reset resets the batch for reuse. 22 Reset() 23 24 // Replay replays the batch contents. 25 Replay(w KeyValueWriter) error 26 } 27 28 // Batcher wraps the NewBatch method of a backing data store. 29 type Batcher interface { 30 // NewBatch creates a write-only database that buffers changes to its host db 31 // until a final write is called. 32 NewBatch() Batch 33 }