import { ExportNode } from "../export/types.js"; import { MutableTree } from "../mutable-tree.js"; //#region src/import/importer.d.ts /** * Error thrown when calling methods on a closed importer */ declare class ErrNoImport extends Error { constructor(); } /** * Importer imports data into an empty MutableTree. * It is created by MutableTree.import(). Users must call close() when done. * * ExportNodes must be imported in the order returned by Exporter, * i.e. depth-first post-order (LRN). * * Importer is not concurrency-safe, it is the caller's responsibility to ensure * the tree is not modified while performing an import. * * Based on Go IAVL import.go lines 17-34. */ declare class Importer { private tree; private version; private batchSize; private stack; private nonces; /** * Creates a new Importer for an empty MutableTree. * * @param tree - The MutableTree to import into (must be empty) * @param version - The version to import (must match exported version) * @throws Error if version is negative, tree is not empty, or database has existing versions * * Based on Go IAVL import.go lines 36-58. */ constructor(tree: MutableTree, version: bigint); /** * Writes a node to the database. * Handles batching and flushing when batch size exceeds MAX_BATCH_SIZE. * * Based on Go IAVL import.go lines 60-104. */ private writeNode; /** * Adds an ExportNode to the import. * ExportNodes must be added in the order returned by Exporter (post-order LRN). * Nodes are periodically flushed to the database, but the imported version * is not visible until commit() is called. * * Based on Go IAVL import.go lines 120-186. * * @param exportNode - The exported node to add * @throws Error if importer is closed, node is nil, or version is invalid */ add(exportNode: ExportNode): Promise; /** * Finalizes the import by flushing outstanding nodes to the database, * making the version visible, and updating tree metadata. * Can only be called once, and calls close() internally. * * Based on Go IAVL import.go lines 188-229. * * @throws Error if importer is closed or stack has invalid state */ commit(): Promise; /** * Frees all resources. Safe to call multiple times. * Uncommitted nodes may already have been flushed to the database, * but will not be visible. * * Based on Go IAVL import.go lines 106-118. */ close(): void; } //#endregion export { ErrNoImport, Importer }; //# sourceMappingURL=importer.d.ts.map