@duckdb/node-api 1.1.3-alpha.8 → 1.1.3-alpha.9
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/LICENSE +1 -1
- package/README.md +59 -3
- package/lib/DuckDBConnection.d.ts +13 -11
- package/lib/DuckDBConnection.js +33 -17
- package/lib/DuckDBDataChunk.d.ts +5 -1
- package/lib/DuckDBDataChunk.js +35 -2
- package/lib/DuckDBPreparedStatement.d.ts +9 -1
- package/lib/DuckDBPreparedStatement.js +41 -10
- package/lib/DuckDBType.d.ts +111 -2
- package/lib/DuckDBType.js +363 -12
- package/lib/DuckDBVector.d.ts +197 -61
- package/lib/DuckDBVector.js +1067 -177
- package/lib/conversion/bytesFromString.d.ts +1 -0
- package/lib/conversion/bytesFromString.js +7 -0
- package/lib/createValue.d.ts +4 -0
- package/lib/createValue.js +159 -0
- package/lib/typeForValue.d.ts +3 -0
- package/lib/typeForValue.js +83 -0
- package/lib/values/DuckDBBlobValue.d.ts +1 -1
- package/lib/values/DuckDBBlobValue.js +7 -4
- package/package.json +2 -2
package/lib/DuckDBVector.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DuckDBVarIntVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBBitVector = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.
|
|
6
|
+
exports.DuckDBVarIntVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBBitVector = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.DuckDBEnum32Vector = exports.DuckDBEnum16Vector = exports.DuckDBEnum8Vector = exports.DuckDBTimestampNanosecondsVector = exports.DuckDBTimestampMillisecondsVector = exports.DuckDBTimestampSecondsVector = exports.DuckDBDecimal128Vector = exports.DuckDBDecimal64Vector = exports.DuckDBDecimal32Vector = exports.DuckDBDecimal16Vector = exports.DuckDBBlobVector = exports.DuckDBVarCharVector = exports.DuckDBUHugeIntVector = exports.DuckDBHugeIntVector = exports.DuckDBIntervalVector = exports.DuckDBTimeVector = exports.DuckDBDateVector = exports.DuckDBTimestampVector = exports.DuckDBDoubleVector = exports.DuckDBFloatVector = exports.DuckDBUBigIntVector = exports.DuckDBUIntegerVector = exports.DuckDBUSmallIntVector = exports.DuckDBUTinyIntVector = exports.DuckDBBigIntVector = exports.DuckDBIntegerVector = exports.DuckDBSmallIntVector = exports.DuckDBTinyIntVector = exports.DuckDBBooleanVector = exports.DuckDBVector = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
|
|
@@ -49,7 +49,7 @@ function getInt128(dataView, offset) {
|
|
|
49
49
|
function getUInt128(dataView, offset) {
|
|
50
50
|
const lower = getUInt64(dataView, offset);
|
|
51
51
|
const upper = getUInt64(dataView, offset + 8);
|
|
52
|
-
return BigInt.asUintN(64, upper) << BigInt(64) | BigInt.asUintN(64, lower);
|
|
52
|
+
return (BigInt.asUintN(64, upper) << BigInt(64)) | BigInt.asUintN(64, lower);
|
|
53
53
|
}
|
|
54
54
|
function getStringBytes(dataView, offset) {
|
|
55
55
|
const lengthInBytes = dataView.getUint32(offset, true);
|
|
@@ -88,6 +88,30 @@ function getVarIntFromBytes(bytes) {
|
|
|
88
88
|
}
|
|
89
89
|
return positive ? result : -result;
|
|
90
90
|
}
|
|
91
|
+
function getBytesFromVarInt(varint) {
|
|
92
|
+
const numberBytes = [];
|
|
93
|
+
if (varint === 0n) {
|
|
94
|
+
numberBytes.push(0);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
while (varint !== 0n) {
|
|
98
|
+
numberBytes.push(Number(BigInt.asUintN(8, varint)));
|
|
99
|
+
varint >>= 8n;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const varIntBytes = new Uint8Array(3 + numberBytes.length);
|
|
103
|
+
let header = 0x800000 | numberBytes.length;
|
|
104
|
+
if (varint < 0) {
|
|
105
|
+
header = ~header;
|
|
106
|
+
}
|
|
107
|
+
varIntBytes[0] = 0xff & (header >> 16);
|
|
108
|
+
varIntBytes[1] = 0xff & (header >> 8);
|
|
109
|
+
varIntBytes[2] = 0xff & header;
|
|
110
|
+
for (let i = 0; i < numberBytes.length; i++) {
|
|
111
|
+
varIntBytes[3 + i] = numberBytes[i];
|
|
112
|
+
}
|
|
113
|
+
return varIntBytes;
|
|
114
|
+
}
|
|
91
115
|
function getBoolean1(dataView, offset) {
|
|
92
116
|
return getUInt8(dataView, offset) !== 0;
|
|
93
117
|
}
|
|
@@ -115,19 +139,82 @@ function makeGetBoolean() {
|
|
|
115
139
|
}
|
|
116
140
|
}
|
|
117
141
|
const getBoolean = makeGetBoolean();
|
|
118
|
-
function
|
|
142
|
+
// function setInt8(dataView: DataView, offset: number, value: number) {
|
|
143
|
+
// dataView.setInt8(offset, value);
|
|
144
|
+
// }
|
|
145
|
+
function setUInt8(dataView, offset, value) {
|
|
146
|
+
dataView.setUint8(offset, value);
|
|
147
|
+
}
|
|
148
|
+
function setInt16(dataView, offset, value) {
|
|
149
|
+
dataView.setInt16(offset, value, littleEndian);
|
|
150
|
+
}
|
|
151
|
+
function setUInt16(dataView, offset, value) {
|
|
152
|
+
dataView.setUint16(offset, value, littleEndian);
|
|
153
|
+
}
|
|
154
|
+
function setInt32(dataView, offset, value) {
|
|
155
|
+
dataView.setInt32(offset, value, littleEndian);
|
|
156
|
+
}
|
|
157
|
+
function setUInt32(dataView, offset, value) {
|
|
158
|
+
dataView.setUint32(offset, value, littleEndian);
|
|
159
|
+
}
|
|
160
|
+
function setInt64(dataView, offset, value) {
|
|
161
|
+
dataView.setBigInt64(offset, value, littleEndian);
|
|
162
|
+
}
|
|
163
|
+
function setUInt64(dataView, offset, value) {
|
|
164
|
+
dataView.setBigUint64(offset, value, littleEndian);
|
|
165
|
+
}
|
|
166
|
+
function setInt128(dataView, offset, value) {
|
|
167
|
+
const lower = BigInt.asUintN(64, value);
|
|
168
|
+
const upper = BigInt.asIntN(64, value >> BigInt(64));
|
|
169
|
+
dataView.setBigUint64(offset, lower, littleEndian);
|
|
170
|
+
dataView.setBigInt64(offset + 8, upper, littleEndian);
|
|
171
|
+
}
|
|
172
|
+
function setUInt128(dataView, offset, value) {
|
|
173
|
+
const lower = BigInt.asUintN(64, value);
|
|
174
|
+
const upper = BigInt.asUintN(64, value >> BigInt(64));
|
|
175
|
+
dataView.setBigUint64(offset, lower, littleEndian);
|
|
176
|
+
dataView.setBigUint64(offset + 8, upper, littleEndian);
|
|
177
|
+
}
|
|
178
|
+
function setBoolean1(dataView, offset, value) {
|
|
179
|
+
setUInt8(dataView, offset, value ? 1 : 0);
|
|
180
|
+
}
|
|
181
|
+
function setBoolean2(dataView, offset, value) {
|
|
182
|
+
setUInt16(dataView, offset, value ? 1 : 0);
|
|
183
|
+
}
|
|
184
|
+
function setBoolean4(dataView, offset, value) {
|
|
185
|
+
setUInt32(dataView, offset, value ? 1 : 0);
|
|
186
|
+
}
|
|
187
|
+
function setBoolean8(dataView, offset, value) {
|
|
188
|
+
setUInt64(dataView, offset, value ? BigInt(1) : BigInt(0));
|
|
189
|
+
}
|
|
190
|
+
function makeSetBoolean() {
|
|
191
|
+
switch (node_bindings_1.default.sizeof_bool) {
|
|
192
|
+
case 1:
|
|
193
|
+
return setBoolean1;
|
|
194
|
+
case 2:
|
|
195
|
+
return setBoolean2;
|
|
196
|
+
case 4:
|
|
197
|
+
return setBoolean4;
|
|
198
|
+
case 8:
|
|
199
|
+
return setBoolean8;
|
|
200
|
+
default:
|
|
201
|
+
throw new Error(`Unsupported boolean size: ${node_bindings_1.default.sizeof_bool}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const setBoolean = makeSetBoolean();
|
|
205
|
+
function getDecimal16(dataView, offset, type) {
|
|
119
206
|
const value = getInt16(dataView, offset);
|
|
120
207
|
return new values_1.DuckDBDecimalValue(BigInt(value), type.width, type.scale);
|
|
121
208
|
}
|
|
122
|
-
function
|
|
209
|
+
function getDecimal32(dataView, offset, type) {
|
|
123
210
|
const value = getInt32(dataView, offset);
|
|
124
211
|
return new values_1.DuckDBDecimalValue(BigInt(value), type.width, type.scale);
|
|
125
212
|
}
|
|
126
|
-
function
|
|
213
|
+
function getDecimal64(dataView, offset, type) {
|
|
127
214
|
const value = getInt64(dataView, offset);
|
|
128
215
|
return new values_1.DuckDBDecimalValue(value, type.width, type.scale);
|
|
129
216
|
}
|
|
130
|
-
function
|
|
217
|
+
function getDecimal128(dataView, offset, type) {
|
|
131
218
|
const value = getInt128(dataView, offset);
|
|
132
219
|
return new values_1.DuckDBDecimalValue(value, type.width, type.scale);
|
|
133
220
|
}
|
|
@@ -156,28 +243,65 @@ function vectorData(vector, byteCount) {
|
|
|
156
243
|
class DuckDBValidity {
|
|
157
244
|
data;
|
|
158
245
|
offset;
|
|
159
|
-
|
|
246
|
+
itemCount;
|
|
247
|
+
constructor(data, offset, itemCount) {
|
|
160
248
|
this.data = data;
|
|
161
249
|
this.offset = offset;
|
|
250
|
+
this.itemCount = itemCount;
|
|
162
251
|
}
|
|
163
252
|
static fromVector(vector, itemCount) {
|
|
164
|
-
const
|
|
165
|
-
const bytes = node_bindings_1.default.vector_get_validity(vector,
|
|
253
|
+
const uint64Count = Math.ceil(itemCount / 64);
|
|
254
|
+
const bytes = node_bindings_1.default.vector_get_validity(vector, uint64Count * 8);
|
|
166
255
|
if (!bytes) {
|
|
167
|
-
return new DuckDBValidity(null, 0);
|
|
256
|
+
return new DuckDBValidity(null, 0, itemCount);
|
|
168
257
|
}
|
|
169
|
-
const bigints = new BigUint64Array(bytes.buffer, bytes.byteOffset,
|
|
170
|
-
return new DuckDBValidity(bigints, 0);
|
|
258
|
+
const bigints = new BigUint64Array(bytes.buffer, bytes.byteOffset, uint64Count);
|
|
259
|
+
return new DuckDBValidity(bigints, 0, itemCount);
|
|
171
260
|
}
|
|
172
261
|
itemValid(itemIndex) {
|
|
173
262
|
if (!this.data) {
|
|
174
263
|
return true;
|
|
175
264
|
}
|
|
176
265
|
const bit = this.offset + itemIndex;
|
|
177
|
-
return (this.data[Math.floor(bit / 64)] & (BigInt(1) << BigInt(bit % 64))) !==
|
|
266
|
+
return ((this.data[Math.floor(bit / 64)] & (BigInt(1) << BigInt(bit % 64))) !==
|
|
267
|
+
BigInt(0));
|
|
268
|
+
}
|
|
269
|
+
setItemValid(itemIndex, valid) {
|
|
270
|
+
if (!this.data && !valid) {
|
|
271
|
+
// An item is being set to invalid and we don't have a data buffer, so create it. If an item is being set to valid
|
|
272
|
+
// and we don't have a data buffer, then there's nothing to do; a null data buffer indicates all items are valid.
|
|
273
|
+
const uint64Count = Math.ceil(this.itemCount / 64);
|
|
274
|
+
const buffer = new ArrayBuffer(uint64Count * 8);
|
|
275
|
+
this.data = new BigUint64Array(buffer, 0, uint64Count);
|
|
276
|
+
// Initialize to all items to valid.
|
|
277
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
278
|
+
this.data[i] = 0xffffffffffffffffn;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (this.data) {
|
|
282
|
+
const bit = this.offset + itemIndex;
|
|
283
|
+
const uint64Index = Math.floor(bit / 64);
|
|
284
|
+
const uint64WithBitSet = BigInt(1) << BigInt(bit % 64);
|
|
285
|
+
if (valid) {
|
|
286
|
+
if ((this.data[uint64Index] & uint64WithBitSet) === 0n) {
|
|
287
|
+
this.data[uint64Index] |= uint64WithBitSet;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
if ((this.data[uint64Index] & uint64WithBitSet) !== 0n) {
|
|
292
|
+
this.data[uint64Index] &= ~uint64WithBitSet;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
178
296
|
}
|
|
179
|
-
|
|
180
|
-
|
|
297
|
+
flush(vector) {
|
|
298
|
+
if (this.data) {
|
|
299
|
+
node_bindings_1.default.vector_ensure_validity_writable(vector);
|
|
300
|
+
node_bindings_1.default.copy_data_to_vector_validity(vector, 0, this.data.buffer, this.data.byteOffset, this.data.byteLength);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
slice(offset, itemCount) {
|
|
304
|
+
return new DuckDBValidity(this.data, this.offset + offset, itemCount);
|
|
181
305
|
}
|
|
182
306
|
}
|
|
183
307
|
class DuckDBVector {
|
|
@@ -185,7 +309,9 @@ class DuckDBVector {
|
|
|
185
309
|
return node_bindings_1.default.vector_size();
|
|
186
310
|
}
|
|
187
311
|
static create(vector, itemCount, knownType) {
|
|
188
|
-
const vectorType = knownType
|
|
312
|
+
const vectorType = knownType
|
|
313
|
+
? knownType
|
|
314
|
+
: DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.vector_get_column_type(vector)).asType();
|
|
189
315
|
switch (vectorType.typeId) {
|
|
190
316
|
case DuckDBTypeId_1.DuckDBTypeId.BOOLEAN:
|
|
191
317
|
return DuckDBBooleanVector.fromRawVector(vector, itemCount);
|
|
@@ -232,16 +358,16 @@ class DuckDBVector {
|
|
|
232
358
|
throw new Error(`DECIMAL width not positive: ${width}`);
|
|
233
359
|
}
|
|
234
360
|
else if (width <= 4) {
|
|
235
|
-
return
|
|
361
|
+
return DuckDBDecimal16Vector.fromRawVector(vectorType, vector, itemCount);
|
|
236
362
|
}
|
|
237
363
|
else if (width <= 9) {
|
|
238
|
-
return
|
|
364
|
+
return DuckDBDecimal32Vector.fromRawVector(vectorType, vector, itemCount);
|
|
239
365
|
}
|
|
240
366
|
else if (width <= 18) {
|
|
241
|
-
return
|
|
367
|
+
return DuckDBDecimal64Vector.fromRawVector(vectorType, vector, itemCount);
|
|
242
368
|
}
|
|
243
369
|
else if (width <= 38) {
|
|
244
|
-
return
|
|
370
|
+
return DuckDBDecimal128Vector.fromRawVector(vectorType, vector, itemCount);
|
|
245
371
|
}
|
|
246
372
|
else {
|
|
247
373
|
throw new Error(`DECIMAL width too large: ${width}`);
|
|
@@ -259,11 +385,11 @@ class DuckDBVector {
|
|
|
259
385
|
const { internalTypeId } = vectorType;
|
|
260
386
|
switch (internalTypeId) {
|
|
261
387
|
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
|
|
262
|
-
return
|
|
388
|
+
return DuckDBEnum8Vector.fromRawVector(vectorType, vector, itemCount);
|
|
263
389
|
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
|
|
264
|
-
return
|
|
390
|
+
return DuckDBEnum16Vector.fromRawVector(vectorType, vector, itemCount);
|
|
265
391
|
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
|
|
266
|
-
return
|
|
392
|
+
return DuckDBEnum32Vector.fromRawVector(vectorType, vector, itemCount);
|
|
267
393
|
default:
|
|
268
394
|
throw new Error(`unsupported ENUM internal type: ${internalTypeId}`);
|
|
269
395
|
}
|
|
@@ -324,18 +450,20 @@ exports.DuckDBVector = DuckDBVector;
|
|
|
324
450
|
class DuckDBBooleanVector extends DuckDBVector {
|
|
325
451
|
dataView;
|
|
326
452
|
validity;
|
|
453
|
+
vector;
|
|
327
454
|
_itemCount;
|
|
328
|
-
constructor(dataView, validity, itemCount) {
|
|
455
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
329
456
|
super();
|
|
330
457
|
this.dataView = dataView;
|
|
331
458
|
this.validity = validity;
|
|
459
|
+
this.vector = vector;
|
|
332
460
|
this._itemCount = itemCount;
|
|
333
461
|
}
|
|
334
462
|
static fromRawVector(vector, itemCount) {
|
|
335
463
|
const data = vectorData(vector, itemCount * node_bindings_1.default.sizeof_bool);
|
|
336
464
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
337
465
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
338
|
-
return new DuckDBBooleanVector(dataView, validity, itemCount);
|
|
466
|
+
return new DuckDBBooleanVector(dataView, validity, vector, itemCount);
|
|
339
467
|
}
|
|
340
468
|
get type() {
|
|
341
469
|
return DuckDBType_1.DuckDBBooleanType.instance;
|
|
@@ -344,26 +472,43 @@ class DuckDBBooleanVector extends DuckDBVector {
|
|
|
344
472
|
return this._itemCount;
|
|
345
473
|
}
|
|
346
474
|
getItem(itemIndex) {
|
|
347
|
-
return this.validity.itemValid(itemIndex)
|
|
475
|
+
return this.validity.itemValid(itemIndex)
|
|
476
|
+
? getBoolean(this.dataView, itemIndex * node_bindings_1.default.sizeof_bool)
|
|
477
|
+
: null;
|
|
478
|
+
}
|
|
479
|
+
setItem(itemIndex, value) {
|
|
480
|
+
if (value != null) {
|
|
481
|
+
setBoolean(this.dataView, itemIndex * node_bindings_1.default.sizeof_bool, value);
|
|
482
|
+
this.validity.setItemValid(itemIndex, true);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
this.validity.setItemValid(itemIndex, false);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
flush() {
|
|
489
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
490
|
+
this.validity.flush(this.vector);
|
|
348
491
|
}
|
|
349
492
|
slice(offset, length) {
|
|
350
|
-
return new DuckDBBooleanVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * node_bindings_1.default.sizeof_bool, length * node_bindings_1.default.sizeof_bool), this.validity.slice(offset), length);
|
|
493
|
+
return new DuckDBBooleanVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * node_bindings_1.default.sizeof_bool, length * node_bindings_1.default.sizeof_bool), this.validity.slice(offset, length), this.vector, length);
|
|
351
494
|
}
|
|
352
495
|
}
|
|
353
496
|
exports.DuckDBBooleanVector = DuckDBBooleanVector;
|
|
354
497
|
class DuckDBTinyIntVector extends DuckDBVector {
|
|
355
498
|
items;
|
|
356
499
|
validity;
|
|
357
|
-
|
|
500
|
+
vector;
|
|
501
|
+
constructor(items, validity, vector) {
|
|
358
502
|
super();
|
|
359
503
|
this.items = items;
|
|
360
504
|
this.validity = validity;
|
|
505
|
+
this.vector = vector;
|
|
361
506
|
}
|
|
362
507
|
static fromRawVector(vector, itemCount) {
|
|
363
508
|
const data = vectorData(vector, itemCount * Int8Array.BYTES_PER_ELEMENT);
|
|
364
509
|
const items = new Int8Array(data.buffer, data.byteOffset, itemCount);
|
|
365
510
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
366
|
-
return new DuckDBTinyIntVector(items, validity);
|
|
511
|
+
return new DuckDBTinyIntVector(items, validity, vector);
|
|
367
512
|
}
|
|
368
513
|
get type() {
|
|
369
514
|
return DuckDBType_1.DuckDBTinyIntType.instance;
|
|
@@ -374,24 +519,39 @@ class DuckDBTinyIntVector extends DuckDBVector {
|
|
|
374
519
|
getItem(itemIndex) {
|
|
375
520
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
376
521
|
}
|
|
522
|
+
setItem(itemIndex, value) {
|
|
523
|
+
if (value != null) {
|
|
524
|
+
this.items[itemIndex] = value;
|
|
525
|
+
this.validity.setItemValid(itemIndex, true);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
this.validity.setItemValid(itemIndex, false);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
flush() {
|
|
532
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
533
|
+
this.validity.flush(this.vector);
|
|
534
|
+
}
|
|
377
535
|
slice(offset, length) {
|
|
378
|
-
return new DuckDBTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
536
|
+
return new DuckDBTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
379
537
|
}
|
|
380
538
|
}
|
|
381
539
|
exports.DuckDBTinyIntVector = DuckDBTinyIntVector;
|
|
382
540
|
class DuckDBSmallIntVector extends DuckDBVector {
|
|
383
541
|
items;
|
|
384
542
|
validity;
|
|
385
|
-
|
|
543
|
+
vector;
|
|
544
|
+
constructor(items, validity, vector) {
|
|
386
545
|
super();
|
|
387
546
|
this.items = items;
|
|
388
547
|
this.validity = validity;
|
|
548
|
+
this.vector = vector;
|
|
389
549
|
}
|
|
390
550
|
static fromRawVector(vector, itemCount) {
|
|
391
551
|
const data = vectorData(vector, itemCount * Int16Array.BYTES_PER_ELEMENT);
|
|
392
552
|
const items = new Int16Array(data.buffer, data.byteOffset, itemCount);
|
|
393
553
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
394
|
-
return new DuckDBSmallIntVector(items, validity);
|
|
554
|
+
return new DuckDBSmallIntVector(items, validity, vector);
|
|
395
555
|
}
|
|
396
556
|
get type() {
|
|
397
557
|
return DuckDBType_1.DuckDBSmallIntType.instance;
|
|
@@ -402,24 +562,39 @@ class DuckDBSmallIntVector extends DuckDBVector {
|
|
|
402
562
|
getItem(itemIndex) {
|
|
403
563
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
404
564
|
}
|
|
565
|
+
setItem(itemIndex, value) {
|
|
566
|
+
if (value != null) {
|
|
567
|
+
this.items[itemIndex] = value;
|
|
568
|
+
this.validity.setItemValid(itemIndex, true);
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
this.validity.setItemValid(itemIndex, false);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
flush() {
|
|
575
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
576
|
+
this.validity.flush(this.vector);
|
|
577
|
+
}
|
|
405
578
|
slice(offset, length) {
|
|
406
|
-
return new DuckDBSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
579
|
+
return new DuckDBSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
407
580
|
}
|
|
408
581
|
}
|
|
409
582
|
exports.DuckDBSmallIntVector = DuckDBSmallIntVector;
|
|
410
583
|
class DuckDBIntegerVector extends DuckDBVector {
|
|
411
584
|
items;
|
|
412
585
|
validity;
|
|
413
|
-
|
|
586
|
+
vector;
|
|
587
|
+
constructor(items, validity, vector) {
|
|
414
588
|
super();
|
|
415
589
|
this.items = items;
|
|
416
590
|
this.validity = validity;
|
|
591
|
+
this.vector = vector;
|
|
417
592
|
}
|
|
418
593
|
static fromRawVector(vector, itemCount) {
|
|
419
594
|
const data = vectorData(vector, itemCount * Int32Array.BYTES_PER_ELEMENT);
|
|
420
595
|
const items = new Int32Array(data.buffer, data.byteOffset, itemCount);
|
|
421
596
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
422
|
-
return new DuckDBIntegerVector(items, validity);
|
|
597
|
+
return new DuckDBIntegerVector(items, validity, vector);
|
|
423
598
|
}
|
|
424
599
|
get type() {
|
|
425
600
|
return DuckDBType_1.DuckDBIntegerType.instance;
|
|
@@ -430,24 +605,39 @@ class DuckDBIntegerVector extends DuckDBVector {
|
|
|
430
605
|
getItem(itemIndex) {
|
|
431
606
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
432
607
|
}
|
|
608
|
+
setItem(itemIndex, value) {
|
|
609
|
+
if (value != null) {
|
|
610
|
+
this.items[itemIndex] = value;
|
|
611
|
+
this.validity.setItemValid(itemIndex, true);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
this.validity.setItemValid(itemIndex, false);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
flush() {
|
|
618
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
619
|
+
this.validity.flush(this.vector);
|
|
620
|
+
}
|
|
433
621
|
slice(offset, length) {
|
|
434
|
-
return new DuckDBIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
622
|
+
return new DuckDBIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
435
623
|
}
|
|
436
624
|
}
|
|
437
625
|
exports.DuckDBIntegerVector = DuckDBIntegerVector;
|
|
438
626
|
class DuckDBBigIntVector extends DuckDBVector {
|
|
439
627
|
items;
|
|
440
628
|
validity;
|
|
441
|
-
|
|
629
|
+
vector;
|
|
630
|
+
constructor(items, validity, vector) {
|
|
442
631
|
super();
|
|
443
632
|
this.items = items;
|
|
444
633
|
this.validity = validity;
|
|
634
|
+
this.vector = vector;
|
|
445
635
|
}
|
|
446
636
|
static fromRawVector(vector, itemCount) {
|
|
447
637
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
448
638
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
449
639
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
450
|
-
return new DuckDBBigIntVector(items, validity);
|
|
640
|
+
return new DuckDBBigIntVector(items, validity, vector);
|
|
451
641
|
}
|
|
452
642
|
get type() {
|
|
453
643
|
return DuckDBType_1.DuckDBBigIntType.instance;
|
|
@@ -458,24 +648,39 @@ class DuckDBBigIntVector extends DuckDBVector {
|
|
|
458
648
|
getItem(itemIndex) {
|
|
459
649
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
460
650
|
}
|
|
651
|
+
setItem(itemIndex, value) {
|
|
652
|
+
if (value != null) {
|
|
653
|
+
this.items[itemIndex] = value;
|
|
654
|
+
this.validity.setItemValid(itemIndex, true);
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
this.validity.setItemValid(itemIndex, false);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
flush() {
|
|
661
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
662
|
+
this.validity.flush(this.vector);
|
|
663
|
+
}
|
|
461
664
|
slice(offset, length) {
|
|
462
|
-
return new DuckDBBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
665
|
+
return new DuckDBBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
463
666
|
}
|
|
464
667
|
}
|
|
465
668
|
exports.DuckDBBigIntVector = DuckDBBigIntVector;
|
|
466
669
|
class DuckDBUTinyIntVector extends DuckDBVector {
|
|
467
670
|
items;
|
|
468
671
|
validity;
|
|
469
|
-
|
|
672
|
+
vector;
|
|
673
|
+
constructor(items, validity, vector) {
|
|
470
674
|
super();
|
|
471
675
|
this.items = items;
|
|
472
676
|
this.validity = validity;
|
|
677
|
+
this.vector = vector;
|
|
473
678
|
}
|
|
474
679
|
static fromRawVector(vector, itemCount) {
|
|
475
680
|
const data = vectorData(vector, itemCount * Uint8Array.BYTES_PER_ELEMENT);
|
|
476
681
|
const items = new Uint8Array(data.buffer, data.byteOffset, itemCount);
|
|
477
682
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
478
|
-
return new DuckDBUTinyIntVector(items, validity);
|
|
683
|
+
return new DuckDBUTinyIntVector(items, validity, vector);
|
|
479
684
|
}
|
|
480
685
|
get type() {
|
|
481
686
|
return DuckDBType_1.DuckDBUTinyIntType.instance;
|
|
@@ -486,24 +691,39 @@ class DuckDBUTinyIntVector extends DuckDBVector {
|
|
|
486
691
|
getItem(itemIndex) {
|
|
487
692
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
488
693
|
}
|
|
694
|
+
setItem(itemIndex, value) {
|
|
695
|
+
if (value != null) {
|
|
696
|
+
this.items[itemIndex] = value;
|
|
697
|
+
this.validity.setItemValid(itemIndex, true);
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
this.validity.setItemValid(itemIndex, false);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
flush() {
|
|
704
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
705
|
+
this.validity.flush(this.vector);
|
|
706
|
+
}
|
|
489
707
|
slice(offset, length) {
|
|
490
|
-
return new DuckDBUTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
708
|
+
return new DuckDBUTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
491
709
|
}
|
|
492
710
|
}
|
|
493
711
|
exports.DuckDBUTinyIntVector = DuckDBUTinyIntVector;
|
|
494
712
|
class DuckDBUSmallIntVector extends DuckDBVector {
|
|
495
713
|
items;
|
|
496
714
|
validity;
|
|
497
|
-
|
|
715
|
+
vector;
|
|
716
|
+
constructor(items, validity, vector) {
|
|
498
717
|
super();
|
|
499
718
|
this.items = items;
|
|
500
719
|
this.validity = validity;
|
|
720
|
+
this.vector = vector;
|
|
501
721
|
}
|
|
502
722
|
static fromRawVector(vector, itemCount) {
|
|
503
723
|
const data = vectorData(vector, itemCount * Uint16Array.BYTES_PER_ELEMENT);
|
|
504
724
|
const items = new Uint16Array(data.buffer, data.byteOffset, itemCount);
|
|
505
725
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
506
|
-
return new DuckDBUSmallIntVector(items, validity);
|
|
726
|
+
return new DuckDBUSmallIntVector(items, validity, vector);
|
|
507
727
|
}
|
|
508
728
|
get type() {
|
|
509
729
|
return DuckDBType_1.DuckDBUSmallIntType.instance;
|
|
@@ -514,24 +734,39 @@ class DuckDBUSmallIntVector extends DuckDBVector {
|
|
|
514
734
|
getItem(itemIndex) {
|
|
515
735
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
516
736
|
}
|
|
737
|
+
setItem(itemIndex, value) {
|
|
738
|
+
if (value != null) {
|
|
739
|
+
this.items[itemIndex] = value;
|
|
740
|
+
this.validity.setItemValid(itemIndex, true);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
this.validity.setItemValid(itemIndex, false);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
flush() {
|
|
747
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
748
|
+
this.validity.flush(this.vector);
|
|
749
|
+
}
|
|
517
750
|
slice(offset, length) {
|
|
518
|
-
return new DuckDBUSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
751
|
+
return new DuckDBUSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
519
752
|
}
|
|
520
753
|
}
|
|
521
754
|
exports.DuckDBUSmallIntVector = DuckDBUSmallIntVector;
|
|
522
755
|
class DuckDBUIntegerVector extends DuckDBVector {
|
|
523
756
|
items;
|
|
524
757
|
validity;
|
|
525
|
-
|
|
758
|
+
vector;
|
|
759
|
+
constructor(items, validity, vector) {
|
|
526
760
|
super();
|
|
527
761
|
this.items = items;
|
|
528
762
|
this.validity = validity;
|
|
763
|
+
this.vector = vector;
|
|
529
764
|
}
|
|
530
765
|
static fromRawVector(vector, itemCount) {
|
|
531
766
|
const data = vectorData(vector, itemCount * Uint32Array.BYTES_PER_ELEMENT);
|
|
532
767
|
const items = new Uint32Array(data.buffer, data.byteOffset, itemCount);
|
|
533
768
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
534
|
-
return new DuckDBUIntegerVector(items, validity);
|
|
769
|
+
return new DuckDBUIntegerVector(items, validity, vector);
|
|
535
770
|
}
|
|
536
771
|
get type() {
|
|
537
772
|
return DuckDBType_1.DuckDBUIntegerType.instance;
|
|
@@ -542,24 +777,39 @@ class DuckDBUIntegerVector extends DuckDBVector {
|
|
|
542
777
|
getItem(itemIndex) {
|
|
543
778
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
544
779
|
}
|
|
780
|
+
setItem(itemIndex, value) {
|
|
781
|
+
if (value != null) {
|
|
782
|
+
this.items[itemIndex] = value;
|
|
783
|
+
this.validity.setItemValid(itemIndex, true);
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
this.validity.setItemValid(itemIndex, false);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
flush() {
|
|
790
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
791
|
+
this.validity.flush(this.vector);
|
|
792
|
+
}
|
|
545
793
|
slice(offset, length) {
|
|
546
|
-
return new DuckDBUIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
794
|
+
return new DuckDBUIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
547
795
|
}
|
|
548
796
|
}
|
|
549
797
|
exports.DuckDBUIntegerVector = DuckDBUIntegerVector;
|
|
550
798
|
class DuckDBUBigIntVector extends DuckDBVector {
|
|
551
799
|
items;
|
|
552
800
|
validity;
|
|
553
|
-
|
|
801
|
+
vector;
|
|
802
|
+
constructor(items, validity, vector) {
|
|
554
803
|
super();
|
|
555
804
|
this.items = items;
|
|
556
805
|
this.validity = validity;
|
|
806
|
+
this.vector = vector;
|
|
557
807
|
}
|
|
558
808
|
static fromRawVector(vector, itemCount) {
|
|
559
809
|
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT);
|
|
560
810
|
const items = new BigUint64Array(data.buffer, data.byteOffset, itemCount);
|
|
561
811
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
562
|
-
return new DuckDBUBigIntVector(items, validity);
|
|
812
|
+
return new DuckDBUBigIntVector(items, validity, vector);
|
|
563
813
|
}
|
|
564
814
|
get type() {
|
|
565
815
|
return DuckDBType_1.DuckDBUBigIntType.instance;
|
|
@@ -570,24 +820,39 @@ class DuckDBUBigIntVector extends DuckDBVector {
|
|
|
570
820
|
getItem(itemIndex) {
|
|
571
821
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
572
822
|
}
|
|
823
|
+
setItem(itemIndex, value) {
|
|
824
|
+
if (value != null) {
|
|
825
|
+
this.items[itemIndex] = value;
|
|
826
|
+
this.validity.setItemValid(itemIndex, true);
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
this.validity.setItemValid(itemIndex, false);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
flush() {
|
|
833
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
834
|
+
this.validity.flush(this.vector);
|
|
835
|
+
}
|
|
573
836
|
slice(offset, length) {
|
|
574
|
-
return new DuckDBUBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
837
|
+
return new DuckDBUBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
575
838
|
}
|
|
576
839
|
}
|
|
577
840
|
exports.DuckDBUBigIntVector = DuckDBUBigIntVector;
|
|
578
841
|
class DuckDBFloatVector extends DuckDBVector {
|
|
579
842
|
items;
|
|
580
843
|
validity;
|
|
581
|
-
|
|
844
|
+
vector;
|
|
845
|
+
constructor(items, validity, vector) {
|
|
582
846
|
super();
|
|
583
847
|
this.items = items;
|
|
584
848
|
this.validity = validity;
|
|
849
|
+
this.vector = vector;
|
|
585
850
|
}
|
|
586
851
|
static fromRawVector(vector, itemCount) {
|
|
587
852
|
const data = vectorData(vector, itemCount * Float32Array.BYTES_PER_ELEMENT);
|
|
588
853
|
const items = new Float32Array(data.buffer, data.byteOffset, itemCount);
|
|
589
854
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
590
|
-
return new DuckDBFloatVector(items, validity);
|
|
855
|
+
return new DuckDBFloatVector(items, validity, vector);
|
|
591
856
|
}
|
|
592
857
|
get type() {
|
|
593
858
|
return DuckDBType_1.DuckDBFloatType.instance;
|
|
@@ -598,24 +863,39 @@ class DuckDBFloatVector extends DuckDBVector {
|
|
|
598
863
|
getItem(itemIndex) {
|
|
599
864
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
600
865
|
}
|
|
866
|
+
setItem(itemIndex, value) {
|
|
867
|
+
if (value != null) {
|
|
868
|
+
this.items[itemIndex] = value;
|
|
869
|
+
this.validity.setItemValid(itemIndex, true);
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
this.validity.setItemValid(itemIndex, false);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
flush() {
|
|
876
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
877
|
+
this.validity.flush(this.vector);
|
|
878
|
+
}
|
|
601
879
|
slice(offset, length) {
|
|
602
|
-
return new DuckDBFloatVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
880
|
+
return new DuckDBFloatVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
603
881
|
}
|
|
604
882
|
}
|
|
605
883
|
exports.DuckDBFloatVector = DuckDBFloatVector;
|
|
606
884
|
class DuckDBDoubleVector extends DuckDBVector {
|
|
607
885
|
items;
|
|
608
886
|
validity;
|
|
609
|
-
|
|
887
|
+
vector;
|
|
888
|
+
constructor(items, validity, vector) {
|
|
610
889
|
super();
|
|
611
890
|
this.items = items;
|
|
612
891
|
this.validity = validity;
|
|
892
|
+
this.vector = vector;
|
|
613
893
|
}
|
|
614
894
|
static fromRawVector(vector, itemCount) {
|
|
615
895
|
const data = vectorData(vector, itemCount * Float64Array.BYTES_PER_ELEMENT);
|
|
616
896
|
const items = new Float64Array(data.buffer, data.byteOffset, itemCount);
|
|
617
897
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
618
|
-
return new DuckDBDoubleVector(items, validity);
|
|
898
|
+
return new DuckDBDoubleVector(items, validity, vector);
|
|
619
899
|
}
|
|
620
900
|
get type() {
|
|
621
901
|
return DuckDBType_1.DuckDBDoubleType.instance;
|
|
@@ -626,24 +906,39 @@ class DuckDBDoubleVector extends DuckDBVector {
|
|
|
626
906
|
getItem(itemIndex) {
|
|
627
907
|
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
628
908
|
}
|
|
909
|
+
setItem(itemIndex, value) {
|
|
910
|
+
if (value != null) {
|
|
911
|
+
this.items[itemIndex] = value;
|
|
912
|
+
this.validity.setItemValid(itemIndex, true);
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
this.validity.setItemValid(itemIndex, false);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
flush() {
|
|
919
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
920
|
+
this.validity.flush(this.vector);
|
|
921
|
+
}
|
|
629
922
|
slice(offset, length) {
|
|
630
|
-
return new DuckDBDoubleVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
923
|
+
return new DuckDBDoubleVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
631
924
|
}
|
|
632
925
|
}
|
|
633
926
|
exports.DuckDBDoubleVector = DuckDBDoubleVector;
|
|
634
927
|
class DuckDBTimestampVector extends DuckDBVector {
|
|
635
928
|
items;
|
|
636
929
|
validity;
|
|
637
|
-
|
|
930
|
+
vector;
|
|
931
|
+
constructor(items, validity, vector) {
|
|
638
932
|
super();
|
|
639
933
|
this.items = items;
|
|
640
934
|
this.validity = validity;
|
|
935
|
+
this.vector = vector;
|
|
641
936
|
}
|
|
642
937
|
static fromRawVector(vector, itemCount) {
|
|
643
938
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
644
939
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
645
940
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
646
|
-
return new DuckDBTimestampVector(items, validity);
|
|
941
|
+
return new DuckDBTimestampVector(items, validity, vector);
|
|
647
942
|
}
|
|
648
943
|
get type() {
|
|
649
944
|
return DuckDBType_1.DuckDBTimestampType.instance;
|
|
@@ -652,26 +947,43 @@ class DuckDBTimestampVector extends DuckDBVector {
|
|
|
652
947
|
return this.items.length;
|
|
653
948
|
}
|
|
654
949
|
getItem(itemIndex) {
|
|
655
|
-
return this.validity.itemValid(itemIndex)
|
|
950
|
+
return this.validity.itemValid(itemIndex)
|
|
951
|
+
? new values_1.DuckDBTimestampValue(this.items[itemIndex])
|
|
952
|
+
: null;
|
|
953
|
+
}
|
|
954
|
+
setItem(itemIndex, value) {
|
|
955
|
+
if (value != null) {
|
|
956
|
+
this.items[itemIndex] = value.micros;
|
|
957
|
+
this.validity.setItemValid(itemIndex, true);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
this.validity.setItemValid(itemIndex, false);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
flush() {
|
|
964
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
965
|
+
this.validity.flush(this.vector);
|
|
656
966
|
}
|
|
657
967
|
slice(offset, length) {
|
|
658
|
-
return new DuckDBTimestampVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
968
|
+
return new DuckDBTimestampVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
659
969
|
}
|
|
660
970
|
}
|
|
661
971
|
exports.DuckDBTimestampVector = DuckDBTimestampVector;
|
|
662
972
|
class DuckDBDateVector extends DuckDBVector {
|
|
663
973
|
items;
|
|
664
974
|
validity;
|
|
665
|
-
|
|
975
|
+
vector;
|
|
976
|
+
constructor(items, validity, vector) {
|
|
666
977
|
super();
|
|
667
978
|
this.items = items;
|
|
668
979
|
this.validity = validity;
|
|
980
|
+
this.vector = vector;
|
|
669
981
|
}
|
|
670
982
|
static fromRawVector(vector, itemCount) {
|
|
671
983
|
const data = vectorData(vector, itemCount * Int32Array.BYTES_PER_ELEMENT);
|
|
672
984
|
const items = new Int32Array(data.buffer, data.byteOffset, itemCount);
|
|
673
985
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
674
|
-
return new DuckDBDateVector(items, validity);
|
|
986
|
+
return new DuckDBDateVector(items, validity, vector);
|
|
675
987
|
}
|
|
676
988
|
get type() {
|
|
677
989
|
return DuckDBType_1.DuckDBDateType.instance;
|
|
@@ -680,26 +992,43 @@ class DuckDBDateVector extends DuckDBVector {
|
|
|
680
992
|
return this.items.length;
|
|
681
993
|
}
|
|
682
994
|
getItem(itemIndex) {
|
|
683
|
-
return this.validity.itemValid(itemIndex)
|
|
995
|
+
return this.validity.itemValid(itemIndex)
|
|
996
|
+
? new values_1.DuckDBDateValue(this.items[itemIndex])
|
|
997
|
+
: null;
|
|
998
|
+
}
|
|
999
|
+
setItem(itemIndex, value) {
|
|
1000
|
+
if (value != null) {
|
|
1001
|
+
this.items[itemIndex] = value.days;
|
|
1002
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
flush() {
|
|
1009
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1010
|
+
this.validity.flush(this.vector);
|
|
684
1011
|
}
|
|
685
1012
|
slice(offset, length) {
|
|
686
|
-
return new DuckDBDateVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1013
|
+
return new DuckDBDateVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
687
1014
|
}
|
|
688
1015
|
}
|
|
689
1016
|
exports.DuckDBDateVector = DuckDBDateVector;
|
|
690
1017
|
class DuckDBTimeVector extends DuckDBVector {
|
|
691
1018
|
items;
|
|
692
1019
|
validity;
|
|
693
|
-
|
|
1020
|
+
vector;
|
|
1021
|
+
constructor(items, validity, vector) {
|
|
694
1022
|
super();
|
|
695
1023
|
this.items = items;
|
|
696
1024
|
this.validity = validity;
|
|
1025
|
+
this.vector = vector;
|
|
697
1026
|
}
|
|
698
1027
|
static fromRawVector(vector, itemCount) {
|
|
699
1028
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
700
1029
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
701
1030
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
702
|
-
return new DuckDBTimeVector(items, validity);
|
|
1031
|
+
return new DuckDBTimeVector(items, validity, vector);
|
|
703
1032
|
}
|
|
704
1033
|
get type() {
|
|
705
1034
|
return DuckDBType_1.DuckDBTimeType.instance;
|
|
@@ -708,28 +1037,45 @@ class DuckDBTimeVector extends DuckDBVector {
|
|
|
708
1037
|
return this.items.length;
|
|
709
1038
|
}
|
|
710
1039
|
getItem(itemIndex) {
|
|
711
|
-
return this.validity.itemValid(itemIndex)
|
|
1040
|
+
return this.validity.itemValid(itemIndex)
|
|
1041
|
+
? new values_1.DuckDBTimeValue(this.items[itemIndex])
|
|
1042
|
+
: null;
|
|
1043
|
+
}
|
|
1044
|
+
setItem(itemIndex, value) {
|
|
1045
|
+
if (value != null) {
|
|
1046
|
+
this.items[itemIndex] = value.micros;
|
|
1047
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
flush() {
|
|
1054
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1055
|
+
this.validity.flush(this.vector);
|
|
712
1056
|
}
|
|
713
1057
|
slice(offset, length) {
|
|
714
|
-
return new DuckDBTimeVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1058
|
+
return new DuckDBTimeVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
715
1059
|
}
|
|
716
1060
|
}
|
|
717
1061
|
exports.DuckDBTimeVector = DuckDBTimeVector;
|
|
718
1062
|
class DuckDBIntervalVector extends DuckDBVector {
|
|
719
1063
|
dataView;
|
|
720
1064
|
validity;
|
|
1065
|
+
vector;
|
|
721
1066
|
_itemCount;
|
|
722
|
-
constructor(dataView, validity, itemCount) {
|
|
1067
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
723
1068
|
super();
|
|
724
1069
|
this.dataView = dataView;
|
|
725
1070
|
this.validity = validity;
|
|
1071
|
+
this.vector = vector;
|
|
726
1072
|
this._itemCount = itemCount;
|
|
727
1073
|
}
|
|
728
1074
|
static fromRawVector(vector, itemCount) {
|
|
729
1075
|
const data = vectorData(vector, itemCount * 16);
|
|
730
1076
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
731
1077
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
732
|
-
return new DuckDBIntervalVector(dataView, validity, itemCount);
|
|
1078
|
+
return new DuckDBIntervalVector(dataView, validity, vector, itemCount);
|
|
733
1079
|
}
|
|
734
1080
|
get type() {
|
|
735
1081
|
return DuckDBType_1.DuckDBIntervalType.instance;
|
|
@@ -747,26 +1093,44 @@ class DuckDBIntervalVector extends DuckDBVector {
|
|
|
747
1093
|
const micros = getInt64(this.dataView, itemStart + 8);
|
|
748
1094
|
return new values_1.DuckDBIntervalValue(months, days, micros);
|
|
749
1095
|
}
|
|
1096
|
+
setItem(itemIndex, value) {
|
|
1097
|
+
if (value != null) {
|
|
1098
|
+
const itemStart = itemIndex * 16;
|
|
1099
|
+
setInt32(this.dataView, itemStart, value.months);
|
|
1100
|
+
setInt32(this.dataView, itemStart + 4, value.days);
|
|
1101
|
+
setInt64(this.dataView, itemStart + 8, value.micros);
|
|
1102
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
flush() {
|
|
1109
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1110
|
+
this.validity.flush(this.vector);
|
|
1111
|
+
}
|
|
750
1112
|
slice(offset, length) {
|
|
751
|
-
return new DuckDBIntervalVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1113
|
+
return new DuckDBIntervalVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
752
1114
|
}
|
|
753
1115
|
}
|
|
754
1116
|
exports.DuckDBIntervalVector = DuckDBIntervalVector;
|
|
755
1117
|
class DuckDBHugeIntVector extends DuckDBVector {
|
|
756
1118
|
dataView;
|
|
757
1119
|
validity;
|
|
1120
|
+
vector;
|
|
758
1121
|
_itemCount;
|
|
759
|
-
constructor(dataView, validity, itemCount) {
|
|
1122
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
760
1123
|
super();
|
|
761
1124
|
this.dataView = dataView;
|
|
762
1125
|
this.validity = validity;
|
|
1126
|
+
this.vector = vector;
|
|
763
1127
|
this._itemCount = itemCount;
|
|
764
1128
|
}
|
|
765
1129
|
static fromRawVector(vector, itemCount) {
|
|
766
1130
|
const data = vectorData(vector, itemCount * 16);
|
|
767
1131
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
768
1132
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
769
|
-
return new DuckDBHugeIntVector(dataView, validity, itemCount);
|
|
1133
|
+
return new DuckDBHugeIntVector(dataView, validity, vector, itemCount);
|
|
770
1134
|
}
|
|
771
1135
|
get type() {
|
|
772
1136
|
return DuckDBType_1.DuckDBHugeIntType.instance;
|
|
@@ -775,33 +1139,50 @@ class DuckDBHugeIntVector extends DuckDBVector {
|
|
|
775
1139
|
return this._itemCount;
|
|
776
1140
|
}
|
|
777
1141
|
getItem(itemIndex) {
|
|
778
|
-
return this.validity.itemValid(itemIndex)
|
|
1142
|
+
return this.validity.itemValid(itemIndex)
|
|
1143
|
+
? getInt128(this.dataView, itemIndex * 16)
|
|
1144
|
+
: null;
|
|
779
1145
|
}
|
|
780
1146
|
getDouble(itemIndex) {
|
|
781
1147
|
return this.validity.itemValid(itemIndex)
|
|
782
1148
|
? node_bindings_1.default.hugeint_to_double(getInt128(this.dataView, itemIndex * 16))
|
|
783
1149
|
: null;
|
|
784
1150
|
}
|
|
1151
|
+
setItem(itemIndex, value) {
|
|
1152
|
+
if (value != null) {
|
|
1153
|
+
setInt128(this.dataView, itemIndex * 16, value);
|
|
1154
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
flush() {
|
|
1161
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1162
|
+
this.validity.flush(this.vector);
|
|
1163
|
+
}
|
|
785
1164
|
slice(offset, length) {
|
|
786
|
-
return new DuckDBHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1165
|
+
return new DuckDBHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
787
1166
|
}
|
|
788
1167
|
}
|
|
789
1168
|
exports.DuckDBHugeIntVector = DuckDBHugeIntVector;
|
|
790
1169
|
class DuckDBUHugeIntVector extends DuckDBVector {
|
|
791
1170
|
dataView;
|
|
792
1171
|
validity;
|
|
1172
|
+
vector;
|
|
793
1173
|
_itemCount;
|
|
794
|
-
constructor(dataView, validity, itemCount) {
|
|
1174
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
795
1175
|
super();
|
|
796
1176
|
this.dataView = dataView;
|
|
797
1177
|
this.validity = validity;
|
|
1178
|
+
this.vector = vector;
|
|
798
1179
|
this._itemCount = itemCount;
|
|
799
1180
|
}
|
|
800
1181
|
static fromRawVector(vector, itemCount) {
|
|
801
1182
|
const data = vectorData(vector, itemCount * 16);
|
|
802
1183
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
803
1184
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
804
|
-
return new DuckDBUHugeIntVector(dataView, validity, itemCount);
|
|
1185
|
+
return new DuckDBUHugeIntVector(dataView, validity, vector, itemCount);
|
|
805
1186
|
}
|
|
806
1187
|
get type() {
|
|
807
1188
|
return DuckDBType_1.DuckDBUHugeIntType.instance;
|
|
@@ -810,33 +1191,56 @@ class DuckDBUHugeIntVector extends DuckDBVector {
|
|
|
810
1191
|
return this._itemCount;
|
|
811
1192
|
}
|
|
812
1193
|
getItem(itemIndex) {
|
|
813
|
-
return this.validity.itemValid(itemIndex)
|
|
1194
|
+
return this.validity.itemValid(itemIndex)
|
|
1195
|
+
? getUInt128(this.dataView, itemIndex * 16)
|
|
1196
|
+
: null;
|
|
814
1197
|
}
|
|
815
1198
|
getDouble(itemIndex) {
|
|
816
1199
|
return this.validity.itemValid(itemIndex)
|
|
817
1200
|
? node_bindings_1.default.uhugeint_to_double(getUInt128(this.dataView, itemIndex * 16))
|
|
818
1201
|
: null;
|
|
819
1202
|
}
|
|
1203
|
+
setItem(itemIndex, value) {
|
|
1204
|
+
if (value != null) {
|
|
1205
|
+
setUInt128(this.dataView, itemIndex * 16, value);
|
|
1206
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
flush() {
|
|
1213
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1214
|
+
this.validity.flush(this.vector);
|
|
1215
|
+
}
|
|
820
1216
|
slice(offset, length) {
|
|
821
|
-
return new DuckDBUHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1217
|
+
return new DuckDBUHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
822
1218
|
}
|
|
823
1219
|
}
|
|
824
1220
|
exports.DuckDBUHugeIntVector = DuckDBUHugeIntVector;
|
|
825
1221
|
class DuckDBVarCharVector extends DuckDBVector {
|
|
826
1222
|
dataView;
|
|
827
1223
|
validity;
|
|
1224
|
+
vector;
|
|
1225
|
+
itemOffset;
|
|
828
1226
|
_itemCount;
|
|
829
|
-
|
|
1227
|
+
itemCache;
|
|
1228
|
+
itemCacheDirty;
|
|
1229
|
+
constructor(dataView, validity, vector, itemOffset, itemCount) {
|
|
830
1230
|
super();
|
|
831
1231
|
this.dataView = dataView;
|
|
832
1232
|
this.validity = validity;
|
|
1233
|
+
this.vector = vector;
|
|
1234
|
+
this.itemOffset = itemOffset;
|
|
833
1235
|
this._itemCount = itemCount;
|
|
1236
|
+
this.itemCache = [];
|
|
1237
|
+
this.itemCacheDirty = [];
|
|
834
1238
|
}
|
|
835
1239
|
static fromRawVector(vector, itemCount) {
|
|
836
1240
|
const data = vectorData(vector, itemCount * 16);
|
|
837
1241
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
838
1242
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
839
|
-
return new DuckDBVarCharVector(dataView, validity, itemCount);
|
|
1243
|
+
return new DuckDBVarCharVector(dataView, validity, vector, 0, itemCount);
|
|
840
1244
|
}
|
|
841
1245
|
get type() {
|
|
842
1246
|
return DuckDBType_1.DuckDBVarCharType.instance;
|
|
@@ -845,28 +1249,61 @@ class DuckDBVarCharVector extends DuckDBVector {
|
|
|
845
1249
|
return this._itemCount;
|
|
846
1250
|
}
|
|
847
1251
|
getItem(itemIndex) {
|
|
848
|
-
|
|
1252
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
1253
|
+
if (cachedItem !== undefined) {
|
|
1254
|
+
return cachedItem;
|
|
1255
|
+
}
|
|
1256
|
+
const item = this.validity.itemValid(itemIndex)
|
|
1257
|
+
? getString(this.dataView, itemIndex * 16)
|
|
1258
|
+
: null;
|
|
1259
|
+
this.itemCache[itemIndex] = item;
|
|
1260
|
+
return item;
|
|
1261
|
+
}
|
|
1262
|
+
setItem(itemIndex, value) {
|
|
1263
|
+
this.itemCache[itemIndex] = value;
|
|
1264
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
1265
|
+
this.itemCacheDirty[itemIndex] = true;
|
|
1266
|
+
}
|
|
1267
|
+
flush() {
|
|
1268
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
1269
|
+
if (this.itemCacheDirty[itemIndex]) {
|
|
1270
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
1271
|
+
if (cachedItem !== undefined && cachedItem !== null) {
|
|
1272
|
+
node_bindings_1.default.vector_assign_string_element(this.vector, this.itemOffset + itemIndex, cachedItem);
|
|
1273
|
+
}
|
|
1274
|
+
this.itemCacheDirty[itemIndex] = false;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
this.validity.flush(this.vector);
|
|
849
1278
|
}
|
|
850
1279
|
slice(offset, length) {
|
|
851
|
-
return new DuckDBVarCharVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1280
|
+
return new DuckDBVarCharVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
852
1281
|
}
|
|
853
1282
|
}
|
|
854
1283
|
exports.DuckDBVarCharVector = DuckDBVarCharVector;
|
|
855
1284
|
class DuckDBBlobVector extends DuckDBVector {
|
|
856
1285
|
dataView;
|
|
857
1286
|
validity;
|
|
1287
|
+
vector;
|
|
1288
|
+
itemOffset;
|
|
858
1289
|
_itemCount;
|
|
859
|
-
|
|
1290
|
+
itemCache;
|
|
1291
|
+
itemCacheDirty;
|
|
1292
|
+
constructor(dataView, validity, vector, itemOffset, itemCount) {
|
|
860
1293
|
super();
|
|
861
1294
|
this.dataView = dataView;
|
|
862
1295
|
this.validity = validity;
|
|
1296
|
+
this.vector = vector;
|
|
1297
|
+
this.itemOffset = itemOffset;
|
|
863
1298
|
this._itemCount = itemCount;
|
|
1299
|
+
this.itemCache = [];
|
|
1300
|
+
this.itemCacheDirty = [];
|
|
864
1301
|
}
|
|
865
1302
|
static fromRawVector(vector, itemCount) {
|
|
866
1303
|
const data = vectorData(vector, itemCount * 16);
|
|
867
1304
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
868
1305
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
869
|
-
return new DuckDBBlobVector(dataView, validity, itemCount);
|
|
1306
|
+
return new DuckDBBlobVector(dataView, validity, vector, 0, itemCount);
|
|
870
1307
|
}
|
|
871
1308
|
get type() {
|
|
872
1309
|
return DuckDBType_1.DuckDBBlobType.instance;
|
|
@@ -875,30 +1312,51 @@ class DuckDBBlobVector extends DuckDBVector {
|
|
|
875
1312
|
return this._itemCount;
|
|
876
1313
|
}
|
|
877
1314
|
getItem(itemIndex) {
|
|
878
|
-
return this.validity.itemValid(itemIndex)
|
|
1315
|
+
return this.validity.itemValid(itemIndex)
|
|
1316
|
+
? new values_1.DuckDBBlobValue(getBuffer(this.dataView, itemIndex * 16))
|
|
1317
|
+
: null;
|
|
1318
|
+
}
|
|
1319
|
+
setItem(itemIndex, value) {
|
|
1320
|
+
this.itemCache[itemIndex] = value;
|
|
1321
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
1322
|
+
this.itemCacheDirty[itemIndex] = true;
|
|
1323
|
+
}
|
|
1324
|
+
flush() {
|
|
1325
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
1326
|
+
if (this.itemCacheDirty[itemIndex]) {
|
|
1327
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
1328
|
+
if (cachedItem !== undefined && cachedItem !== null) {
|
|
1329
|
+
node_bindings_1.default.vector_assign_string_element_len(this.vector, this.itemOffset + itemIndex, cachedItem.bytes);
|
|
1330
|
+
}
|
|
1331
|
+
this.itemCacheDirty[itemIndex] = false;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
this.validity.flush(this.vector);
|
|
879
1335
|
}
|
|
880
1336
|
slice(offset, length) {
|
|
881
|
-
return new DuckDBBlobVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1337
|
+
return new DuckDBBlobVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
882
1338
|
}
|
|
883
1339
|
}
|
|
884
1340
|
exports.DuckDBBlobVector = DuckDBBlobVector;
|
|
885
|
-
class
|
|
1341
|
+
class DuckDBDecimal16Vector extends DuckDBVector {
|
|
886
1342
|
decimalType;
|
|
887
1343
|
dataView;
|
|
888
1344
|
validity;
|
|
1345
|
+
vector;
|
|
889
1346
|
_itemCount;
|
|
890
|
-
constructor(decimalType, dataView, validity, itemCount) {
|
|
1347
|
+
constructor(decimalType, dataView, validity, vector, itemCount) {
|
|
891
1348
|
super();
|
|
892
1349
|
this.decimalType = decimalType;
|
|
893
1350
|
this.dataView = dataView;
|
|
894
1351
|
this.validity = validity;
|
|
1352
|
+
this.vector = vector;
|
|
895
1353
|
this._itemCount = itemCount;
|
|
896
1354
|
}
|
|
897
1355
|
static fromRawVector(decimalType, vector, itemCount) {
|
|
898
1356
|
const data = vectorData(vector, itemCount * 2);
|
|
899
1357
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
900
1358
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
901
|
-
return new
|
|
1359
|
+
return new DuckDBDecimal16Vector(decimalType, dataView, validity, vector, itemCount);
|
|
902
1360
|
}
|
|
903
1361
|
get type() {
|
|
904
1362
|
return this.decimalType;
|
|
@@ -907,33 +1365,52 @@ class DuckDBDecimal2Vector extends DuckDBVector {
|
|
|
907
1365
|
return this._itemCount;
|
|
908
1366
|
}
|
|
909
1367
|
getItem(itemIndex) {
|
|
910
|
-
return this.validity.itemValid(itemIndex)
|
|
1368
|
+
return this.validity.itemValid(itemIndex)
|
|
1369
|
+
? getDecimal16(this.dataView, itemIndex * 2, this.decimalType)
|
|
1370
|
+
: null;
|
|
911
1371
|
}
|
|
912
1372
|
getScaledValue(itemIndex) {
|
|
913
|
-
return this.validity.itemValid(itemIndex)
|
|
1373
|
+
return this.validity.itemValid(itemIndex)
|
|
1374
|
+
? getInt16(this.dataView, itemIndex * 2)
|
|
1375
|
+
: null;
|
|
1376
|
+
}
|
|
1377
|
+
setItem(itemIndex, value) {
|
|
1378
|
+
if (value != null) {
|
|
1379
|
+
setInt16(this.dataView, itemIndex * 2, Number(value.value));
|
|
1380
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1381
|
+
}
|
|
1382
|
+
else {
|
|
1383
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
flush() {
|
|
1387
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1388
|
+
this.validity.flush(this.vector);
|
|
914
1389
|
}
|
|
915
1390
|
slice(offset, length) {
|
|
916
|
-
return new
|
|
1391
|
+
return new DuckDBDecimal16Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 2, length * 2), this.validity.slice(offset, length), this.vector, length);
|
|
917
1392
|
}
|
|
918
1393
|
}
|
|
919
|
-
exports.
|
|
920
|
-
class
|
|
1394
|
+
exports.DuckDBDecimal16Vector = DuckDBDecimal16Vector;
|
|
1395
|
+
class DuckDBDecimal32Vector extends DuckDBVector {
|
|
921
1396
|
decimalType;
|
|
922
1397
|
dataView;
|
|
923
1398
|
validity;
|
|
1399
|
+
vector;
|
|
924
1400
|
_itemCount;
|
|
925
|
-
constructor(decimalType, dataView, validity, itemCount) {
|
|
1401
|
+
constructor(decimalType, dataView, validity, vector, itemCount) {
|
|
926
1402
|
super();
|
|
927
1403
|
this.decimalType = decimalType;
|
|
928
1404
|
this.dataView = dataView;
|
|
929
1405
|
this.validity = validity;
|
|
1406
|
+
this.vector = vector;
|
|
930
1407
|
this._itemCount = itemCount;
|
|
931
1408
|
}
|
|
932
1409
|
static fromRawVector(decimalType, vector, itemCount) {
|
|
933
1410
|
const data = vectorData(vector, itemCount * 4);
|
|
934
1411
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
935
1412
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
936
|
-
return new
|
|
1413
|
+
return new DuckDBDecimal32Vector(decimalType, dataView, validity, vector, itemCount);
|
|
937
1414
|
}
|
|
938
1415
|
get type() {
|
|
939
1416
|
return this.decimalType;
|
|
@@ -942,33 +1419,52 @@ class DuckDBDecimal4Vector extends DuckDBVector {
|
|
|
942
1419
|
return this._itemCount;
|
|
943
1420
|
}
|
|
944
1421
|
getItem(itemIndex) {
|
|
945
|
-
return this.validity.itemValid(itemIndex)
|
|
1422
|
+
return this.validity.itemValid(itemIndex)
|
|
1423
|
+
? getDecimal32(this.dataView, itemIndex * 4, this.decimalType)
|
|
1424
|
+
: null;
|
|
946
1425
|
}
|
|
947
1426
|
getScaledValue(itemIndex) {
|
|
948
|
-
return this.validity.itemValid(itemIndex)
|
|
1427
|
+
return this.validity.itemValid(itemIndex)
|
|
1428
|
+
? getInt32(this.dataView, itemIndex * 4)
|
|
1429
|
+
: null;
|
|
1430
|
+
}
|
|
1431
|
+
setItem(itemIndex, value) {
|
|
1432
|
+
if (value != null) {
|
|
1433
|
+
setInt32(this.dataView, itemIndex * 4, Number(value.value));
|
|
1434
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1435
|
+
}
|
|
1436
|
+
else {
|
|
1437
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
flush() {
|
|
1441
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1442
|
+
this.validity.flush(this.vector);
|
|
949
1443
|
}
|
|
950
1444
|
slice(offset, length) {
|
|
951
|
-
return new
|
|
1445
|
+
return new DuckDBDecimal32Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 4, length * 4), this.validity.slice(offset, length), this.vector, length);
|
|
952
1446
|
}
|
|
953
1447
|
}
|
|
954
|
-
exports.
|
|
955
|
-
class
|
|
1448
|
+
exports.DuckDBDecimal32Vector = DuckDBDecimal32Vector;
|
|
1449
|
+
class DuckDBDecimal64Vector extends DuckDBVector {
|
|
956
1450
|
decimalType;
|
|
957
1451
|
dataView;
|
|
958
1452
|
validity;
|
|
1453
|
+
vector;
|
|
959
1454
|
_itemCount;
|
|
960
|
-
constructor(decimalType, dataView, validity, itemCount) {
|
|
1455
|
+
constructor(decimalType, dataView, validity, vector, itemCount) {
|
|
961
1456
|
super();
|
|
962
1457
|
this.decimalType = decimalType;
|
|
963
1458
|
this.dataView = dataView;
|
|
964
1459
|
this.validity = validity;
|
|
1460
|
+
this.vector = vector;
|
|
965
1461
|
this._itemCount = itemCount;
|
|
966
1462
|
}
|
|
967
1463
|
static fromRawVector(decimalType, vector, itemCount) {
|
|
968
1464
|
const data = vectorData(vector, itemCount * 8);
|
|
969
1465
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
970
1466
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
971
|
-
return new
|
|
1467
|
+
return new DuckDBDecimal64Vector(decimalType, dataView, validity, vector, itemCount);
|
|
972
1468
|
}
|
|
973
1469
|
get type() {
|
|
974
1470
|
return this.decimalType;
|
|
@@ -977,33 +1473,52 @@ class DuckDBDecimal8Vector extends DuckDBVector {
|
|
|
977
1473
|
return this._itemCount;
|
|
978
1474
|
}
|
|
979
1475
|
getItem(itemIndex) {
|
|
980
|
-
return this.validity.itemValid(itemIndex)
|
|
1476
|
+
return this.validity.itemValid(itemIndex)
|
|
1477
|
+
? getDecimal64(this.dataView, itemIndex * 8, this.decimalType)
|
|
1478
|
+
: null;
|
|
981
1479
|
}
|
|
982
1480
|
getScaledValue(itemIndex) {
|
|
983
|
-
return this.validity.itemValid(itemIndex)
|
|
1481
|
+
return this.validity.itemValid(itemIndex)
|
|
1482
|
+
? getInt64(this.dataView, itemIndex * 8)
|
|
1483
|
+
: null;
|
|
1484
|
+
}
|
|
1485
|
+
setItem(itemIndex, value) {
|
|
1486
|
+
if (value != null) {
|
|
1487
|
+
setInt64(this.dataView, itemIndex * 8, value.value);
|
|
1488
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1489
|
+
}
|
|
1490
|
+
else {
|
|
1491
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
flush() {
|
|
1495
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1496
|
+
this.validity.flush(this.vector);
|
|
984
1497
|
}
|
|
985
1498
|
slice(offset, length) {
|
|
986
|
-
return new
|
|
1499
|
+
return new DuckDBDecimal64Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 8, length * 8), this.validity.slice(offset, length), this.vector, length);
|
|
987
1500
|
}
|
|
988
1501
|
}
|
|
989
|
-
exports.
|
|
990
|
-
class
|
|
1502
|
+
exports.DuckDBDecimal64Vector = DuckDBDecimal64Vector;
|
|
1503
|
+
class DuckDBDecimal128Vector extends DuckDBVector {
|
|
991
1504
|
decimalType;
|
|
992
1505
|
dataView;
|
|
993
1506
|
validity;
|
|
1507
|
+
vector;
|
|
994
1508
|
_itemCount;
|
|
995
|
-
constructor(decimalType, dataView, validity, itemCount) {
|
|
1509
|
+
constructor(decimalType, dataView, validity, vector, itemCount) {
|
|
996
1510
|
super();
|
|
997
1511
|
this.decimalType = decimalType;
|
|
998
1512
|
this.dataView = dataView;
|
|
999
1513
|
this.validity = validity;
|
|
1514
|
+
this.vector = vector;
|
|
1000
1515
|
this._itemCount = itemCount;
|
|
1001
1516
|
}
|
|
1002
1517
|
static fromRawVector(decimalType, vector, itemCount) {
|
|
1003
1518
|
const data = vectorData(vector, itemCount * 16);
|
|
1004
1519
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1005
1520
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1006
|
-
return new
|
|
1521
|
+
return new DuckDBDecimal128Vector(decimalType, dataView, validity, vector, itemCount);
|
|
1007
1522
|
}
|
|
1008
1523
|
get type() {
|
|
1009
1524
|
return this.decimalType;
|
|
@@ -1012,29 +1527,48 @@ class DuckDBDecimal16Vector extends DuckDBVector {
|
|
|
1012
1527
|
return this._itemCount;
|
|
1013
1528
|
}
|
|
1014
1529
|
getItem(itemIndex) {
|
|
1015
|
-
return this.validity.itemValid(itemIndex)
|
|
1530
|
+
return this.validity.itemValid(itemIndex)
|
|
1531
|
+
? getDecimal128(this.dataView, itemIndex * 16, this.decimalType)
|
|
1532
|
+
: null;
|
|
1016
1533
|
}
|
|
1017
1534
|
getScaledValue(itemIndex) {
|
|
1018
|
-
return this.validity.itemValid(itemIndex)
|
|
1535
|
+
return this.validity.itemValid(itemIndex)
|
|
1536
|
+
? getInt128(this.dataView, itemIndex * 16)
|
|
1537
|
+
: null;
|
|
1538
|
+
}
|
|
1539
|
+
setItem(itemIndex, value) {
|
|
1540
|
+
if (value != null) {
|
|
1541
|
+
setInt128(this.dataView, itemIndex * 16, value.value);
|
|
1542
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1543
|
+
}
|
|
1544
|
+
else {
|
|
1545
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
flush() {
|
|
1549
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
1550
|
+
this.validity.flush(this.vector);
|
|
1019
1551
|
}
|
|
1020
1552
|
slice(offset, length) {
|
|
1021
|
-
return new
|
|
1553
|
+
return new DuckDBDecimal128Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
1022
1554
|
}
|
|
1023
1555
|
}
|
|
1024
|
-
exports.
|
|
1556
|
+
exports.DuckDBDecimal128Vector = DuckDBDecimal128Vector;
|
|
1025
1557
|
class DuckDBTimestampSecondsVector extends DuckDBVector {
|
|
1026
1558
|
items;
|
|
1027
1559
|
validity;
|
|
1028
|
-
|
|
1560
|
+
vector;
|
|
1561
|
+
constructor(items, validity, vector) {
|
|
1029
1562
|
super();
|
|
1030
1563
|
this.items = items;
|
|
1031
1564
|
this.validity = validity;
|
|
1565
|
+
this.vector = vector;
|
|
1032
1566
|
}
|
|
1033
1567
|
static fromRawVector(vector, itemCount) {
|
|
1034
1568
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1035
1569
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1036
1570
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1037
|
-
return new DuckDBTimestampSecondsVector(items, validity);
|
|
1571
|
+
return new DuckDBTimestampSecondsVector(items, validity, vector);
|
|
1038
1572
|
}
|
|
1039
1573
|
get type() {
|
|
1040
1574
|
return DuckDBType_1.DuckDBTimestampSecondsType.instance;
|
|
@@ -1043,26 +1577,43 @@ class DuckDBTimestampSecondsVector extends DuckDBVector {
|
|
|
1043
1577
|
return this.items.length;
|
|
1044
1578
|
}
|
|
1045
1579
|
getItem(itemIndex) {
|
|
1046
|
-
return this.validity.itemValid(itemIndex)
|
|
1580
|
+
return this.validity.itemValid(itemIndex)
|
|
1581
|
+
? new values_1.DuckDBTimestampSecondsValue(this.items[itemIndex])
|
|
1582
|
+
: null;
|
|
1583
|
+
}
|
|
1584
|
+
setItem(itemIndex, value) {
|
|
1585
|
+
if (value != null) {
|
|
1586
|
+
this.items[itemIndex] = value.seconds;
|
|
1587
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
flush() {
|
|
1594
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1595
|
+
this.validity.flush(this.vector);
|
|
1047
1596
|
}
|
|
1048
1597
|
slice(offset, length) {
|
|
1049
|
-
return new DuckDBTimestampSecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1598
|
+
return new DuckDBTimestampSecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1050
1599
|
}
|
|
1051
1600
|
}
|
|
1052
1601
|
exports.DuckDBTimestampSecondsVector = DuckDBTimestampSecondsVector;
|
|
1053
1602
|
class DuckDBTimestampMillisecondsVector extends DuckDBVector {
|
|
1054
1603
|
items;
|
|
1055
1604
|
validity;
|
|
1056
|
-
|
|
1605
|
+
vector;
|
|
1606
|
+
constructor(items, validity, vector) {
|
|
1057
1607
|
super();
|
|
1058
1608
|
this.items = items;
|
|
1059
1609
|
this.validity = validity;
|
|
1610
|
+
this.vector = vector;
|
|
1060
1611
|
}
|
|
1061
1612
|
static fromRawVector(vector, itemCount) {
|
|
1062
1613
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1063
1614
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1064
1615
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1065
|
-
return new DuckDBTimestampMillisecondsVector(items, validity);
|
|
1616
|
+
return new DuckDBTimestampMillisecondsVector(items, validity, vector);
|
|
1066
1617
|
}
|
|
1067
1618
|
get type() {
|
|
1068
1619
|
return DuckDBType_1.DuckDBTimestampMillisecondsType.instance;
|
|
@@ -1071,26 +1622,43 @@ class DuckDBTimestampMillisecondsVector extends DuckDBVector {
|
|
|
1071
1622
|
return this.items.length;
|
|
1072
1623
|
}
|
|
1073
1624
|
getItem(itemIndex) {
|
|
1074
|
-
return this.validity.itemValid(itemIndex)
|
|
1625
|
+
return this.validity.itemValid(itemIndex)
|
|
1626
|
+
? new values_1.DuckDBTimestampMillisecondsValue(this.items[itemIndex])
|
|
1627
|
+
: null;
|
|
1628
|
+
}
|
|
1629
|
+
setItem(itemIndex, value) {
|
|
1630
|
+
if (value != null) {
|
|
1631
|
+
this.items[itemIndex] = value.milliseconds;
|
|
1632
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1633
|
+
}
|
|
1634
|
+
else {
|
|
1635
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
flush() {
|
|
1639
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1640
|
+
this.validity.flush(this.vector);
|
|
1075
1641
|
}
|
|
1076
1642
|
slice(offset, length) {
|
|
1077
|
-
return new DuckDBTimestampMillisecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1643
|
+
return new DuckDBTimestampMillisecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1078
1644
|
}
|
|
1079
1645
|
}
|
|
1080
1646
|
exports.DuckDBTimestampMillisecondsVector = DuckDBTimestampMillisecondsVector;
|
|
1081
1647
|
class DuckDBTimestampNanosecondsVector extends DuckDBVector {
|
|
1082
1648
|
items;
|
|
1083
1649
|
validity;
|
|
1084
|
-
|
|
1650
|
+
vector;
|
|
1651
|
+
constructor(items, validity, vector) {
|
|
1085
1652
|
super();
|
|
1086
1653
|
this.items = items;
|
|
1087
1654
|
this.validity = validity;
|
|
1655
|
+
this.vector = vector;
|
|
1088
1656
|
}
|
|
1089
1657
|
static fromRawVector(vector, itemCount) {
|
|
1090
1658
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1091
1659
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1092
1660
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1093
|
-
return new DuckDBTimestampNanosecondsVector(items, validity);
|
|
1661
|
+
return new DuckDBTimestampNanosecondsVector(items, validity, vector);
|
|
1094
1662
|
}
|
|
1095
1663
|
get type() {
|
|
1096
1664
|
return DuckDBType_1.DuckDBTimestampNanosecondsType.instance;
|
|
@@ -1099,28 +1667,45 @@ class DuckDBTimestampNanosecondsVector extends DuckDBVector {
|
|
|
1099
1667
|
return this.items.length;
|
|
1100
1668
|
}
|
|
1101
1669
|
getItem(itemIndex) {
|
|
1102
|
-
return this.validity.itemValid(itemIndex)
|
|
1670
|
+
return this.validity.itemValid(itemIndex)
|
|
1671
|
+
? new values_1.DuckDBTimestampNanosecondsValue(this.items[itemIndex])
|
|
1672
|
+
: null;
|
|
1673
|
+
}
|
|
1674
|
+
setItem(itemIndex, value) {
|
|
1675
|
+
if (value != null) {
|
|
1676
|
+
this.items[itemIndex] = value.nanoseconds;
|
|
1677
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
flush() {
|
|
1684
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1685
|
+
this.validity.flush(this.vector);
|
|
1103
1686
|
}
|
|
1104
1687
|
slice(offset, length) {
|
|
1105
|
-
return new DuckDBTimestampNanosecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1688
|
+
return new DuckDBTimestampNanosecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1106
1689
|
}
|
|
1107
1690
|
}
|
|
1108
1691
|
exports.DuckDBTimestampNanosecondsVector = DuckDBTimestampNanosecondsVector;
|
|
1109
|
-
class
|
|
1692
|
+
class DuckDBEnum8Vector extends DuckDBVector {
|
|
1110
1693
|
enumType;
|
|
1111
1694
|
items;
|
|
1112
1695
|
validity;
|
|
1113
|
-
|
|
1696
|
+
vector;
|
|
1697
|
+
constructor(enumType, items, validity, vector) {
|
|
1114
1698
|
super();
|
|
1115
1699
|
this.enumType = enumType;
|
|
1116
1700
|
this.items = items;
|
|
1117
1701
|
this.validity = validity;
|
|
1702
|
+
this.vector = vector;
|
|
1118
1703
|
}
|
|
1119
1704
|
static fromRawVector(enumType, vector, itemCount) {
|
|
1120
1705
|
const data = vectorData(vector, itemCount);
|
|
1121
1706
|
const items = new Uint8Array(data.buffer, data.byteOffset, itemCount);
|
|
1122
1707
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1123
|
-
return new
|
|
1708
|
+
return new DuckDBEnum8Vector(enumType, items, validity, vector);
|
|
1124
1709
|
}
|
|
1125
1710
|
get type() {
|
|
1126
1711
|
return this.enumType;
|
|
@@ -1129,28 +1714,45 @@ class DuckDBEnum1Vector extends DuckDBVector {
|
|
|
1129
1714
|
return this.items.length;
|
|
1130
1715
|
}
|
|
1131
1716
|
getItem(itemIndex) {
|
|
1132
|
-
return this.validity.itemValid(itemIndex)
|
|
1717
|
+
return this.validity.itemValid(itemIndex)
|
|
1718
|
+
? this.enumType.values[this.items[itemIndex]]
|
|
1719
|
+
: null;
|
|
1720
|
+
}
|
|
1721
|
+
setItem(itemIndex, value) {
|
|
1722
|
+
if (value != null) {
|
|
1723
|
+
this.items[itemIndex] = this.enumType.indexForValue(value);
|
|
1724
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1725
|
+
}
|
|
1726
|
+
else {
|
|
1727
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
flush() {
|
|
1731
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1732
|
+
this.validity.flush(this.vector);
|
|
1133
1733
|
}
|
|
1134
1734
|
slice(offset, length) {
|
|
1135
|
-
return new
|
|
1735
|
+
return new DuckDBEnum8Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1136
1736
|
}
|
|
1137
1737
|
}
|
|
1138
|
-
exports.
|
|
1139
|
-
class
|
|
1738
|
+
exports.DuckDBEnum8Vector = DuckDBEnum8Vector;
|
|
1739
|
+
class DuckDBEnum16Vector extends DuckDBVector {
|
|
1140
1740
|
enumType;
|
|
1141
1741
|
items;
|
|
1142
1742
|
validity;
|
|
1143
|
-
|
|
1743
|
+
vector;
|
|
1744
|
+
constructor(enumType, items, validity, vector) {
|
|
1144
1745
|
super();
|
|
1145
1746
|
this.enumType = enumType;
|
|
1146
1747
|
this.items = items;
|
|
1147
1748
|
this.validity = validity;
|
|
1749
|
+
this.vector = vector;
|
|
1148
1750
|
}
|
|
1149
1751
|
static fromRawVector(enumType, vector, itemCount) {
|
|
1150
1752
|
const data = vectorData(vector, itemCount * 2);
|
|
1151
1753
|
const items = new Uint16Array(data.buffer, data.byteOffset, itemCount);
|
|
1152
1754
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1153
|
-
return new
|
|
1755
|
+
return new DuckDBEnum16Vector(enumType, items, validity, vector);
|
|
1154
1756
|
}
|
|
1155
1757
|
get type() {
|
|
1156
1758
|
return this.enumType;
|
|
@@ -1159,28 +1761,45 @@ class DuckDBEnum2Vector extends DuckDBVector {
|
|
|
1159
1761
|
return this.items.length;
|
|
1160
1762
|
}
|
|
1161
1763
|
getItem(itemIndex) {
|
|
1162
|
-
return this.validity.itemValid(itemIndex)
|
|
1764
|
+
return this.validity.itemValid(itemIndex)
|
|
1765
|
+
? this.enumType.values[this.items[itemIndex]]
|
|
1766
|
+
: null;
|
|
1767
|
+
}
|
|
1768
|
+
setItem(itemIndex, value) {
|
|
1769
|
+
if (value != null) {
|
|
1770
|
+
this.items[itemIndex] = this.enumType.indexForValue(value);
|
|
1771
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1772
|
+
}
|
|
1773
|
+
else {
|
|
1774
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
flush() {
|
|
1778
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1779
|
+
this.validity.flush(this.vector);
|
|
1163
1780
|
}
|
|
1164
1781
|
slice(offset, length) {
|
|
1165
|
-
return new
|
|
1782
|
+
return new DuckDBEnum16Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1166
1783
|
}
|
|
1167
1784
|
}
|
|
1168
|
-
exports.
|
|
1169
|
-
class
|
|
1785
|
+
exports.DuckDBEnum16Vector = DuckDBEnum16Vector;
|
|
1786
|
+
class DuckDBEnum32Vector extends DuckDBVector {
|
|
1170
1787
|
enumType;
|
|
1171
1788
|
items;
|
|
1172
1789
|
validity;
|
|
1173
|
-
|
|
1790
|
+
vector;
|
|
1791
|
+
constructor(enumType, items, validity, vector) {
|
|
1174
1792
|
super();
|
|
1175
1793
|
this.enumType = enumType;
|
|
1176
1794
|
this.items = items;
|
|
1177
1795
|
this.validity = validity;
|
|
1796
|
+
this.vector = vector;
|
|
1178
1797
|
}
|
|
1179
1798
|
static fromRawVector(enumType, vector, itemCount) {
|
|
1180
1799
|
const data = vectorData(vector, itemCount * 4);
|
|
1181
1800
|
const items = new Uint32Array(data.buffer, data.byteOffset, itemCount);
|
|
1182
1801
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1183
|
-
return new
|
|
1802
|
+
return new DuckDBEnum32Vector(enumType, items, validity, vector);
|
|
1184
1803
|
}
|
|
1185
1804
|
get type() {
|
|
1186
1805
|
return this.enumType;
|
|
@@ -1189,26 +1808,49 @@ class DuckDBEnum4Vector extends DuckDBVector {
|
|
|
1189
1808
|
return this.items.length;
|
|
1190
1809
|
}
|
|
1191
1810
|
getItem(itemIndex) {
|
|
1192
|
-
return this.validity.itemValid(itemIndex)
|
|
1811
|
+
return this.validity.itemValid(itemIndex)
|
|
1812
|
+
? this.enumType.values[this.items[itemIndex]]
|
|
1813
|
+
: null;
|
|
1814
|
+
}
|
|
1815
|
+
setItem(itemIndex, value) {
|
|
1816
|
+
if (value != null) {
|
|
1817
|
+
this.items[itemIndex] = this.enumType.indexForValue(value);
|
|
1818
|
+
this.validity.setItemValid(itemIndex, true);
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1821
|
+
this.validity.setItemValid(itemIndex, false);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
flush() {
|
|
1825
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
1826
|
+
this.validity.flush(this.vector);
|
|
1193
1827
|
}
|
|
1194
1828
|
slice(offset, length) {
|
|
1195
|
-
return new
|
|
1829
|
+
return new DuckDBEnum32Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1196
1830
|
}
|
|
1197
1831
|
}
|
|
1198
|
-
exports.
|
|
1832
|
+
exports.DuckDBEnum32Vector = DuckDBEnum32Vector;
|
|
1199
1833
|
class DuckDBListVector extends DuckDBVector {
|
|
1834
|
+
parentList;
|
|
1200
1835
|
listType;
|
|
1201
1836
|
entryData;
|
|
1202
1837
|
validity;
|
|
1838
|
+
vector;
|
|
1203
1839
|
childData;
|
|
1840
|
+
itemOffset;
|
|
1204
1841
|
_itemCount;
|
|
1205
|
-
|
|
1842
|
+
itemCache;
|
|
1843
|
+
constructor(parentList, listType, entryData, validity, vector, childData, itemOffset, itemCount) {
|
|
1206
1844
|
super();
|
|
1845
|
+
this.parentList = parentList;
|
|
1207
1846
|
this.listType = listType;
|
|
1208
1847
|
this.entryData = entryData;
|
|
1209
1848
|
this.validity = validity;
|
|
1849
|
+
this.vector = vector;
|
|
1210
1850
|
this.childData = childData;
|
|
1211
|
-
this.
|
|
1851
|
+
this.itemOffset = itemOffset,
|
|
1852
|
+
this._itemCount = itemCount;
|
|
1853
|
+
this.itemCache = [];
|
|
1212
1854
|
}
|
|
1213
1855
|
static fromRawVector(listType, vector, itemCount) {
|
|
1214
1856
|
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT * 2);
|
|
@@ -1217,7 +1859,7 @@ class DuckDBListVector extends DuckDBVector {
|
|
|
1217
1859
|
const child_vector = node_bindings_1.default.list_vector_get_child(vector);
|
|
1218
1860
|
const child_vector_size = node_bindings_1.default.list_vector_get_size(vector);
|
|
1219
1861
|
const childData = DuckDBVector.create(child_vector, child_vector_size, listType.valueType);
|
|
1220
|
-
return new DuckDBListVector(listType, entryData, validity, childData, itemCount);
|
|
1862
|
+
return new DuckDBListVector(null, listType, entryData, validity, vector, childData, 0, itemCount);
|
|
1221
1863
|
}
|
|
1222
1864
|
get type() {
|
|
1223
1865
|
return this.listType;
|
|
@@ -1235,15 +1877,78 @@ class DuckDBListVector extends DuckDBVector {
|
|
|
1235
1877
|
return this.childData.slice(offset, length);
|
|
1236
1878
|
}
|
|
1237
1879
|
getItem(itemIndex) {
|
|
1880
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
1881
|
+
if (cachedItem !== undefined) {
|
|
1882
|
+
return cachedItem;
|
|
1883
|
+
}
|
|
1238
1884
|
const vector = this.getItemVector(itemIndex);
|
|
1239
1885
|
if (!vector) {
|
|
1240
1886
|
return null;
|
|
1241
1887
|
}
|
|
1242
|
-
|
|
1888
|
+
const item = new values_1.DuckDBListValue(vector.toArray());
|
|
1889
|
+
this.itemCache[itemIndex] = item;
|
|
1890
|
+
return item;
|
|
1891
|
+
}
|
|
1892
|
+
setItem(itemIndex, value) {
|
|
1893
|
+
this.itemCache[itemIndex] = value;
|
|
1894
|
+
if (this.parentList) {
|
|
1895
|
+
this.parentList.setItem(this.itemOffset + itemIndex, value);
|
|
1896
|
+
}
|
|
1897
|
+
else {
|
|
1898
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
flush() {
|
|
1902
|
+
if (this.parentList) {
|
|
1903
|
+
this.parentList.flush();
|
|
1904
|
+
for (let i = 0; i < this.itemCount; i++) {
|
|
1905
|
+
this.itemCache[i] = undefined;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
else {
|
|
1909
|
+
// update entryData offset & lengths
|
|
1910
|
+
// calculate new child vector size (sum of all item lengths)
|
|
1911
|
+
let totalLength = 0;
|
|
1912
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
1913
|
+
const entryDataStartIndex = itemIndex * 2;
|
|
1914
|
+
this.entryData[entryDataStartIndex] = BigInt(totalLength);
|
|
1915
|
+
// ensure the cache is populated for all items
|
|
1916
|
+
const item = this.getItem(itemIndex);
|
|
1917
|
+
if (item) {
|
|
1918
|
+
this.entryData[entryDataStartIndex + 1] = BigInt(item.items.length);
|
|
1919
|
+
totalLength += item.items.length;
|
|
1920
|
+
}
|
|
1921
|
+
else {
|
|
1922
|
+
this.entryData[entryDataStartIndex + 1] = 0n;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
// set new child vector size
|
|
1926
|
+
node_bindings_1.default.list_vector_set_size(this.vector, totalLength);
|
|
1927
|
+
// recreate childData after resize
|
|
1928
|
+
const child_vector = node_bindings_1.default.list_vector_get_child(this.vector);
|
|
1929
|
+
const child_vector_size = node_bindings_1.default.list_vector_get_size(this.vector);
|
|
1930
|
+
this.childData = DuckDBVector.create(child_vector, child_vector_size, this.listType.valueType);
|
|
1931
|
+
// set all childData items
|
|
1932
|
+
let childItemAbsoluteIndex = 0;
|
|
1933
|
+
for (let listIndex = 0; listIndex < this._itemCount; listIndex++) {
|
|
1934
|
+
const list = this.getItem(listIndex);
|
|
1935
|
+
if (list) {
|
|
1936
|
+
for (let childItemRelativeIndex = 0; childItemRelativeIndex < list.items.length; childItemRelativeIndex++) {
|
|
1937
|
+
this.childData.setItem(childItemAbsoluteIndex++, list.items[childItemRelativeIndex]);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
// copy childData to child vector
|
|
1942
|
+
this.childData.flush();
|
|
1943
|
+
// copy entryData to vector
|
|
1944
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.entryData.buffer, this.entryData.byteOffset, this.entryData.byteLength);
|
|
1945
|
+
// flush validity
|
|
1946
|
+
this.validity.flush(this.vector);
|
|
1947
|
+
}
|
|
1243
1948
|
}
|
|
1244
1949
|
slice(offset, length) {
|
|
1245
1950
|
const entryDataStartIndex = offset * 2;
|
|
1246
|
-
return new DuckDBListVector(this.listType, this.entryData.slice(entryDataStartIndex, entryDataStartIndex + length * 2), this.validity.slice(offset), this.childData, length);
|
|
1951
|
+
return new DuckDBListVector(this, this.listType, this.entryData.slice(entryDataStartIndex, entryDataStartIndex + length * 2), this.validity.slice(offset, length), this.vector, this.childData, offset, length);
|
|
1247
1952
|
}
|
|
1248
1953
|
}
|
|
1249
1954
|
exports.DuckDBListVector = DuckDBListVector;
|
|
@@ -1252,12 +1957,14 @@ class DuckDBStructVector extends DuckDBVector {
|
|
|
1252
1957
|
_itemCount;
|
|
1253
1958
|
entryVectors;
|
|
1254
1959
|
validity;
|
|
1255
|
-
|
|
1960
|
+
vector;
|
|
1961
|
+
constructor(structType, itemCount, entryVectors, validity, vector) {
|
|
1256
1962
|
super();
|
|
1257
1963
|
this.structType = structType;
|
|
1258
1964
|
this._itemCount = itemCount;
|
|
1259
1965
|
this.entryVectors = entryVectors;
|
|
1260
1966
|
this.validity = validity;
|
|
1967
|
+
this.vector = vector;
|
|
1261
1968
|
}
|
|
1262
1969
|
static fromRawVector(structType, vector, itemCount) {
|
|
1263
1970
|
const entryCount = structType.entryCount;
|
|
@@ -1267,7 +1974,7 @@ class DuckDBStructVector extends DuckDBVector {
|
|
|
1267
1974
|
entryVectors.push(DuckDBVector.create(child_vector, itemCount, structType.entryTypes[i]));
|
|
1268
1975
|
}
|
|
1269
1976
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1270
|
-
return new DuckDBStructVector(structType, itemCount, entryVectors, validity);
|
|
1977
|
+
return new DuckDBStructVector(structType, itemCount, entryVectors, validity, vector);
|
|
1271
1978
|
}
|
|
1272
1979
|
get type() {
|
|
1273
1980
|
return this.structType;
|
|
@@ -1282,7 +1989,8 @@ class DuckDBStructVector extends DuckDBVector {
|
|
|
1282
1989
|
const entries = {};
|
|
1283
1990
|
const entryCount = this.structType.entryCount;
|
|
1284
1991
|
for (let i = 0; i < entryCount; i++) {
|
|
1285
|
-
entries[this.structType.entryNames[i]] =
|
|
1992
|
+
entries[this.structType.entryNames[i]] =
|
|
1993
|
+
this.entryVectors[i].getItem(itemIndex);
|
|
1286
1994
|
}
|
|
1287
1995
|
return new values_1.DuckDBStructValue(entries);
|
|
1288
1996
|
}
|
|
@@ -1292,8 +2000,33 @@ class DuckDBStructVector extends DuckDBVector {
|
|
|
1292
2000
|
}
|
|
1293
2001
|
return this.entryVectors[entryIndex].getItem(itemIndex);
|
|
1294
2002
|
}
|
|
2003
|
+
setItem(itemIndex, value) {
|
|
2004
|
+
if (value != null) {
|
|
2005
|
+
const entryCount = this.structType.entryCount;
|
|
2006
|
+
for (let i = 0; i < entryCount; i++) {
|
|
2007
|
+
this.entryVectors[i].setItem(itemIndex, value.entries[this.structType.entryNames[i]]);
|
|
2008
|
+
}
|
|
2009
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2010
|
+
}
|
|
2011
|
+
else {
|
|
2012
|
+
const entryCount = this.structType.entryCount;
|
|
2013
|
+
for (let i = 0; i < entryCount; i++) {
|
|
2014
|
+
this.entryVectors[i].setItem(itemIndex, null);
|
|
2015
|
+
}
|
|
2016
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
setItemValue(itemIndex, entryIndex, value) {
|
|
2020
|
+
return this.entryVectors[entryIndex].setItem(itemIndex, value);
|
|
2021
|
+
}
|
|
2022
|
+
flush() {
|
|
2023
|
+
for (const entryVector of this.entryVectors) {
|
|
2024
|
+
entryVector.flush();
|
|
2025
|
+
}
|
|
2026
|
+
this.validity.flush(this.vector);
|
|
2027
|
+
}
|
|
1295
2028
|
slice(offset, length) {
|
|
1296
|
-
return new DuckDBStructVector(this.structType, length, this.entryVectors.map(entryVector => entryVector.slice(offset, length)), this.validity.slice(offset));
|
|
2029
|
+
return new DuckDBStructVector(this.structType, length, this.entryVectors.map((entryVector) => entryVector.slice(offset, length)), this.validity.slice(offset, length), this.vector);
|
|
1297
2030
|
}
|
|
1298
2031
|
}
|
|
1299
2032
|
exports.DuckDBStructVector = DuckDBStructVector;
|
|
@@ -1333,6 +2066,17 @@ class DuckDBMapVector extends DuckDBVector {
|
|
|
1333
2066
|
}
|
|
1334
2067
|
return new values_1.DuckDBMapValue(entries);
|
|
1335
2068
|
}
|
|
2069
|
+
setItem(itemIndex, value) {
|
|
2070
|
+
if (value != null) {
|
|
2071
|
+
this.listVector.setItem(itemIndex, (0, values_1.listValue)(value.entries.map((entry) => (0, values_1.structValue)({ 'key': entry.key, 'value': entry.value }))));
|
|
2072
|
+
}
|
|
2073
|
+
else {
|
|
2074
|
+
this.listVector.setItem(itemIndex, null);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
flush() {
|
|
2078
|
+
this.listVector.flush();
|
|
2079
|
+
}
|
|
1336
2080
|
slice(offset, length) {
|
|
1337
2081
|
return new DuckDBMapVector(this.mapType, this.listVector.slice(offset, length));
|
|
1338
2082
|
}
|
|
@@ -1341,12 +2085,14 @@ exports.DuckDBMapVector = DuckDBMapVector;
|
|
|
1341
2085
|
class DuckDBArrayVector extends DuckDBVector {
|
|
1342
2086
|
arrayType;
|
|
1343
2087
|
validity;
|
|
2088
|
+
vector;
|
|
1344
2089
|
childData;
|
|
1345
2090
|
_itemCount;
|
|
1346
|
-
constructor(arrayType, validity, childData, itemCount) {
|
|
2091
|
+
constructor(arrayType, validity, vector, childData, itemCount) {
|
|
1347
2092
|
super();
|
|
1348
2093
|
this.arrayType = arrayType;
|
|
1349
2094
|
this.validity = validity;
|
|
2095
|
+
this.vector = vector;
|
|
1350
2096
|
this.childData = childData;
|
|
1351
2097
|
this._itemCount = itemCount;
|
|
1352
2098
|
}
|
|
@@ -1355,7 +2101,7 @@ class DuckDBArrayVector extends DuckDBVector {
|
|
|
1355
2101
|
const child_vector = node_bindings_1.default.array_vector_get_child(vector);
|
|
1356
2102
|
const childItemsPerArray = DuckDBArrayVector.itemSize(arrayType) * arrayType.length;
|
|
1357
2103
|
const childData = DuckDBVector.create(child_vector, itemCount * childItemsPerArray, arrayType.valueType);
|
|
1358
|
-
return new DuckDBArrayVector(arrayType, validity, childData, itemCount);
|
|
2104
|
+
return new DuckDBArrayVector(arrayType, validity, vector, childData, itemCount);
|
|
1359
2105
|
}
|
|
1360
2106
|
static itemSize(arrayType) {
|
|
1361
2107
|
if (arrayType.valueType instanceof DuckDBType_1.DuckDBArrayType) {
|
|
@@ -1375,28 +2121,52 @@ class DuckDBArrayVector extends DuckDBVector {
|
|
|
1375
2121
|
if (!this.validity.itemValid(itemIndex)) {
|
|
1376
2122
|
return null;
|
|
1377
2123
|
}
|
|
1378
|
-
return new values_1.DuckDBArrayValue(this.childData
|
|
2124
|
+
return new values_1.DuckDBArrayValue(this.childData
|
|
2125
|
+
.slice(itemIndex * this.arrayType.length, this.arrayType.length)
|
|
2126
|
+
.toArray());
|
|
2127
|
+
}
|
|
2128
|
+
setItem(itemIndex, value) {
|
|
2129
|
+
if (value != null) {
|
|
2130
|
+
const startIndex = itemIndex * this.arrayType.length;
|
|
2131
|
+
for (let i = 0; i < this.arrayType.length; i++) {
|
|
2132
|
+
this.childData.setItem(startIndex + i, value.items[i]);
|
|
2133
|
+
}
|
|
2134
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
const startIndex = itemIndex * this.arrayType.length;
|
|
2138
|
+
for (let i = 0; i < this.arrayType.length; i++) {
|
|
2139
|
+
this.childData.setItem(startIndex + i, null);
|
|
2140
|
+
}
|
|
2141
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
flush() {
|
|
2145
|
+
this.childData.flush();
|
|
2146
|
+
this.validity.flush(this.vector);
|
|
1379
2147
|
}
|
|
1380
2148
|
slice(offset, length) {
|
|
1381
|
-
return new DuckDBArrayVector(this.arrayType, this.validity.slice(offset), this.childData.slice(offset * this.arrayType.length, length * this.arrayType.length), length);
|
|
2149
|
+
return new DuckDBArrayVector(this.arrayType, this.validity.slice(offset, length), this.vector, this.childData.slice(offset * this.arrayType.length, length * this.arrayType.length), length);
|
|
1382
2150
|
}
|
|
1383
2151
|
}
|
|
1384
2152
|
exports.DuckDBArrayVector = DuckDBArrayVector;
|
|
1385
2153
|
class DuckDBUUIDVector extends DuckDBVector {
|
|
1386
2154
|
dataView;
|
|
1387
2155
|
validity;
|
|
2156
|
+
vector;
|
|
1388
2157
|
_itemCount;
|
|
1389
|
-
constructor(dataView, validity, itemCount) {
|
|
2158
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
1390
2159
|
super();
|
|
1391
2160
|
this.dataView = dataView;
|
|
1392
2161
|
this.validity = validity;
|
|
2162
|
+
this.vector = vector;
|
|
1393
2163
|
this._itemCount = itemCount;
|
|
1394
2164
|
}
|
|
1395
2165
|
static fromRawVector(vector, itemCount) {
|
|
1396
2166
|
const data = vectorData(vector, itemCount * 16);
|
|
1397
2167
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1398
2168
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1399
|
-
return new DuckDBUUIDVector(dataView, validity, itemCount);
|
|
2169
|
+
return new DuckDBUUIDVector(dataView, validity, vector, itemCount);
|
|
1400
2170
|
}
|
|
1401
2171
|
get type() {
|
|
1402
2172
|
return DuckDBType_1.DuckDBUUIDType.instance;
|
|
@@ -1405,10 +2175,25 @@ class DuckDBUUIDVector extends DuckDBVector {
|
|
|
1405
2175
|
return this._itemCount;
|
|
1406
2176
|
}
|
|
1407
2177
|
getItem(itemIndex) {
|
|
1408
|
-
return this.validity.itemValid(itemIndex)
|
|
2178
|
+
return this.validity.itemValid(itemIndex)
|
|
2179
|
+
? new values_1.DuckDBUUIDValue(getInt128(this.dataView, itemIndex * 16))
|
|
2180
|
+
: null;
|
|
2181
|
+
}
|
|
2182
|
+
setItem(itemIndex, value) {
|
|
2183
|
+
if (value != null) {
|
|
2184
|
+
setInt128(this.dataView, itemIndex * 16, value.hugeint);
|
|
2185
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2186
|
+
}
|
|
2187
|
+
else {
|
|
2188
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
flush() {
|
|
2192
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
2193
|
+
this.validity.flush(this.vector);
|
|
1409
2194
|
}
|
|
1410
2195
|
slice(offset, length) {
|
|
1411
|
-
return new DuckDBUUIDVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
2196
|
+
return new DuckDBUUIDVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
1412
2197
|
}
|
|
1413
2198
|
}
|
|
1414
2199
|
exports.DuckDBUUIDVector = DuckDBUUIDVector;
|
|
@@ -1449,6 +2234,27 @@ class DuckDBUnionVector extends DuckDBVector {
|
|
|
1449
2234
|
const value = this.structVector.getItemValue(itemIndex, entryIndex);
|
|
1450
2235
|
return new values_1.DuckDBUnionValue(tag, value);
|
|
1451
2236
|
}
|
|
2237
|
+
setItem(itemIndex, value) {
|
|
2238
|
+
if (value != null) {
|
|
2239
|
+
const memberIndex = this.unionType.memberIndexForTag(value.tag);
|
|
2240
|
+
this.structVector.setItemValue(itemIndex, 0, memberIndex);
|
|
2241
|
+
const entryIndex = memberIndex + 1;
|
|
2242
|
+
this.structVector.setItemValue(itemIndex, entryIndex, value.value);
|
|
2243
|
+
for (let i = 1; i <= this.unionType.memberCount; i++) {
|
|
2244
|
+
if (i !== entryIndex) {
|
|
2245
|
+
this.structVector.setItemValue(itemIndex, i, null);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
else {
|
|
2250
|
+
for (let i = 0; i <= this.unionType.memberCount; i++) {
|
|
2251
|
+
this.structVector.setItemValue(itemIndex, i, null);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
flush() {
|
|
2256
|
+
this.structVector.flush();
|
|
2257
|
+
}
|
|
1452
2258
|
slice(offset, length) {
|
|
1453
2259
|
return new DuckDBUnionVector(this.unionType, this.structVector.slice(offset, length));
|
|
1454
2260
|
}
|
|
@@ -1457,18 +2263,26 @@ exports.DuckDBUnionVector = DuckDBUnionVector;
|
|
|
1457
2263
|
class DuckDBBitVector extends DuckDBVector {
|
|
1458
2264
|
dataView;
|
|
1459
2265
|
validity;
|
|
2266
|
+
vector;
|
|
2267
|
+
itemOffset;
|
|
1460
2268
|
_itemCount;
|
|
1461
|
-
|
|
2269
|
+
itemCache;
|
|
2270
|
+
itemCacheDirty;
|
|
2271
|
+
constructor(dataView, validity, vector, itemOffset, itemCount) {
|
|
1462
2272
|
super();
|
|
1463
2273
|
this.dataView = dataView;
|
|
1464
2274
|
this.validity = validity;
|
|
2275
|
+
this.vector = vector;
|
|
2276
|
+
this.itemOffset = itemOffset;
|
|
1465
2277
|
this._itemCount = itemCount;
|
|
2278
|
+
this.itemCache = [];
|
|
2279
|
+
this.itemCacheDirty = [];
|
|
1466
2280
|
}
|
|
1467
2281
|
static fromRawVector(vector, itemCount) {
|
|
1468
2282
|
const data = vectorData(vector, itemCount * 16);
|
|
1469
2283
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1470
2284
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1471
|
-
return new DuckDBBitVector(dataView, validity, itemCount);
|
|
2285
|
+
return new DuckDBBitVector(dataView, validity, vector, 0, itemCount);
|
|
1472
2286
|
}
|
|
1473
2287
|
get type() {
|
|
1474
2288
|
return DuckDBType_1.DuckDBBitType.instance;
|
|
@@ -1483,24 +2297,43 @@ class DuckDBBitVector extends DuckDBVector {
|
|
|
1483
2297
|
const bytes = getStringBytes(this.dataView, itemIndex * 16);
|
|
1484
2298
|
return bytes ? new values_1.DuckDBBitValue(bytes) : null;
|
|
1485
2299
|
}
|
|
2300
|
+
setItem(itemIndex, value) {
|
|
2301
|
+
this.itemCache[itemIndex] = value;
|
|
2302
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
2303
|
+
this.itemCacheDirty[itemIndex] = true;
|
|
2304
|
+
}
|
|
2305
|
+
flush() {
|
|
2306
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
2307
|
+
if (this.itemCacheDirty[itemIndex]) {
|
|
2308
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
2309
|
+
if (cachedItem !== undefined && cachedItem !== null) {
|
|
2310
|
+
node_bindings_1.default.vector_assign_string_element_len(this.vector, this.itemOffset + itemIndex, cachedItem.data);
|
|
2311
|
+
}
|
|
2312
|
+
this.itemCacheDirty[itemIndex] = false;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
this.validity.flush(this.vector);
|
|
2316
|
+
}
|
|
1486
2317
|
slice(offset, length) {
|
|
1487
|
-
return new DuckDBBitVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
2318
|
+
return new DuckDBBitVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
1488
2319
|
}
|
|
1489
2320
|
}
|
|
1490
2321
|
exports.DuckDBBitVector = DuckDBBitVector;
|
|
1491
2322
|
class DuckDBTimeTZVector extends DuckDBVector {
|
|
1492
2323
|
items;
|
|
1493
2324
|
validity;
|
|
1494
|
-
|
|
2325
|
+
vector;
|
|
2326
|
+
constructor(items, validity, vector) {
|
|
1495
2327
|
super();
|
|
1496
2328
|
this.items = items;
|
|
1497
2329
|
this.validity = validity;
|
|
2330
|
+
this.vector = vector;
|
|
1498
2331
|
}
|
|
1499
2332
|
static fromRawVector(vector, itemCount) {
|
|
1500
2333
|
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT);
|
|
1501
2334
|
const items = new BigUint64Array(data.buffer, data.byteOffset, itemCount);
|
|
1502
2335
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1503
|
-
return new DuckDBTimeTZVector(items, validity);
|
|
2336
|
+
return new DuckDBTimeTZVector(items, validity, vector);
|
|
1504
2337
|
}
|
|
1505
2338
|
get type() {
|
|
1506
2339
|
return DuckDBType_1.DuckDBTimeTZType.instance;
|
|
@@ -1509,26 +2342,43 @@ class DuckDBTimeTZVector extends DuckDBVector {
|
|
|
1509
2342
|
return this.items.length;
|
|
1510
2343
|
}
|
|
1511
2344
|
getItem(itemIndex) {
|
|
1512
|
-
return this.validity.itemValid(itemIndex)
|
|
2345
|
+
return this.validity.itemValid(itemIndex)
|
|
2346
|
+
? values_1.DuckDBTimeTZValue.fromBits(this.items[itemIndex])
|
|
2347
|
+
: null;
|
|
2348
|
+
}
|
|
2349
|
+
setItem(itemIndex, value) {
|
|
2350
|
+
if (value != null) {
|
|
2351
|
+
this.items[itemIndex] = value.bits;
|
|
2352
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2353
|
+
}
|
|
2354
|
+
else {
|
|
2355
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
flush() {
|
|
2359
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
2360
|
+
this.validity.flush(this.vector);
|
|
1513
2361
|
}
|
|
1514
2362
|
slice(offset, length) {
|
|
1515
|
-
return new DuckDBTimeTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
2363
|
+
return new DuckDBTimeTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1516
2364
|
}
|
|
1517
2365
|
}
|
|
1518
2366
|
exports.DuckDBTimeTZVector = DuckDBTimeTZVector;
|
|
1519
2367
|
class DuckDBTimestampTZVector extends DuckDBVector {
|
|
1520
2368
|
items;
|
|
1521
2369
|
validity;
|
|
1522
|
-
|
|
2370
|
+
vector;
|
|
2371
|
+
constructor(items, validity, vector) {
|
|
1523
2372
|
super();
|
|
1524
2373
|
this.items = items;
|
|
1525
2374
|
this.validity = validity;
|
|
2375
|
+
this.vector = vector;
|
|
1526
2376
|
}
|
|
1527
2377
|
static fromRawVector(vector, itemCount) {
|
|
1528
2378
|
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1529
2379
|
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1530
2380
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1531
|
-
return new DuckDBTimestampTZVector(items, validity);
|
|
2381
|
+
return new DuckDBTimestampTZVector(items, validity, vector);
|
|
1532
2382
|
}
|
|
1533
2383
|
get type() {
|
|
1534
2384
|
return DuckDBType_1.DuckDBTimestampTZType.instance;
|
|
@@ -1537,28 +2387,51 @@ class DuckDBTimestampTZVector extends DuckDBVector {
|
|
|
1537
2387
|
return this.items.length;
|
|
1538
2388
|
}
|
|
1539
2389
|
getItem(itemIndex) {
|
|
1540
|
-
return this.validity.itemValid(itemIndex)
|
|
2390
|
+
return this.validity.itemValid(itemIndex)
|
|
2391
|
+
? new values_1.DuckDBTimestampTZValue(this.items[itemIndex])
|
|
2392
|
+
: null;
|
|
2393
|
+
}
|
|
2394
|
+
setItem(itemIndex, value) {
|
|
2395
|
+
if (value != null) {
|
|
2396
|
+
this.items[itemIndex] = value.micros;
|
|
2397
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2398
|
+
}
|
|
2399
|
+
else {
|
|
2400
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
flush() {
|
|
2404
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
2405
|
+
this.validity.flush(this.vector);
|
|
1541
2406
|
}
|
|
1542
2407
|
slice(offset, length) {
|
|
1543
|
-
return new DuckDBTimestampTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
2408
|
+
return new DuckDBTimestampTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
1544
2409
|
}
|
|
1545
2410
|
}
|
|
1546
2411
|
exports.DuckDBTimestampTZVector = DuckDBTimestampTZVector;
|
|
1547
2412
|
class DuckDBVarIntVector extends DuckDBVector {
|
|
1548
2413
|
dataView;
|
|
1549
2414
|
validity;
|
|
2415
|
+
vector;
|
|
2416
|
+
itemOffset;
|
|
1550
2417
|
_itemCount;
|
|
1551
|
-
|
|
2418
|
+
itemCache;
|
|
2419
|
+
itemCacheDirty;
|
|
2420
|
+
constructor(dataView, validity, vector, itemOffset, itemCount) {
|
|
1552
2421
|
super();
|
|
1553
2422
|
this.dataView = dataView;
|
|
1554
2423
|
this.validity = validity;
|
|
2424
|
+
this.vector = vector;
|
|
2425
|
+
this.itemOffset = itemOffset;
|
|
1555
2426
|
this._itemCount = itemCount;
|
|
2427
|
+
this.itemCache = [];
|
|
2428
|
+
this.itemCacheDirty = [];
|
|
1556
2429
|
}
|
|
1557
2430
|
static fromRawVector(vector, itemCount) {
|
|
1558
2431
|
const data = vectorData(vector, itemCount * 16);
|
|
1559
2432
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1560
2433
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1561
|
-
return new DuckDBVarIntVector(dataView, validity, itemCount);
|
|
2434
|
+
return new DuckDBVarIntVector(dataView, validity, vector, 0, itemCount);
|
|
1562
2435
|
}
|
|
1563
2436
|
get type() {
|
|
1564
2437
|
return DuckDBType_1.DuckDBVarIntType.instance;
|
|
@@ -1573,8 +2446,25 @@ class DuckDBVarIntVector extends DuckDBVector {
|
|
|
1573
2446
|
const bytes = getStringBytes(this.dataView, itemIndex * 16);
|
|
1574
2447
|
return bytes ? getVarIntFromBytes(bytes) : null;
|
|
1575
2448
|
}
|
|
2449
|
+
setItem(itemIndex, value) {
|
|
2450
|
+
this.itemCache[itemIndex] = value;
|
|
2451
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
2452
|
+
this.itemCacheDirty[itemIndex] = true;
|
|
2453
|
+
}
|
|
2454
|
+
flush() {
|
|
2455
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
2456
|
+
if (this.itemCacheDirty[itemIndex]) {
|
|
2457
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
2458
|
+
if (cachedItem !== undefined && cachedItem !== null) {
|
|
2459
|
+
node_bindings_1.default.vector_assign_string_element_len(this.vector, this.itemOffset + itemIndex, getBytesFromVarInt(cachedItem));
|
|
2460
|
+
}
|
|
2461
|
+
this.itemCacheDirty[itemIndex] = false;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
this.validity.flush(this.vector);
|
|
2465
|
+
}
|
|
1576
2466
|
slice(offset, length) {
|
|
1577
|
-
return new DuckDBVarIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
2467
|
+
return new DuckDBVarIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
1578
2468
|
}
|
|
1579
2469
|
}
|
|
1580
2470
|
exports.DuckDBVarIntVector = DuckDBVarIntVector;
|