Skip to content

Commit

Permalink
Add: Batch add test
Browse files Browse the repository at this point in the history
  • Loading branch information
davvard committed Jul 31, 2023
1 parent 74860d6 commit 5f99b05
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions javascript/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ var results = index.search(new Float32Array([13, 14]), 2)
assert.deepEqual(results.keys, new BigUint64Array([15n, 16n]))
assert.deepEqual(results.distances, new Float32Array([45, 130]))

// Batch

var index2 = new usearch.Index({ metric: 'l2sq', connectivity: 16, dimensions: 2 })

const keys = [15, 16]
const vectors = [new Float32Array([10, 20]), new Float32Array([10, 25])]
index2.add(keys, vectors)
assert.equal(index.size(), 2)

var results = index.search(new Float32Array([13, 14]), 2)
assert.deepEqual(results.keys, new BigUint64Array([15n, 16n]))
assert.deepEqual(results.distances, new Float32Array([45, 130]))

console.log('JavaScript tests passed!')

0 comments on commit 5f99b05

Please sign in to comment.