import { MemoryStorage } from "../../zql/src/ivm/memory-storage.js";
import { TableSource } from "./table-source.js";
export class QueryDelegateImpl {
    #lc;
    #db;
    #schema;
    #sources;
    #logConfig;
    defaultQueryComplete = true;
    #commitObservers = new Set();
    constructor(lc, db, schema, logConfig) {
        this.#lc = lc.withContext('class', 'QueryDelegateImpl');
        this.#db = db;
        this.#schema = schema;
        this.#sources = new Map();
        this.#logConfig = logConfig ?? {
            format: 'text',
            ivmSampling: 0,
            level: 'info',
            slowHydrateThreshold: 0,
            slowRowThreshold: 0,
        };
    }
    getSource(tableName) {
        let source = this.#sources.get(tableName);
        if (source) {
            return source;
        }
        const tableSchema = this.#schema.tables[tableName];
        source = new TableSource(this.#lc, this.#logConfig, this.#db, tableName, tableSchema.columns, tableSchema.primaryKey);
        this.#sources.set(tableName, source);
        return source;
    }
    createStorage() {
        return new MemoryStorage();
    }
    decorateSourceInput(input) {
        return input;
    }
    decorateInput(input) {
        return input;
    }
    decorateFilterInput(input) {
        return input;
    }
    addServerQuery() {
        return () => { };
    }
    addEdge() { }
    addCustomQuery() {
        return () => { };
    }
    updateServerQuery() { }
    updateCustomQuery() { }
    flushQueryChanges() { }
    onTransactionCommit(cb) {
        this.#commitObservers.add(cb);
        return () => {
            this.#commitObservers.delete(cb);
        };
    }
    batchViewUpdates(applyViewUpdates) {
        const ret = applyViewUpdates();
        for (const observer of this.#commitObservers) {
            observer();
        }
        return ret;
    }
    assertValidRunOptions() { }
    addMetric() { }
}
//# sourceMappingURL=query-delegate.js.map