Skip to content

Commit

Permalink
mock level2
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrmt committed Sep 28, 2023
1 parent a33ec3e commit 48be89f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
20 changes: 10 additions & 10 deletions cmd/tools/cli/benchmark/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func main() {
})

ids := make([]uint, len(vectors))
run(ctx, false, path, len(vectors[0]), vectors, ids, time.Hour*2, output)
run(ctx, false, path, len(vectors[0]), vectors, ids, time.Hour*1, output)
sleep(ctx, time.Second*5, time.Minute*4, func() {
output("waiting for next")
}, func() {
Expand All @@ -298,15 +298,15 @@ func main() {
output("starting")
})
run(ctx, true, path, len(vectors[0]), nil, nil, 0, output)
sleep(ctx, time.Second*5, time.Minute*4, func() {
output("waiting for next")
}, func() {
runtime.GC()
output("gc")
time.Sleep(time.Minute)
output("starting")
})
run(ctx, true, path, len(vectors[0]), vectors, ids, time.Hour*2, output)
// sleep(ctx, time.Second*5, time.Minute*4, func() {
// output("waiting for next")
// }, func() {
// runtime.GC()
// output("gc")
// time.Sleep(time.Minute)
// output("starting")
// })
// run(ctx, true, path, len(vectors[0]), vectors, ids, time.Hour*2, output)

ids = ids[:0:0]
ids = nil
Expand Down
18 changes: 6 additions & 12 deletions internal/core/algorithm/ngt/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,18 +517,16 @@ func (n *ngt) Insert(vec []float32) (id uint, err error) {
}
dim := C.uint32_t(n.dimension)
cvec := (*C.float)(&vec[0])
ebuf := n.GetErrorBuffer()
n.lock(true)
oid := C.ngt_insert_index_as_float(n.index, cvec, dim, ebuf)
oid := C.ngt_insert_index_as_float(nil, cvec, dim, nil)
n.unlock(true)
id = uint(oid)
cvec = nil
vec = vec[:0:0]
vec = nil
if id == 0 {
return 0, n.newGoError(ebuf)
return 0, errors.Errorf("Insert Error")
}
n.PutErrorBuffer(ebuf)
n.cnt.Add(1)

return id, nil
Expand Down Expand Up @@ -622,14 +620,12 @@ func (n *ngt) CreateIndex(poolSize uint32) error {
if poolSize == 0 {
poolSize = n.poolSize
}
ebuf := n.GetErrorBuffer()
n.lock(true)
ret := C.ngt_create_index(n.index, C.uint32_t(poolSize), ebuf)
ret := C.ngt_create_index(nil, C.uint32_t(poolSize), nil)
n.unlock(true)
if ret == ErrorCode {
return n.newGoError(ebuf)
return errors.Errorf("CreateIndex Error")
}
n.PutErrorBuffer(ebuf)

return nil
}
Expand Down Expand Up @@ -672,14 +668,12 @@ func (n *ngt) SaveIndexWithPath(idxPath string) error {

// Remove removes from NGT index.
func (n *ngt) Remove(id uint) error {
ebuf := n.GetErrorBuffer()
n.lock(true)
ret := C.ngt_remove_index(n.index, C.ObjectID(id), ebuf)
ret := C.ngt_remove_index(nil, C.ObjectID(id), nil)
n.unlock(true)
if ret == ErrorCode {
return n.newGoError(ebuf)
return errors.Errorf("Remove Error")
}
n.PutErrorBuffer(ebuf)

n.cnt.Add(^uint64(0))

Expand Down

0 comments on commit 48be89f

Please sign in to comment.