Documentation
¶
Index ¶
- Variables
- type Entry
- type FastYAMLEncoder
- type IndexManager
- func (im *IndexManager) AddIndex(field string, indexType string) error
- func (im *IndexManager) Remove(key string)
- func (im *IndexManager) RemoveIndex(field string, indexType string) error
- func (im *IndexManager) Search(query map[string]interface{}) ([]string, error)
- func (im *IndexManager) Update(key string, value interface{}) error
- type SearchQuery
- type SearchResult
- type Store
- func (s *Store) AddToIndex(field string, key string, value interface{}) error
- func (s *Store) Close() error
- func (s *Store) CreateIndex(field string, indexType string) error
- func (s *Store) Delete(key string)
- func (s *Store) Get(key string) (*Entry, bool)
- func (s *Store) GetStats() StoreStats
- func (s *Store) RemoveIndex(field string, indexType string) error
- func (s *Store) Search(query SearchQuery) ([]SearchResult, error)
- func (s *Store) Set(key string, value interface{}) error
- func (s *Store) SetWithTTL(key string, value interface{}, ttl time.Duration) error
- func (s *Store) Sync() error
- type StoreOptions
- type StoreStats
- type TextSearchResult
- type TrigramIndex
- type VectorIndex
- type VectorSearchResult
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = StoreOptions{ InitialSize: 32 << 20, MaxSize: 512 << 20, SyncInterval: time.Minute, Debug: false, }
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Value interface{} `yaml:"value"`
Timestamp int64 `yaml:"timestamp,omitempty"`
TTL int64 `yaml:"ttl,omitempty"`
}
Entry represents a single value in the store with metadata
type FastYAMLEncoder ¶
type FastYAMLEncoder struct {
// contains filtered or unexported fields
}
FastYAMLEncoder provides optimized YAML encoding with buffer pooling
func NewFastYAMLEncoder ¶
func NewFastYAMLEncoder() *FastYAMLEncoder
NewFastYAMLEncoder creates a new encoder with initialized buffer pool
func (*FastYAMLEncoder) Decode ¶
func (f *FastYAMLEncoder) Decode(data []byte, v interface{}) error
Decode performs YAML decoding with validation
func (*FastYAMLEncoder) Encode ¶
func (f *FastYAMLEncoder) Encode(v interface{}) ([]byte, error)
Encode performs YAML encoding with buffer reuse
type IndexManager ¶
IndexManager handles multiple index types
func NewIndexManager ¶
func NewIndexManager() *IndexManager
NewIndexManager creates a new index manager
func (*IndexManager) AddIndex ¶
func (im *IndexManager) AddIndex(field string, indexType string) error
AddIndex creates a new index for the specified field
func (*IndexManager) Remove ¶
func (im *IndexManager) Remove(key string)
Remove removes a key from all indexes
func (*IndexManager) RemoveIndex ¶
func (im *IndexManager) RemoveIndex(field string, indexType string) error
RemoveIndex removes an index of the specified type
func (*IndexManager) Search ¶
func (im *IndexManager) Search(query map[string]interface{}) ([]string, error)
Search performs a search across all relevant indexes
func (*IndexManager) Update ¶
func (im *IndexManager) Update(key string, value interface{}) error
Update updates all indexes for a given key-value pair
type SearchQuery ¶
type SearchQuery struct {
Text string `json:"text,omitempty"`
Vector []float32 `json:"vector,omitempty"`
Filters map[string]interface{} `json:"filters,omitempty"`
MaxResults int `json:"max_results,omitempty"`
MinScore float64 `json:"min_score,omitempty"`
}
SearchQuery represents a combined search query
type SearchResult ¶
type SearchResult struct {
Key string `json:"key"`
Value interface{} `json:"value"`
TextScore float64 `json:"text_score,omitempty"`
VecScore float32 `json:"vector_score,omitempty"`
Combined float64 `json:"combined_score"`
}
SearchResult represents a combined search result
type Store ¶
Store represents an enhanced memory-mapped key-value store
func NewStore ¶
func NewStore(filepath string, opts StoreOptions) (*Store, error)
NewStore creates a new memory-mapped store with the given options
func (*Store) AddToIndex ¶
AddToIndex adds or updates a value in the specified index
func (*Store) CreateIndex ¶
CreateIndex creates a new index of the specified type
func (*Store) RemoveIndex ¶
RemoveIndex removes an index of the specified type
func (*Store) Search ¶
func (s *Store) Search(query SearchQuery) ([]SearchResult, error)
Search performs a combined search across all indexes
func (*Store) SetWithTTL ¶
type StoreOptions ¶
StoreOptions configures the store initialization
type StoreStats ¶
type StoreStats struct {
sync.Mutex
// Basic Operations
Reads uint64 `json:"reads" yaml:"reads"`
Writes uint64 `json:"writes" yaml:"writes"`
Deletes uint64 `json:"deletes" yaml:"deletes"`
SyncCount uint64 `json:"sync_count" yaml:"sync_count"`
LastSyncTime time.Time `json:"last_sync_time" yaml:"last_sync_time"`
// Storage Stats
DataSize int64 `json:"data_size" yaml:"data_size"` // Current size of YAML data
FileSize int64 `json:"file_size" yaml:"file_size"` // Total size of mmap file
EntryCount uint64 `json:"entry_count" yaml:"entry_count"` // Number of active entries
ExpiredCount uint64 `json:"expired_count" yaml:"expired_count"` // Number of expired entries
// Index Stats
IndexStats struct {
TextIndexes struct {
Count int `json:"count" yaml:"count"`
EntryCount int `json:"entry_count" yaml:"entry_count"`
} `json:"text_indexes" yaml:"text_indexes"`
VectorIndexes struct {
Count int `json:"count" yaml:"count"`
EntryCount int `json:"entry_count" yaml:"entry_count"`
} `json:"vector_indexes" yaml:"vector_indexes"`
BTreeIndexes struct {
Count int `json:"count" yaml:"count"`
EntryCount int `json:"entry_count" yaml:"entry_count"`
} `json:"btree_indexes" yaml:"btree_indexes"`
} `json:"index_stats" yaml:"index_stats"`
// Performance Stats
PerformanceStats struct {
AvgReadLatency float64 `json:"avg_read_latency" yaml:"avg_read_latency"` // in milliseconds
AvgWriteLatency float64 `json:"avg_write_latency" yaml:"avg_write_latency"` // in milliseconds
AvgSyncLatency float64 `json:"avg_sync_latency" yaml:"avg_sync_latency"` // in milliseconds
LastGC time.Time `json:"last_gc" yaml:"last_gc"` // Last time expired entries were cleaned
} `json:"performance_stats" yaml:"performance_stats"`
}
StoreStats tracks operational statistics for monitoring.
type TextSearchResult ¶
TextSearchResult represents a single text search result with score
type TrigramIndex ¶
TrigramIndex provides text search using trigram-based indexing
func NewTrigramIndex ¶
func NewTrigramIndex() *TrigramIndex
NewTrigramIndex creates a new trigram-based text index
func (*TrigramIndex) FuzzySearch ¶
func (ti *TrigramIndex) FuzzySearch(query string, minScore float64, maxResults int) []TextSearchResult
FuzzySearch performs fuzzy text search with configurable parameters
func (*TrigramIndex) Remove ¶
func (ti *TrigramIndex) Remove(key string)
Remove deletes a document from the index
func (*TrigramIndex) Search ¶
func (ti *TrigramIndex) Search(query string, maxResults int) []TextSearchResult
Search performs a fuzzy text search using trigrams
func (*TrigramIndex) Update ¶
func (ti *TrigramIndex) Update(key string, text string)
Update adds or updates a document in the index
type VectorIndex ¶
VectorIndex provides vector similarity search capabilities
func NewVectorIndex ¶
func NewVectorIndex(dimensions int) *VectorIndex
NewVectorIndex creates a new vector index with specified dimensions
func (*VectorIndex) BatchSearch ¶
func (vi *VectorIndex) BatchSearch(queries [][]float32, k int) ([][]VectorSearchResult, error)
BatchSearch performs vector search with multiple query vectors
func (*VectorIndex) Remove ¶
func (vi *VectorIndex) Remove(key string)
Remove deletes a vector from the index
func (*VectorIndex) Search ¶
func (vi *VectorIndex) Search(query []float32, k int) ([]VectorSearchResult, error)
Search performs approximate nearest neighbor search
type VectorSearchResult ¶
VectorSearchResult represents a single search result with score