change module name 10
This commit is contained in:
@@ -33,8 +33,9 @@ type IndexStore interface {
|
||||
UnindexRecord(collection, partition string, fields []string, record map[string]any, lineIndex int)
|
||||
|
||||
// Rebuild перестраивает вклад в индекс для одной партиции (или всей коллекции, если одна партиция).
|
||||
// partition — имя партиции; records — записи, позиция в срезе = lineIndex.
|
||||
Rebuild(collection, partition string, fields []string, records []any) error
|
||||
// lineIndexes[i] — 0-based номер физической строки в файле для records[i] (после пустых/удалённых строк).
|
||||
// Если lineIndexes == nil или len != len(records), используются плотные индексы 0..len-1 (устаревшее поведение).
|
||||
Rebuild(collection, partition string, fields []string, records []any, lineIndexes []int) error
|
||||
|
||||
// Clear очищает индекс коллекции (все партиции).
|
||||
Clear(collection string) error
|
||||
@@ -164,7 +165,7 @@ func (s *InMemoryIndexStore) Lookup(collection, field, value string) ([]IndexPos
|
||||
}
|
||||
|
||||
// Rebuild перестраивает вклад партиции в индекс.
|
||||
func (s *InMemoryIndexStore) Rebuild(collection, partition string, fields []string, records []any) error {
|
||||
func (s *InMemoryIndexStore) Rebuild(collection, partition string, fields []string, records []any, lineIndexes []int) error {
|
||||
if partition == "" {
|
||||
partition = DefaultPartition
|
||||
}
|
||||
@@ -194,7 +195,11 @@ func (s *InMemoryIndexStore) Rebuild(collection, partition string, fields []stri
|
||||
}
|
||||
|
||||
// Добавляем новые позиции
|
||||
for idx, rec := range records {
|
||||
for i, rec := range records {
|
||||
lineIdx := i
|
||||
if lineIndexes != nil && i < len(lineIndexes) {
|
||||
lineIdx = lineIndexes[i]
|
||||
}
|
||||
recMap, ok := rec.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
@@ -205,7 +210,7 @@ func (s *InMemoryIndexStore) Rebuild(collection, partition string, fields []stri
|
||||
if s.index[key] == nil {
|
||||
s.index[key] = make(map[string][]IndexPosition)
|
||||
}
|
||||
s.index[key][val] = append(s.index[key][val], IndexPosition{Partition: partition, LineIndex: idx})
|
||||
s.index[key][val] = append(s.index[key][val], IndexPosition{Partition: partition, LineIndex: lineIdx})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user