Skip to content

Commit f5bd4ab

Browse files
authored
Vector Integration test error (#1301)
1 parent 5e20637 commit f5bd4ab

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/core/src/vector.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export default class Vector<K extends Float32Array | Float64Array | Int8Array |
5959
this._type = vectorTypes.FLOAT32
6060
} else if (typedArray instanceof Float64Array) {
6161
this._type = vectorTypes.FLOAT64
62+
} else if (
63+
typedArray instanceof Uint8Array ||
64+
typedArray instanceof Uint16Array ||
65+
typedArray instanceof Uint32Array ||
66+
typedArray instanceof BigUint64Array
67+
) {
68+
throw newError('The neo4j Vector class does not support Unsigned Integer Arrays, please use a signed IntArray')
6269
} else {
6370
throw newError(`The neo4j Vector class is a wrapper for TypedArrays. got ${typeof typedArray}`)
6471
}

packages/neo4j-driver-deno/lib/core/vector.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/neo4j-driver/test/vector-type.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('#integration vector type', () => {
2222
let driverGlobal
2323
let protocolVersion
2424
const uri = `bolt://${sharedNeo4j.hostnameWithBoltPort}`
25+
let edition
2526

2627
beforeAll(async () => {
2728
driverGlobal = neo4j.driver(uri, sharedNeo4j.authToken)
@@ -30,6 +31,7 @@ describe('#integration vector type', () => {
3031
sharedNeo4j.authToken
3132
)
3233
protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(tmpDriver)
34+
edition = await sharedNeo4j.getEdition(driverGlobal)
3335
await tmpDriver.close()
3436
})
3537

@@ -45,13 +47,13 @@ describe('#integration vector type', () => {
4547
})
4648

4749
it('write and read vectors', async () => {
48-
if (protocolVersion >= 6.0) {
50+
if (protocolVersion >= 6.0 && edition === 'enterprise') {
4951
const driver = driverGlobal
5052

5153
const bufferWriter = Uint8Array.from([1, 1])
5254
await driver.executeQuery('CREATE (p:Product) SET p.vector_from_array = $vector_from_array, p.vector_from_buffer = $vector_from_buffer', {
5355
vector_from_array: neo4j.vector(Float32Array.from([1, 2, 3, 4])), // Typed arrays can be created from a regular list of Numbers
54-
vector_from_buffer: neo4j.vector(new Uint8Array(bufferWriter.buffer)) // Or from a bytebuffer
56+
vector_from_buffer: neo4j.vector(new Int8Array(bufferWriter.buffer)) // Or from a bytebuffer
5557
})
5658
const res = await driver.executeQuery('MATCH (p:Product) RETURN p.vector_from_array as arrayVector, p.vector_from_buffer as bufferVector')
5759

0 commit comments

Comments
 (0)