UNPKG

@itwin/core-backend

Version:
77 lines 2.91 kB
import { ChangeInstance, ChangeSource } from "./ChangesetReaderTypes"; /** * Cache used by [[PartialChangeUnifier]] to accumulate and merge * partial EC change instances. * @beta */ export interface ChangeCache extends Disposable { /** Retrieve a cached instance by key, or `undefined` if absent. */ get(key: string): ChangeInstance | undefined; /** Insert or replace a cached instance. */ set(key: string, value: ChangeInstance): void; /** Iterate over all cached instances. */ all(): IterableIterator<ChangeInstance>; /** Number of instances currently in the cache. */ count(): number; } /** @beta */ export declare namespace ChangeUnifierCache { /** * Creates an in-memory cache backed by a `Map`. * Fast, but may exhaust memory for very large changesets. * @returns An [[ChangeCache]] backed by an in-memory `Map`. * @beta */ function createInMemoryCache(): ChangeCache; /** * Creates a SQLite-backed cache stored in a temporary SQlite database. * Slower than in-memory but useful in handling large changesets. * Temporary SQlite database is first created in memory and * parts of a temporary database might be flushed to disk if the database becomes large or * if SQLite comes under memory pressure. * @param bufferedReadInstanceSizeInBytes Read-batch size in bytes (default 10 MB). * @returns An [[ChangeCache]] backed by a SQLite temp table. * @beta */ function createSqliteBackedCache(bufferedReadInstanceSizeInBytes?: number): ChangeCache; } /** * Combines partial EC change instances (one per SQLite table row) into complete * instances that span all tables mapping to a single EC entity. * * The merge key is derived from the `instanceKey` and `stage` stored in `$meta.instanceKey` and `$meta.stage`. * * **Usage:** * ```ts * using reader = ChangesetReader.openFile({ fileName, db }); * using unifier = new PartialChangeUnifier(); * while (reader.step()) { * unifier.appendFrom(reader); * } * for (const instance of unifier.instances) { ... } * ``` * @beta */ export declare class PartialChangeUnifier implements Disposable { private readonly _cache; constructor(_cache?: ChangeCache); /** Releases the underlying cache. */ [Symbol.dispose](): void; /** Number of complete (merged) instances currently accumulated. */ get instanceCount(): number; /** * Append partial changes from the current reader row and merge them into the cache. * * @param source Any [ChangeSource]($backend) positioned on a valid row. * @beta */ appendFrom(source: ChangeSource): void; /** * Iterator over all fully-merged EC change instances. * @beta */ get instances(): IterableIterator<ChangeInstance>; private buildKey; private combine; } //# sourceMappingURL=PartialChangeUnifier.d.ts.map