@lancedb/lancedb 0.7.1 → 0.9.0

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.
Files changed (92) hide show
  1. package/dist/arrow.d.ts +2 -3
  2. package/dist/arrow.js +2 -27
  3. package/dist/connection.d.ts +9 -0
  4. package/dist/connection.js +16 -2
  5. package/dist/embedding/embedding_function.d.ts +11 -0
  6. package/dist/embedding/embedding_function.js +28 -7
  7. package/dist/embedding/index.d.ts +2 -1
  8. package/dist/embedding/index.js +7 -6
  9. package/dist/embedding/openai.d.ts +1 -1
  10. package/dist/embedding/registry.d.ts +9 -7
  11. package/dist/embedding/registry.js +24 -6
  12. package/dist/embedding/transformers.d.ts +37 -0
  13. package/dist/embedding/transformers.js +147 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/query.js +15 -9
  16. package/dist/remote/client.d.ts +1 -1
  17. package/dist/remote/client.js +6 -8
  18. package/dist/remote/connection.d.ts +2 -3
  19. package/dist/remote/connection.js +2 -2
  20. package/dist/sanitize.js +4 -2
  21. package/dist/table.d.ts +3 -0
  22. package/dist/table.js +1 -1
  23. package/package.json +17 -13
  24. package/Cargo.toml +0 -28
  25. package/biome.json +0 -158
  26. package/build.rs +0 -5
  27. package/dist/native.d.ts +0 -208
  28. package/examples/ann_indexes.ts +0 -49
  29. package/examples/basic.ts +0 -149
  30. package/examples/embedding.ts +0 -83
  31. package/examples/filtering.ts +0 -34
  32. package/examples/jsconfig.json +0 -27
  33. package/examples/package-lock.json +0 -79
  34. package/examples/package.json +0 -18
  35. package/examples/search.ts +0 -37
  36. package/jest.config.js +0 -7
  37. package/lancedb/arrow.ts +0 -947
  38. package/lancedb/connection.ts +0 -333
  39. package/lancedb/embedding/embedding_function.ts +0 -194
  40. package/lancedb/embedding/index.ts +0 -113
  41. package/lancedb/embedding/openai.ts +0 -113
  42. package/lancedb/embedding/registry.ts +0 -188
  43. package/lancedb/index.ts +0 -142
  44. package/lancedb/indices.ts +0 -203
  45. package/lancedb/merge.ts +0 -70
  46. package/lancedb/query.ts +0 -507
  47. package/lancedb/remote/client.ts +0 -221
  48. package/lancedb/remote/connection.ts +0 -201
  49. package/lancedb/remote/index.ts +0 -3
  50. package/lancedb/remote/table.ts +0 -226
  51. package/lancedb/sanitize.ts +0 -588
  52. package/lancedb/table.ts +0 -669
  53. package/lancedb/util.ts +0 -69
  54. package/native.d.ts +0 -208
  55. package/nodejs-artifacts/arrow.d.ts +0 -250
  56. package/nodejs-artifacts/arrow.js +0 -768
  57. package/nodejs-artifacts/connection.d.ts +0 -171
  58. package/nodejs-artifacts/connection.js +0 -135
  59. package/nodejs-artifacts/embedding/embedding_function.d.ts +0 -79
  60. package/nodejs-artifacts/embedding/embedding_function.js +0 -112
  61. package/nodejs-artifacts/embedding/index.d.ts +0 -28
  62. package/nodejs-artifacts/embedding/index.js +0 -114
  63. package/nodejs-artifacts/embedding/openai.d.ts +0 -18
  64. package/nodejs-artifacts/embedding/openai.js +0 -105
  65. package/nodejs-artifacts/embedding/registry.d.ts +0 -53
  66. package/nodejs-artifacts/embedding/registry.js +0 -127
  67. package/nodejs-artifacts/index.d.ts +0 -55
  68. package/nodejs-artifacts/index.js +0 -57
  69. package/nodejs-artifacts/indices.d.ts +0 -165
  70. package/nodejs-artifacts/indices.js +0 -71
  71. package/nodejs-artifacts/merge.d.ts +0 -54
  72. package/nodejs-artifacts/merge.js +0 -64
  73. package/nodejs-artifacts/native.d.ts +0 -208
  74. package/nodejs-artifacts/native.js +0 -330
  75. package/nodejs-artifacts/query.d.ts +0 -283
  76. package/nodejs-artifacts/query.js +0 -448
  77. package/nodejs-artifacts/remote/client.d.ts +0 -28
  78. package/nodejs-artifacts/remote/client.js +0 -172
  79. package/nodejs-artifacts/remote/connection.d.ts +0 -25
  80. package/nodejs-artifacts/remote/connection.js +0 -110
  81. package/nodejs-artifacts/remote/index.d.ts +0 -3
  82. package/nodejs-artifacts/remote/index.js +0 -9
  83. package/nodejs-artifacts/remote/table.d.ts +0 -42
  84. package/nodejs-artifacts/remote/table.js +0 -179
  85. package/nodejs-artifacts/sanitize.d.ts +0 -31
  86. package/nodejs-artifacts/sanitize.js +0 -436
  87. package/nodejs-artifacts/table.d.ts +0 -395
  88. package/nodejs-artifacts/table.js +0 -230
  89. package/nodejs-artifacts/util.d.ts +0 -14
  90. package/nodejs-artifacts/util.js +0 -65
  91. package/tsconfig.json +0 -25
  92. package/typedoc.json +0 -10
@@ -22,16 +22,14 @@ class RestfulLanceDBClient {
22
22
  #apiKey;
23
23
  #hostOverride;
24
24
  #closed = false;
25
- #connectionTimeout = 12 * 1000; // 12 seconds;
26
- #readTimeout = 30 * 1000; // 30 seconds;
25
+ #timeout = 12 * 1000; // 12 seconds;
27
26
  #session;
28
- constructor(dbName, apiKey, region, hostOverride, connectionTimeout, readTimeout) {
27
+ constructor(dbName, apiKey, region, hostOverride, timeout) {
29
28
  this.#dbName = dbName;
30
29
  this.#apiKey = apiKey;
31
30
  this.#region = region;
32
31
  this.#hostOverride = hostOverride ?? this.#hostOverride;
33
- this.#connectionTimeout = connectionTimeout ?? this.#connectionTimeout;
34
- this.#readTimeout = readTimeout ?? this.#readTimeout;
32
+ this.#timeout = timeout ?? this.#timeout;
35
33
  }
36
34
  // todo: cache the session.
37
35
  get session() {
@@ -46,7 +44,7 @@ class RestfulLanceDBClient {
46
44
  Authorization: `Bearer ${this.#apiKey}`,
47
45
  },
48
46
  transformResponse: decodeErrorData,
49
- timeout: this.#connectionTimeout,
47
+ timeout: this.#timeout,
50
48
  });
51
49
  }
52
50
  }
@@ -91,7 +89,7 @@ class RestfulLanceDBClient {
91
89
  });
92
90
  }
93
91
  catch (e) {
94
- if (e instanceof axios_1.AxiosError) {
92
+ if (e instanceof axios_1.AxiosError && e.response) {
95
93
  response = e.response;
96
94
  }
97
95
  else {
@@ -120,7 +118,7 @@ class RestfulLanceDBClient {
120
118
  });
121
119
  }
122
120
  catch (e) {
123
- if (e instanceof axios_1.AxiosError) {
121
+ if (e instanceof axios_1.AxiosError && e.response) {
124
122
  response = e.response;
125
123
  }
126
124
  else {
@@ -5,12 +5,11 @@ export interface RemoteConnectionOptions {
5
5
  apiKey?: string;
6
6
  region?: string;
7
7
  hostOverride?: string;
8
- connectionTimeout?: number;
9
- readTimeout?: number;
8
+ timeout?: number;
10
9
  }
11
10
  export declare class RemoteConnection extends Connection {
12
11
  #private;
13
- constructor(url: string, { apiKey, region, hostOverride, connectionTimeout, readTimeout, }: RemoteConnectionOptions);
12
+ constructor(url: string, { apiKey, region, hostOverride, timeout }: RemoteConnectionOptions);
14
13
  isOpen(): boolean;
15
14
  close(): void;
16
15
  display(): string;
@@ -13,7 +13,7 @@ class RemoteConnection extends connection_1.Connection {
13
13
  #region;
14
14
  #client;
15
15
  #tableCache = new util_1.TTLCache(300000);
16
- constructor(url, { apiKey, region, hostOverride, connectionTimeout, readTimeout, }) {
16
+ constructor(url, { apiKey, region, hostOverride, timeout }) {
17
17
  super();
18
18
  apiKey = apiKey ?? process.env.LANCEDB_API_KEY;
19
19
  region = region ?? process.env.LANCEDB_REGION;
@@ -30,7 +30,7 @@ class RemoteConnection extends connection_1.Connection {
30
30
  this.#dbName = parsed.hostname;
31
31
  this.#apiKey = apiKey;
32
32
  this.#region = region;
33
- this.#client = new client_1.RestfulLanceDBClient(this.#dbName, this.#apiKey, this.#region, hostOverride, connectionTimeout, readTimeout);
33
+ this.#client = new client_1.RestfulLanceDBClient(this.#dbName, this.#apiKey, this.#region, hostOverride, timeout);
34
34
  }
35
35
  isOpen() {
36
36
  return this.#client.isOpen();
package/dist/sanitize.js CHANGED
@@ -215,8 +215,10 @@ function sanitizeType(typeLike) {
215
215
  if (typeof typeLike !== "object" || typeLike === null) {
216
216
  throw Error("Expected a Type but object was null/undefined");
217
217
  }
218
- if (!("typeId" in typeLike) || !(typeof typeLike.typeId !== "function")) {
219
- throw Error("Expected a Type to have a typeId function");
218
+ if (!("typeId" in typeLike) ||
219
+ !(typeof typeLike.typeId !== "function" ||
220
+ typeof typeLike.typeId !== "number")) {
221
+ throw Error("Expected a Type to have a typeId property");
220
222
  }
221
223
  let typeId;
222
224
  if (typeof typeLike.typeId === "function") {
package/dist/table.d.ts CHANGED
@@ -221,12 +221,15 @@ export declare abstract class Table {
221
221
  * of the given query vector
222
222
  * @param {string} query - the query. This will be converted to a vector using the table's provided embedding function
223
223
  * @note If no embedding functions are defined in the table, this will error when collecting the results.
224
+ *
225
+ * This is just a convenience method for calling `.query().nearestTo(await myEmbeddingFunction(query))`
224
226
  */
225
227
  abstract search(query: string): VectorQuery;
226
228
  /**
227
229
  * Create a search query to find the nearest neighbors
228
230
  * of the given query vector
229
231
  * @param {IntoVector} query - the query vector
232
+ * This is just a convenience method for calling `.query().nearestTo(query)`
230
233
  */
231
234
  abstract search(query: IntoVector): VectorQuery;
232
235
  /**
package/dist/table.js CHANGED
@@ -93,7 +93,7 @@ class LocalTable extends Table {
93
93
  const mode = options?.mode ?? "append";
94
94
  const schema = await this.schema();
95
95
  const registry = (0, registry_1.getRegistry)();
96
- const functions = registry.parseFunctions(schema.metadata);
96
+ const functions = await registry.parseFunctions(schema.metadata);
97
97
  const buffer = await (0, arrow_1.fromDataToBuffer)(data, functions.values().next().value, schema);
98
98
  await this.inner.add(buffer, mode);
99
99
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "vector database",
11
11
  "ann"
12
12
  ],
13
- "version": "0.7.1",
13
+ "version": "0.9.0",
14
14
  "main": "dist/index.js",
15
15
  "exports": {
16
16
  ".": "./dist/index.js",
@@ -32,25 +32,29 @@
32
32
  },
33
33
  "license": "Apache 2.0",
34
34
  "devDependencies": {
35
+ "@aws-sdk/client-dynamodb": "^3.33.0",
35
36
  "@aws-sdk/client-kms": "^3.33.0",
36
37
  "@aws-sdk/client-s3": "^3.33.0",
37
- "@aws-sdk/client-dynamodb": "^3.33.0",
38
38
  "@biomejs/biome": "^1.7.3",
39
39
  "@jest/globals": "^29.7.0",
40
40
  "@napi-rs/cli": "^2.18.3",
41
+ "@types/axios": "^0.14.0",
41
42
  "@types/jest": "^29.1.2",
42
43
  "@types/tmp": "^0.2.6",
43
- "apache-arrow-old": "npm:apache-arrow@13.0.0",
44
+ "apache-arrow-13": "npm:apache-arrow@13.0.0",
45
+ "apache-arrow-14": "npm:apache-arrow@14.0.0",
46
+ "apache-arrow-15": "npm:apache-arrow@15.0.0",
47
+ "apache-arrow-16": "npm:apache-arrow@16.0.0",
48
+ "apache-arrow-17": "npm:apache-arrow@17.0.0",
44
49
  "eslint": "^8.57.0",
45
50
  "jest": "^29.7.0",
46
51
  "shx": "^0.3.4",
47
52
  "tmp": "^0.2.3",
48
53
  "ts-jest": "^29.1.2",
49
- "typedoc": "^0.25.7",
50
- "typedoc-plugin-markdown": "^3.17.1",
54
+ "typedoc": "^0.26.4",
55
+ "typedoc-plugin-markdown": "^4.2.1",
51
56
  "typescript": "^5.3.3",
52
- "typescript-eslint": "^7.1.0",
53
- "@types/axios": "^0.14.0"
57
+ "typescript-eslint": "^7.1.0"
54
58
  },
55
59
  "ava": {
56
60
  "timeout": "3m"
@@ -88,13 +92,13 @@
88
92
  "reflect-metadata": "^0.2.2"
89
93
  },
90
94
  "optionalDependencies": {
91
- "@lancedb/lancedb-darwin-arm64": "0.7.1",
92
- "@lancedb/lancedb-linux-arm64-gnu": "0.7.1",
93
- "@lancedb/lancedb-darwin-x64": "0.7.1",
94
- "@lancedb/lancedb-linux-x64-gnu": "0.7.1",
95
- "@lancedb/lancedb-win32-x64-msvc": "0.7.1"
95
+ "@lancedb/lancedb-darwin-arm64": "0.9.0",
96
+ "@lancedb/lancedb-linux-arm64-gnu": "0.9.0",
97
+ "@lancedb/lancedb-darwin-x64": "0.9.0",
98
+ "@lancedb/lancedb-linux-x64-gnu": "0.9.0",
99
+ "@lancedb/lancedb-win32-x64-msvc": "0.9.0"
96
100
  },
97
101
  "peerDependencies": {
98
- "apache-arrow": "^15.0.0"
102
+ "apache-arrow": ">=13.0.0 <=17.0.0"
99
103
  }
100
104
  }
package/Cargo.toml DELETED
@@ -1,28 +0,0 @@
1
- [package]
2
- name = "lancedb-nodejs"
3
- edition.workspace = true
4
- version = "0.0.0"
5
- license.workspace = true
6
- description.workspace = true
7
- repository.workspace = true
8
- keywords.workspace = true
9
- categories.workspace = true
10
-
11
- [lib]
12
- crate-type = ["cdylib"]
13
-
14
- [dependencies]
15
- arrow-ipc.workspace = true
16
- futures.workspace = true
17
- lancedb = { path = "../rust/lancedb" }
18
- napi = { version = "2.16.8", default-features = false, features = [
19
- "napi9",
20
- "async",
21
- ] }
22
- napi-derive = "2.16.4"
23
-
24
- # Prevent dynamic linking of lzma, which comes from datafusion
25
- lzma-sys = { version = "*", features = ["static"] }
26
-
27
- [build-dependencies]
28
- napi-build = "2.1"
package/biome.json DELETED
@@ -1,158 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3
- "organizeImports": {
4
- "enabled": true
5
- },
6
- "files": {
7
- "ignore": [
8
- "**/dist/**/*",
9
- "**/native.js",
10
- "**/native.d.ts",
11
- "**/npm/**/*",
12
- "**/.vscode/**"
13
- ]
14
- },
15
- "formatter": {
16
- "indentStyle": "space"
17
- },
18
- "linter": {
19
- "enabled": true,
20
- "rules": {
21
- "recommended": false,
22
- "complexity": {
23
- "noBannedTypes": "error",
24
- "noExtraBooleanCast": "error",
25
- "noMultipleSpacesInRegularExpressionLiterals": "error",
26
- "noUselessCatch": "error",
27
- "noUselessThisAlias": "error",
28
- "noUselessTypeConstraint": "error",
29
- "noWith": "error"
30
- },
31
- "correctness": {
32
- "noConstAssign": "error",
33
- "noConstantCondition": "error",
34
- "noEmptyCharacterClassInRegex": "error",
35
- "noEmptyPattern": "error",
36
- "noGlobalObjectCalls": "error",
37
- "noInnerDeclarations": "error",
38
- "noInvalidConstructorSuper": "error",
39
- "noNewSymbol": "error",
40
- "noNonoctalDecimalEscape": "error",
41
- "noPrecisionLoss": "error",
42
- "noSelfAssign": "error",
43
- "noSetterReturn": "error",
44
- "noSwitchDeclarations": "error",
45
- "noUndeclaredVariables": "error",
46
- "noUnreachable": "error",
47
- "noUnreachableSuper": "error",
48
- "noUnsafeFinally": "error",
49
- "noUnsafeOptionalChaining": "error",
50
- "noUnusedLabels": "error",
51
- "noUnusedVariables": "warn",
52
- "useIsNan": "error",
53
- "useValidForDirection": "error",
54
- "useYield": "error"
55
- },
56
- "style": {
57
- "noNamespace": "error",
58
- "useAsConstAssertion": "error",
59
- "useBlockStatements": "off",
60
- "useNamingConvention": {
61
- "level": "error",
62
- "options": {
63
- "strictCase": false
64
- }
65
- }
66
- },
67
- "suspicious": {
68
- "noAssignInExpressions": "error",
69
- "noAsyncPromiseExecutor": "error",
70
- "noCatchAssign": "error",
71
- "noClassAssign": "error",
72
- "noCompareNegZero": "error",
73
- "noControlCharactersInRegex": "error",
74
- "noDebugger": "error",
75
- "noDuplicateCase": "error",
76
- "noDuplicateClassMembers": "error",
77
- "noDuplicateObjectKeys": "error",
78
- "noDuplicateParameters": "error",
79
- "noEmptyBlockStatements": "error",
80
- "noExplicitAny": "warn",
81
- "noExtraNonNullAssertion": "error",
82
- "noFallthroughSwitchClause": "error",
83
- "noFunctionAssign": "error",
84
- "noGlobalAssign": "error",
85
- "noImportAssign": "error",
86
- "noMisleadingCharacterClass": "error",
87
- "noMisleadingInstantiator": "error",
88
- "noPrototypeBuiltins": "error",
89
- "noRedeclare": "error",
90
- "noShadowRestrictedNames": "error",
91
- "noUnsafeDeclarationMerging": "error",
92
- "noUnsafeNegation": "error",
93
- "useGetterReturn": "error",
94
- "useValidTypeof": "error"
95
- }
96
- },
97
- "ignore": [
98
- "**/dist/**/*",
99
- "**/native.js",
100
- "**/native.d.ts",
101
- "__test__/docs/**/*",
102
- "examples/**/*"
103
- ]
104
- },
105
- "javascript": {
106
- "globals": []
107
- },
108
- "overrides": [
109
- {
110
- "include": ["__test__/s3_integration.test.ts"],
111
- "linter": {
112
- "rules": {
113
- "style": {
114
- "useNamingConvention": "off"
115
- }
116
- }
117
- }
118
- },
119
- {
120
- "include": [
121
- "**/*.ts",
122
- "**/*.tsx",
123
- "**/*.mts",
124
- "**/*.cts",
125
- "__test__/*.test.ts"
126
- ],
127
- "linter": {
128
- "rules": {
129
- "correctness": {
130
- "noConstAssign": "off",
131
- "noGlobalObjectCalls": "off",
132
- "noInvalidConstructorSuper": "off",
133
- "noNewSymbol": "off",
134
- "noSetterReturn": "off",
135
- "noUndeclaredVariables": "off",
136
- "noUnreachable": "off",
137
- "noUnreachableSuper": "off"
138
- },
139
- "style": {
140
- "noArguments": "error",
141
- "noVar": "error",
142
- "useConst": "error"
143
- },
144
- "suspicious": {
145
- "noDuplicateClassMembers": "off",
146
- "noDuplicateObjectKeys": "off",
147
- "noDuplicateParameters": "off",
148
- "noFunctionAssign": "off",
149
- "noImportAssign": "off",
150
- "noRedeclare": "off",
151
- "noUnsafeNegation": "off",
152
- "useGetterReturn": "off"
153
- }
154
- }
155
- }
156
- }
157
- ]
158
- }
package/build.rs DELETED
@@ -1,5 +0,0 @@
1
- extern crate napi_build;
2
-
3
- fn main() {
4
- napi_build::setup();
5
- }
package/dist/native.d.ts DELETED
@@ -1,208 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- /** A description of an index currently configured on a column */
7
- export interface IndexConfig {
8
- /** The name of the index */
9
- name: string
10
- /** The type of the index */
11
- indexType: string
12
- /**
13
- * The columns in the index
14
- *
15
- * Currently this is always an array of size 1. In the future there may
16
- * be more columns to represent composite indices.
17
- */
18
- columns: Array<string>
19
- }
20
- /** Statistics about a compaction operation. */
21
- export interface CompactionStats {
22
- /** The number of fragments removed */
23
- fragmentsRemoved: number
24
- /** The number of new, compacted fragments added */
25
- fragmentsAdded: number
26
- /** The number of data files removed */
27
- filesRemoved: number
28
- /** The number of new, compacted data files added */
29
- filesAdded: number
30
- }
31
- /** Statistics about a cleanup operation */
32
- export interface RemovalStats {
33
- /** The number of bytes removed */
34
- bytesRemoved: number
35
- /** The number of old versions removed */
36
- oldVersionsRemoved: number
37
- }
38
- /** Statistics about an optimize operation */
39
- export interface OptimizeStats {
40
- /** Statistics about the compaction operation */
41
- compaction: CompactionStats
42
- /** Statistics about the removal operation */
43
- prune: RemovalStats
44
- }
45
- /**
46
- * A definition of a column alteration. The alteration changes the column at
47
- * `path` to have the new name `name`, to be nullable if `nullable` is true,
48
- * and to have the data type `data_type`. At least one of `rename` or `nullable`
49
- * must be provided.
50
- */
51
- export interface ColumnAlteration {
52
- /**
53
- * The path to the column to alter. This is a dot-separated path to the column.
54
- * If it is a top-level column then it is just the name of the column. If it is
55
- * a nested column then it is the path to the column, e.g. "a.b.c" for a column
56
- * `c` nested inside a column `b` nested inside a column `a`.
57
- */
58
- path: string
59
- /**
60
- * The new name of the column. If not provided then the name will not be changed.
61
- * This must be distinct from the names of all other columns in the table.
62
- */
63
- rename?: string
64
- /** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
65
- nullable?: boolean
66
- }
67
- /** A definition of a new column to add to a table. */
68
- export interface AddColumnsSql {
69
- /** The name of the new column. */
70
- name: string
71
- /**
72
- * The values to populate the new column with, as a SQL expression.
73
- * The expression can reference other columns in the table.
74
- */
75
- valueSql: string
76
- }
77
- export interface IndexStatistics {
78
- /** The number of rows indexed by the index */
79
- numIndexedRows: number
80
- /** The number of rows not indexed */
81
- numUnindexedRows: number
82
- /** The type of the index */
83
- indexType?: string
84
- /** The metadata for each index */
85
- indices: Array<IndexMetadata>
86
- }
87
- export interface IndexMetadata {
88
- metricType?: string
89
- indexType?: string
90
- }
91
- export interface ConnectionOptions {
92
- /**
93
- * (For LanceDB OSS only): The interval, in seconds, at which to check for
94
- * updates to the table from other processes. If None, then consistency is not
95
- * checked. For performance reasons, this is the default. For strong
96
- * consistency, set this to zero seconds. Then every read will check for
97
- * updates from other processes. As a compromise, you can set this to a
98
- * non-zero value for eventual consistency. If more than that interval
99
- * has passed since the last check, then the table will be checked for updates.
100
- * Note: this consistency only applies to read operations. Write operations are
101
- * always consistent.
102
- */
103
- readConsistencyInterval?: number
104
- /**
105
- * (For LanceDB OSS only): configuration for object storage.
106
- *
107
- * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
108
- */
109
- storageOptions?: Record<string, string>
110
- }
111
- /** Write mode for writing a table. */
112
- export const enum WriteMode {
113
- Create = 'Create',
114
- Append = 'Append',
115
- Overwrite = 'Overwrite'
116
- }
117
- /** Write options when creating a Table. */
118
- export interface WriteOptions {
119
- /** Write mode for writing to a table. */
120
- mode?: WriteMode
121
- }
122
- export interface OpenTableOptions {
123
- storageOptions?: Record<string, string>
124
- }
125
- export class Connection {
126
- /** Create a new Connection instance from the given URI. */
127
- static new(uri: string, options: ConnectionOptions): Promise<Connection>
128
- display(): string
129
- isOpen(): boolean
130
- close(): void
131
- /** List all tables in the dataset. */
132
- tableNames(startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
133
- /**
134
- * Create table from a Apache Arrow IPC (file) buffer.
135
- *
136
- * Parameters:
137
- * - name: The name of the table.
138
- * - buf: The buffer containing the IPC file.
139
- *
140
- */
141
- createTable(name: string, buf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null, useLegacyFormat?: boolean | undefined | null): Promise<Table>
142
- createEmptyTable(name: string, schemaBuf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null, useLegacyFormat?: boolean | undefined | null): Promise<Table>
143
- openTable(name: string, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
144
- /** Drop table with the name. Or raise an error if the table does not exist. */
145
- dropTable(name: string): Promise<void>
146
- }
147
- export class Index {
148
- static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
149
- static btree(): Index
150
- }
151
- /** Typescript-style Async Iterator over RecordBatches */
152
- export class RecordBatchIterator {
153
- next(): Promise<Buffer | null>
154
- }
155
- /** A builder used to create and run a merge insert operation */
156
- export class NativeMergeInsertBuilder {
157
- whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
158
- whenNotMatchedInsertAll(): NativeMergeInsertBuilder
159
- whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
160
- execute(buf: Buffer): Promise<void>
161
- }
162
- export class Query {
163
- onlyIf(predicate: string): void
164
- select(columns: Array<[string, string]>): void
165
- limit(limit: number): void
166
- nearestTo(vector: Float32Array): VectorQuery
167
- execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
168
- explainPlan(verbose: boolean): Promise<string>
169
- }
170
- export class VectorQuery {
171
- column(column: string): void
172
- distanceType(distanceType: string): void
173
- postfilter(): void
174
- refineFactor(refineFactor: number): void
175
- nprobes(nprobe: number): void
176
- bypassVectorIndex(): void
177
- onlyIf(predicate: string): void
178
- select(columns: Array<[string, string]>): void
179
- limit(limit: number): void
180
- execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
181
- explainPlan(verbose: boolean): Promise<string>
182
- }
183
- export class Table {
184
- name: string
185
- display(): string
186
- isOpen(): boolean
187
- close(): void
188
- /** Return Schema as empty Arrow IPC file. */
189
- schema(): Promise<Buffer>
190
- add(buf: Buffer, mode: string): Promise<void>
191
- countRows(filter?: string | undefined | null): Promise<number>
192
- delete(predicate: string): Promise<void>
193
- createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null): Promise<void>
194
- update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<void>
195
- query(): Query
196
- vectorSearch(vector: Float32Array): VectorQuery
197
- addColumns(transforms: Array<AddColumnsSql>): Promise<void>
198
- alterColumns(alterations: Array<ColumnAlteration>): Promise<void>
199
- dropColumns(columns: Array<string>): Promise<void>
200
- version(): Promise<number>
201
- checkout(version: number): Promise<void>
202
- checkoutLatest(): Promise<void>
203
- restore(): Promise<void>
204
- optimize(olderThanMs?: number | undefined | null): Promise<OptimizeStats>
205
- listIndices(): Promise<Array<IndexConfig>>
206
- indexStats(indexName: string): Promise<IndexStatistics | null>
207
- mergeInsert(on: Array<string>): NativeMergeInsertBuilder
208
- }
@@ -1,49 +0,0 @@
1
- // --8<-- [start:import]
2
- import * as lancedb from "@lancedb/lancedb";
3
- // --8<-- [end:import]
4
-
5
- // --8<-- [start:ingest]
6
- const db = await lancedb.connect("/tmp/lancedb/");
7
-
8
- const data = Array.from({ length: 10_000 }, (_, i) => ({
9
- vector: Array(1536).fill(i),
10
- id: `${i}`,
11
- content: "",
12
- longId: `${i}`,
13
- }));
14
-
15
- const table = await db.createTable("my_vectors", data, { mode: "overwrite" });
16
- await table.createIndex("vector", {
17
- config: lancedb.Index.ivfPq({
18
- numPartitions: 16,
19
- numSubVectors: 48,
20
- }),
21
- });
22
- // --8<-- [end:ingest]
23
-
24
- // --8<-- [start:search1]
25
- const _results1 = await table
26
- .search(Array(1536).fill(1.2))
27
- .limit(2)
28
- .nprobes(20)
29
- .refineFactor(10)
30
- .toArray();
31
- // --8<-- [end:search1]
32
-
33
- // --8<-- [start:search2]
34
- const _results2 = await table
35
- .search(Array(1536).fill(1.2))
36
- .where("id != '1141'")
37
- .limit(2)
38
- .toArray();
39
- // --8<-- [end:search2]
40
-
41
- // --8<-- [start:search3]
42
- const _results3 = await table
43
- .search(Array(1536).fill(1.2))
44
- .select(["id"])
45
- .limit(2)
46
- .toArray();
47
- // --8<-- [end:search3]
48
-
49
- console.log("Ann indexes: done");