yggio 0.0.14 → 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/README.md +2 -3
- package/benchmarks/fix.js +24 -28
- package/benchmarks/types.js +0 -1
- package/binding.d.ts +225 -198
- package/binding.js +522 -812
- package/fields.js +43 -47
- package/index.d.ts +1541 -1051
- package/index.js +24 -18
- package/package.json +5 -5
- package/properties.js +13 -1
- package/records.js +83 -32
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
|
|
194
|
-
const nativeScalarIter = NativeScalar
|
|
195
|
-
const nativeScalarGet = NativeScalar
|
|
196
|
-
const nativeScalarSet = NativeScalar
|
|
197
|
-
const nativeScalarRemove = NativeScalar
|
|
198
|
-
const nativeScalarArithmetic = Object.freeze(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
|
222
|
-
const nativeAvroIntoSingleObject =
|
|
223
|
-
NativeAvroSchema
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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 =
|
|
1291
|
+
const CAST_OPTION_NAMES = ['safe', 'representation']
|
|
1305
1292
|
function castOptionArgs(options) {
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
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 (!
|
|
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
|
|
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 =
|
|
1321
|
+
const SORT_OPTION_NAMES = ['descending', 'nullsFirst']
|
|
1325
1322
|
function sortOptionArgs(options, label) {
|
|
1326
|
-
|
|
1327
|
-
if (
|
|
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
|
-
|
|
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 =
|
|
1602
|
+
const JOIN_OPTION_NAMES = ['coalesce', 'suffix', 'build', 'prune', 'spill', 'pushdownKeys']
|
|
1670
1603
|
function joinOptionArgs(options, label) {
|
|
1671
|
-
|
|
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 =
|
|
1610
|
+
const PARTITION_OPTION_NAMES = ['maxOpen', 'threads', 'clustered']
|
|
1691
1611
|
function partitionOptionArgs(options, label) {
|
|
1692
|
-
|
|
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,
|
|
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
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
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
|
-
|
|
2563
|
-
|
|
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(
|
|
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
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
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
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
value(
|
|
3191
|
-
|
|
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(
|
|
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('
|
|
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 :
|
|
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
|
|
3231
|
-
|
|
3232
|
-
return
|
|
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
|
|
3248
|
-
const
|
|
3249
|
-
compile:
|
|
3250
|
-
apply:
|
|
3251
|
-
applyChunked:
|
|
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
|
|
3254
|
-
delete
|
|
3255
|
-
const
|
|
3256
|
-
|
|
3257
|
-
'
|
|
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(
|
|
2977
|
+
Object.defineProperty(CastPlan, 'compile', {
|
|
3274
2978
|
configurable: true,
|
|
3275
2979
|
value(source, target, options) {
|
|
3276
|
-
return
|
|
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(
|
|
2988
|
+
Object.defineProperty(CastPlan.prototype, 'apply', {
|
|
3285
2989
|
configurable: true,
|
|
3286
2990
|
value(serie) {
|
|
3287
2991
|
if (serie instanceof NativeChunkedSerie) {
|
|
3288
|
-
return Reflect.apply(
|
|
2992
|
+
return Reflect.apply(nativeCastPlan.applyChunked, this, [serie])
|
|
3289
2993
|
}
|
|
3290
2994
|
if (!(serie instanceof NativeSerie)) {
|
|
3291
|
-
throw new TypeError('
|
|
2995
|
+
throw new TypeError('CastPlan.apply takes a Serie or a ChunkedSerie')
|
|
3292
2996
|
}
|
|
3293
|
-
return describedSerie(Reflect.apply(
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
4474
|
-
Field
|
|
4475
|
-
|
|
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
|
|
4490
|
-
const
|
|
4491
|
-
|
|
4492
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
@@ -4992,6 +4607,105 @@ for (const Clause of [NativeTerm, NativeFilter, NativeSelector]) {
|
|
|
4992
4607
|
})
|
|
4993
4608
|
}
|
|
4994
4609
|
|
|
4610
|
+
// A plan binds its own parameters, in every section and every plan it holds
|
|
4611
|
+
// (`Plan::with_parameters`): no schema, the record alone.
|
|
4612
|
+
{
|
|
4613
|
+
const nativeBind = takePrivate(NativePlan, '_bindNative')
|
|
4614
|
+
Object.defineProperty(NativePlan.prototype, 'bind', {
|
|
4615
|
+
configurable: true,
|
|
4616
|
+
value(parameters) {
|
|
4617
|
+
return nativeBind.call(this, suppliedParameters(parameters))
|
|
4618
|
+
},
|
|
4619
|
+
})
|
|
4620
|
+
}
|
|
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
|
+
|
|
4995
4709
|
// One Arrow surface per applier: `applyArrowReader` keeps a native reader
|
|
4996
4710
|
// lazy, `applyArrowBatch` and `applyArrowTable` keep the Apache Arrow JS
|
|
4997
4711
|
// holder they were given, and `applyArrow` infers which of the three it has.
|
|
@@ -5051,7 +4765,7 @@ function defineArrowAppliers(Owner, label, { records = true } = {}) {
|
|
|
5051
4765
|
value(rows, schema) {
|
|
5052
4766
|
const held = rows instanceof Scalar ? rows : Scalar.from(Array.from(rows))
|
|
5053
4767
|
const root = schema === undefined || schema === null ? undefined : intoField(schema)
|
|
5054
|
-
return nativeRecords.call(this, held, root)
|
|
4768
|
+
return describedSerie(nativeRecords.call(this, held, root))
|
|
5055
4769
|
},
|
|
5056
4770
|
}
|
|
5057
4771
|
}
|
|
@@ -5134,35 +4848,6 @@ defineArrowAppliers(NativeExpression, 'Expression')
|
|
|
5134
4848
|
})
|
|
5135
4849
|
}
|
|
5136
4850
|
|
|
5137
|
-
// StreamSerie stream one native row at a time and iterate as JavaScript does.
|
|
5138
|
-
{
|
|
5139
|
-
const nativeNext = takePrivate(NativeStreamSerie, '_nextNative')
|
|
5140
|
-
const nativeCollect = NativeStreamSerie.prototype.collect
|
|
5141
|
-
Object.defineProperties(NativeStreamSerie.prototype, {
|
|
5142
|
-
next: {
|
|
5143
|
-
configurable: true,
|
|
5144
|
-
value() {
|
|
5145
|
-
const row = nativeNext.call(this)
|
|
5146
|
-
return row === null || row === undefined
|
|
5147
|
-
? { done: true, value: undefined }
|
|
5148
|
-
: { done: false, value: row }
|
|
5149
|
-
},
|
|
5150
|
-
},
|
|
5151
|
-
[Symbol.iterator]: {
|
|
5152
|
-
configurable: true,
|
|
5153
|
-
value() {
|
|
5154
|
-
return this
|
|
5155
|
-
},
|
|
5156
|
-
},
|
|
5157
|
-
collect: {
|
|
5158
|
-
configurable: true,
|
|
5159
|
-
value() {
|
|
5160
|
-
return nativeCollect.call(this)
|
|
5161
|
-
},
|
|
5162
|
-
},
|
|
5163
|
-
})
|
|
5164
|
-
}
|
|
5165
|
-
|
|
5166
4851
|
// Parquet's DTOs cross through the shared Scalar transport, never through a
|
|
5167
4852
|
// second JavaScript metadata model.
|
|
5168
4853
|
const nativeIOReadParquetStatistics =
|
|
@@ -5639,15 +5324,16 @@ for (const name of [
|
|
|
5639
5324
|
// dictionary, the message it types and the process default are one name
|
|
5640
5325
|
// rather than four top-level classes.
|
|
5641
5326
|
//
|
|
5642
|
-
// A message value is whatever `Scalar.from` reads, and
|
|
5643
|
-
// in this loader, so the public
|
|
5644
|
-
// the
|
|
5645
|
-
// a factory, never by `new`: the
|
|
5327
|
+
// A message value is whatever `Scalar.from` reads, and a line whatever
|
|
5328
|
+
// `toBytes` reads; those conversions live in this loader, so the public
|
|
5329
|
+
// factories are the one widening gate and hand the native class the value it
|
|
5330
|
+
// already understands. A message is built by a factory, never by `new`: the
|
|
5331
|
+
// core reads a line, a record or a row into one.
|
|
5646
5332
|
const NativeMarketMessage = binding.MarketMessage
|
|
5647
5333
|
const asScalar = (value) => (value instanceof Scalar ? value : Scalar.from(value))
|
|
5648
5334
|
function MarketMessage() {
|
|
5649
5335
|
throw new TypeError(
|
|
5650
|
-
'MarketMessage has no constructor: build one with MarketMessage.fromFixRecord or MarketMessage.fromRow',
|
|
5336
|
+
'MarketMessage has no constructor: build one with MarketMessage.fromLine, MarketMessage.fromFixRecord or MarketMessage.fromRow',
|
|
5651
5337
|
)
|
|
5652
5338
|
}
|
|
5653
5339
|
MarketMessage.prototype = NativeMarketMessage.prototype
|
|
@@ -5658,11 +5344,29 @@ Object.defineProperty(MarketMessage.prototype, 'constructor', {
|
|
|
5658
5344
|
})
|
|
5659
5345
|
// A record, a row read back and a value written cross the one gate: whatever
|
|
5660
5346
|
// `Scalar.from` reads, and the core alone types it.
|
|
5661
|
-
MarketMessage.fromFixRecord = function fromFixRecord(field, value,
|
|
5662
|
-
return NativeMarketMessage.fromFixRecord(field, asScalar(value),
|
|
5347
|
+
MarketMessage.fromFixRecord = function fromFixRecord(field, value, options) {
|
|
5348
|
+
return NativeMarketMessage.fromFixRecord(field, asScalar(value), options)
|
|
5349
|
+
}
|
|
5350
|
+
MarketMessage.fromRow = function fromRow(schema, row, options) {
|
|
5351
|
+
return NativeMarketMessage.fromRow(schema, asScalar(row), options)
|
|
5352
|
+
}
|
|
5353
|
+
for (const name of ['fromLine', 'fromFixMessage', 'fromUllinkLine', 'fromFixmlMessage']) {
|
|
5354
|
+
const native = NativeMarketMessage[name]
|
|
5355
|
+
MarketMessage[name] = {
|
|
5356
|
+
[name](body, options) {
|
|
5357
|
+
return native.call(NativeMarketMessage, toBytes(body), options)
|
|
5358
|
+
},
|
|
5359
|
+
}[name]
|
|
5663
5360
|
}
|
|
5664
|
-
|
|
5665
|
-
|
|
5361
|
+
// A native factory builds through the class it is called on, so each is
|
|
5362
|
+
// called on the native class, never on this constructor that refuses `new`.
|
|
5363
|
+
for (const name of ['fromTextLine', 'fromPairs']) {
|
|
5364
|
+
const native = NativeMarketMessage[name]
|
|
5365
|
+
MarketMessage[name] = {
|
|
5366
|
+
[name](value, options) {
|
|
5367
|
+
return native.call(NativeMarketMessage, value, options)
|
|
5368
|
+
},
|
|
5369
|
+
}[name]
|
|
5666
5370
|
}
|
|
5667
5371
|
MarketMessage.field = NativeMarketMessage.field
|
|
5668
5372
|
const nativeMarketMessageSet = NativeMarketMessage.prototype.set
|
|
@@ -5671,30 +5375,42 @@ NativeMarketMessage.prototype.set = function set(key, value) {
|
|
|
5671
5375
|
}
|
|
5672
5376
|
|
|
5673
5377
|
// A line crosses as the `TextLine` a text read answered - there is nothing to
|
|
5674
|
-
// widen, because a line is a decoded row and not a value -
|
|
5675
|
-
//
|
|
5676
|
-
//
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
}
|
|
5685
|
-
const
|
|
5686
|
-
|
|
5687
|
-
|
|
5378
|
+
// widen, because a line is a decoded row and not a value - a batch source as
|
|
5379
|
+
// whatever `BatchReader.from` accepts: a reader, an Arrow JS table or batch,
|
|
5380
|
+
// IPC bytes - and a root as any `FieldLike`. That widening lives here, beside
|
|
5381
|
+
// the conversions it uses.
|
|
5382
|
+
const NativeMarketMessages = binding.MarketMessages
|
|
5383
|
+
const fieldOrAbsent = (field) => (field === undefined || field === null ? field : intoField(field))
|
|
5384
|
+
{
|
|
5385
|
+
const nativeFromArrowReader = NativeMarketMessages.prototype.fromArrowReader
|
|
5386
|
+
NativeMarketMessages.prototype.fromArrowReader = function fromArrowReader(source, field) {
|
|
5387
|
+
return nativeFromArrowReader.call(this, BatchReader.from(source), fieldOrAbsent(field))
|
|
5388
|
+
}
|
|
5389
|
+
const nativeFromTextArrowReader = NativeMarketMessages.prototype.fromTextArrowReader
|
|
5390
|
+
NativeMarketMessages.prototype.fromTextArrowReader = function fromTextArrowReader(source) {
|
|
5391
|
+
return nativeFromTextArrowReader.call(this, BatchReader.from(source))
|
|
5392
|
+
}
|
|
5393
|
+
for (const name of ['intoArrowReader', 'intoSerie']) {
|
|
5394
|
+
const native = NativeMarketMessages.prototype[name]
|
|
5395
|
+
NativeMarketMessages.prototype[name] = {
|
|
5396
|
+
[name](field) {
|
|
5397
|
+
return native.call(this, fieldOrAbsent(field))
|
|
5398
|
+
},
|
|
5399
|
+
}[name]
|
|
5400
|
+
}
|
|
5401
|
+
const nativeMessageSearch = binding.Underlyings.prototype.messageSearch
|
|
5402
|
+
binding.Underlyings.prototype.messageSearch = function messageSearch(text, field, options) {
|
|
5403
|
+
return nativeMessageSearch.call(this, text, intoField(field), options)
|
|
5404
|
+
}
|
|
5688
5405
|
}
|
|
5689
5406
|
|
|
5690
|
-
// A
|
|
5691
|
-
// protocol runs here, and the native
|
|
5692
|
-
//
|
|
5693
|
-
//
|
|
5694
|
-
//
|
|
5695
|
-
//
|
|
5696
|
-
//
|
|
5697
|
-
// travels through the native stage as that stage's own failure.
|
|
5407
|
+
// A source over an iterable pulls one item at a time: the iterable's own
|
|
5408
|
+
// protocol runs here, and the native stream asks for the next item only when
|
|
5409
|
+
// it is read that far, so nothing is collected on the way across. `read`
|
|
5410
|
+
// turns one item into the value the native source takes. What the iterable
|
|
5411
|
+
// or the reading throws ends the pull: it travels through the native stream
|
|
5412
|
+
// as the item after the last one - what a stage or a sink downstream reports
|
|
5413
|
+
// - and is kept in `failed`, as itself, for `next` to throw in its place.
|
|
5698
5414
|
const FAILED = Symbol('yggio.fix.failed')
|
|
5699
5415
|
function pullOf(iterable, read, what, failed) {
|
|
5700
5416
|
if (iterable == null || typeof iterable[Symbol.iterator] !== 'function') {
|
|
@@ -5702,14 +5418,13 @@ function pullOf(iterable, read, what, failed) {
|
|
|
5702
5418
|
}
|
|
5703
5419
|
const iterator = iterable[Symbol.iterator]()
|
|
5704
5420
|
return () => {
|
|
5705
|
-
if (failed
|
|
5421
|
+
if (failed.error !== undefined) return null
|
|
5706
5422
|
try {
|
|
5707
5423
|
const step = iterator.next()
|
|
5708
5424
|
return step.done ? null : read(step.value)
|
|
5709
5425
|
} catch (error) {
|
|
5710
|
-
if (failed === undefined) throw error
|
|
5711
5426
|
failed.error = error
|
|
5712
|
-
|
|
5427
|
+
throw error
|
|
5713
5428
|
}
|
|
5714
5429
|
}
|
|
5715
5430
|
}
|
|
@@ -5726,15 +5441,15 @@ function asLine(value) {
|
|
|
5726
5441
|
return value
|
|
5727
5442
|
}
|
|
5728
5443
|
{
|
|
5729
|
-
const
|
|
5730
|
-
[
|
|
5731
|
-
[
|
|
5732
|
-
[
|
|
5444
|
+
const sources = [
|
|
5445
|
+
['fromLines', '_fromLinesNative', toBytes, 'lines'],
|
|
5446
|
+
['fromTextLines', '_fromTextLinesNative', asLine, 'lines'],
|
|
5447
|
+
['fromItems', '_fromItemsNative', asMessage, 'messages'],
|
|
5733
5448
|
]
|
|
5734
|
-
for (const [
|
|
5735
|
-
const native =
|
|
5736
|
-
delete
|
|
5737
|
-
|
|
5449
|
+
for (const [name, hidden, read, what] of sources) {
|
|
5450
|
+
const native = NativeMarketMessages.prototype[hidden]
|
|
5451
|
+
delete NativeMarketMessages.prototype[hidden]
|
|
5452
|
+
NativeMarketMessages.prototype[name] = {
|
|
5738
5453
|
[name](iterable) {
|
|
5739
5454
|
const failed = {}
|
|
5740
5455
|
const stream = native.call(this, pullOf(iterable, read, what, failed))
|
|
@@ -5743,38 +5458,44 @@ function asLine(value) {
|
|
|
5743
5458
|
},
|
|
5744
5459
|
}[name]
|
|
5745
5460
|
}
|
|
5746
|
-
//
|
|
5747
|
-
//
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
delete binding.FixCodec.prototype._formatMessagesNative
|
|
5758
|
-
binding.FixCodec.prototype.formatMessages = function formatMessages(messages, field) {
|
|
5759
|
-
return nativeFormat.call(this, intoField(field), pullOf(messages, asMessage, 'messages'))
|
|
5461
|
+
// A stage reads the stream it takes, so the failure kept for that stream
|
|
5462
|
+
// is the one its own stream throws.
|
|
5463
|
+
for (const name of ['intoLifecycle', 'intoLineage']) {
|
|
5464
|
+
const native = NativeMarketMessages.prototype[name]
|
|
5465
|
+
NativeMarketMessages.prototype[name] = {
|
|
5466
|
+
[name]() {
|
|
5467
|
+
const stream = native.call(this)
|
|
5468
|
+
stream[FAILED] = this[FAILED]
|
|
5469
|
+
return stream
|
|
5470
|
+
},
|
|
5471
|
+
}[name]
|
|
5760
5472
|
}
|
|
5761
5473
|
}
|
|
5762
5474
|
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
const
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5475
|
+
// A stream over an iterable ends where the iterable failed: the native stream
|
|
5476
|
+
// throws a copy of the failure in place of its end, and the failure kept for
|
|
5477
|
+
// it is thrown instead, once, as itself.
|
|
5478
|
+
function keptFailure(stream) {
|
|
5479
|
+
const failed = stream[FAILED]
|
|
5480
|
+
if (failed === undefined || failed.error === undefined) return undefined
|
|
5481
|
+
const { error } = failed
|
|
5482
|
+
failed.error = undefined
|
|
5483
|
+
return error
|
|
5484
|
+
}
|
|
5485
|
+
const nativeMarketMessagesNext = NativeMarketMessages.prototype.next
|
|
5486
|
+
NativeMarketMessages.prototype.next = function next() {
|
|
5487
|
+
let value
|
|
5488
|
+
try {
|
|
5489
|
+
value = nativeMarketMessagesNext.call(this)
|
|
5490
|
+
} catch (error) {
|
|
5491
|
+
throw keptFailure(this) ?? error
|
|
5774
5492
|
}
|
|
5493
|
+
if (value !== null) return { value, done: false }
|
|
5494
|
+
const failed = keptFailure(this)
|
|
5495
|
+
if (failed !== undefined) throw failed
|
|
5775
5496
|
return { value: undefined, done: true }
|
|
5776
5497
|
}
|
|
5777
|
-
Object.defineProperty(
|
|
5498
|
+
Object.defineProperty(NativeMarketMessages.prototype, Symbol.iterator, {
|
|
5778
5499
|
configurable: true,
|
|
5779
5500
|
value: function messages() { return this },
|
|
5780
5501
|
})
|
|
@@ -5810,9 +5531,9 @@ const fix = Object.freeze({
|
|
|
5810
5531
|
ULBRIDGE_ROWHEADER: ulbridgeRowheader,
|
|
5811
5532
|
FixRegistry: binding.FixRegistry,
|
|
5812
5533
|
MarketMessage,
|
|
5813
|
-
|
|
5534
|
+
MarketMessagesOptions: binding.MarketMessagesOptions,
|
|
5535
|
+
MarketMessages: NativeMarketMessages,
|
|
5814
5536
|
MsgType: binding.MsgType,
|
|
5815
|
-
FixMessages: binding.FixMessages,
|
|
5816
5537
|
Underlyings: binding.Underlyings,
|
|
5817
5538
|
crateFields: binding.fixCrateFields,
|
|
5818
5539
|
underlyingField: binding.fixUnderlyingField,
|
|
@@ -5822,6 +5543,8 @@ const fix = Object.freeze({
|
|
|
5822
5543
|
fxRateField: binding.fixFxRateField,
|
|
5823
5544
|
pluginField: binding.fixPluginField,
|
|
5824
5545
|
pluginSide: binding.fixPluginSide,
|
|
5546
|
+
reports: binding.fixReports,
|
|
5547
|
+
rules: binding.fixRules,
|
|
5825
5548
|
})
|
|
5826
5549
|
|
|
5827
5550
|
// The FIX values are reached through the namespace and nowhere else, so a
|
|
@@ -5829,17 +5552,17 @@ const fix = Object.freeze({
|
|
|
5829
5552
|
for (const name of [
|
|
5830
5553
|
'FixFieldIterator',
|
|
5831
5554
|
'MarketMessage',
|
|
5832
|
-
'
|
|
5555
|
+
'MarketMessagesOptions',
|
|
5556
|
+
'MarketMessages',
|
|
5833
5557
|
'FixRegistry',
|
|
5834
5558
|
'MsgType',
|
|
5835
|
-
'FixMessages',
|
|
5836
5559
|
'Underlyings',
|
|
5837
5560
|
'JsFixFieldIterator',
|
|
5838
5561
|
'JsMarketMessage',
|
|
5839
|
-
'
|
|
5562
|
+
'JsMarketMessagesOptions',
|
|
5563
|
+
'JsMarketMessages',
|
|
5840
5564
|
'JsFixRegistry',
|
|
5841
5565
|
'JsMsgType',
|
|
5842
|
-
'JsFixMessages',
|
|
5843
5566
|
'JsUnderlyings',
|
|
5844
5567
|
'fixCrateFields',
|
|
5845
5568
|
'fixUnderlyingField',
|
|
@@ -5849,6 +5572,8 @@ for (const name of [
|
|
|
5849
5572
|
'fixFxRateField',
|
|
5850
5573
|
'fixPluginField',
|
|
5851
5574
|
'fixPluginSide',
|
|
5575
|
+
'fixReports',
|
|
5576
|
+
'fixRules',
|
|
5852
5577
|
]) {
|
|
5853
5578
|
delete binding[name]
|
|
5854
5579
|
}
|
|
@@ -7026,22 +6751,7 @@ function nativeKeyBy(value, label) {
|
|
|
7026
6751
|
if (value instanceof binding.FieldPath) return [value]
|
|
7027
6752
|
if (Array.isArray(value) && value.every(path => path instanceof binding.FieldPath)) return value
|
|
7028
6753
|
if (value instanceof NativeTerm || Array.isArray(value)) return windowKey(value, label)
|
|
7029
|
-
if ([NativeSerie, NativeChunkedSerie,
|
|
6754
|
+
if ([NativeSerie, NativeChunkedSerie, KeySerie, KeySeries, StreamKeySerie, NativeWindowSerie].some(Owner => value instanceof Owner)) return value
|
|
7030
6755
|
if (value && typeof value === 'object' && (value instanceof arrow().Vector || value instanceof arrow().Table || value instanceof arrow().RecordBatch)) return Serie.from(value)
|
|
7031
6756
|
throw new TypeError(label + ' takes selector text, a Selector, FieldPath values, or typed external keys; construct value keys with Serie.from')
|
|
7032
6757
|
}
|
|
7033
|
-
for (const Owner of [NativeStreamSerie]) {
|
|
7034
|
-
const window = Owner.prototype._windowByNative
|
|
7035
|
-
const partition = Owner.prototype._partitionByNative
|
|
7036
|
-
delete Owner.prototype._windowByNative
|
|
7037
|
-
delete Owner.prototype._partitionByNative
|
|
7038
|
-
Object.defineProperties(Owner.prototype, {
|
|
7039
|
-
windowBy: { configurable: true, value(by, sorted) { return window.call(this, nativeKeyBy(by, 'StreamSerie.windowBy'), windowSorted(sorted, 'StreamSerie.windowBy')) } },
|
|
7040
|
-
partitionBy: { configurable: true, value(by, options) { return partition.call(this, nativeKeyBy(by, 'StreamSerie.partitionBy'), partitionOptionArgs(options, 'StreamSerie.partitionBy')) } },
|
|
7041
|
-
})
|
|
7042
|
-
}
|
|
7043
|
-
Object.defineProperties(StreamChunkedSerie.prototype, {
|
|
7044
|
-
schema: { configurable: true, get() { const root = this.field.intoArrow(); return new (arrow().Schema)(root.type.children, root.metadata) } },
|
|
7045
|
-
readNextBatch: { configurable: true, value() { const chunk = nextStreamChunk(this); if (chunk == null) return null; return describedSerie(chunk).intoArrowBatch() } },
|
|
7046
|
-
readAll: { configurable: true, value() { return this.intoArrowReader().intoTable() } },
|
|
7047
|
-
})
|