import type { Filter, KeyValues, QueryOptions } from '../types/query-types.js';
import type { IndexedItem, IndexLevelOptions } from './index-level.js';
import type { LevelWrapperBatchOperation } from './level-wrapper.js';
import type { CompoundIndexDefinition } from './index-level.js';
import type { LevelWrapper } from './level-wrapper.js';
/** Separator between compound key segments (higher than \x00 so prefix scans work correctly). */
export declare const COMPOUND_SEGMENT_SEPARATOR = "\u0001";
/**
 * Gets the compound index partition for a given compound index definition.
 * Compound index sublevels use the naming convention `__compound:<name>__`.
 */
export declare function getCompoundIndexPartition(db: LevelWrapper<string>, tenant: string, compoundIndex: CompoundIndexDefinition): Promise<LevelWrapper<string>>;
/**
 * Builds a compound index key from the given indexes and compound index definition.
 *
 * Key format: `<prop1>\x01<prop2>\x01...\x01<sortValue>\x00<messageCid>`
 *
 * @returns the compound key, or undefined if the indexes don't contain all required properties.
 */
export declare function buildCompoundKey(messageCid: string, indexes: KeyValues, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): string | undefined;
/**
 * Builds the prefix portion of a compound key from filter values (without the sort/messageCid suffix).
 * Used for range scans: all entries with this prefix match the filter.
 */
export declare function buildCompoundPrefix(filter: Filter, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string): string | undefined;
/**
 * Creates a put operation for a compound index entry.
 * Returns undefined if the indexes don't contain all required compound index properties.
 */
export declare function createCompoundIndexPutOperation(db: LevelWrapper<string>, tenant: string, item: IndexedItem, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): Promise<LevelWrapperBatchOperation<string>> | undefined;
/**
 * Creates a delete operation for a compound index entry.
 * Returns undefined if the indexes don't contain all required compound index properties.
 */
export declare function createCompoundIndexDeleteOperation(db: LevelWrapper<string>, tenant: string, messageCid: string, indexes: KeyValues, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string): Promise<LevelWrapperBatchOperation<string>> | undefined;
/**
 * Generic helper to create a batch operation for any named partition under a tenant.
 */
export declare function createOperationForPartition(db: LevelWrapper<string>, tenant: string, partitionName: string, operation: LevelWrapperBatchOperation<string>): Promise<LevelWrapperBatchOperation<string>>;
/**
 * Selects the best compound index that covers the given filter and sort requirements.
 *
 * A compound index "covers" a query when:
 * 1. Every property in the compound index definition is present in the filter as an equality filter.
 * 2. The compound index's sort property matches the query's sort property.
 *
 * Among multiple matching compound indexes, the one with the most properties is preferred
 * (more specific = fewer false positives in the prefix scan).
 */
export declare function selectCompoundIndex(filter: Filter, queryOptions: QueryOptions, compoundIndexes: CompoundIndexDefinition[]): CompoundIndexDefinition | undefined;
/**
 * Queries using a compound index. This is the most efficient query strategy: a single LevelDB
 * range scan that filters, sorts, and paginates all at once.
 *
 * The compound key encodes the filter properties as a prefix and the sort property as a suffix,
 * so iterating over keys with the filter prefix yields results in sort order.
 *
 * Any remaining filter properties not covered by the compound index are verified in memory.
 *
 * @param queryWithIteratorPagingFallback callback to fall back to iterator paging if compound prefix fails.
 */
export declare function queryWithCompoundIndex(db: LevelWrapper<string>, tenant: string, filter: Filter, queryOptions: QueryOptions, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, delimiter: string, queryWithIteratorPagingFallback: (tenant: string, filters: Filter[], queryOptions: QueryOptions, options?: IndexLevelOptions) => Promise<IndexedItem[]>, options?: IndexLevelOptions): Promise<IndexedItem[]>;
/**
 * Counts items matching a compound index prefix without loading full records.
 * Iterates only keys (not values) for maximum efficiency.
 *
 * @param queryFallback callback to fall back to full query if compound prefix fails.
 */
export declare function countWithCompoundIndex(db: LevelWrapper<string>, tenant: string, filter: Filter, compoundIndex: CompoundIndexDefinition, encodeValue: (value: string | number | boolean) => string, queryFallback: (tenant: string, filters: Filter[], queryOptions: QueryOptions, options?: IndexLevelOptions) => Promise<IndexedItem[]>, options?: IndexLevelOptions): Promise<number>;
//# sourceMappingURL=index-level-compound.d.ts.map