import { BaseIndex, IndexOperation } from './base-index.js'; import { CompareOptions } from '../query/builder/types.js'; import { BasicExpression } from '../query/ir.js'; /** * Options for range queries */ export interface RangeQueryOptions { from?: any; to?: any; fromInclusive?: boolean; toInclusive?: boolean; } /** * Options for Basic index */ export interface BasicIndexOptions { compareFn?: (a: any, b: any) => number; compareOptions?: CompareOptions; } /** * Basic index using Map + sorted Array. * * - Map for O(1) equality lookups * - Sorted Array for O(log n) range queries via binary search * - O(n) updates to maintain sort order * * Simpler and smaller than BTreeIndex, good for read-heavy workloads. * Use BTreeIndex for write-heavy workloads with large collections. */ export declare class BasicIndex extends BaseIndex { readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">; private valueMap; private sortedValues; private indexedKeys; private compareFn; constructor(id: number, expression: BasicExpression, name?: string, options?: any); protected initialize(_options?: BasicIndexOptions): void; /** * Adds a value to the index */ add(key: TKey, item: any): void; /** * Removes a value from the index */ remove(key: TKey, item: any): void; /** * Updates a value in the index */ update(key: TKey, oldItem: any, newItem: any): void; /** * Builds the index from a collection of entries */ build(entries: Iterable<[TKey, any]>): void; /** * Clears all data from the index */ clear(): void; /** * Performs a lookup operation */ lookup(operation: IndexOperation, value: any): Set; /** * Gets the number of indexed keys */ get keyCount(): number; /** * Performs an equality lookup - O(1) */ equalityLookup(value: any): Set; /** * Performs a range query using binary search - O(log n + m) */ rangeQuery(options?: RangeQueryOptions): Set; /** * Performs a reversed range query */ rangeQueryReversed(options?: RangeQueryOptions): Set; /** * Returns the next n items in sorted order */ take(n: number, from?: any, filterFn?: (key: TKey) => boolean): Array; /** * Returns the next n items in reverse sorted order */ takeReversed(n: number, from?: any, filterFn?: (key: TKey) => boolean): Array; /** * Returns the first n items in sorted order (from the start) */ takeFromStart(n: number, filterFn?: (key: TKey) => boolean): Array; /** * Returns the first n items in reverse sorted order (from the end) */ takeReversedFromEnd(n: number, filterFn?: (key: TKey) => boolean): Array; /** * Performs an IN array lookup - O(k) where k is values.length */ inArrayLookup(values: Array): Set; get indexedKeysSet(): Set; get orderedEntriesArray(): Array<[any, Set]>; get orderedEntriesArrayReversed(): Array<[any, Set]>; get valueMapData(): Map>; }