"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lmdbGetTableSize = lmdbGetTableSize;
const TableSizeObject_ts_1 = require("../../TableSizeObject.js");
const harper_logger_js_1 = __importDefault(require("../../../../utility/logging/harper_logger.js"));
/**
 * Calculates the number of entries & data size in bytes for a table & its transaction log
 * @param table
 * @returns {TableSizeObject}
 */
function lmdbGetTableSize(table) {
    const tableStats = new TableSizeObject_ts_1.TableSizeObject(table.databaseName, table.tableName);
    try {
        const dbiStat = table.primaryStore.getStats();
        //get the txn log record count
        const txnDbiStat = table.auditStore?.getStats();
        tableStats.recordCount = dbiStat.entryCount;
        tableStats.transactionLogRecordCount = txnDbiStat.entryCount;
    }
    catch (e) {
        harper_logger_js_1.default.warn(`unable to stat table dbi due to ${e}`);
    }
    return tableStats;
}
//# sourceMappingURL=lmdbGetTableSize.js.map