@tursodatabase/database-wasm 0.3.0-pre.3 → 0.3.0-pre.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,17 @@
1
1
  import { expect, test } from 'vitest';
2
2
  import { connect, Database } from './promise-default.js';
3
+ test('vector-test', async () => {
4
+ const db = await connect(":memory:");
5
+ const v1 = new Array(1024).fill(0).map((_, i) => i);
6
+ const v2 = new Array(1024).fill(0).map((_, i) => 1024 - i);
7
+ const result = await db.prepare(`SELECT
8
+ vector_distance_cos(vector32('${JSON.stringify(v1)}'), vector32('${JSON.stringify(v2)}')) as cosf32,
9
+ vector_distance_cos(vector64('${JSON.stringify(v1)}'), vector64('${JSON.stringify(v2)}')) as cosf64,
10
+ vector_distance_l2(vector32('${JSON.stringify(v1)}'), vector32('${JSON.stringify(v2)}')) as l2f32,
11
+ vector_distance_l2(vector64('${JSON.stringify(v1)}'), vector64('${JSON.stringify(v2)}')) as l2f64
12
+ `).all();
13
+ console.info(result);
14
+ });
3
15
  test('explain', async () => {
4
16
  const db = await connect(":memory:");
5
17
  const stmt = db.prepare("EXPLAIN SELECT 1");
Binary file