UNPKG

antarys

Version:

High-performance Node.js client for Antarys vector database with HTTP/2, connection pooling, and intelligent caching

103 lines 3.32 kB
import { VectorRecord, SearchParams, SearchResults, BatchSearchResults, UpsertResponse, DeleteResponse, CacheStats, CollectionInfo, Logger } from '../shared/types'; import { QueryCache, BufferPool } from './caching'; interface VectorOpsContext { request: <T = any>(options: any) => Promise<T>; queryCache: QueryCache; bufferPool: BufferPool; logger: Logger; collectionCache: Map<string, CollectionInfo>; getCollectionDimensions: (collectionName: string) => Promise<number | undefined>; validateVectorDimensions: (collectionName: string, vector: number[]) => Promise<boolean>; } interface BatchUpsertOptions { batchSize?: number; showProgress?: boolean; parallelWorkers?: number; validateDimensions?: boolean; } interface QueryOptions extends SearchParams { skipCache?: boolean; validateDimensions?: boolean; } export declare class VectorOperations { private readonly host; private readonly collectionName; private readonly context; private readonly workerPool; private readonly maxWorkers; private cacheHits; private cacheMisses; private upsertQueue; private upsertTimeout?; private readonly batchDelay; constructor(host: string, collectionName: string, context: VectorOpsContext); /** * Upsert vectors with intelligent batching and worker thread parallelization */ upsert(vectors: VectorRecord[], options?: BatchUpsertOptions): Promise<UpsertResponse>; /** * Optimized batch upsert with retry logic */ upsertBatch(batch: VectorRecord[]): Promise<UpsertResponse>; /** * High-performance vector similarity search with caching */ query(params?: QueryOptions): Promise<SearchResults>; /** * Batch query for multiple vectors with worker thread parallelization */ batchQuery(vectors: number[][], options?: Omit<QueryOptions, 'vector'>): Promise<BatchSearchResults>; /** * Delete vectors by ID */ delete(ids: string[]): Promise<DeleteResponse>; /** * Get a specific vector by ID */ getVector(vectorId: string): Promise<VectorRecord | null>; /** * Count vectors in collection */ countVectors(): Promise<number>; /** * Get cache performance statistics */ getCacheStats(): CacheStats; /** * Clear query cache for this collection */ clearCache(): Promise<{ success: boolean; message: string; }>; /** * Get collection dimensions (cached) */ getCollectionDimensions(): Promise<number | undefined>; /** * Validate vector dimensions against collection */ validateVectorDimensions(vector: number[]): Promise<boolean>; /** * Validate dimensions for a batch of vectors */ private validateBatchDimensions; /** * Preprocess vectors using worker threads for CPU-intensive operations */ private preprocessVectorsParallel; /** * Direct preprocessing for small datasets or fallback */ private preprocessVectorsDirect; /** * Optimize vector for JSON serialization and network transmission */ private optimizeVector; /** * Clean up resources including worker pool */ close(): Promise<void>; } export {}; //# sourceMappingURL=vector_ops.d.ts.map