Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions TreeDB/collections/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9233,6 +9233,21 @@ func buildIndexedSemanticUpdateRecords(collectionName string, runtimes []indexRu
return nil
}
records := make([]indexedSemanticRecord, 0, len(updates))
totalIndexDeltas := 0
if len(runtimes) > 0 {
for _, update := range updates {
if !update.indexStateChanged {
continue
}
for runtimeIdx := range runtimes {
Comment on lines +9238 to +9242
if preparedBatchUpdateIndexChanged(update, runtimeIdx) {
totalIndexDeltas++
}
}
}
}
indexDeltas := make([]indexedSemanticIndexDelta, totalIndexDeltas)
indexDeltaPos := 0
Comment on lines +9249 to +9250
for i, update := range updates {
var documentID []byte
if i < len(primaryEntries) && len(primaryEntries[i].key) > 0 {
Expand All @@ -9247,21 +9262,26 @@ func buildIndexedSemanticUpdateRecords(collectionName string, runtimes []indexRu
documentID: documentID,
}
if update.indexStateChanged && len(runtimes) > 0 {
indexDeltaStart := indexDeltaPos
for runtimeIdx, runtime := range runtimes {
if !preparedBatchUpdateIndexChanged(update, runtimeIdx) {
continue
}
if runtime.def.unique {
record.fallback = indexedSemanticFallbackRawOnly
}
record.indexDeltas = append(record.indexDeltas, indexedSemanticIndexDelta{
indexDeltas[indexDeltaPos] = indexedSemanticIndexDelta{
indexName: runtime.def.name,
rootName: runtimeSecondaryRootName(collectionName, runtime),
runtimeIdx: runtimeIdx,
unique: runtime.def.unique,
oldValues: cloneIndexedSemanticValueSet(update.oldState.valuesAt(runtimeIdx)),
newValues: cloneIndexedSemanticValueSet(update.newState.valuesAt(runtimeIdx)),
})
}
indexDeltaPos++
}
if indexDeltaPos > indexDeltaStart {
record.indexDeltas = indexDeltas[indexDeltaStart:indexDeltaPos:indexDeltaPos]
}
}
records = append(records, record)
Expand Down
Loading