CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
/**
|
|
* Hash-based Partitioner
|
|
* Provides deterministic partitioning for distributed writes
|
|
*/
|
|
import { SharedConfig } from '../types/distributedTypes.js';
|
|
export declare class HashPartitioner {
|
|
private partitionCount;
|
|
private partitionPrefix;
|
|
constructor(config: SharedConfig);
|
|
/**
|
|
* Get partition for a given vector ID using deterministic hashing
|
|
* @param vectorId - The unique identifier of the vector
|
|
* @returns The partition path
|
|
*/
|
|
getPartition(vectorId: string): string;
|
|
/**
|
|
* Get partition with domain metadata (domain stored as metadata, not in path)
|
|
* @param vectorId - The unique identifier of the vector
|
|
* @param domain - The domain identifier (for metadata only)
|
|
* @returns The partition path
|
|
*/
|
|
getPartitionWithDomain(vectorId: string, domain?: string): string;
|
|
/**
|
|
* Get all partition paths
|
|
* @returns Array of all partition paths
|
|
*/
|
|
getAllPartitions(): string[];
|
|
/**
|
|
* Get partition index from partition path
|
|
* @param partitionPath - The partition path
|
|
* @returns The partition index
|
|
*/
|
|
getPartitionIndex(partitionPath: string): number;
|
|
/**
|
|
* Hash a string to a number for consistent partitioning
|
|
* @param str - The string to hash
|
|
* @returns A positive integer hash
|
|
*/
|
|
private hashString;
|
|
/**
|
|
* Get partitions for batch operations
|
|
* Groups vector IDs by their target partition
|
|
* @param vectorIds - Array of vector IDs
|
|
* @returns Map of partition to vector IDs
|
|
*/
|
|
getPartitionsForBatch(vectorIds: string[]): Map<string, string[]>;
|
|
}
|
|
/**
|
|
* Affinity-based Partitioner
|
|
* Extends HashPartitioner to prefer certain partitions for a writer
|
|
* while maintaining correctness
|
|
*/
|
|
export declare class AffinityPartitioner extends HashPartitioner {
|
|
private preferredPartitions;
|
|
private instanceId;
|
|
constructor(config: SharedConfig, instanceId: string);
|
|
/**
|
|
* Calculate preferred partitions for this instance
|
|
*/
|
|
private calculatePreferredPartitions;
|
|
/**
|
|
* Check if a partition is preferred for this instance
|
|
* @param partitionPath - The partition path
|
|
* @returns Whether this partition is preferred
|
|
*/
|
|
isPreferredPartition(partitionPath: string): boolean;
|
|
/**
|
|
* Get all preferred partitions for this instance
|
|
* @returns Array of preferred partition paths
|
|
*/
|
|
getPreferredPartitions(): string[];
|
|
/**
|
|
* Update preferred partitions based on new config
|
|
* @param config - The updated shared configuration
|
|
*/
|
|
updatePreferences(config: SharedConfig): void;
|
|
}
|