Buffer)The Buffer engine provides an in-memory buffer that flushes data to a destination table based on time, row count, or size thresholds:
import { OlapTable, ClickHouseEngines } from '@514labs/moose-lib'; // First create the destination tableexport const destinationTable = new OlapTable<Record>("destination", { engine: ClickHouseEngines.MergeTree, orderByFields: ["id", "timestamp"]}); // Then create buffer that writes to itexport const bufferTable = new OlapTable<Record>("buffer", { engine: ClickHouseEngines.Buffer, targetDatabase: "local", targetTable: "destination", numLayers: 16, minTime: 10, // Min 10 seconds before flush maxTime: 100, // Max 100 seconds before flush minRows: 10000, // Min 10k rows before flush maxRows: 1000000, // Max 1M rows before flush minBytes: 10485760, // Min 10MB before flush maxBytes: 104857600 // Max 100MB before flush});orderByFields, partitionBy, or sampleByExpression on buffer tablesFor more details, see the ClickHouse Buffer documentation.