Skip to content

IngestBuffer

Defined in: db/IngestBuffer.ts:17

Staging buffer for DuckDB ingestion.

Accumulates incoming data points and provides them in batches via drain(). The drain pattern decouples data arrival from DuckDB insertion timing (polling interval), avoiding the need for index-based tracking.

Contract: t values pushed to this buffer MUST be strictly monotonically increasing. Out-of-order data will be silently missed by incremental queries. This is guaranteed by the orts simulator (simulation time always advances). Consumers using uneri with other data sources must enforce this property.

T extends TimePoint = TimePoint

new IngestBuffer<T>(): IngestBuffer<T>

IngestBuffer<T>

get latestT(): number

Defined in: db/IngestBuffer.ts:112

The latest t value seen across all pushed points. Used for timeRange calculation in chart components. Returns -Infinity if no points have been pushed.

number


get pendingCount(): number

Defined in: db/IngestBuffer.ts:103

Number of points waiting to be drained.

number

consumeRebuild(): T[] | null

Defined in: db/IngestBuffer.ts:94

Consume a pending rebuild signal. Returns the rebuild data merged with any points pushed since markRebuild(), or null if no rebuild is pending. The rebuild flag and pending buffer are both cleared.

T[] | null


drain(): T[]

Defined in: db/IngestBuffer.ts:64

Drain all pending points, returning them and clearing the buffer. Returns an empty array if nothing is pending.

T[]


markRebuild(fullData): void

Defined in: db/IngestBuffer.ts:79

Signal a full table rebuild. The tick loop should clear the DuckDB table and insert the returned data from consumeRebuild().

Clears any stale pending points to prevent duplicates (fullData is the complete replacement dataset). Points pushed after this call are treated as genuinely new and will be included by consumeRebuild().

T[]

void


prependMany(points): void

Defined in: db/IngestBuffer.ts:56

Prepend points to the front of the buffer. Used for re-queuing failed insert batches: since new points may have arrived in pending during the async insert, appending the failed batch would break t-monotonicity. Prepending preserves order.

T[]

void


push(point): void

Defined in: db/IngestBuffer.ts:23

Push a single point. Must satisfy t > latestT (strictly increasing).

T

void


pushMany(points): void

Defined in: db/IngestBuffer.ts:41

Push multiple points at once (appended to end).

T[]

void