Skip to content

Commit 875239d

Browse files
added changes
1 parent 6a92657 commit 875239d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tok/partitioned_hnsw/partitioned_hnsw.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ type partitionedHNSW[T c.Float] struct {
2626
hnswOptions opt.Options
2727
partitionStrat string
2828

29-
caches []index.CacheType
30-
buildPass int
29+
caches []index.CacheType
30+
buildPass int
31+
buildSyncMaps map[int]*sync.Mutex
3132
}
3233

3334
func (ph *partitionedHNSW[T]) applyOptions(o opt.Options) error {
@@ -75,7 +76,10 @@ func (ph *partitionedHNSW[T]) BuildInsert(ctx context.Context, uuid uint64, vec
7576
if index%NUM_PASSES != passIdx {
7677
return nil
7778
}
78-
return ph.clusterMap[index].BuildInsert(ctx, uuid, vec)
79+
ph.buildSyncMaps[index].Lock()
80+
defer ph.buildSyncMaps[index].Unlock()
81+
_, err = ph.clusterMap[index].Insert(ctx, ph.caches[index], uuid, vec)
82+
return err
7983
}
8084

8185
const NUM_PASSES = 10
@@ -107,6 +111,7 @@ func (ph *partitionedHNSW[T]) StartBuild(caches []index.CacheType) {
107111
if i%NUM_PASSES != (ph.buildPass - ph.partition.NumPasses()) {
108112
continue
109113
}
114+
ph.buildSyncMaps[i] = &sync.Mutex{}
110115
ph.clusterMap[i].StartBuild([]index.CacheType{ph.caches[i]})
111116
}
112117
}

tok/tok.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package tok
77

88
import (
99
"encoding/binary"
10-
"fmt"
1110
"math/big"
1211
"plugin"
1312
"strings"
@@ -157,7 +156,6 @@ func GetTokenizer(name string) (Tokenizer, bool) {
157156

158157
// GetIndexFactory returns IndexFactory given name.
159158
func GetIndexFactory(name string) (IndexFactory, bool) {
160-
fmt.Println("HERE GET INDEX FACTORY", indexFactories, name)
161159
f, found := indexFactories[name]
162160
return f, found
163161
}

0 commit comments

Comments
 (0)