yggio 0.0.15 → 0.0.16

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/binding.js CHANGED
@@ -182,6 +182,27 @@ const {
182
182
  Version,
183
183
  } = binding
184
184
 
185
+ // Take a native's private members off its prototype, keyed as `names` keys
186
+ // them - a method as it is, an accessor as its getter - each deleted once
187
+ // taken, so the loader holds the only handle.
188
+ function takePrivates(owner, names) {
189
+ const taken = {}
190
+ for (const [key, name] of Object.entries(names)) {
191
+ const descriptor = Object.getOwnPropertyDescriptor(owner.prototype, name)
192
+ const member = descriptor?.get ?? descriptor?.value
193
+ if (typeof member !== 'function') {
194
+ throw new TypeError(`native binding is missing ${owner.name}.${name}`)
195
+ }
196
+ delete owner.prototype[name]
197
+ taken[key] = member
198
+ }
199
+ return taken
200
+ }
201
+
202
+ function takePrivate(owner, name) {
203
+ return takePrivates(owner, { [name]: name })[name]
204
+ }
205
+
185
206
  // The pivot keeps its private conversion handles inside this loader: `from`
186
207
  // needs the intrinsic tables assembled below and `asJs` needs the transport
187
208
  // reader, and neither of those belongs on the published class.
@@ -190,88 +211,68 @@ const nativeScalarFromDecimalParts =
190
211
  NativeScalar._fromDecimalPartsNative.bind(NativeScalar)
191
212
  const nativeScalarFromTemporalParts =
192
213
  NativeScalar._fromTemporalPartsNative.bind(NativeScalar)
193
- const nativeScalarAsJs = NativeScalar.prototype._asJsNative
194
- const nativeScalarIter = NativeScalar.prototype._iterNative
195
- const nativeScalarGet = NativeScalar.prototype._getNative
196
- const nativeScalarSet = NativeScalar.prototype._setNative
197
- const nativeScalarRemove = NativeScalar.prototype._removeNative
198
- const nativeScalarArithmetic = Object.freeze({
199
- add: NativeScalar.prototype._addNative,
200
- subtract: NativeScalar.prototype._subtractNative,
201
- multiply: NativeScalar.prototype._multiplyNative,
202
- divide: NativeScalar.prototype._divideNative,
203
- remainder: NativeScalar.prototype._remainderNative,
204
- negate: NativeScalar.prototype._negateNative,
205
- absolute: NativeScalar.prototype._absoluteNative,
206
- })
214
+ const nativeScalarAsJs = takePrivate(NativeScalar, '_asJsNative')
215
+ const nativeScalarIter = takePrivate(NativeScalar, '_iterNative')
216
+ const nativeScalarGet = takePrivate(NativeScalar, '_getNative')
217
+ const nativeScalarSet = takePrivate(NativeScalar, '_setNative')
218
+ const nativeScalarRemove = takePrivate(NativeScalar, '_removeNative')
219
+ const nativeScalarArithmetic = Object.freeze(
220
+ takePrivates(NativeScalar, {
221
+ add: '_addNative',
222
+ subtract: '_subtractNative',
223
+ multiply: '_multiplyNative',
224
+ divide: '_divideNative',
225
+ remainder: '_remainderNative',
226
+ negate: '_negateNative',
227
+ absolute: '_absoluteNative',
228
+ }),
229
+ )
207
230
  const NativeTerm = binding.Term
208
- const nativeTermArithmetic = Object.freeze({
209
- add: NativeTerm.prototype._addNative,
210
- subtract: NativeTerm.prototype._subtractNative,
211
- multiply: NativeTerm.prototype._multiplyNative,
212
- divide: NativeTerm.prototype._divideNative,
213
- remainder: NativeTerm.prototype._remainderNative,
214
- })
231
+ const nativeTermArithmetic = Object.freeze(
232
+ takePrivates(NativeTerm, {
233
+ add: '_addNative',
234
+ subtract: '_subtractNative',
235
+ multiply: '_multiplyNative',
236
+ divide: '_divideNative',
237
+ remainder: '_remainderNative',
238
+ }),
239
+ )
215
240
  const nativeAvroSchemaFromValue =
216
241
  NativeAvroSchema._fromScalarNative.bind(NativeAvroSchema)
217
242
  const nativeAvroSchemaFromUtf8 =
218
243
  NativeAvroSchema._fromUtf8Native.bind(NativeAvroSchema)
219
244
  const nativeAvroSchemaFromBytes =
220
245
  NativeAvroSchema._fromBytesNative.bind(NativeAvroSchema)
221
- const nativeAvroSchemaIntoValue = NativeAvroSchema.prototype._intoScalarNative
222
- const nativeAvroIntoSingleObject =
223
- NativeAvroSchema.prototype._intoSingleObjectNative
224
- const nativeAvroFromSingleObject =
225
- NativeAvroSchema.prototype._fromSingleObjectNative
226
- const nativeAvroBlockRows = NativeAvroBlock.prototype._rowsNative
227
- const nativeAvroBlocksMetadata = NativeAvroBlocks.prototype._metadataNative
246
+ const nativeAvroSchemaIntoValue = takePrivate(NativeAvroSchema, '_intoScalarNative')
247
+ const nativeAvroIntoSingleObject = takePrivate(
248
+ NativeAvroSchema,
249
+ '_intoSingleObjectNative',
250
+ )
251
+ const nativeAvroFromSingleObject = takePrivate(
252
+ NativeAvroSchema,
253
+ '_fromSingleObjectNative',
254
+ )
255
+ const nativeAvroBlockRows = takePrivate(NativeAvroBlock, '_rowsNative')
256
+ const nativeAvroBlocksMetadata = takePrivate(NativeAvroBlocks, '_metadataNative')
228
257
  const nativePartitionSpecFromValue =
229
258
  NativePartitionSpec._fromScalarNative.bind(NativePartitionSpec)
230
- const nativePartitionSpecIntoValue =
231
- NativePartitionSpec.prototype._intoScalarNative
259
+ const nativePartitionSpecIntoValue = takePrivate(
260
+ NativePartitionSpec,
261
+ '_intoScalarNative',
262
+ )
232
263
  const nativeAvroBlocksGet = NativeAvroBlocks.prototype.get
233
264
  const nativeAvroBlocksNext = NativeAvroBlocks.prototype.next
234
265
  const nativeAvroBlocks = binding.avroBlocksNative
235
266
  const nativeAvroLoads = binding.avroLoadsNative
236
267
  const nativeAvroDumps = binding.avroDumpsNative
237
- delete NativeScalar.prototype._asJsNative
238
- delete NativeScalar.prototype._iterNative
239
- delete NativeScalar.prototype._getNative
240
- delete NativeScalar.prototype._setNative
241
- delete NativeScalar.prototype._removeNative
242
- for (const nativeName of [
243
- '_addNative',
244
- '_subtractNative',
245
- '_multiplyNative',
246
- '_divideNative',
247
- '_remainderNative',
248
- '_negateNative',
249
- '_absoluteNative',
250
- ]) {
251
- delete NativeScalar.prototype[nativeName]
252
- }
253
- for (const nativeName of [
254
- '_addNative',
255
- '_subtractNative',
256
- '_multiplyNative',
257
- '_divideNative',
258
- '_remainderNative',
259
- ]) {
260
- delete NativeTerm.prototype[nativeName]
261
- }
262
- delete NativeAvroSchema.prototype._intoScalarNative
263
- delete NativeAvroSchema.prototype._intoSingleObjectNative
264
- delete NativeAvroSchema.prototype._fromSingleObjectNative
265
- delete NativeAvroBlock.prototype._rowsNative
266
- delete NativeAvroBlocks.prototype._metadataNative
267
- delete NativePartitionSpec.prototype._intoScalarNative
268
268
  delete binding.avroBlocksNative
269
269
  delete binding.avroLoadsNative
270
270
  delete binding.avroDumpsNative
271
271
  delete binding.ScalarIterator
272
272
 
273
- const { normalizeMetadata } = require('./fields.js')
273
+ const { normalizeMetadata, pairEntries } = require('./fields.js')
274
274
  const optionProperties = require('./properties.js')
275
+ const { isPlainObject } = optionProperties
275
276
 
276
277
  function publicNativeClass(
277
278
  NativeClass,
@@ -604,20 +605,26 @@ Object.defineProperty(DataType, 'variant', {
604
605
  const fields = createFields(DataType, Field, internalDtype)
605
606
  const { installDefaults } = require('./defaults.js')
606
607
  installDefaults({ DataType, Field, Version, NativeDataType, NativeField })
608
+ // Each namespace binds the format-generic natives to its fixed name: JSON's
609
+ // single-value doors read one JSON document and its collection doors JSON
610
+ // Lines.
611
+ function nativeFormatDoors(single, all) {
612
+ return Object.freeze({
613
+ dumpAll: binding._codecDumpAllNative.bind(null, all),
614
+ dumpAllPath: binding._codecDumpAllPathNative.bind(null, all),
615
+ dumpPath: binding._codecDumpPathNative.bind(null, single),
616
+ dumps: binding._codecDumpsNative.bind(null, single),
617
+ loadAllPath: binding._codecLoadAllPathNative.bind(null, all),
618
+ loadPath: binding._codecLoadPathNative.bind(null, single),
619
+ loads: binding._codecLoadsNative.bind(null, single),
620
+ loadsAll: binding._codecLoadsAllNative.bind(null, all),
621
+ })
622
+ }
607
623
  const nativeCodec = Object.freeze({
608
624
  inferFormat: binding.codecInferFormat,
609
625
  loadsInferred: binding.codecLoadsInferredNative,
610
626
  normalizeFormat: binding.codecNormalizeFormat,
611
- json: Object.freeze({
612
- dumpAll: binding.jsonLinesDumpAllNative,
613
- dumpAllPath: binding.jsonLinesDumpPathNative,
614
- dumpPath: binding.jsonDumpPathNative,
615
- dumps: binding.jsonDumpsNative,
616
- loadAllPath: binding.jsonLinesLoadPathNative,
617
- loadPath: binding.jsonLoadPathNative,
618
- loads: binding.jsonLoadsNative,
619
- loadsAll: binding.jsonLinesLoadsNative,
620
- }),
627
+ json: nativeFormatDoors('json', 'json_lines'),
621
628
  toml: Object.freeze({
622
629
  dumpPath: binding._codecDumpPathNative.bind(null, 'toml'),
623
630
  dumps: binding._codecDumpsNative.bind(null, 'toml'),
@@ -630,39 +637,20 @@ const nativeCodec = Object.freeze({
630
637
  loadPath: binding._codecLoadPathNative.bind(null, 'xml'),
631
638
  loads: binding._codecLoadsNative.bind(null, 'xml'),
632
639
  }),
633
- yaml: Object.freeze({
634
- dumpAll: binding.yamlDumpAllNative,
635
- dumpAllPath: binding.yamlDumpAllPathNative,
636
- dumpPath: binding.yamlDumpPathNative,
637
- dumps: binding.yamlDumpsNative,
638
- loadAllPath: binding.yamlLoadAllPathNative,
639
- loadPath: binding._codecLoadPathNative.bind(null, 'yaml'),
640
- loads: binding._codecLoadsNative.bind(null, 'yaml'),
641
- loadsAll: binding.yamlLoadsAllNative,
642
- }),
640
+ yaml: nativeFormatDoors('yaml', 'yaml'),
643
641
  })
644
642
  for (const name of [
645
643
  'codecInferFormat',
646
644
  'codecLoadsInferredNative',
647
645
  'codecNormalizeFormat',
646
+ '_codecDumpAllNative',
647
+ '_codecDumpAllPathNative',
648
648
  '_codecDumpPathNative',
649
649
  '_codecDumpsNative',
650
+ '_codecLoadAllPathNative',
650
651
  '_codecLoadPathNative',
652
+ '_codecLoadsAllNative',
651
653
  '_codecLoadsNative',
652
- 'jsonDumpPathNative',
653
- 'jsonDumpsNative',
654
- 'jsonLinesDumpAllNative',
655
- 'jsonLinesDumpPathNative',
656
- 'jsonLinesLoadPathNative',
657
- 'jsonLinesLoadsNative',
658
- 'jsonLoadPathNative',
659
- 'jsonLoadsNative',
660
- 'yamlDumpAllNative',
661
- 'yamlDumpAllPathNative',
662
- 'yamlDumpPathNative',
663
- 'yamlDumpsNative',
664
- 'yamlLoadAllPathNative',
665
- 'yamlLoadsAllNative',
666
654
  ]) {
667
655
  delete binding[name]
668
656
  }
@@ -856,7 +844,6 @@ function refuseFillingForJson(format, options) {
856
844
  function loadArguments(format, options) {
857
845
  if (format === FORMAT_JSON || format === FORMAT_JSON_LINES) {
858
846
  refuseFillingForJson(format, options)
859
- return [options.field]
860
847
  }
861
848
  return [options.field, ...fillingArguments(options)]
862
849
  }
@@ -1301,39 +1288,40 @@ Object.defineProperties(PartitionSpec.prototype, {
1301
1288
  // field's own nullability, answered the same way everywhere. An absent
1302
1289
  // answer is skipped and takes the core's default; a key the cast does not
1303
1290
  // know is refused rather than silently doing nothing.
1304
- const CAST_OPTION_NAMES = new Set(['safe', 'representation'])
1291
+ const CAST_OPTION_NAMES = ['safe', 'representation']
1305
1292
  function castOptionArgs(options) {
1306
- if (options === undefined || options === null) return []
1307
- if (typeof options !== 'object') {
1308
- throw new TypeError('cast options must be an object of safe and representation')
1293
+ options = closedOptions(options, CAST_OPTION_NAMES, 'cast')
1294
+ return options === undefined ? [] : [options.safe, options.representation]
1295
+ }
1296
+
1297
+ // A plain object of the answers `names` lists, read once by a native door:
1298
+ // absent is `undefined`, and anything but an object, or a key `names` does not
1299
+ // list, is refused naming them.
1300
+ function closedOptions(options, names, label) {
1301
+ if (options === undefined || options === null) return undefined
1302
+ const listed =
1303
+ names.length === 1
1304
+ ? names[0]
1305
+ : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`
1306
+ if (typeof options !== 'object' || Array.isArray(options)) {
1307
+ throw new TypeError(`${label} options must be an object of ${listed}`)
1309
1308
  }
1310
1309
  for (const key of Object.keys(options)) {
1311
- if (!CAST_OPTION_NAMES.has(key)) {
1312
- throw new TypeError(
1313
- `cast options take safe and representation, got ${JSON.stringify(key)}`,
1314
- )
1310
+ if (!names.includes(key)) {
1311
+ throw new TypeError(`${label} options take ${listed}, got ${JSON.stringify(key)}`)
1315
1312
  }
1316
1313
  }
1317
- return [options.safe, options.representation]
1314
+ return options
1318
1315
  }
1319
1316
 
1320
1317
  // The two facts an ordering states beside its key, in the order the native
1321
1318
  // doors read them: `descending` and `nullsFirst`. An absent answer is skipped
1322
1319
  // and `null` clears it, each taking the core's default - ascending, nulls
1323
1320
  // last; anything but a boolean, and a key no ordering knows, is refused.
1324
- const SORT_OPTION_NAMES = new Set(['descending', 'nullsFirst'])
1321
+ const SORT_OPTION_NAMES = ['descending', 'nullsFirst']
1325
1322
  function sortOptionArgs(options, label) {
1326
- if (options === undefined || options === null) return []
1327
- if (typeof options !== 'object' || Array.isArray(options)) {
1328
- throw new TypeError(`${label} options must be an object of descending and nullsFirst`)
1329
- }
1330
- for (const key of Object.keys(options)) {
1331
- if (!SORT_OPTION_NAMES.has(key)) {
1332
- throw new TypeError(
1333
- `${label} options take descending and nullsFirst, got ${JSON.stringify(key)}`,
1334
- )
1335
- }
1336
- }
1323
+ options = closedOptions(options, SORT_OPTION_NAMES, label)
1324
+ if (options === undefined) return []
1337
1325
  for (const key of SORT_OPTION_NAMES) {
1338
1326
  const value = options[key]
1339
1327
  if (value !== undefined && value !== null && typeof value !== 'boolean') {
@@ -1448,132 +1436,77 @@ const nativeSerie = Object.freeze({
1448
1436
  lit: NativeSerie._litNative.bind(NativeSerie),
1449
1437
  fromArrowArray: NativeSerie._fromArrowArrayIpcNative.bind(NativeSerie),
1450
1438
  fromArrowBatch: NativeSerie._fromArrowBatchIpcNative.bind(NativeSerie),
1451
- leaf: Object.getOwnPropertyDescriptor(NativeSerie.prototype, '_leafNative').get,
1452
- asJs: NativeSerie.prototype._asJsNative,
1453
- iter: NativeSerie.prototype._iterNative,
1454
- splice: NativeSerie.prototype._spliceNative,
1455
- set: NativeSerie.prototype._setNative,
1456
- push: NativeSerie.prototype._pushNative,
1457
- insert: NativeSerie.prototype._insertNative,
1458
- extend: NativeSerie.prototype._extendNative,
1459
- resize: NativeSerie.prototype._resizeNative,
1460
- setCell: NativeSerie.prototype._setCellNative,
1461
- cast: NativeSerie.prototype._castNative,
1462
- intoArrowScalar: NativeSerie.prototype._intoArrowScalarIpcNative,
1463
- intoArrowArray: NativeSerie.prototype._intoArrowArrayIpcNative,
1464
- intoArrowBatch: NativeSerie.prototype._intoArrowBatchIpcNative,
1465
- equals: NativeSerie.prototype._equalsNative,
1466
- compare: NativeSerie.prototype._compareNative,
1467
- offsets: NativeSerie.prototype._offsetsNative,
1468
- sizes: NativeSerie.prototype._sizesNative,
1469
- width: NativeSerie.prototype._widthNative,
1470
- range: NativeSerie.prototype._rangeNative,
1471
- row: NativeSerie.prototype._rowNative,
1472
- entries: NativeSerie.prototype._entriesNative,
1473
- keys: NativeSerie.prototype._keysNative,
1474
- values: NativeSerie.prototype._valuesNative,
1475
- keysSorted: NativeSerie.prototype._keysSortedNative,
1476
- names: NativeSerie.prototype._namesNative,
1477
- withoutChild: NativeSerie.prototype._withoutChildNative,
1478
- sortIndices: NativeSerie.prototype._sortIndicesNative,
1479
- isSorted: NativeSerie.prototype._isSortedNative,
1480
- intoSorted: NativeSerie.prototype._intoSortedNative,
1481
- intoUnique: NativeSerie.prototype._intoUniqueNative,
1482
- intoReversed: NativeSerie.prototype._intoReversedNative,
1483
- intoTaken: NativeSerie.prototype._intoTakenNative,
1484
- intoFiltered: NativeSerie.prototype._intoFilteredNative,
1485
- partitionBy: NativeSerie.prototype._partitionByNative,
1486
- asSorted: NativeSerie.prototype._asSortedNative,
1487
- asUnique: NativeSerie.prototype._asUniqueNative,
1488
- asReversed: NativeSerie.prototype._asReversedNative,
1489
- asTaken: NativeSerie.prototype._asTakenNative,
1490
- asFiltered: NativeSerie.prototype._asFilteredNative,
1491
- sortIndicesBy: NativeSerie.prototype._sortIndicesByNative,
1492
- intoSortBy: NativeSerie.prototype._intoSortByNative,
1493
- asSortBy: NativeSerie.prototype._asSortByNative,
1494
- joinWith: NativeSerie.prototype._joinWithNative,
1495
- asSpilled: NativeSerie.prototype._asSpilledNative,
1496
- intoSpilled: NativeSerie.prototype._intoSpilledNative,
1497
- window: NativeSerie.prototype._windowNative,
1498
- windowBy: NativeSerie.prototype._windowByNative,
1499
- // The natives that answer a serie, each handed out as its leaf's class.
1500
- answering: Object.freeze({
1501
- slice: NativeSerie.prototype._sliceNative,
1502
- child: NativeSerie.prototype._childNative,
1503
- childAt: NativeSerie.prototype._childAtNative,
1504
- items: NativeSerie.prototype._itemsNative,
1505
- getChildByPath: NativeSerie.prototype._getChildByPathNative,
1506
- clone: NativeSerie.prototype._cloneNative,
1507
- intoRun: NativeSerie.prototype._intoRunNative,
1508
- }),
1509
- children: NativeSerie.prototype._childrenNative,
1510
1439
  empty: NativeSerie._emptyNative.bind(NativeSerie),
1511
1440
  withCapacity: NativeSerie._withCapacityNative.bind(NativeSerie),
1512
1441
  fromArrowReader: NativeSerie._fromArrowReaderNative.bind(NativeSerie),
1513
- scalarAsSerie: NativeScalar.prototype._asSerieNative,
1442
+ fromSortedSpans: NativeSerie._fromSortedSpansNative.bind(NativeSerie),
1443
+ ...takePrivates(NativeSerie, {
1444
+ intoChunks: '_intoChunksNative',
1445
+ intoCast: '_intoCastNative',
1446
+ leaf: '_leafNative',
1447
+ asJs: '_asJsNative',
1448
+ iter: '_iterNative',
1449
+ splice: '_spliceNative',
1450
+ set: '_setNative',
1451
+ push: '_pushNative',
1452
+ insert: '_insertNative',
1453
+ extend: '_extendNative',
1454
+ resize: '_resizeNative',
1455
+ setCell: '_setCellNative',
1456
+ cast: '_castNative',
1457
+ intoArrowScalar: '_intoArrowScalarIpcNative',
1458
+ intoArrowArray: '_intoArrowArrayIpcNative',
1459
+ intoArrowBatch: '_intoArrowBatchIpcNative',
1460
+ equals: '_equalsNative',
1461
+ compare: '_compareNative',
1462
+ offsets: '_offsetsNative',
1463
+ sizes: '_sizesNative',
1464
+ width: '_widthNative',
1465
+ range: '_rangeNative',
1466
+ row: '_rowNative',
1467
+ entries: '_entriesNative',
1468
+ keys: '_keysNative',
1469
+ values: '_valuesNative',
1470
+ keysSorted: '_keysSortedNative',
1471
+ names: '_namesNative',
1472
+ withoutChild: '_withoutChildNative',
1473
+ sortIndices: '_sortIndicesNative',
1474
+ isSorted: '_isSortedNative',
1475
+ intoSorted: '_intoSortedNative',
1476
+ intoUnique: '_intoUniqueNative',
1477
+ intoReversed: '_intoReversedNative',
1478
+ intoTaken: '_intoTakenNative',
1479
+ intoFiltered: '_intoFilteredNative',
1480
+ partitionBy: '_partitionByNative',
1481
+ asSorted: '_asSortedNative',
1482
+ asUnique: '_asUniqueNative',
1483
+ asReversed: '_asReversedNative',
1484
+ asTaken: '_asTakenNative',
1485
+ asFiltered: '_asFilteredNative',
1486
+ sortIndicesBy: '_sortIndicesByNative',
1487
+ intoSortBy: '_intoSortByNative',
1488
+ asSortBy: '_asSortByNative',
1489
+ joinWith: '_joinWithNative',
1490
+ asSpilled: '_asSpilledNative',
1491
+ intoSpilled: '_intoSpilledNative',
1492
+ window: '_windowNative',
1493
+ windowBy: '_windowByNative',
1494
+ children: '_childrenNative',
1495
+ }),
1496
+ // The natives that answer a serie, each handed out as its leaf's class.
1497
+ answering: Object.freeze(
1498
+ takePrivates(NativeSerie, {
1499
+ slice: '_sliceNative',
1500
+ child: '_childNative',
1501
+ childAt: '_childAtNative',
1502
+ items: '_itemsNative',
1503
+ getChildByPath: '_getChildByPathNative',
1504
+ clone: '_cloneNative',
1505
+ intoRun: '_intoRunNative',
1506
+ }),
1507
+ ),
1508
+ scalarAsSerie: takePrivate(NativeScalar, '_asSerieNative'),
1514
1509
  })
1515
- for (const name of [
1516
- '_leafNative',
1517
- '_asJsNative',
1518
- '_iterNative',
1519
- '_spliceNative',
1520
- '_setNative',
1521
- '_pushNative',
1522
- '_insertNative',
1523
- '_extendNative',
1524
- '_resizeNative',
1525
- '_setCellNative',
1526
- '_castNative',
1527
- '_intoArrowScalarIpcNative',
1528
- '_intoArrowArrayIpcNative',
1529
- '_intoArrowBatchIpcNative',
1530
- '_equalsNative',
1531
- '_compareNative',
1532
- '_offsetsNative',
1533
- '_sizesNative',
1534
- '_widthNative',
1535
- '_rangeNative',
1536
- '_rowNative',
1537
- '_entriesNative',
1538
- '_keysNative',
1539
- '_valuesNative',
1540
- '_keysSortedNative',
1541
- '_namesNative',
1542
- '_withoutChildNative',
1543
- '_sliceNative',
1544
- '_childNative',
1545
- '_childAtNative',
1546
- '_itemsNative',
1547
- '_getChildByPathNative',
1548
- '_cloneNative',
1549
- '_intoRunNative',
1550
- '_childrenNative',
1551
- '_sortIndicesNative',
1552
- '_isSortedNative',
1553
- '_intoSortedNative',
1554
- '_intoUniqueNative',
1555
- '_intoReversedNative',
1556
- '_intoTakenNative',
1557
- '_intoFilteredNative',
1558
- '_partitionByNative',
1559
- '_partitionByPathsNative',
1560
- '_asSortedNative',
1561
- '_asUniqueNative',
1562
- '_asReversedNative',
1563
- '_asTakenNative',
1564
- '_asFilteredNative',
1565
- '_sortIndicesByNative',
1566
- '_intoSortByNative',
1567
- '_asSortByNative',
1568
- '_joinWithNative',
1569
- '_asSpilledNative',
1570
- '_intoSpilledNative',
1571
- '_windowNative',
1572
- '_windowByNative',
1573
- ]) {
1574
- delete NativeSerie.prototype[name]
1575
- }
1576
- delete NativeScalar.prototype._asSerieNative
1577
1510
  delete binding.SerieIterator
1578
1511
 
1579
1512
  // One value converted for a column: a native Scalar or Serie as it is,
@@ -1666,55 +1599,17 @@ function joinHow(how, label) {
1666
1599
  // The facts beside a join's keys and kind, one plain object the native door
1667
1600
  // reads once; an absent object or answer is skipped, and a key no join
1668
1601
  // knows is refused.
1669
- const JOIN_OPTION_NAMES = new Set(['coalesce', 'suffix', 'build', 'prune', 'spill', 'pushdownKeys'])
1602
+ const JOIN_OPTION_NAMES = ['coalesce', 'suffix', 'build', 'prune', 'spill', 'pushdownKeys']
1670
1603
  function joinOptionArgs(options, label) {
1671
- if (options === undefined || options === null) return undefined
1672
- if (typeof options !== 'object' || Array.isArray(options)) {
1673
- throw new TypeError(
1674
- `${label} options must be an object of coalesce, suffix, build, prune, spill and pushdownKeys`,
1675
- )
1676
- }
1677
- for (const key of Object.keys(options)) {
1678
- if (!JOIN_OPTION_NAMES.has(key)) {
1679
- throw new TypeError(
1680
- `${label} options take coalesce, suffix, build, prune, spill and pushdownKeys, got ${JSON.stringify(key)}`,
1681
- )
1682
- }
1683
- }
1684
- return options
1604
+ return closedOptions(options, JOIN_OPTION_NAMES, label)
1685
1605
  }
1686
1606
 
1687
1607
  // How a stream is cut into partitions, one plain object the native door
1688
1608
  // reads once; an absent object or answer is skipped, and a key no
1689
1609
  // partitioning knows is refused.
1690
- const PARTITION_OPTION_NAMES = new Set(['maxOpen', 'threads', 'clustered'])
1610
+ const PARTITION_OPTION_NAMES = ['maxOpen', 'threads', 'clustered']
1691
1611
  function partitionOptionArgs(options, label) {
1692
- if (options === undefined || options === null) return undefined
1693
- if (typeof options !== 'object' || Array.isArray(options)) {
1694
- throw new TypeError(`${label} options must be an object of maxOpen, threads and clustered`)
1695
- }
1696
- for (const key of Object.keys(options)) {
1697
- if (!PARTITION_OPTION_NAMES.has(key)) {
1698
- throw new TypeError(
1699
- `${label} options take maxOpen, threads and clustered, got ${JSON.stringify(key)}`,
1700
- )
1701
- }
1702
- }
1703
- return options
1704
- }
1705
-
1706
- // The windows a held serie lends hold the serie windowed, or the one serie
1707
- // of the rows `sorted` gathered, which is handed out as its leaf's class.
1708
-
1709
-
1710
- // The field paths a record partitions by: one path - its text or a FieldPath
1711
- // - or an iterable of them.
1712
- function fieldPathsArgument(paths, label) {
1713
- if (typeof paths === 'string' || paths instanceof binding.FieldPath) return [paths]
1714
- if (paths == null || typeof paths[Symbol.iterator] !== 'function') {
1715
- throw new TypeError(`${label} must be a field path or an iterable of them`)
1716
- }
1717
- return Array.from(paths)
1612
+ return closedOptions(options, PARTITION_OPTION_NAMES, label)
1718
1613
  }
1719
1614
 
1720
1615
  const Serie = publicNativeClass(
@@ -1730,6 +1625,7 @@ const Serie = publicNativeClass(
1730
1625
  '_withCapacityNative',
1731
1626
  '_fromArrowReaderNative',
1732
1627
  '_fromSourceNative',
1628
+ '_fromSortedSpansNative',
1733
1629
  ]),
1734
1630
  (args) => (args[0] == null ? [] : [serieValues(args[0], undefined, 'Serie values')]),
1735
1631
  )
@@ -1846,7 +1742,7 @@ Object.defineProperties(Serie, {
1846
1742
  configurable: true,
1847
1743
  value(value, field, options) {
1848
1744
  let held
1849
- if ([NativeSerie, NativeChunkedSerie, NativeStreamChunkedSerie, NativeStreamSerie, KeySerie, KeySeries, StreamKeySerie, NativeWindowSerie].some(Owner => value instanceof Owner)) {
1745
+ if ([NativeSerie, NativeChunkedSerie, KeySerie, KeySeries, StreamKeySerie, NativeWindowSerie].some(Owner => value instanceof Owner)) {
1850
1746
  held = describedSerie(nativeSerie.fromSource(value))
1851
1747
  } else if (value instanceof arrow().Vector) {
1852
1748
  return Serie.fromArrowArray(value, field, options)
@@ -2033,6 +1929,27 @@ Object.defineProperties(Serie.prototype, {
2033
1929
  ])
2034
1930
  },
2035
1931
  },
1932
+ intoChunks: {
1933
+ configurable: true,
1934
+ value() {
1935
+ const chunks = Reflect.apply(nativeSerie.intoChunks, this, [])
1936
+ const failed = this[FAILED]
1937
+ return (function* walk() {
1938
+ for (let serie; (serie = nextSerieChunk(chunks, failed)) !== null; ) yield describedSerie(serie)
1939
+ })()
1940
+ },
1941
+ },
1942
+ intoCast: {
1943
+ configurable: true,
1944
+ value(field, options) {
1945
+ return describedSerie(
1946
+ Reflect.apply(nativeSerie.intoCast, this, [
1947
+ field instanceof NativeField || field instanceof NativeDataType ? field : Field.from(field),
1948
+ ...castOptionArgs(options),
1949
+ ]),
1950
+ )
1951
+ },
1952
+ },
2036
1953
  cast: {
2037
1954
  configurable: true,
2038
1955
  value(field, options) {
@@ -2148,7 +2065,7 @@ Object.defineProperties(Serie.prototype, {
2148
2065
  )
2149
2066
  },
2150
2067
  },
2151
- partitionBy: { configurable: true, writable: true, value(by, options) { return Reflect.apply(nativeSerie.partitionBy, this, [nativeKeyBy(by, 'Serie.prototype.partitionBy'), ]) } },
2068
+ partitionBy: { configurable: true, writable: true, value(by, options) { return Reflect.apply(nativeSerie.partitionBy, this, [nativeKeyBy(by, 'Serie.prototype.partitionBy'), partitionOptionArgs(options, 'Serie.prototype.partitionBy')]) } },
2152
2069
 
2153
2070
  asSorted: {
2154
2071
  configurable: true,
@@ -2280,59 +2197,33 @@ Object.defineProperty(Scalar.prototype, 'asSerie', {
2280
2197
  // class; values are typed through the field the serie carries.
2281
2198
  const NativeWindowSerie = binding.WindowSerie
2282
2199
  const nativeWindowSerie = Object.freeze({
2283
- asJs: NativeWindowSerie.prototype._asJsNative,
2284
- iter: NativeWindowSerie.prototype._iterNative,
2285
- isSorted: NativeWindowSerie.prototype._isSortedNative,
2286
- sortIndices: NativeWindowSerie.prototype._sortIndicesNative,
2287
- window: NativeWindowSerie.prototype._windowNative,
2288
- windowBy: NativeWindowSerie.prototype._windowByNative,
2289
- intoSerie: NativeWindowSerie.prototype._intoSerieNative,
2290
- intoSorted: NativeWindowSerie.prototype._intoSortedNative,
2291
- intoUnique: NativeWindowSerie.prototype._intoUniqueNative,
2292
- intoReversed: NativeWindowSerie.prototype._intoReversedNative,
2293
- intoTaken: NativeWindowSerie.prototype._intoTakenNative,
2294
- intoFiltered: NativeWindowSerie.prototype._intoFilteredNative,
2295
- partitionBy: NativeWindowSerie.prototype._partitionByNative,
2296
- equals: NativeWindowSerie.prototype._equalsNative,
2297
- set: NativeWindowSerie.prototype._setNative,
2298
- fill: NativeWindowSerie.prototype._fillNative,
2299
- copyFrom: NativeWindowSerie.prototype._copyFromNative,
2300
- splice: NativeWindowSerie.prototype._spliceNative,
2301
- asSorted: NativeWindowSerie.prototype._asSortedNative,
2302
- asReversed: NativeWindowSerie.prototype._asReversedNative,
2303
- asTaken: NativeWindowSerie.prototype._asTakenNative,
2304
- sortIndicesBy: NativeWindowSerie.prototype._sortIndicesByNative,
2305
- intoSortBy: NativeWindowSerie.prototype._intoSortByNative,
2306
- asSortBy: NativeWindowSerie.prototype._asSortByNative,
2200
+ ...takePrivates(NativeWindowSerie, {
2201
+ asJs: '_asJsNative',
2202
+ iter: '_iterNative',
2203
+ isSorted: '_isSortedNative',
2204
+ sortIndices: '_sortIndicesNative',
2205
+ window: '_windowNative',
2206
+ windowBy: '_windowByNative',
2207
+ intoSerie: '_intoSerieNative',
2208
+ intoSorted: '_intoSortedNative',
2209
+ intoUnique: '_intoUniqueNative',
2210
+ intoReversed: '_intoReversedNative',
2211
+ intoTaken: '_intoTakenNative',
2212
+ intoFiltered: '_intoFilteredNative',
2213
+ partitionBy: '_partitionByNative',
2214
+ equals: '_equalsNative',
2215
+ set: '_setNative',
2216
+ fill: '_fillNative',
2217
+ copyFrom: '_copyFromNative',
2218
+ splice: '_spliceNative',
2219
+ asSorted: '_asSortedNative',
2220
+ asReversed: '_asReversedNative',
2221
+ asTaken: '_asTakenNative',
2222
+ sortIndicesBy: '_sortIndicesByNative',
2223
+ intoSortBy: '_intoSortByNative',
2224
+ asSortBy: '_asSortByNative',
2225
+ }),
2307
2226
  })
2308
- for (const name of [
2309
- '_asJsNative',
2310
- '_iterNative',
2311
- '_isSortedNative',
2312
- '_sortIndicesNative',
2313
- '_windowNative',
2314
- '_windowByNative',
2315
- '_intoSerieNative',
2316
- '_intoSortedNative',
2317
- '_intoUniqueNative',
2318
- '_intoReversedNative',
2319
- '_intoTakenNative',
2320
- '_intoFilteredNative',
2321
- '_partitionByNative',
2322
- '_equalsNative',
2323
- '_setNative',
2324
- '_fillNative',
2325
- '_copyFromNative',
2326
- '_spliceNative',
2327
- '_asSortedNative',
2328
- '_asReversedNative',
2329
- '_asTakenNative',
2330
- '_sortIndicesByNative',
2331
- '_intoSortByNative',
2332
- '_asSortByNative',
2333
- ]) {
2334
- delete NativeWindowSerie.prototype[name]
2335
- }
2336
2227
  const WindowSerie = function () {
2337
2228
  throw new TypeError('WindowSerie is handed out by Serie; take one with serie.window(offset, length)')
2338
2229
  }
@@ -2559,52 +2450,11 @@ Object.defineProperties(WindowSerie.prototype, {
2559
2450
  },
2560
2451
  })
2561
2452
 
2562
- // A stream of record series: the natives it reads by are kept here, and
2563
- // each serie it yields is handed out as its leaf's class.
2564
- const NativeStreamChunkedSerie = binding.StreamChunkedSerie
2565
- const nativeStreamChunkedSerie = Object.freeze({
2566
- fromArrowReader: NativeStreamChunkedSerie._fromArrowReaderNative.bind(NativeStreamChunkedSerie),
2567
- fromSerie: NativeStreamChunkedSerie._fromSerieNative.bind(NativeStreamChunkedSerie),
2568
- fromChunked: NativeStreamChunkedSerie._fromChunkedNative.bind(NativeStreamChunkedSerie),
2569
- fromSortedSpans: NativeStreamChunkedSerie._fromSortedSpansNative.bind(NativeStreamChunkedSerie),
2570
- next: NativeStreamChunkedSerie.prototype._nextNative,
2571
- cast: NativeStreamChunkedSerie.prototype._castNative,
2572
- windowBy: NativeStreamChunkedSerie.prototype._windowByNative,
2573
- partitionBy: NativeStreamChunkedSerie.prototype._partitionByNative,
2574
- intoSorted: NativeStreamChunkedSerie.prototype._intoSortedNative,
2575
- intoSortBy: NativeStreamChunkedSerie.prototype._intoSortByNative,
2576
- joinWith: NativeStreamChunkedSerie.prototype._joinWithNative,
2577
- asSpilled: NativeStreamChunkedSerie.prototype._asSpilledNative,
2578
- intoSpilled: NativeStreamChunkedSerie.prototype._intoSpilledNative,
2579
- })
2580
- for (const name of [
2581
- '_nextNative',
2582
- '_castNative',
2583
- '_windowByNative',
2584
- '_partitionByNative',
2585
- '_intoSortedNative',
2586
- '_intoSortByNative',
2587
- '_joinWithNative',
2588
- '_asSpilledNative',
2589
- '_intoSpilledNative',
2590
- ]) {
2591
- delete NativeStreamChunkedSerie.prototype[name]
2592
- }
2593
- const StreamChunkedSerie = publicNativeClass(
2594
- NativeStreamChunkedSerie,
2595
- 'StreamChunkedSerie',
2596
- new Set([
2597
- '_fromArrowReaderNative',
2598
- '_fromSerieNative',
2599
- '_fromChunkedNative',
2600
- '_fromSortedSpansNative',
2601
- ]),
2602
- )
2603
- function nextStreamChunk(stream) {
2604
- const failed = stream[FAILED]
2453
+ const nativeSerieChunksNext = takePrivate(binding.SerieChunks, '_nextNative')
2454
+ function nextSerieChunk(chunks, failed) {
2605
2455
  let serie
2606
2456
  try {
2607
- serie = Reflect.apply(nativeStreamChunkedSerie.next, stream, [])
2457
+ serie = Reflect.apply(nativeSerieChunksNext, chunks, [])
2608
2458
  } catch (error) {
2609
2459
  if (failed !== undefined && failed.error !== undefined) {
2610
2460
  const { error: original } = failed
@@ -2620,107 +2470,6 @@ function nextStreamChunk(stream) {
2620
2470
  }
2621
2471
  return serie
2622
2472
  }
2623
- Object.defineProperty(StreamChunkedSerie, 'fromArrowReader', {
2624
- configurable: true,
2625
- value(reader, root, options) {
2626
- return nativeStreamChunkedSerie.fromArrowReader(
2627
- nativeBatchReader(reader, 'StreamChunkedSerie.fromArrowReader'),
2628
- optionalField(root),
2629
- ...castOptionArgs(options),
2630
- )
2631
- },
2632
- })
2633
- // A held column is a stream of the one record serie it is.
2634
- Object.defineProperty(StreamChunkedSerie, 'fromSerie', {
2635
- configurable: true,
2636
- value(serie) {
2637
- if (!(serie instanceof NativeSerie)) {
2638
- throw new TypeError('StreamChunkedSerie.fromSerie takes a Serie')
2639
- }
2640
- return nativeStreamChunkedSerie.fromSerie(serie)
2641
- },
2642
- })
2643
- Object.defineProperties(StreamChunkedSerie.prototype, {
2644
- [Symbol.iterator]: {
2645
- configurable: true,
2646
- value: function* series() {
2647
- for (let serie; (serie = nextStreamChunk(this)) !== null; ) {
2648
- yield describedSerie(serie)
2649
- }
2650
- },
2651
- },
2652
- // Every record cast into another root by one plan; the reader is consumed.
2653
- cast: {
2654
- configurable: true,
2655
- value(field, options) {
2656
- return Reflect.apply(nativeStreamChunkedSerie.cast, this, [
2657
- field instanceof NativeField || field instanceof NativeDataType ? field : Field.from(field),
2658
- ...castOptionArgs(options),
2659
- ])
2660
- },
2661
- },
2662
- // The stream cut into one lazy reader per window; the reader is consumed.
2663
- windowBy: { configurable: true, writable: true, value(by, sorted) { return Reflect.apply(nativeStreamChunkedSerie.windowBy, this, [nativeKeyBy(by, 'StreamChunkedSerie.prototype.windowBy'), windowSorted(sorted, 'StreamChunkedSerie.prototype.windowBy')]) } },
2664
- // The stream cut by key into partitions, each `[key, rows]` pair yielded
2665
- // as its partition closes; the reader is consumed.
2666
- partitionBy: { configurable: true, writable: true, value(by, options) { return Reflect.apply(nativeStreamChunkedSerie.partitionBy, this, [nativeKeyBy(by, 'StreamChunkedSerie.prototype.partitionBy'), partitionOptionArgs(options, 'StreamChunkedSerie.prototype.partitionBy')]) } },
2667
- // The stream drained, sorted and read back as the held stream of the
2668
- // merged chunks; the reader is consumed.
2669
- intoSorted: {
2670
- configurable: true,
2671
- value(options) {
2672
- return Reflect.apply(
2673
- nativeStreamChunkedSerie.intoSorted,
2674
- this,
2675
- sortOptionArgs(options, 'StreamChunkedSerie.intoSorted'),
2676
- )
2677
- },
2678
- },
2679
- intoSortBy: {
2680
- configurable: true,
2681
- value(by) {
2682
- return Reflect.apply(nativeStreamChunkedSerie.intoSortBy, this, [orderingKeys(by)])
2683
- },
2684
- },
2685
- // The records this reader holds spilled in place, answering this reader;
2686
- // `intoSpilled` hands them over as a new reader, this one consumed.
2687
- asSpilled: {
2688
- configurable: true,
2689
- value(options) {
2690
- Reflect.apply(nativeStreamChunkedSerie.asSpilled, this, [options])
2691
- return this
2692
- },
2693
- },
2694
- intoSpilled: {
2695
- configurable: true,
2696
- value(options) {
2697
- return Reflect.apply(nativeStreamChunkedSerie.intoSpilled, this, [options])
2698
- },
2699
- },
2700
- // The stream joined with a held column, a chunked one or another stream,
2701
- // which is consumed too; one probe batch joined at a time.
2702
- joinWith: {
2703
- configurable: true,
2704
- value(other, by, how, options) {
2705
- if (other === this) {
2706
- throw new TypeError('StreamChunkedSerie.joinWith cannot join a stream with itself')
2707
- }
2708
- if (
2709
- !(other instanceof NativeSerie) &&
2710
- !(other instanceof NativeChunkedSerie) &&
2711
- !(other instanceof NativeStreamChunkedSerie)
2712
- ) {
2713
- throw new TypeError('StreamChunkedSerie.joinWith takes a Serie, a ChunkedSerie or a StreamChunkedSerie')
2714
- }
2715
- return Reflect.apply(nativeStreamChunkedSerie.joinWith, this, [
2716
- other,
2717
- literalValue(by),
2718
- joinHow(how, 'StreamChunkedSerie.joinWith'),
2719
- joinOptionArgs(options, 'StreamChunkedSerie.joinWith'),
2720
- ])
2721
- },
2722
- },
2723
- })
2724
2473
 
2725
2474
  // Key items have explicit context and payload. Held collections iterate repeatedly.
2726
2475
  const KeySerie = publicNativeClass(binding.KeySerie, 'KeySerie', new Set(), () => { throw new TypeError('KeySerie is returned by clustering') })
@@ -2766,68 +2515,37 @@ const nativeChunkedSerie = Object.freeze({
2766
2515
  fromArrowArray: NativeChunkedSerie._fromArrowArrayIpcNative.bind(NativeChunkedSerie),
2767
2516
  fromArrowBatch: NativeChunkedSerie._fromArrowBatchIpcNative.bind(NativeChunkedSerie),
2768
2517
  fromArrowReader: NativeChunkedSerie._fromArrowReaderNative.bind(NativeChunkedSerie),
2769
- chunks: NativeChunkedSerie.prototype._chunksNative,
2770
- chunk: NativeChunkedSerie.prototype._chunkNative,
2771
- asJs: NativeChunkedSerie.prototype._asJsNative,
2772
- iter: NativeChunkedSerie.prototype._iterNative,
2773
- pushChunk: NativeChunkedSerie.prototype._pushChunkNative,
2774
- intoSerie: NativeChunkedSerie.prototype._intoSerieNative,
2775
- cast: NativeChunkedSerie.prototype._castNative,
2776
- intoArrowArray: NativeChunkedSerie.prototype._intoArrowArrayIpcNative,
2777
- equals: NativeChunkedSerie.prototype._equalsNative,
2778
- compare: NativeChunkedSerie.prototype._compareNative,
2779
- sortIndices: NativeChunkedSerie.prototype._sortIndicesNative,
2780
- isSorted: NativeChunkedSerie.prototype._isSortedNative,
2781
- intoSorted: NativeChunkedSerie.prototype._intoSortedNative,
2782
- intoTaken: NativeChunkedSerie.prototype._intoTakenNative,
2783
- intoFiltered: NativeChunkedSerie.prototype._intoFilteredNative,
2784
- partitionBy: NativeChunkedSerie.prototype._partitionByNative,
2785
- windowBy: NativeChunkedSerie.prototype._windowByNative,
2786
- asSorted: NativeChunkedSerie.prototype._asSortedNative,
2787
- asUnique: NativeChunkedSerie.prototype._asUniqueNative,
2788
- asReversed: NativeChunkedSerie.prototype._asReversedNative,
2789
- asTaken: NativeChunkedSerie.prototype._asTakenNative,
2790
- asFiltered: NativeChunkedSerie.prototype._asFilteredNative,
2791
- sortIndicesBy: NativeChunkedSerie.prototype._sortIndicesByNative,
2792
- intoSortBy: NativeChunkedSerie.prototype._intoSortByNative,
2793
- asSortBy: NativeChunkedSerie.prototype._asSortByNative,
2794
- joinWith: NativeChunkedSerie.prototype._joinWithNative,
2795
- asSpilled: NativeChunkedSerie.prototype._asSpilledNative,
2796
- intoSpilled: NativeChunkedSerie.prototype._intoSpilledNative,
2518
+ ...takePrivates(NativeChunkedSerie, {
2519
+ chunks: '_chunksNative',
2520
+ chunk: '_chunkNative',
2521
+ asJs: '_asJsNative',
2522
+ iter: '_iterNative',
2523
+ pushChunk: '_pushChunkNative',
2524
+ intoSerie: '_intoSerieNative',
2525
+ cast: '_castNative',
2526
+ intoArrowArray: '_intoArrowArrayIpcNative',
2527
+ equals: '_equalsNative',
2528
+ compare: '_compareNative',
2529
+ sortIndices: '_sortIndicesNative',
2530
+ isSorted: '_isSortedNative',
2531
+ intoSorted: '_intoSortedNative',
2532
+ intoTaken: '_intoTakenNative',
2533
+ intoFiltered: '_intoFilteredNative',
2534
+ partitionBy: '_partitionByNative',
2535
+ windowBy: '_windowByNative',
2536
+ asSorted: '_asSortedNative',
2537
+ asUnique: '_asUniqueNative',
2538
+ asReversed: '_asReversedNative',
2539
+ asTaken: '_asTakenNative',
2540
+ asFiltered: '_asFilteredNative',
2541
+ sortIndicesBy: '_sortIndicesByNative',
2542
+ intoSortBy: '_intoSortByNative',
2543
+ asSortBy: '_asSortByNative',
2544
+ joinWith: '_joinWithNative',
2545
+ asSpilled: '_asSpilledNative',
2546
+ intoSpilled: '_intoSpilledNative',
2547
+ }),
2797
2548
  })
2798
- for (const name of [
2799
- '_chunksNative',
2800
- '_chunkNative',
2801
- '_asJsNative',
2802
- '_iterNative',
2803
- '_pushChunkNative',
2804
- '_intoSerieNative',
2805
- '_castNative',
2806
- '_intoArrowArrayIpcNative',
2807
- '_equalsNative',
2808
- '_compareNative',
2809
- '_sortIndicesNative',
2810
- '_isSortedNative',
2811
- '_intoSortedNative',
2812
- '_intoTakenNative',
2813
- '_intoFilteredNative',
2814
- '_partitionByNative',
2815
- '_partitionByChunkedNative',
2816
- '_windowByNative',
2817
- '_asSortedNative',
2818
- '_asUniqueNative',
2819
- '_asReversedNative',
2820
- '_asTakenNative',
2821
- '_asFilteredNative',
2822
- '_sortIndicesByNative',
2823
- '_intoSortByNative',
2824
- '_asSortByNative',
2825
- '_joinWithNative',
2826
- '_asSpilledNative',
2827
- '_intoSpilledNative',
2828
- ]) {
2829
- delete NativeChunkedSerie.prototype[name]
2830
- }
2831
2549
  const ChunkedSerie = publicNativeClass(
2832
2550
  NativeChunkedSerie,
2833
2551
  'ChunkedSerie',
@@ -3184,33 +2902,19 @@ Object.defineProperties(ChunkedSerie.prototype, {
3184
2902
  },
3185
2903
  })
3186
2904
 
3187
- // A held chunked column is a stream of one record serie per chunk.
3188
- Object.defineProperty(StreamChunkedSerie, 'fromChunked', {
3189
- configurable: true,
3190
- value(chunked) {
3191
- if (!(chunked instanceof NativeChunkedSerie)) {
3192
- throw new TypeError('StreamChunkedSerie.fromChunked takes a ChunkedSerie')
3193
- }
3194
- return nativeStreamChunkedSerie.fromChunked(chunked)
3195
- },
3196
- })
3197
-
3198
- function asSpanStream(value) {
3199
- if (value instanceof NativeStreamChunkedSerie) return value
3200
- if (value instanceof NativeChunkedSerie) return nativeStreamChunkedSerie.fromChunked(value)
3201
- if (value instanceof NativeSerie) return nativeStreamChunkedSerie.fromSerie(value)
3202
- if (value instanceof binding.BatchReader) return nativeStreamChunkedSerie.fromArrowReader(value)
3203
- throw new TypeError(
3204
- 'StreamChunkedSerie.fromSortedSpans spans must yield a StreamChunkedSerie, a ChunkedSerie, a Serie or a BatchReader',
3205
- )
2905
+ function asSpanSerie(value) {
2906
+ if (value instanceof NativeSerie) return value
2907
+ if (value instanceof NativeChunkedSerie) return nativeSerie.fromSource(value)
2908
+ if (value instanceof binding.BatchReader) return nativeSerie.fromArrowReader(value)
2909
+ throw new TypeError('Serie.fromSortedSpans spans must yield a Serie, a ChunkedSerie or a BatchReader')
3206
2910
  }
3207
2911
 
3208
2912
  // Non-overlapping spans sorted one span in memory at a time.
3209
- Object.defineProperty(StreamChunkedSerie, 'fromSortedSpans', {
2913
+ Object.defineProperty(Serie, 'fromSortedSpans', {
3210
2914
  configurable: true,
3211
2915
  value(spans, by) {
3212
2916
  if (spans == null || typeof spans[Symbol.iterator] !== 'function') {
3213
- throw new TypeError('StreamChunkedSerie.fromSortedSpans spans must be an iterable')
2917
+ throw new TypeError('Serie.fromSortedSpans spans must be an iterable')
3214
2918
  }
3215
2919
  const orderings = orderingKeys(by)
3216
2920
  const failed = {}
@@ -3220,16 +2924,16 @@ Object.defineProperty(StreamChunkedSerie, 'fromSortedSpans', {
3220
2924
  try {
3221
2925
  if (iterator === undefined) iterator = spans[Symbol.iterator]()
3222
2926
  const step = iterator.next()
3223
- return step.done ? null : asSpanStream(step.value)
2927
+ return step.done ? null : asSpanSerie(step.value)
3224
2928
  } catch (error) {
3225
2929
  failed.error = error
3226
2930
  throw error
3227
2931
  }
3228
2932
  }
3229
2933
  try {
3230
- const stream = nativeStreamChunkedSerie.fromSortedSpans(pull, orderings)
3231
- stream[FAILED] = failed
3232
- return stream
2934
+ const serie = nativeSerie.fromSortedSpans(pull, orderings)
2935
+ serie[FAILED] = failed
2936
+ return describedSerie(serie)
3233
2937
  } catch (error) {
3234
2938
  if (failed.error !== undefined) {
3235
2939
  const { error: original } = failed
@@ -3244,17 +2948,17 @@ Object.defineProperty(StreamChunkedSerie, 'fromSortedSpans', {
3244
2948
  // The cast compiled once. A source is a Field, or the schema an Apache Arrow
3245
2949
  // JS schema, table or batch carries, imported as the record `row` its
3246
2950
  // batches are read as; anything else is a FieldLike.
3247
- const NativeArrowCastPlan = binding.ArrowCastPlan
3248
- const nativeArrowCastPlan = Object.freeze({
3249
- compile: NativeArrowCastPlan._compileNative.bind(NativeArrowCastPlan),
3250
- apply: NativeArrowCastPlan.prototype._applyNative,
3251
- applyChunked: NativeArrowCastPlan.prototype._applyChunkedNative,
2951
+ const NativeCastPlan = binding.CastPlan
2952
+ const nativeCastPlan = Object.freeze({
2953
+ compile: NativeCastPlan._compileNative.bind(NativeCastPlan),
2954
+ apply: NativeCastPlan.prototype._applyNative,
2955
+ applyChunked: NativeCastPlan.prototype._applyChunkedNative,
3252
2956
  })
3253
- delete NativeArrowCastPlan.prototype._applyNative
3254
- delete NativeArrowCastPlan.prototype._applyChunkedNative
3255
- const ArrowCastPlan = publicNativeClass(
3256
- NativeArrowCastPlan,
3257
- 'ArrowCastPlan',
2957
+ delete NativeCastPlan.prototype._applyNative
2958
+ delete NativeCastPlan.prototype._applyChunkedNative
2959
+ const CastPlan = publicNativeClass(
2960
+ NativeCastPlan,
2961
+ 'CastPlan',
3258
2962
  new Set(['_compileNative']),
3259
2963
  )
3260
2964
 
@@ -3270,10 +2974,10 @@ function castPlanSource(source) {
3270
2974
  return Field.from(source)
3271
2975
  }
3272
2976
 
3273
- Object.defineProperty(ArrowCastPlan, 'compile', {
2977
+ Object.defineProperty(CastPlan, 'compile', {
3274
2978
  configurable: true,
3275
2979
  value(source, target, options) {
3276
- return nativeArrowCastPlan.compile(
2980
+ return nativeCastPlan.compile(
3277
2981
  castPlanSource(source),
3278
2982
  target instanceof NativeField ? target : Field.from(target),
3279
2983
  ...castOptionArgs(options),
@@ -3281,16 +2985,16 @@ Object.defineProperty(ArrowCastPlan, 'compile', {
3281
2985
  },
3282
2986
  })
3283
2987
  // A serie is cast as it is; a chunked serie chunk by chunk, kept apart.
3284
- Object.defineProperty(ArrowCastPlan.prototype, 'apply', {
2988
+ Object.defineProperty(CastPlan.prototype, 'apply', {
3285
2989
  configurable: true,
3286
2990
  value(serie) {
3287
2991
  if (serie instanceof NativeChunkedSerie) {
3288
- return Reflect.apply(nativeArrowCastPlan.applyChunked, this, [serie])
2992
+ return Reflect.apply(nativeCastPlan.applyChunked, this, [serie])
3289
2993
  }
3290
2994
  if (!(serie instanceof NativeSerie)) {
3291
- throw new TypeError('ArrowCastPlan.apply takes a Serie or a ChunkedSerie')
2995
+ throw new TypeError('CastPlan.apply takes a Serie or a ChunkedSerie')
3292
2996
  }
3293
- return describedSerie(Reflect.apply(nativeArrowCastPlan.apply, this, [serie]))
2997
+ return describedSerie(Reflect.apply(nativeCastPlan.apply, this, [serie]))
3294
2998
  },
3295
2999
  })
3296
3000
 
@@ -3300,18 +3004,8 @@ Object.defineProperty(ArrowCastPlan.prototype, 'apply', {
3300
3004
  // default, and refuses a key it does not know; the bounds are u64s, so they
3301
3005
  // and `NEVER` and the default cross as bigints, read off the core once.
3302
3006
  const NativeSpillOptions = binding.SpillOptions
3303
- const SPILL_OPTION_NAMES = new Set(['byteSize', 'folder', 'budget'])
3304
3007
  const SpillOptions = publicNativeClass(NativeSpillOptions, 'SpillOptions', new Set(), (args) => {
3305
- const options = args[0]
3306
- if (options === undefined || options === null) return args
3307
- if (typeof options !== 'object' || Array.isArray(options)) {
3308
- throw new TypeError('SpillOptions options must be an object of byteSize, folder and budget')
3309
- }
3310
- for (const key of Object.keys(options)) {
3311
- if (!SPILL_OPTION_NAMES.has(key)) {
3312
- throw new TypeError(`SpillOptions options take byteSize, folder and budget, got ${JSON.stringify(key)}`)
3313
- }
3314
- }
3008
+ closedOptions(args[0], ['byteSize', 'folder', 'budget'], 'SpillOptions')
3315
3009
  return args
3316
3010
  })
3317
3011
  Object.defineProperty(SpillOptions, 'NEVER', {
@@ -3323,18 +3017,8 @@ delete binding._spillNeverNative
3323
3017
  delete binding._defaultSpillByteSizeNative
3324
3018
 
3325
3019
  const NativeParallelism = binding.Parallelism
3326
- const PARALLELISM_OPTION_NAMES = new Set(['threads'])
3327
3020
  const Parallelism = publicNativeClass(NativeParallelism, 'Parallelism', new Set(), (args) => {
3328
- const options = args[0]
3329
- if (options === undefined || options === null) return args
3330
- if (typeof options !== 'object' || Array.isArray(options)) {
3331
- throw new TypeError('Parallelism options must be an object of threads')
3332
- }
3333
- for (const key of Object.keys(options)) {
3334
- if (!PARALLELISM_OPTION_NAMES.has(key)) {
3335
- throw new TypeError(`Parallelism options take threads, got ${JSON.stringify(key)}`)
3336
- }
3337
- }
3021
+ closedOptions(args[0], ['threads'], 'Parallelism')
3338
3022
  return args
3339
3023
  })
3340
3024
 
@@ -3342,12 +3026,11 @@ binding.SpillOptions = SpillOptions
3342
3026
  binding.Parallelism = Parallelism
3343
3027
  binding.Serie = Serie
3344
3028
  binding.WindowSerie = WindowSerie
3345
- binding.StreamChunkedSerie = StreamChunkedSerie
3346
3029
  binding.KeySerie = KeySerie
3347
3030
  binding.KeySeries = KeySeries
3348
3031
  binding.StreamKeySerie = StreamKeySerie
3349
3032
  binding.ChunkedSerie = ChunkedSerie
3350
- binding.ArrowCastPlan = ArrowCastPlan
3033
+ binding.CastPlan = CastPlan
3351
3034
  binding.SerieSerie = SerieSerie
3352
3035
  binding.LargeSerieSerie = LargeSerieSerie
3353
3036
  binding.SerieViewSerie = SerieViewSerie
@@ -4470,35 +4153,23 @@ Object.defineProperty(Field, 'fromArrow', {
4470
4153
  },
4471
4154
  })
4472
4155
 
4473
- const fieldUpdate = Field.prototype.update
4474
- Field.prototype.update = function update(values) {
4475
- return fieldUpdate.call(this, normalizeMetadata(values))
4476
- }
4477
-
4478
- Object.defineProperty(Field.prototype, Symbol.iterator, {
4479
- configurable: true,
4480
- value: function* metadataEntries() {
4481
- for (const { key, value } of this.entries()) yield [key, value]
4482
- },
4483
- })
4484
-
4485
- // One protocol's properties are a Map keyed by bare names. The native view
4486
- // holds the Field rather than a copy of its metadata, so this loader only adds
4487
- // the two language protocols Node-API cannot spell: the built-in collection
4156
+ // A field's metadata, and one protocol's properties - a Map keyed by bare
4157
+ // names, over the Field the native view holds rather than a copy - take the
4158
+ // two language protocols Node-API cannot spell: the built-in collection
4488
4159
  // inputs `update` accepts, and iteration.
4489
- const { ProtocolField } = binding
4490
- const protocolUpdate = ProtocolField.prototype.update
4491
- ProtocolField.prototype.update = function update(values) {
4492
- return protocolUpdate.call(this, normalizeMetadata(values))
4160
+ for (const Owner of [Field, binding.ProtocolField]) {
4161
+ const nativeUpdate = Owner.prototype.update
4162
+ Owner.prototype.update = function update(values) {
4163
+ return nativeUpdate.call(this, normalizeMetadata(values))
4164
+ }
4165
+ Object.defineProperty(Owner.prototype, Symbol.iterator, {
4166
+ configurable: true,
4167
+ value: function* metadataEntries() {
4168
+ for (const { key, value } of this.entries()) yield [key, value]
4169
+ },
4170
+ })
4493
4171
  }
4494
4172
 
4495
- Object.defineProperty(ProtocolField.prototype, Symbol.iterator, {
4496
- configurable: true,
4497
- value: function* propertyEntries() {
4498
- for (const { key, value } of this.entries()) yield [key, value]
4499
- },
4500
- })
4501
-
4502
4173
  for (const PathValue of [Uri, Url, Urn, Arn]) {
4503
4174
  Object.defineProperty(PathValue.prototype, Symbol.iterator, {
4504
4175
  configurable: true,
@@ -4734,54 +4405,10 @@ Object.defineProperty(Timezone, 'UTC', {
4734
4405
  writable: false,
4735
4406
  })
4736
4407
 
4737
- function isPlainObject(value) {
4738
- if (value === null || typeof value !== 'object' || Array.isArray(value)) {
4739
- return false
4740
- }
4741
- const prototype = Object.getPrototypeOf(value)
4742
- return prototype === Object.prototype || prototype === null
4743
- }
4744
-
4745
- function partitionEntry(column, value) {
4746
- if (typeof column !== 'string' || typeof value !== 'string') {
4747
- throw new TypeError(
4748
- 'partition filters must name a column and a value as strings',
4749
- )
4750
- }
4751
- return { column, value }
4752
- }
4753
-
4754
- // The native call takes one array of entries; a Map, an entry array, and a
4755
- // plain object are the three ways JavaScript spells the same set of pairs.
4408
+ // The native call takes one array of `{ column, value }` entries.
4756
4409
  function partitionFilters(filters) {
4757
4410
  if (filters === undefined || filters === null) return []
4758
- if (filters instanceof Map) {
4759
- return Array.from(filters, ([column, value]) =>
4760
- partitionEntry(column, value),
4761
- )
4762
- }
4763
- if (Array.isArray(filters)) {
4764
- return filters.map((entry) => {
4765
- if (Array.isArray(entry)) {
4766
- if (entry.length !== 2) {
4767
- throw new TypeError('partition filter tuples must contain two items')
4768
- }
4769
- return partitionEntry(entry[0], entry[1])
4770
- }
4771
- if (entry === null || typeof entry !== 'object') {
4772
- throw new TypeError('partition filters must be objects or tuples')
4773
- }
4774
- return partitionEntry(entry.column, entry.value)
4775
- })
4776
- }
4777
- if (isPlainObject(filters)) {
4778
- return Object.entries(filters).map(([column, value]) =>
4779
- partitionEntry(column, value),
4780
- )
4781
- }
4782
- throw new TypeError(
4783
- 'partition filters must be an object, Map, or entry array',
4784
- )
4411
+ return pairEntries(filters, 'column', 'value', 'partition filter')
4785
4412
  }
4786
4413
 
4787
4414
  const childrenWhere = IOBase.prototype.childrenWhere
@@ -4925,7 +4552,7 @@ binding.TextLine = publicNativeClass(binding.TextLine, 'TextLine', new Set(), (a
4925
4552
  const { BatchReader, RecordOptions, TextOptions } = binding
4926
4553
  // Runtime-only state used by the async record bridge. It is intentionally not
4927
4554
  // a fourth public write abstraction.
4928
- delete binding.ArrowWriteSession
4555
+ delete binding.WriteSession
4929
4556
 
4930
4557
  // The record surface is one shape in both directions: a read returns a
4931
4558
  // `BatchReader` and a write consumes one. This installs the Apache Arrow JS
@@ -4940,8 +4567,6 @@ const { intoField } = installRecords({
4940
4567
  IOResult: binding.IOResult,
4941
4568
  RecordOptions,
4942
4569
  Serie,
4943
- StreamChunkedSerie,
4944
- StreamSerie: binding.StreamSerie,
4945
4570
  KeySerie,
4946
4571
  KeySeries,
4947
4572
  StreamKeySerie,
@@ -4963,16 +4588,6 @@ const NativeBoundSelector = binding.BoundSelector
4963
4588
  const NativeBound = binding.Bound
4964
4589
  const NativePlan = binding.Plan
4965
4590
  const NativeExpression = binding.Expression
4966
- const NativeStreamSerie = binding.StreamSerie
4967
-
4968
- function takePrivate(owner, name) {
4969
- const method = owner.prototype[name]
4970
- if (typeof method !== 'function') {
4971
- throw new TypeError(`native binding is missing ${owner.name}.${name}`)
4972
- }
4973
- delete owner.prototype[name]
4974
- return method
4975
- }
4976
4591
 
4977
4592
  function suppliedParameters(parameters) {
4978
4593
  return parameters === undefined || parameters === null
@@ -5004,6 +4619,93 @@ for (const Clause of [NativeTerm, NativeFilter, NativeSelector]) {
5004
4619
  })
5005
4620
  }
5006
4621
 
4622
+ // An engine's session: `connect` opens one, a cursor runs statements on it.
4623
+ // The native doors take one shape each - the URL, the warehouse, the dialect
4624
+ // and the session properties apart; one record `Scalar` of parameters; one
4625
+ // native `BatchReader` of rows - and answer promises from the libuv pool. The
4626
+ // loader spells what JavaScript has of its own: `execute` settling with the
4627
+ // cursor, an `AbortSignal` mapped to the session's cancel, `for await` over
4628
+ // the rows as Apache Arrow JS batches, and any Arrow input into `writeSerie`.
4629
+ {
4630
+ const nativeConnect = binding._connectNative
4631
+ delete binding._connectNative
4632
+ const NativeConnection = binding.Connection
4633
+ const NativeCursor = binding.Cursor
4634
+ const nativeWriteSerie = takePrivate(NativeConnection, '_writeSerieNative')
4635
+ const nativeExecute = takePrivate(NativeCursor, '_executeNative')
4636
+ const nativeCancel = takePrivate(NativeCursor, '_cancelNative')
4637
+ const nativeFetchArrow = takePrivate(NativeCursor, '_fetchArrowNative')
4638
+
4639
+ // No URL is the Yggio engine, over `warehouse` or the process's own; the
4640
+ // properties are the remote engine's, or the Yggio session's.
4641
+ binding.connect = async function connect(url, options) {
4642
+ if (options !== undefined && options !== null && !isPlainObject(options)) {
4643
+ throw new TypeError('connect options must be a plain object of warehouse, dialect and properties')
4644
+ }
4645
+ const { warehouse, dialect, ...properties } = options ?? {}
4646
+ const location = url instanceof URL || url instanceof Url ? url.toString() : url
4647
+ return nativeConnect(location, warehouse, dialect, properties)
4648
+ }
4649
+
4650
+ Object.defineProperties(NativeConnection.prototype, {
4651
+ writeSerie: {
4652
+ configurable: true,
4653
+ async value(table, data, mode = 'append') {
4654
+ return nativeWriteSerie.call(this, table, BatchReader.from(data), mode)
4655
+ },
4656
+ },
4657
+ })
4658
+
4659
+ Object.defineProperties(NativeCursor.prototype, {
4660
+ // Settles with this cursor once the statement ran; an aborted `signal`
4661
+ // rejects with its reason and asks the session to cancel what runs. A
4662
+ // session that cannot cancel - the Yggio engine, whose statement runs as
4663
+ // its rows are pulled - has nothing running to stop, so its refusal is
4664
+ // not the caller's error: the abort is.
4665
+ execute: {
4666
+ configurable: true,
4667
+ async value(operation, parameters, options) {
4668
+ const { signal } = closedOptions(options, ['signal'], 'Cursor.execute') ?? {}
4669
+ signal?.throwIfAborted()
4670
+ const running = nativeExecute.call(this, operation, suppliedParameters(parameters))
4671
+ if (signal === undefined) {
4672
+ await running
4673
+ return this
4674
+ }
4675
+ // Settled after an abort, the run's own failure is no one's to read.
4676
+ running.catch(() => {})
4677
+ let onAbort
4678
+ const aborted = new Promise((_, reject) => {
4679
+ onAbort = () => {
4680
+ nativeCancel.call(this).catch(() => {})
4681
+ reject(signal.reason)
4682
+ }
4683
+ signal.addEventListener('abort', onAbort, { once: true })
4684
+ })
4685
+ try {
4686
+ await Promise.race([running, aborted])
4687
+ } finally {
4688
+ signal.removeEventListener('abort', onAbort)
4689
+ }
4690
+ return this
4691
+ },
4692
+ },
4693
+ // The rows drained off the event loop, as one Apache Arrow JS table.
4694
+ fetchArrowTable: {
4695
+ configurable: true,
4696
+ async value() {
4697
+ return arrow().tableFromIPC(await nativeFetchArrow.call(this))
4698
+ },
4699
+ },
4700
+ [Symbol.asyncIterator]: {
4701
+ configurable: true,
4702
+ value: async function* batches() {
4703
+ yield* this.reader()
4704
+ },
4705
+ },
4706
+ })
4707
+ }
4708
+
5007
4709
  // One Arrow surface per applier: `applyArrowReader` keeps a native reader
5008
4710
  // lazy, `applyArrowBatch` and `applyArrowTable` keep the Apache Arrow JS
5009
4711
  // holder they were given, and `applyArrow` infers which of the three it has.
@@ -5063,7 +4765,7 @@ function defineArrowAppliers(Owner, label, { records = true } = {}) {
5063
4765
  value(rows, schema) {
5064
4766
  const held = rows instanceof Scalar ? rows : Scalar.from(Array.from(rows))
5065
4767
  const root = schema === undefined || schema === null ? undefined : intoField(schema)
5066
- return nativeRecords.call(this, held, root)
4768
+ return describedSerie(nativeRecords.call(this, held, root))
5067
4769
  },
5068
4770
  }
5069
4771
  }
@@ -5146,35 +4848,6 @@ defineArrowAppliers(NativeExpression, 'Expression')
5146
4848
  })
5147
4849
  }
5148
4850
 
5149
- // StreamSerie stream one native row at a time and iterate as JavaScript does.
5150
- {
5151
- const nativeNext = takePrivate(NativeStreamSerie, '_nextNative')
5152
- const nativeCollect = NativeStreamSerie.prototype.collect
5153
- Object.defineProperties(NativeStreamSerie.prototype, {
5154
- next: {
5155
- configurable: true,
5156
- value() {
5157
- const row = nativeNext.call(this)
5158
- return row === null || row === undefined
5159
- ? { done: true, value: undefined }
5160
- : { done: false, value: row }
5161
- },
5162
- },
5163
- [Symbol.iterator]: {
5164
- configurable: true,
5165
- value() {
5166
- return this
5167
- },
5168
- },
5169
- collect: {
5170
- configurable: true,
5171
- value() {
5172
- return nativeCollect.call(this)
5173
- },
5174
- },
5175
- })
5176
- }
5177
-
5178
4851
  // Parquet's DTOs cross through the shared Scalar transport, never through a
5179
4852
  // second JavaScript metadata model.
5180
4853
  const nativeIOReadParquetStatistics =
@@ -7078,22 +6751,7 @@ function nativeKeyBy(value, label) {
7078
6751
  if (value instanceof binding.FieldPath) return [value]
7079
6752
  if (Array.isArray(value) && value.every(path => path instanceof binding.FieldPath)) return value
7080
6753
  if (value instanceof NativeTerm || Array.isArray(value)) return windowKey(value, label)
7081
- if ([NativeSerie, NativeChunkedSerie, NativeStreamChunkedSerie, NativeStreamSerie, KeySerie, KeySeries, StreamKeySerie, NativeWindowSerie].some(Owner => value instanceof Owner)) return value
6754
+ if ([NativeSerie, NativeChunkedSerie, KeySerie, KeySeries, StreamKeySerie, NativeWindowSerie].some(Owner => value instanceof Owner)) return value
7082
6755
  if (value && typeof value === 'object' && (value instanceof arrow().Vector || value instanceof arrow().Table || value instanceof arrow().RecordBatch)) return Serie.from(value)
7083
6756
  throw new TypeError(label + ' takes selector text, a Selector, FieldPath values, or typed external keys; construct value keys with Serie.from')
7084
6757
  }
7085
- for (const Owner of [NativeStreamSerie]) {
7086
- const window = Owner.prototype._windowByNative
7087
- const partition = Owner.prototype._partitionByNative
7088
- delete Owner.prototype._windowByNative
7089
- delete Owner.prototype._partitionByNative
7090
- Object.defineProperties(Owner.prototype, {
7091
- windowBy: { configurable: true, value(by, sorted) { return window.call(this, nativeKeyBy(by, 'StreamSerie.windowBy'), windowSorted(sorted, 'StreamSerie.windowBy')) } },
7092
- partitionBy: { configurable: true, value(by, options) { return partition.call(this, nativeKeyBy(by, 'StreamSerie.partitionBy'), partitionOptionArgs(options, 'StreamSerie.partitionBy')) } },
7093
- })
7094
- }
7095
- Object.defineProperties(StreamChunkedSerie.prototype, {
7096
- schema: { configurable: true, get() { const root = this.field.intoArrow(); return new (arrow().Schema)(root.type.children, root.metadata) } },
7097
- readNextBatch: { configurable: true, value() { const chunk = nextStreamChunk(this); if (chunk == null) return null; return describedSerie(chunk).intoArrowBatch() } },
7098
- readAll: { configurable: true, value() { return this.intoArrowReader().intoTable() } },
7099
- })