/**
 * Query engine for executing log queries
 */
import { generateFacets } from '../aggregation/facet-generator.js';
import { sortLogEntries } from '../utils/sorting.js';
import { matchesQuery } from './filter-predicates.js';
/**
 * Execute a query against log entries
 */
export function executeQuery(entries, query, totalCount) {
    const startTime = performance.now();
    // Filter entries
    const filteredEntries = entries.filter(entry => matchesQuery(entry, query));
    // Apply sorting
    const sortedEntries = sortLogEntries(filteredEntries, query);
    // Apply pagination
    const offset = query.offset || 0;
    const limit = query.limit || 100;
    const paginatedEntries = sortedEntries.slice(offset, offset + limit);
    const queryTime = performance.now() - startTime;
    // Generate facets
    const filteredCount = filteredEntries.length;
    const facets = generateFacets(filteredEntries);
    return {
        entries: paginatedEntries,
        totalCount,
        filteredCount,
        queryTime,
        hasMore: offset + limit < filteredEntries.length,
        facets,
    };
}
//# sourceMappingURL=query-engine.js.map