WriteBatch

A group of writes that commit together.

A batch is one log record, one checksum and — under Durability.SYNC — one fsync, so batching is both the atomicity mechanism and the throughput mechanism. Recovery replays a record only if its checksum holds, which is what makes a batch all-or-nothing across a crash.

Atomicity here is a statement about durability: after recovery a batch is either wholly present or wholly absent. It is not yet a statement about visibility — a concurrent reader may observe part of a batch that is mid-apply, which is what snapshots exist to fix and where they will.

Not thread-safe; build a batch on one thread and hand it to DocumentStore.write.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val size: Int

Number of operations, which is also the number of sequence numbers the commit consumes.

Functions

Link copied to clipboard
fun clear()

Discards every staged operation, so the batch can be reused.

Link copied to clipboard
fun delete(key: Key): WriteBatch

Stages a deletion of key.

Link copied to clipboard

true when nothing has been staged. Writing an empty batch does nothing.

Link copied to clipboard
fun put(key: Key, document: Variant): WriteBatch

Stages document under key, replacing whatever is there.

Link copied to clipboard
open override fun toString(): String