@lancedb/lancedb 0.29.0 → 0.29.1-beta.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.
- package/AGENTS.md +6 -6
- package/CONTRIBUTING.md +15 -13
- package/dist/arrow.d.ts +6 -0
- package/dist/arrow.js +10 -0
- package/dist/connection.d.ts +74 -0
- package/dist/connection.js +15 -0
- package/dist/index.d.ts +118 -5
- package/dist/index.js +48 -1
- package/dist/native.d.ts +110 -0
- package/dist/native.js +53 -52
- package/dist/query.d.ts +10 -0
- package/dist/query.js +14 -0
- package/dist/scannable.d.ts +92 -0
- package/dist/scannable.js +200 -0
- package/dist/table.d.ts +71 -0
- package/dist/table.js +10 -0
- package/package.json +21 -20
- package/pnpm-workspace.yaml +18 -0
package/dist/native.js
CHANGED
|
@@ -76,8 +76,8 @@ function requireNative() {
|
|
|
76
76
|
try {
|
|
77
77
|
const binding = require('@lancedb/lancedb-android-arm64');
|
|
78
78
|
const bindingPackageVersion = require('@lancedb/lancedb-android-arm64/package.json').version;
|
|
79
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
80
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
79
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
80
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
81
81
|
}
|
|
82
82
|
return binding;
|
|
83
83
|
}
|
|
@@ -95,8 +95,8 @@ function requireNative() {
|
|
|
95
95
|
try {
|
|
96
96
|
const binding = require('@lancedb/lancedb-android-arm-eabi');
|
|
97
97
|
const bindingPackageVersion = require('@lancedb/lancedb-android-arm-eabi/package.json').version;
|
|
98
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
99
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
98
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
99
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
100
100
|
}
|
|
101
101
|
return binding;
|
|
102
102
|
}
|
|
@@ -120,8 +120,8 @@ function requireNative() {
|
|
|
120
120
|
try {
|
|
121
121
|
const binding = require('@lancedb/lancedb-win32-x64-gnu');
|
|
122
122
|
const bindingPackageVersion = require('@lancedb/lancedb-win32-x64-gnu/package.json').version;
|
|
123
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
124
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
123
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
124
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
125
125
|
}
|
|
126
126
|
return binding;
|
|
127
127
|
}
|
|
@@ -139,8 +139,8 @@ function requireNative() {
|
|
|
139
139
|
try {
|
|
140
140
|
const binding = require('@lancedb/lancedb-win32-x64-msvc');
|
|
141
141
|
const bindingPackageVersion = require('@lancedb/lancedb-win32-x64-msvc/package.json').version;
|
|
142
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
143
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
142
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
143
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
144
144
|
}
|
|
145
145
|
return binding;
|
|
146
146
|
}
|
|
@@ -159,8 +159,8 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require('@lancedb/lancedb-win32-ia32-msvc');
|
|
161
161
|
const bindingPackageVersion = require('@lancedb/lancedb-win32-ia32-msvc/package.json').version;
|
|
162
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
162
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
164
164
|
}
|
|
165
165
|
return binding;
|
|
166
166
|
}
|
|
@@ -178,8 +178,8 @@ function requireNative() {
|
|
|
178
178
|
try {
|
|
179
179
|
const binding = require('@lancedb/lancedb-win32-arm64-msvc');
|
|
180
180
|
const bindingPackageVersion = require('@lancedb/lancedb-win32-arm64-msvc/package.json').version;
|
|
181
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
182
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
181
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
182
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
183
183
|
}
|
|
184
184
|
return binding;
|
|
185
185
|
}
|
|
@@ -201,8 +201,8 @@ function requireNative() {
|
|
|
201
201
|
try {
|
|
202
202
|
const binding = require('@lancedb/lancedb-darwin-universal');
|
|
203
203
|
const bindingPackageVersion = require('@lancedb/lancedb-darwin-universal/package.json').version;
|
|
204
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
205
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
204
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
205
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
206
206
|
}
|
|
207
207
|
return binding;
|
|
208
208
|
}
|
|
@@ -219,8 +219,8 @@ function requireNative() {
|
|
|
219
219
|
try {
|
|
220
220
|
const binding = require('@lancedb/lancedb-darwin-x64');
|
|
221
221
|
const bindingPackageVersion = require('@lancedb/lancedb-darwin-x64/package.json').version;
|
|
222
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
222
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
224
224
|
}
|
|
225
225
|
return binding;
|
|
226
226
|
}
|
|
@@ -238,8 +238,8 @@ function requireNative() {
|
|
|
238
238
|
try {
|
|
239
239
|
const binding = require('@lancedb/lancedb-darwin-arm64');
|
|
240
240
|
const bindingPackageVersion = require('@lancedb/lancedb-darwin-arm64/package.json').version;
|
|
241
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
241
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
242
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
243
243
|
}
|
|
244
244
|
return binding;
|
|
245
245
|
}
|
|
@@ -262,8 +262,8 @@ function requireNative() {
|
|
|
262
262
|
try {
|
|
263
263
|
const binding = require('@lancedb/lancedb-freebsd-x64');
|
|
264
264
|
const bindingPackageVersion = require('@lancedb/lancedb-freebsd-x64/package.json').version;
|
|
265
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
265
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
267
267
|
}
|
|
268
268
|
return binding;
|
|
269
269
|
}
|
|
@@ -281,8 +281,8 @@ function requireNative() {
|
|
|
281
281
|
try {
|
|
282
282
|
const binding = require('@lancedb/lancedb-freebsd-arm64');
|
|
283
283
|
const bindingPackageVersion = require('@lancedb/lancedb-freebsd-arm64/package.json').version;
|
|
284
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
285
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
284
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
285
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
286
286
|
}
|
|
287
287
|
return binding;
|
|
288
288
|
}
|
|
@@ -306,8 +306,8 @@ function requireNative() {
|
|
|
306
306
|
try {
|
|
307
307
|
const binding = require('@lancedb/lancedb-linux-x64-musl');
|
|
308
308
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-x64-musl/package.json').version;
|
|
309
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
309
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
311
311
|
}
|
|
312
312
|
return binding;
|
|
313
313
|
}
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('@lancedb/lancedb-linux-x64-gnu');
|
|
327
327
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-x64-gnu/package.json').version;
|
|
328
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
328
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
330
330
|
}
|
|
331
331
|
return binding;
|
|
332
332
|
}
|
|
@@ -346,8 +346,8 @@ function requireNative() {
|
|
|
346
346
|
try {
|
|
347
347
|
const binding = require('@lancedb/lancedb-linux-arm64-musl');
|
|
348
348
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-arm64-musl/package.json').version;
|
|
349
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
350
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
349
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
350
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
351
351
|
}
|
|
352
352
|
return binding;
|
|
353
353
|
}
|
|
@@ -365,8 +365,8 @@ function requireNative() {
|
|
|
365
365
|
try {
|
|
366
366
|
const binding = require('@lancedb/lancedb-linux-arm64-gnu');
|
|
367
367
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-arm64-gnu/package.json').version;
|
|
368
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
369
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
368
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
369
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
370
370
|
}
|
|
371
371
|
return binding;
|
|
372
372
|
}
|
|
@@ -386,8 +386,8 @@ function requireNative() {
|
|
|
386
386
|
try {
|
|
387
387
|
const binding = require('@lancedb/lancedb-linux-arm-musleabihf');
|
|
388
388
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-arm-musleabihf/package.json').version;
|
|
389
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
390
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
389
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
390
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
391
391
|
}
|
|
392
392
|
return binding;
|
|
393
393
|
}
|
|
@@ -405,8 +405,8 @@ function requireNative() {
|
|
|
405
405
|
try {
|
|
406
406
|
const binding = require('@lancedb/lancedb-linux-arm-gnueabihf');
|
|
407
407
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-arm-gnueabihf/package.json').version;
|
|
408
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
409
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
408
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
409
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
410
410
|
}
|
|
411
411
|
return binding;
|
|
412
412
|
}
|
|
@@ -426,8 +426,8 @@ function requireNative() {
|
|
|
426
426
|
try {
|
|
427
427
|
const binding = require('@lancedb/lancedb-linux-loong64-musl');
|
|
428
428
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-loong64-musl/package.json').version;
|
|
429
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
430
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
429
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
430
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
431
431
|
}
|
|
432
432
|
return binding;
|
|
433
433
|
}
|
|
@@ -445,8 +445,8 @@ function requireNative() {
|
|
|
445
445
|
try {
|
|
446
446
|
const binding = require('@lancedb/lancedb-linux-loong64-gnu');
|
|
447
447
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-loong64-gnu/package.json').version;
|
|
448
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
449
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
448
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
449
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
450
450
|
}
|
|
451
451
|
return binding;
|
|
452
452
|
}
|
|
@@ -466,8 +466,8 @@ function requireNative() {
|
|
|
466
466
|
try {
|
|
467
467
|
const binding = require('@lancedb/lancedb-linux-riscv64-musl');
|
|
468
468
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-riscv64-musl/package.json').version;
|
|
469
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
470
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
469
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
470
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
471
471
|
}
|
|
472
472
|
return binding;
|
|
473
473
|
}
|
|
@@ -485,8 +485,8 @@ function requireNative() {
|
|
|
485
485
|
try {
|
|
486
486
|
const binding = require('@lancedb/lancedb-linux-riscv64-gnu');
|
|
487
487
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-riscv64-gnu/package.json').version;
|
|
488
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
489
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
488
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
489
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
490
490
|
}
|
|
491
491
|
return binding;
|
|
492
492
|
}
|
|
@@ -505,8 +505,8 @@ function requireNative() {
|
|
|
505
505
|
try {
|
|
506
506
|
const binding = require('@lancedb/lancedb-linux-ppc64-gnu');
|
|
507
507
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-ppc64-gnu/package.json').version;
|
|
508
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
509
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
508
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
509
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
510
510
|
}
|
|
511
511
|
return binding;
|
|
512
512
|
}
|
|
@@ -524,8 +524,8 @@ function requireNative() {
|
|
|
524
524
|
try {
|
|
525
525
|
const binding = require('@lancedb/lancedb-linux-s390x-gnu');
|
|
526
526
|
const bindingPackageVersion = require('@lancedb/lancedb-linux-s390x-gnu/package.json').version;
|
|
527
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
528
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
527
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
528
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
529
529
|
}
|
|
530
530
|
return binding;
|
|
531
531
|
}
|
|
@@ -548,8 +548,8 @@ function requireNative() {
|
|
|
548
548
|
try {
|
|
549
549
|
const binding = require('@lancedb/lancedb-openharmony-arm64');
|
|
550
550
|
const bindingPackageVersion = require('@lancedb/lancedb-openharmony-arm64/package.json').version;
|
|
551
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
552
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
551
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
552
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
553
553
|
}
|
|
554
554
|
return binding;
|
|
555
555
|
}
|
|
@@ -567,8 +567,8 @@ function requireNative() {
|
|
|
567
567
|
try {
|
|
568
568
|
const binding = require('@lancedb/lancedb-openharmony-x64');
|
|
569
569
|
const bindingPackageVersion = require('@lancedb/lancedb-openharmony-x64/package.json').version;
|
|
570
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
571
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
570
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
571
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
572
572
|
}
|
|
573
573
|
return binding;
|
|
574
574
|
}
|
|
@@ -586,8 +586,8 @@ function requireNative() {
|
|
|
586
586
|
try {
|
|
587
587
|
const binding = require('@lancedb/lancedb-openharmony-arm');
|
|
588
588
|
const bindingPackageVersion = require('@lancedb/lancedb-openharmony-arm/package.json').version;
|
|
589
|
-
if (bindingPackageVersion !== '0.29.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
590
|
-
throw new Error(`Native binding package version mismatch, expected 0.29.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
589
|
+
if (bindingPackageVersion !== '0.29.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
590
|
+
throw new Error(`Native binding package version mismatch, expected 0.29.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
591
591
|
}
|
|
592
592
|
return binding;
|
|
593
593
|
}
|
|
@@ -657,6 +657,7 @@ module.exports.Connection = nativeBinding.Connection;
|
|
|
657
657
|
module.exports.Index = nativeBinding.Index;
|
|
658
658
|
module.exports.JsFullTextQuery = nativeBinding.JsFullTextQuery;
|
|
659
659
|
module.exports.JsHeaderProvider = nativeBinding.JsHeaderProvider;
|
|
660
|
+
module.exports.NapiScannable = nativeBinding.NapiScannable;
|
|
660
661
|
module.exports.NativeMergeInsertBuilder = nativeBinding.NativeMergeInsertBuilder;
|
|
661
662
|
module.exports.PermutationBuilder = nativeBinding.PermutationBuilder;
|
|
662
663
|
module.exports.Query = nativeBinding.Query;
|
package/dist/query.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export interface QueryExecutionOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
timeoutMs?: number;
|
|
21
21
|
}
|
|
22
|
+
export interface ColumnOrdering {
|
|
23
|
+
columnName: string;
|
|
24
|
+
ascending?: boolean;
|
|
25
|
+
nullsFirst?: boolean;
|
|
26
|
+
}
|
|
22
27
|
/**
|
|
23
28
|
* Options that control the behavior of a full text search
|
|
24
29
|
*/
|
|
@@ -201,6 +206,11 @@ export declare class StandardQueryBase<NativeQueryType extends NativeQuery | Nat
|
|
|
201
206
|
* This is useful for pagination.
|
|
202
207
|
*/
|
|
203
208
|
offset(offset: number): this;
|
|
209
|
+
/**
|
|
210
|
+
* Sort the results by the specified column(s).
|
|
211
|
+
* @returns This query builder.
|
|
212
|
+
*/
|
|
213
|
+
orderBy(ordering: ColumnOrdering | ColumnOrdering[]): this;
|
|
204
214
|
/**
|
|
205
215
|
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
206
216
|
* any data that is not yet indexed.
|
package/dist/query.js
CHANGED
|
@@ -332,6 +332,20 @@ class StandardQueryBase extends QueryBase {
|
|
|
332
332
|
this.doCall((inner) => inner.offset(offset));
|
|
333
333
|
return this;
|
|
334
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Sort the results by the specified column(s).
|
|
337
|
+
* @returns This query builder.
|
|
338
|
+
*/
|
|
339
|
+
orderBy(ordering) {
|
|
340
|
+
const orderings = Array.isArray(ordering) ? ordering : [ordering];
|
|
341
|
+
const normalized = orderings.map((o) => ({
|
|
342
|
+
columnName: o.columnName,
|
|
343
|
+
ascending: o.ascending ?? true,
|
|
344
|
+
nullsFirst: o.nullsFirst ?? false,
|
|
345
|
+
}));
|
|
346
|
+
this.doCall((inner) => inner.orderBy(normalized));
|
|
347
|
+
return this;
|
|
348
|
+
}
|
|
335
349
|
/**
|
|
336
350
|
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
337
351
|
* any data that is not yet indexed.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Table as ArrowTable, RecordBatch, RecordBatchReader, Schema } from "apache-arrow";
|
|
2
|
+
import { NapiScannable } from "./native.js";
|
|
3
|
+
export interface ScannableOptions {
|
|
4
|
+
/** Hint about the number of rows. Not validated against the stream. */
|
|
5
|
+
numRows?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the source can be scanned more than once. Defaults to `true` for
|
|
8
|
+
* `fromTable` / `fromFactory` and `false` for `fromIterable` /
|
|
9
|
+
* `fromRecordBatchReader`.
|
|
10
|
+
*/
|
|
11
|
+
rescannable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A data source that can be scanned as a stream of Arrow `RecordBatch`es.
|
|
15
|
+
*
|
|
16
|
+
* `Scannable` wraps the schema + optional row count + rescannable flag and
|
|
17
|
+
* a callback that yields batches one at a time. It is passed to consumers
|
|
18
|
+
* (e.g. `Table.add`, `createTable`, `mergeInsert` — follow-up work) that
|
|
19
|
+
* need to pull data without materializing the full dataset in JS memory.
|
|
20
|
+
*
|
|
21
|
+
* Batches cross the JS↔Rust boundary as Arrow IPC Stream messages; a fresh
|
|
22
|
+
* writer serializes each batch, and the Rust side decodes it with
|
|
23
|
+
* `arrow_ipc::reader::StreamReader`. One batch is in flight at a time.
|
|
24
|
+
*/
|
|
25
|
+
export declare class Scannable {
|
|
26
|
+
readonly schema: Schema;
|
|
27
|
+
readonly numRows: number | null;
|
|
28
|
+
readonly rescannable: boolean;
|
|
29
|
+
/** @hidden */
|
|
30
|
+
private readonly native;
|
|
31
|
+
private constructor();
|
|
32
|
+
/** @hidden Access the native handle for passing through to Rust consumers. */
|
|
33
|
+
get inner(): NapiScannable;
|
|
34
|
+
/**
|
|
35
|
+
* Build a Scannable from an explicit schema and a factory that returns a
|
|
36
|
+
* fresh batch iterator on each call.
|
|
37
|
+
*
|
|
38
|
+
* The factory is invoked once per scan. Each iterator yields
|
|
39
|
+
* `RecordBatch`es matching the declared schema. Use this when you need
|
|
40
|
+
* direct control over the pull loop — for example, to wrap a streaming
|
|
41
|
+
* source whose batches are produced lazily.
|
|
42
|
+
*
|
|
43
|
+
* @param schema - The Arrow schema of the produced batches.
|
|
44
|
+
* @param factory - Called at the start of each scan to produce a batch
|
|
45
|
+
* iterator. Must be idempotent when `rescannable` is true.
|
|
46
|
+
* @param opts - Optional hints. `rescannable` defaults to `true`; set to
|
|
47
|
+
* `false` if calling `factory()` twice would not reproduce the same data.
|
|
48
|
+
*/
|
|
49
|
+
static fromFactory(schema: Schema, factory: () => AsyncIterable<RecordBatch> | Iterable<RecordBatch> | AsyncIterator<RecordBatch> | Iterator<RecordBatch>, opts?: ScannableOptions): Promise<Scannable>;
|
|
50
|
+
/**
|
|
51
|
+
* Build a Scannable from an in-memory Arrow `Table`. Always rescannable;
|
|
52
|
+
* the table's batches are replayed on each scan.
|
|
53
|
+
*
|
|
54
|
+
* The table's row count is authoritative: `opts.numRows` must either be
|
|
55
|
+
* omitted or equal to `table.numRows`. `opts.rescannable` of `false` is
|
|
56
|
+
* rejected because in-memory Tables are always rescannable.
|
|
57
|
+
*/
|
|
58
|
+
static fromTable(table: ArrowTable, opts?: ScannableOptions): Promise<Scannable>;
|
|
59
|
+
/**
|
|
60
|
+
* Build a Scannable from an iterable of `RecordBatch`es. `rescannable`
|
|
61
|
+
* defaults to `false`. Pass an explicit schema so the consumer can
|
|
62
|
+
* validate before any batch is pulled.
|
|
63
|
+
*
|
|
64
|
+
* `opts.rescannable: true` is honest for replayable iterables (Arrays,
|
|
65
|
+
* Sets, or custom iterables whose `[Symbol.iterator]()` returns a fresh
|
|
66
|
+
* iterator each call). It is rejected for one-shot iterables (generators,
|
|
67
|
+
* async generators, or already-an-iterator inputs) because their
|
|
68
|
+
* `[Symbol.iterator]()` returns the same exhausted object on the second
|
|
69
|
+
* scan. For replayable sources outside this shape, use
|
|
70
|
+
* `fromFactory(schema, () => createIter(), { rescannable: true })`.
|
|
71
|
+
*
|
|
72
|
+
* Note: when `opts.rescannable` is `true`, the constructor calls
|
|
73
|
+
* `[Symbol.iterator]()` once on the input to perform the structural check.
|
|
74
|
+
*/
|
|
75
|
+
static fromIterable(schema: Schema, iter: AsyncIterable<RecordBatch> | Iterable<RecordBatch>, opts?: ScannableOptions): Promise<Scannable>;
|
|
76
|
+
/**
|
|
77
|
+
* Build a Scannable from an Arrow `RecordBatchReader`. A reader can only
|
|
78
|
+
* be consumed once; `rescannable` defaults to `false`.
|
|
79
|
+
*
|
|
80
|
+
* The reader must already be opened (via `.open()`) so its `.schema` is
|
|
81
|
+
* populated. `RecordBatchReader.from(...)` returns an unopened reader.
|
|
82
|
+
*
|
|
83
|
+
* `opts.rescannable: true` is rejected because `RecordBatchReader` is a
|
|
84
|
+
* self-iterator (its `[Symbol.iterator]()` returns itself), and this
|
|
85
|
+
* constructor does not call `reader.reset()` between scans, so a second
|
|
86
|
+
* scan would always see an exhausted reader. For genuinely replayable
|
|
87
|
+
* sources, use
|
|
88
|
+
* `fromFactory(schema, () => openReader(), { rescannable: true })`,
|
|
89
|
+
* which mints a fresh reader on each scan.
|
|
90
|
+
*/
|
|
91
|
+
static fromRecordBatchReader(reader: RecordBatchReader, opts?: ScannableOptions): Promise<Scannable>;
|
|
92
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Scannable = void 0;
|
|
6
|
+
const arrow_1 = require("./arrow");
|
|
7
|
+
const native_js_1 = require("./native.js");
|
|
8
|
+
/**
|
|
9
|
+
* A data source that can be scanned as a stream of Arrow `RecordBatch`es.
|
|
10
|
+
*
|
|
11
|
+
* `Scannable` wraps the schema + optional row count + rescannable flag and
|
|
12
|
+
* a callback that yields batches one at a time. It is passed to consumers
|
|
13
|
+
* (e.g. `Table.add`, `createTable`, `mergeInsert` — follow-up work) that
|
|
14
|
+
* need to pull data without materializing the full dataset in JS memory.
|
|
15
|
+
*
|
|
16
|
+
* Batches cross the JS↔Rust boundary as Arrow IPC Stream messages; a fresh
|
|
17
|
+
* writer serializes each batch, and the Rust side decodes it with
|
|
18
|
+
* `arrow_ipc::reader::StreamReader`. One batch is in flight at a time.
|
|
19
|
+
*/
|
|
20
|
+
class Scannable {
|
|
21
|
+
schema;
|
|
22
|
+
numRows;
|
|
23
|
+
rescannable;
|
|
24
|
+
/** @hidden */
|
|
25
|
+
native;
|
|
26
|
+
constructor(native, schema, numRows, rescannable) {
|
|
27
|
+
this.native = native;
|
|
28
|
+
this.schema = schema;
|
|
29
|
+
this.numRows = numRows;
|
|
30
|
+
this.rescannable = rescannable;
|
|
31
|
+
}
|
|
32
|
+
/** @hidden Access the native handle for passing through to Rust consumers. */
|
|
33
|
+
get inner() {
|
|
34
|
+
return this.native;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build a Scannable from an explicit schema and a factory that returns a
|
|
38
|
+
* fresh batch iterator on each call.
|
|
39
|
+
*
|
|
40
|
+
* The factory is invoked once per scan. Each iterator yields
|
|
41
|
+
* `RecordBatch`es matching the declared schema. Use this when you need
|
|
42
|
+
* direct control over the pull loop — for example, to wrap a streaming
|
|
43
|
+
* source whose batches are produced lazily.
|
|
44
|
+
*
|
|
45
|
+
* @param schema - The Arrow schema of the produced batches.
|
|
46
|
+
* @param factory - Called at the start of each scan to produce a batch
|
|
47
|
+
* iterator. Must be idempotent when `rescannable` is true.
|
|
48
|
+
* @param opts - Optional hints. `rescannable` defaults to `true`; set to
|
|
49
|
+
* `false` if calling `factory()` twice would not reproduce the same data.
|
|
50
|
+
*/
|
|
51
|
+
static async fromFactory(schema, factory, opts = {}) {
|
|
52
|
+
const numRows = opts.numRows ?? null;
|
|
53
|
+
if (numRows != null && !Number.isInteger(numRows)) {
|
|
54
|
+
throw new TypeError("numRows must be an integer");
|
|
55
|
+
}
|
|
56
|
+
const rescannable = opts.rescannable ?? true;
|
|
57
|
+
let iter = null;
|
|
58
|
+
const getNextBatch = async (isStart) => {
|
|
59
|
+
// `isStart` is true on the first pull of every new scan_as_stream.
|
|
60
|
+
// Drop any cached iterator so factory() is re-invoked for the next scan
|
|
61
|
+
if (isStart) {
|
|
62
|
+
iter = null;
|
|
63
|
+
}
|
|
64
|
+
if (iter === null) {
|
|
65
|
+
iter = normalizeIterator(factory());
|
|
66
|
+
}
|
|
67
|
+
const result = await iter.next();
|
|
68
|
+
if (result.done) {
|
|
69
|
+
iter = null;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return (0, arrow_1.fromRecordBatchToStreamBuffer)(result.value);
|
|
73
|
+
};
|
|
74
|
+
const schemaBuf = await (0, arrow_1.fromTableToBuffer)((0, arrow_1.makeEmptyTable)(schema));
|
|
75
|
+
const native = new native_js_1.NapiScannable(schemaBuf, numRows, rescannable, getNextBatch);
|
|
76
|
+
return new Scannable(native, schema, numRows, rescannable);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Build a Scannable from an in-memory Arrow `Table`. Always rescannable;
|
|
80
|
+
* the table's batches are replayed on each scan.
|
|
81
|
+
*
|
|
82
|
+
* The table's row count is authoritative: `opts.numRows` must either be
|
|
83
|
+
* omitted or equal to `table.numRows`. `opts.rescannable` of `false` is
|
|
84
|
+
* rejected because in-memory Tables are always rescannable.
|
|
85
|
+
*/
|
|
86
|
+
static async fromTable(table, opts = {}) {
|
|
87
|
+
if (opts.numRows != null && opts.numRows !== table.numRows) {
|
|
88
|
+
throw new TypeError(`opts.numRows (${opts.numRows}) does not match table.numRows (${table.numRows}). ` +
|
|
89
|
+
`The table's row count is authoritative; omit numRows or pass the matching value.`);
|
|
90
|
+
}
|
|
91
|
+
if (opts.rescannable === false) {
|
|
92
|
+
throw new TypeError(`fromTable does not accept rescannable: false. ` +
|
|
93
|
+
`In-memory Arrow Tables are always rescannable; omit the option or pass true.`);
|
|
94
|
+
}
|
|
95
|
+
return Scannable.fromFactory(table.schema, () => table.batches, {
|
|
96
|
+
numRows: table.numRows,
|
|
97
|
+
rescannable: true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build a Scannable from an iterable of `RecordBatch`es. `rescannable`
|
|
102
|
+
* defaults to `false`. Pass an explicit schema so the consumer can
|
|
103
|
+
* validate before any batch is pulled.
|
|
104
|
+
*
|
|
105
|
+
* `opts.rescannable: true` is honest for replayable iterables (Arrays,
|
|
106
|
+
* Sets, or custom iterables whose `[Symbol.iterator]()` returns a fresh
|
|
107
|
+
* iterator each call). It is rejected for one-shot iterables (generators,
|
|
108
|
+
* async generators, or already-an-iterator inputs) because their
|
|
109
|
+
* `[Symbol.iterator]()` returns the same exhausted object on the second
|
|
110
|
+
* scan. For replayable sources outside this shape, use
|
|
111
|
+
* `fromFactory(schema, () => createIter(), { rescannable: true })`.
|
|
112
|
+
*
|
|
113
|
+
* Note: when `opts.rescannable` is `true`, the constructor calls
|
|
114
|
+
* `[Symbol.iterator]()` once on the input to perform the structural check.
|
|
115
|
+
*/
|
|
116
|
+
static async fromIterable(schema, iter, opts = {}) {
|
|
117
|
+
if (opts.rescannable === true && isOneShotIterable(iter)) {
|
|
118
|
+
throw new TypeError(`fromIterable: rescannable: true is not honest for one-shot iterables ` +
|
|
119
|
+
`(generators, async generators, or iterators where [Symbol.iterator]() ` +
|
|
120
|
+
`returns the same object). The source would be exhausted after the first scan. ` +
|
|
121
|
+
`Use fromFactory(schema, () => createIter(), { rescannable: true }) for sources ` +
|
|
122
|
+
`where each call mints a fresh iterator.`);
|
|
123
|
+
}
|
|
124
|
+
return Scannable.fromFactory(schema, () => iter, {
|
|
125
|
+
numRows: opts.numRows,
|
|
126
|
+
rescannable: opts.rescannable ?? false,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Build a Scannable from an Arrow `RecordBatchReader`. A reader can only
|
|
131
|
+
* be consumed once; `rescannable` defaults to `false`.
|
|
132
|
+
*
|
|
133
|
+
* The reader must already be opened (via `.open()`) so its `.schema` is
|
|
134
|
+
* populated. `RecordBatchReader.from(...)` returns an unopened reader.
|
|
135
|
+
*
|
|
136
|
+
* `opts.rescannable: true` is rejected because `RecordBatchReader` is a
|
|
137
|
+
* self-iterator (its `[Symbol.iterator]()` returns itself), and this
|
|
138
|
+
* constructor does not call `reader.reset()` between scans, so a second
|
|
139
|
+
* scan would always see an exhausted reader. For genuinely replayable
|
|
140
|
+
* sources, use
|
|
141
|
+
* `fromFactory(schema, () => openReader(), { rescannable: true })`,
|
|
142
|
+
* which mints a fresh reader on each scan.
|
|
143
|
+
*/
|
|
144
|
+
static async fromRecordBatchReader(reader, opts = {}) {
|
|
145
|
+
if (opts.rescannable === true) {
|
|
146
|
+
throw new TypeError(`fromRecordBatchReader does not accept rescannable: true. ` +
|
|
147
|
+
`RecordBatchReader is a self-iterator (its [Symbol.iterator]() ` +
|
|
148
|
+
`returns itself) and would be exhausted after the first scan. ` +
|
|
149
|
+
`Use fromFactory(schema, () => openReader(), { rescannable: true }) ` +
|
|
150
|
+
`for sources where each call mints a fresh reader.`);
|
|
151
|
+
}
|
|
152
|
+
return Scannable.fromFactory(reader.schema, () => reader, {
|
|
153
|
+
numRows: opts.numRows,
|
|
154
|
+
rescannable: false,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.Scannable = Scannable;
|
|
159
|
+
function normalizeIterator(source) {
|
|
160
|
+
if (source == null) {
|
|
161
|
+
throw new TypeError("Scannable factory returned null/undefined");
|
|
162
|
+
}
|
|
163
|
+
if (typeof source[Symbol.asyncIterator] === "function") {
|
|
164
|
+
return source[Symbol.asyncIterator]();
|
|
165
|
+
}
|
|
166
|
+
if (typeof source[Symbol.iterator] === "function") {
|
|
167
|
+
return source[Symbol.iterator]();
|
|
168
|
+
}
|
|
169
|
+
// Already an iterator (has `.next`).
|
|
170
|
+
if (typeof source.next === "function") {
|
|
171
|
+
return source;
|
|
172
|
+
}
|
|
173
|
+
throw new TypeError("Scannable factory returned a non-iterable value");
|
|
174
|
+
}
|
|
175
|
+
// A "self-iterator" returns the same object from `[Symbol.iterator]()` /
|
|
176
|
+
// `[Symbol.asyncIterator]()`. Generators behave this way, so they exhaust
|
|
177
|
+
// after one pass. Replayable iterables (Array, Set, custom) return a fresh
|
|
178
|
+
// iterator each call. Detection mirrors `normalizeIterator`'s ordering so
|
|
179
|
+
// classification matches scan-time behavior.
|
|
180
|
+
function isOneShotIterable(source) {
|
|
181
|
+
// null/undefined are not one-shot in any meaningful sense; let
|
|
182
|
+
// `normalizeIterator` raise the actual error at scan time.
|
|
183
|
+
if (source == null)
|
|
184
|
+
return false;
|
|
185
|
+
const ref = source;
|
|
186
|
+
if (typeof source[Symbol.asyncIterator] ===
|
|
187
|
+
"function") {
|
|
188
|
+
const it = source[Symbol.asyncIterator]();
|
|
189
|
+
return it === ref;
|
|
190
|
+
}
|
|
191
|
+
if (typeof source[Symbol.iterator] === "function") {
|
|
192
|
+
const it = source[Symbol.iterator]();
|
|
193
|
+
return it === ref;
|
|
194
|
+
}
|
|
195
|
+
// Already-an-iterator (has `.next` but no `Symbol.iterator`) is by
|
|
196
|
+
// definition one-shot.
|
|
197
|
+
if (typeof source.next === "function")
|
|
198
|
+
return true;
|
|
199
|
+
return false;
|
|
200
|
+
}
|