@duckdb/node-api 1.1.2-alpha.1
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 +7 -0
- package/README.md +5 -0
- package/lib/DuckDBAppender.d.ts +36 -0
- package/lib/DuckDBAppender.js +106 -0
- package/lib/DuckDBConnection.d.ts +18 -0
- package/lib/DuckDBConnection.js +51 -0
- package/lib/DuckDBDataChunk.d.ts +13 -0
- package/lib/DuckDBDataChunk.js +37 -0
- package/lib/DuckDBExtractedStatements.d.ts +11 -0
- package/lib/DuckDBExtractedStatements.js +28 -0
- package/lib/DuckDBInstance.d.ts +9 -0
- package/lib/DuckDBInstance.js +39 -0
- package/lib/DuckDBLogicalType.d.ts +70 -0
- package/lib/DuckDBLogicalType.js +292 -0
- package/lib/DuckDBPendingResult.d.ts +14 -0
- package/lib/DuckDBPendingResult.js +43 -0
- package/lib/DuckDBPreparedStatement.d.ts +40 -0
- package/lib/DuckDBPreparedStatement.js +116 -0
- package/lib/DuckDBResult.d.ts +20 -0
- package/lib/DuckDBResult.js +46 -0
- package/lib/DuckDBType.d.ts +164 -0
- package/lib/DuckDBType.js +279 -0
- package/lib/DuckDBTypeId.d.ts +39 -0
- package/lib/DuckDBTypeId.js +44 -0
- package/lib/DuckDBValue.d.ts +8 -0
- package/lib/DuckDBValue.js +2 -0
- package/lib/DuckDBVector.d.ts +491 -0
- package/lib/DuckDBVector.js +1676 -0
- package/lib/configurationOptionDescriptions.d.ts +1 -0
- package/lib/configurationOptionDescriptions.js +16 -0
- package/lib/enums.d.ts +4 -0
- package/lib/enums.js +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +32 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +10 -0
- package/package.json +13 -0
|
@@ -0,0 +1,1676 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DuckDBVarIntVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBTimeTZValue = exports.DuckDBBitVector = exports.DuckDBBitValue = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.DuckDBEnum4Vector = exports.DuckDBEnum2Vector = exports.DuckDBEnum1Vector = exports.DuckDBTimestampNanosecondsVector = exports.DuckDBTimestampMillisecondsVector = exports.DuckDBTimestampSecondsVector = exports.DuckDBDecimal16Vector = exports.DuckDBDecimal8Vector = exports.DuckDBDecimal4Vector = exports.DuckDBDecimal2Vector = exports.DuckDBBlobVector = exports.DuckDBVarCharVector = exports.DuckDBUHugeIntVector = exports.DuckDBHugeIntVector = exports.DuckDBIntervalVector = exports.DuckDBInterval = 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 = exports.DuckDBLargeDecimal = exports.DuckDBSmallDecimal = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
|
|
10
|
+
const DuckDBType_1 = require("./DuckDBType");
|
|
11
|
+
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
12
|
+
const littleEndian = os_1.default.endianness() === 'LE';
|
|
13
|
+
// function getInt8(dataView: DataView, offset: number): number {
|
|
14
|
+
// return dataView.getInt8(offset);
|
|
15
|
+
// }
|
|
16
|
+
function getUInt8(dataView, offset) {
|
|
17
|
+
return dataView.getUint8(offset);
|
|
18
|
+
}
|
|
19
|
+
function getInt16(dataView, offset) {
|
|
20
|
+
return dataView.getInt16(offset, littleEndian);
|
|
21
|
+
}
|
|
22
|
+
function getUInt16(dataView, offset) {
|
|
23
|
+
return dataView.getUint16(offset, littleEndian);
|
|
24
|
+
}
|
|
25
|
+
function getInt32(dataView, offset) {
|
|
26
|
+
return dataView.getInt32(offset, littleEndian);
|
|
27
|
+
}
|
|
28
|
+
function getUInt32(dataView, offset) {
|
|
29
|
+
return dataView.getUint32(offset, littleEndian);
|
|
30
|
+
}
|
|
31
|
+
function getInt64(dataView, offset) {
|
|
32
|
+
return dataView.getBigInt64(offset, littleEndian);
|
|
33
|
+
}
|
|
34
|
+
function getUInt64(dataView, offset) {
|
|
35
|
+
return dataView.getBigUint64(offset, littleEndian);
|
|
36
|
+
}
|
|
37
|
+
// function getFloat32(dataView: DataView, offset: number): number {
|
|
38
|
+
// return dataView.getFloat32(offset, littleEndian);
|
|
39
|
+
// }
|
|
40
|
+
// function getFloat64(dataView: DataView, offset: number): number {
|
|
41
|
+
// return dataView.getFloat64(offset, littleEndian);
|
|
42
|
+
// }
|
|
43
|
+
function getInt128(dataView, offset) {
|
|
44
|
+
const lower = getUInt64(dataView, offset);
|
|
45
|
+
const upper = getInt64(dataView, offset + 8);
|
|
46
|
+
return (upper << BigInt(64)) + lower;
|
|
47
|
+
}
|
|
48
|
+
function getUInt128(dataView, offset) {
|
|
49
|
+
const lower = getUInt64(dataView, offset);
|
|
50
|
+
const upper = getUInt64(dataView, offset + 8);
|
|
51
|
+
return BigInt.asUintN(64, upper) << BigInt(64) | BigInt.asUintN(64, lower);
|
|
52
|
+
}
|
|
53
|
+
function getStringBytes(dataView, offset) {
|
|
54
|
+
const lengthInBytes = dataView.getUint32(offset, true);
|
|
55
|
+
if (lengthInBytes <= 12) {
|
|
56
|
+
return new Uint8Array(dataView.buffer, dataView.byteOffset + offset + 4, lengthInBytes);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return node_bindings_1.default.get_data_from_pointer(dataView.buffer, dataView.byteOffset + offset + 8, lengthInBytes);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const textDecoder = new TextDecoder();
|
|
63
|
+
function getString(dataView, offset) {
|
|
64
|
+
const stringBytes = getStringBytes(dataView, offset);
|
|
65
|
+
if (!stringBytes) {
|
|
66
|
+
// should we throw here instead?
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return textDecoder.decode(stringBytes);
|
|
70
|
+
}
|
|
71
|
+
function getBuffer(dataView, offset) {
|
|
72
|
+
const stringBytes = getStringBytes(dataView, offset);
|
|
73
|
+
if (!stringBytes) {
|
|
74
|
+
// should we throw here instead?
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return Buffer.from(stringBytes);
|
|
78
|
+
}
|
|
79
|
+
function getVarIntFromBytes(bytes) {
|
|
80
|
+
const firstByte = bytes[0];
|
|
81
|
+
const positive = (firstByte & 0x80) > 0;
|
|
82
|
+
const uint64Mask = positive ? 0n : 0xffffffffffffffffn;
|
|
83
|
+
const uint8Mask = positive ? 0 : 0xff;
|
|
84
|
+
const dv = new DataView(bytes.buffer, bytes.byteOffset + 3, bytes.byteLength - 3);
|
|
85
|
+
const lastUint64Offset = dv.byteLength - 8;
|
|
86
|
+
let offset = 0;
|
|
87
|
+
let result = 0n;
|
|
88
|
+
while (offset <= lastUint64Offset) {
|
|
89
|
+
result = (result << 64n) | (dv.getBigUint64(offset) ^ uint64Mask);
|
|
90
|
+
offset += 8;
|
|
91
|
+
}
|
|
92
|
+
while (offset < dv.byteLength) {
|
|
93
|
+
result = (result << 8n) | BigInt(dv.getUint8(offset) ^ uint8Mask);
|
|
94
|
+
offset += 1;
|
|
95
|
+
}
|
|
96
|
+
return positive ? result : -result;
|
|
97
|
+
}
|
|
98
|
+
function getBoolean1(dataView, offset) {
|
|
99
|
+
return getUInt8(dataView, offset) !== 0;
|
|
100
|
+
}
|
|
101
|
+
function getBoolean2(dataView, offset) {
|
|
102
|
+
return getUInt16(dataView, offset) !== 0;
|
|
103
|
+
}
|
|
104
|
+
function getBoolean4(dataView, offset) {
|
|
105
|
+
return getUInt32(dataView, offset) !== 0;
|
|
106
|
+
}
|
|
107
|
+
function getBoolean8(dataView, offset) {
|
|
108
|
+
return getUInt64(dataView, offset) !== BigInt(0);
|
|
109
|
+
}
|
|
110
|
+
function makeGetBoolean() {
|
|
111
|
+
switch (node_bindings_1.default.sizeof_bool) {
|
|
112
|
+
case 1:
|
|
113
|
+
return getBoolean1;
|
|
114
|
+
case 2:
|
|
115
|
+
return getBoolean2;
|
|
116
|
+
case 4:
|
|
117
|
+
return getBoolean4;
|
|
118
|
+
case 8:
|
|
119
|
+
return getBoolean8;
|
|
120
|
+
default:
|
|
121
|
+
throw new Error(`Unsupported boolean size: ${node_bindings_1.default.sizeof_bool}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const getBoolean = makeGetBoolean();
|
|
125
|
+
class DuckDBSmallDecimal {
|
|
126
|
+
scaledValue;
|
|
127
|
+
type;
|
|
128
|
+
constructor(scaledValue, type) {
|
|
129
|
+
this.scaledValue = scaledValue;
|
|
130
|
+
this.type = type;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.DuckDBSmallDecimal = DuckDBSmallDecimal;
|
|
134
|
+
class DuckDBLargeDecimal {
|
|
135
|
+
scaledValue;
|
|
136
|
+
type;
|
|
137
|
+
constructor(scaledValue, type) {
|
|
138
|
+
this.scaledValue = scaledValue;
|
|
139
|
+
this.type = type;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.DuckDBLargeDecimal = DuckDBLargeDecimal;
|
|
143
|
+
function getDecimal2(dataView, offset, type) {
|
|
144
|
+
const scaledValue = getInt16(dataView, offset);
|
|
145
|
+
return new DuckDBSmallDecimal(scaledValue, type);
|
|
146
|
+
}
|
|
147
|
+
function getDecimal4(dataView, offset, type) {
|
|
148
|
+
const scaledValue = getInt32(dataView, offset);
|
|
149
|
+
return new DuckDBSmallDecimal(scaledValue, type);
|
|
150
|
+
}
|
|
151
|
+
function getDecimal8(dataView, offset, type) {
|
|
152
|
+
const scaledValue = getInt64(dataView, offset);
|
|
153
|
+
return new DuckDBLargeDecimal(scaledValue, type);
|
|
154
|
+
}
|
|
155
|
+
function getDecimal16(dataView, offset, type) {
|
|
156
|
+
const scaledValue = getInt128(dataView, offset);
|
|
157
|
+
return new DuckDBLargeDecimal(scaledValue, type);
|
|
158
|
+
}
|
|
159
|
+
function vectorData(vector, byteCount) {
|
|
160
|
+
return node_bindings_1.default.vector_get_data(vector, byteCount);
|
|
161
|
+
}
|
|
162
|
+
// This version of DuckDBValidity is almost 10x slower.
|
|
163
|
+
// class DuckDBValidity {
|
|
164
|
+
// private readonly validity_pointer: ddb.uint64_pointer;
|
|
165
|
+
// private readonly offset: number;
|
|
166
|
+
// private constructor(validity_pointer: ddb.uint64_pointer, offset: number = 0) {
|
|
167
|
+
// this.validity_pointer = validity_pointer;
|
|
168
|
+
// this.offset = offset;
|
|
169
|
+
// }
|
|
170
|
+
// public static fromVector(vector: ddb.duckdb_vector, itemCount: number, offset: number = 0): DuckDBValidity {
|
|
171
|
+
// const validity_pointer = ddb.duckdb_vector_get_validity(vector);
|
|
172
|
+
// return new DuckDBValidity(validity_pointer, offset);
|
|
173
|
+
// }
|
|
174
|
+
// public itemValid(itemIndex: number): boolean {
|
|
175
|
+
// return ddb.duckdb_validity_row_is_valid(this.validity_pointer, this.offset + itemIndex);
|
|
176
|
+
// }
|
|
177
|
+
// public slice(offset: number): DuckDBValidity {
|
|
178
|
+
// return new DuckDBValidity(this.validity_pointer, this.offset + offset);
|
|
179
|
+
// }
|
|
180
|
+
// }
|
|
181
|
+
class DuckDBValidity {
|
|
182
|
+
data;
|
|
183
|
+
offset;
|
|
184
|
+
constructor(data, offset) {
|
|
185
|
+
this.data = data;
|
|
186
|
+
this.offset = offset;
|
|
187
|
+
}
|
|
188
|
+
static fromVector(vector, itemCount) {
|
|
189
|
+
const bigintCount = Math.ceil(itemCount / 64);
|
|
190
|
+
const bytes = node_bindings_1.default.vector_get_validity(vector, bigintCount * 8);
|
|
191
|
+
const bigints = new BigUint64Array(bytes.buffer, bytes.byteOffset, bigintCount);
|
|
192
|
+
return new DuckDBValidity(bigints, 0);
|
|
193
|
+
}
|
|
194
|
+
itemValid(itemIndex) {
|
|
195
|
+
if (!this.data) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
const bit = this.offset + itemIndex;
|
|
199
|
+
return (this.data[Math.floor(bit / 64)] & (BigInt(1) << BigInt(bit % 64))) !== BigInt(0);
|
|
200
|
+
}
|
|
201
|
+
slice(offset) {
|
|
202
|
+
return new DuckDBValidity(this.data, this.offset + offset);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class DuckDBVector {
|
|
206
|
+
static standardSize() {
|
|
207
|
+
return node_bindings_1.default.vector_size();
|
|
208
|
+
}
|
|
209
|
+
static create(vector, itemCount, knownType) {
|
|
210
|
+
const vectorType = knownType ? knownType : DuckDBLogicalType_1.DuckDBLogicalType.consumeAsType(node_bindings_1.default.vector_get_column_type(vector));
|
|
211
|
+
switch (vectorType.typeId) {
|
|
212
|
+
case DuckDBTypeId_1.DuckDBTypeId.BOOLEAN:
|
|
213
|
+
return DuckDBBooleanVector.fromRawVector(vector, itemCount);
|
|
214
|
+
case DuckDBTypeId_1.DuckDBTypeId.TINYINT:
|
|
215
|
+
return DuckDBTinyIntVector.fromRawVector(vector, itemCount);
|
|
216
|
+
case DuckDBTypeId_1.DuckDBTypeId.SMALLINT:
|
|
217
|
+
return DuckDBSmallIntVector.fromRawVector(vector, itemCount);
|
|
218
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER:
|
|
219
|
+
return DuckDBIntegerVector.fromRawVector(vector, itemCount);
|
|
220
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGINT:
|
|
221
|
+
return DuckDBBigIntVector.fromRawVector(vector, itemCount);
|
|
222
|
+
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
|
|
223
|
+
return DuckDBUTinyIntVector.fromRawVector(vector, itemCount);
|
|
224
|
+
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
|
|
225
|
+
return DuckDBUSmallIntVector.fromRawVector(vector, itemCount);
|
|
226
|
+
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
|
|
227
|
+
return DuckDBUIntegerVector.fromRawVector(vector, itemCount);
|
|
228
|
+
case DuckDBTypeId_1.DuckDBTypeId.UBIGINT:
|
|
229
|
+
return DuckDBUBigIntVector.fromRawVector(vector, itemCount);
|
|
230
|
+
case DuckDBTypeId_1.DuckDBTypeId.FLOAT:
|
|
231
|
+
return DuckDBFloatVector.fromRawVector(vector, itemCount);
|
|
232
|
+
case DuckDBTypeId_1.DuckDBTypeId.DOUBLE:
|
|
233
|
+
return DuckDBDoubleVector.fromRawVector(vector, itemCount);
|
|
234
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP:
|
|
235
|
+
return DuckDBTimestampVector.fromRawVector(vector, itemCount);
|
|
236
|
+
case DuckDBTypeId_1.DuckDBTypeId.DATE:
|
|
237
|
+
return DuckDBDateVector.fromRawVector(vector, itemCount);
|
|
238
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME:
|
|
239
|
+
return DuckDBTimeVector.fromRawVector(vector, itemCount);
|
|
240
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTERVAL:
|
|
241
|
+
return DuckDBIntervalVector.fromRawVector(vector, itemCount);
|
|
242
|
+
case DuckDBTypeId_1.DuckDBTypeId.HUGEINT:
|
|
243
|
+
return DuckDBHugeIntVector.fromRawVector(vector, itemCount);
|
|
244
|
+
case DuckDBTypeId_1.DuckDBTypeId.UHUGEINT:
|
|
245
|
+
return DuckDBUHugeIntVector.fromRawVector(vector, itemCount);
|
|
246
|
+
case DuckDBTypeId_1.DuckDBTypeId.VARCHAR:
|
|
247
|
+
return DuckDBVarCharVector.fromRawVector(vector, itemCount);
|
|
248
|
+
case DuckDBTypeId_1.DuckDBTypeId.BLOB:
|
|
249
|
+
return DuckDBBlobVector.fromRawVector(vector, itemCount);
|
|
250
|
+
case DuckDBTypeId_1.DuckDBTypeId.DECIMAL:
|
|
251
|
+
if (vectorType instanceof DuckDBType_1.DuckDBDecimalType) {
|
|
252
|
+
const { width } = vectorType;
|
|
253
|
+
if (width <= 0) {
|
|
254
|
+
throw new Error(`DECIMAL width not positive: ${width}`);
|
|
255
|
+
}
|
|
256
|
+
else if (width <= 4) {
|
|
257
|
+
return DuckDBDecimal2Vector.fromRawVector(vectorType, vector, itemCount);
|
|
258
|
+
}
|
|
259
|
+
else if (width <= 9) {
|
|
260
|
+
return DuckDBDecimal4Vector.fromRawVector(vectorType, vector, itemCount);
|
|
261
|
+
}
|
|
262
|
+
else if (width <= 18) {
|
|
263
|
+
return DuckDBDecimal8Vector.fromRawVector(vectorType, vector, itemCount);
|
|
264
|
+
}
|
|
265
|
+
else if (width <= 38) {
|
|
266
|
+
return DuckDBDecimal16Vector.fromRawVector(vectorType, vector, itemCount);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
throw new Error(`DECIMAL width too large: ${width}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
throw new Error('DuckDBType has DECIMAL type id but is not an instance of DuckDBDecimalType');
|
|
273
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S:
|
|
274
|
+
return DuckDBTimestampSecondsVector.fromRawVector(vector, itemCount);
|
|
275
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS:
|
|
276
|
+
return DuckDBTimestampMillisecondsVector.fromRawVector(vector, itemCount);
|
|
277
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS:
|
|
278
|
+
return DuckDBTimestampNanosecondsVector.fromRawVector(vector, itemCount);
|
|
279
|
+
case DuckDBTypeId_1.DuckDBTypeId.ENUM:
|
|
280
|
+
if (vectorType instanceof DuckDBType_1.DuckDBEnumType) {
|
|
281
|
+
const { internalTypeId } = vectorType;
|
|
282
|
+
switch (internalTypeId) {
|
|
283
|
+
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
|
|
284
|
+
return DuckDBEnum1Vector.fromRawVector(vectorType, vector, itemCount);
|
|
285
|
+
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
|
|
286
|
+
return DuckDBEnum2Vector.fromRawVector(vectorType, vector, itemCount);
|
|
287
|
+
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
|
|
288
|
+
return DuckDBEnum4Vector.fromRawVector(vectorType, vector, itemCount);
|
|
289
|
+
default:
|
|
290
|
+
throw new Error(`unsupported ENUM internal type: ${internalTypeId}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
throw new Error('DuckDBType has ENUM type id but is not an instance of DuckDBEnumType');
|
|
294
|
+
case DuckDBTypeId_1.DuckDBTypeId.LIST:
|
|
295
|
+
if (vectorType instanceof DuckDBType_1.DuckDBListType) {
|
|
296
|
+
return DuckDBListVector.fromRawVector(vectorType, vector, itemCount);
|
|
297
|
+
}
|
|
298
|
+
throw new Error('DuckDBType has LIST type id but is not an instance of DuckDBListType');
|
|
299
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRUCT:
|
|
300
|
+
if (vectorType instanceof DuckDBType_1.DuckDBStructType) {
|
|
301
|
+
return DuckDBStructVector.fromRawVector(vectorType, vector, itemCount);
|
|
302
|
+
}
|
|
303
|
+
throw new Error('DuckDBType has STRUCT type id but is not an instance of DuckDBStructType');
|
|
304
|
+
case DuckDBTypeId_1.DuckDBTypeId.MAP:
|
|
305
|
+
if (vectorType instanceof DuckDBType_1.DuckDBMapType) {
|
|
306
|
+
return DuckDBMapVector.fromRawVector(vectorType, vector, itemCount);
|
|
307
|
+
}
|
|
308
|
+
throw new Error('DuckDBType has MAP type id but is not an instance of DuckDBMapType');
|
|
309
|
+
case DuckDBTypeId_1.DuckDBTypeId.ARRAY:
|
|
310
|
+
if (vectorType instanceof DuckDBType_1.DuckDBArrayType) {
|
|
311
|
+
return DuckDBArrayVector.fromRawVector(vectorType, vector, itemCount);
|
|
312
|
+
}
|
|
313
|
+
throw new Error('DuckDBType has ARRAY type id but is not an instance of DuckDBArrayType');
|
|
314
|
+
case DuckDBTypeId_1.DuckDBTypeId.UUID:
|
|
315
|
+
return DuckDBUUIDVector.fromRawVector(vector, itemCount);
|
|
316
|
+
case DuckDBTypeId_1.DuckDBTypeId.UNION:
|
|
317
|
+
if (vectorType instanceof DuckDBType_1.DuckDBUnionType) {
|
|
318
|
+
return DuckDBUnionVector.fromRawVector(vectorType, vector, itemCount);
|
|
319
|
+
}
|
|
320
|
+
throw new Error('DuckDBType has UNION type id but is not an instance of DuckDBUnionType');
|
|
321
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIT:
|
|
322
|
+
return DuckDBBitVector.fromRawVector(vector, itemCount);
|
|
323
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_TZ:
|
|
324
|
+
return DuckDBTimeTZVector.fromRawVector(vector, itemCount);
|
|
325
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ:
|
|
326
|
+
return DuckDBTimestampTZVector.fromRawVector(vector, itemCount);
|
|
327
|
+
case DuckDBTypeId_1.DuckDBTypeId.ANY:
|
|
328
|
+
throw new Error(`Invalid vector type: ANY`);
|
|
329
|
+
case DuckDBTypeId_1.DuckDBTypeId.VARINT:
|
|
330
|
+
return DuckDBVarIntVector.fromRawVector(vector, itemCount);
|
|
331
|
+
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
332
|
+
throw new Error(`Invalid vector type: SQLNULL`);
|
|
333
|
+
default:
|
|
334
|
+
throw new Error(`Invalid type id: ${vectorType.typeId}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
exports.DuckDBVector = DuckDBVector;
|
|
339
|
+
class DuckDBBooleanVector extends DuckDBVector {
|
|
340
|
+
dataView;
|
|
341
|
+
validity;
|
|
342
|
+
_itemCount;
|
|
343
|
+
constructor(dataView, validity, itemCount) {
|
|
344
|
+
super();
|
|
345
|
+
this.dataView = dataView;
|
|
346
|
+
this.validity = validity;
|
|
347
|
+
this._itemCount = itemCount;
|
|
348
|
+
}
|
|
349
|
+
static fromRawVector(vector, itemCount) {
|
|
350
|
+
const data = vectorData(vector, itemCount * node_bindings_1.default.sizeof_bool);
|
|
351
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
352
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
353
|
+
return new DuckDBBooleanVector(dataView, validity, itemCount);
|
|
354
|
+
}
|
|
355
|
+
get type() {
|
|
356
|
+
return DuckDBType_1.DuckDBBooleanType.instance;
|
|
357
|
+
}
|
|
358
|
+
get itemCount() {
|
|
359
|
+
return this._itemCount;
|
|
360
|
+
}
|
|
361
|
+
getItem(itemIndex) {
|
|
362
|
+
return this.validity.itemValid(itemIndex) ? getBoolean(this.dataView, itemIndex * node_bindings_1.default.sizeof_bool) : null;
|
|
363
|
+
}
|
|
364
|
+
slice(offset, length) {
|
|
365
|
+
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);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
exports.DuckDBBooleanVector = DuckDBBooleanVector;
|
|
369
|
+
class DuckDBTinyIntVector extends DuckDBVector {
|
|
370
|
+
items;
|
|
371
|
+
validity;
|
|
372
|
+
constructor(items, validity) {
|
|
373
|
+
super();
|
|
374
|
+
this.items = items;
|
|
375
|
+
this.validity = validity;
|
|
376
|
+
}
|
|
377
|
+
static fromRawVector(vector, itemCount) {
|
|
378
|
+
const data = vectorData(vector, itemCount * Int8Array.BYTES_PER_ELEMENT);
|
|
379
|
+
const items = new Int8Array(data.buffer, data.byteOffset, itemCount);
|
|
380
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
381
|
+
return new DuckDBTinyIntVector(items, validity);
|
|
382
|
+
}
|
|
383
|
+
get type() {
|
|
384
|
+
return DuckDBType_1.DuckDBTinyIntType.instance;
|
|
385
|
+
}
|
|
386
|
+
get itemCount() {
|
|
387
|
+
return this.items.length;
|
|
388
|
+
}
|
|
389
|
+
getItem(itemIndex) {
|
|
390
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
391
|
+
}
|
|
392
|
+
slice(offset, length) {
|
|
393
|
+
return new DuckDBTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.DuckDBTinyIntVector = DuckDBTinyIntVector;
|
|
397
|
+
class DuckDBSmallIntVector extends DuckDBVector {
|
|
398
|
+
items;
|
|
399
|
+
validity;
|
|
400
|
+
constructor(items, validity) {
|
|
401
|
+
super();
|
|
402
|
+
this.items = items;
|
|
403
|
+
this.validity = validity;
|
|
404
|
+
}
|
|
405
|
+
static fromRawVector(vector, itemCount) {
|
|
406
|
+
const data = vectorData(vector, itemCount * Int16Array.BYTES_PER_ELEMENT);
|
|
407
|
+
const items = new Int16Array(data.buffer, data.byteOffset, itemCount);
|
|
408
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
409
|
+
return new DuckDBSmallIntVector(items, validity);
|
|
410
|
+
}
|
|
411
|
+
get type() {
|
|
412
|
+
return DuckDBType_1.DuckDBSmallIntType.instance;
|
|
413
|
+
}
|
|
414
|
+
get itemCount() {
|
|
415
|
+
return this.items.length;
|
|
416
|
+
}
|
|
417
|
+
getItem(itemIndex) {
|
|
418
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
419
|
+
}
|
|
420
|
+
slice(offset, length) {
|
|
421
|
+
return new DuckDBSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.DuckDBSmallIntVector = DuckDBSmallIntVector;
|
|
425
|
+
class DuckDBIntegerVector extends DuckDBVector {
|
|
426
|
+
items;
|
|
427
|
+
validity;
|
|
428
|
+
constructor(items, validity) {
|
|
429
|
+
super();
|
|
430
|
+
this.items = items;
|
|
431
|
+
this.validity = validity;
|
|
432
|
+
}
|
|
433
|
+
static fromRawVector(vector, itemCount) {
|
|
434
|
+
const data = vectorData(vector, itemCount * Int32Array.BYTES_PER_ELEMENT);
|
|
435
|
+
const items = new Int32Array(data.buffer, data.byteOffset, itemCount);
|
|
436
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
437
|
+
return new DuckDBIntegerVector(items, validity);
|
|
438
|
+
}
|
|
439
|
+
get type() {
|
|
440
|
+
return DuckDBType_1.DuckDBIntegerType.instance;
|
|
441
|
+
}
|
|
442
|
+
get itemCount() {
|
|
443
|
+
return this.items.length;
|
|
444
|
+
}
|
|
445
|
+
getItem(itemIndex) {
|
|
446
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
447
|
+
}
|
|
448
|
+
slice(offset, length) {
|
|
449
|
+
return new DuckDBIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
exports.DuckDBIntegerVector = DuckDBIntegerVector;
|
|
453
|
+
class DuckDBBigIntVector extends DuckDBVector {
|
|
454
|
+
items;
|
|
455
|
+
validity;
|
|
456
|
+
constructor(items, validity) {
|
|
457
|
+
super();
|
|
458
|
+
this.items = items;
|
|
459
|
+
this.validity = validity;
|
|
460
|
+
}
|
|
461
|
+
static fromRawVector(vector, itemCount) {
|
|
462
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
463
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
464
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
465
|
+
return new DuckDBBigIntVector(items, validity);
|
|
466
|
+
}
|
|
467
|
+
get type() {
|
|
468
|
+
return DuckDBType_1.DuckDBBigIntType.instance;
|
|
469
|
+
}
|
|
470
|
+
get itemCount() {
|
|
471
|
+
return this.items.length;
|
|
472
|
+
}
|
|
473
|
+
getItem(itemIndex) {
|
|
474
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
475
|
+
}
|
|
476
|
+
slice(offset, length) {
|
|
477
|
+
return new DuckDBBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
exports.DuckDBBigIntVector = DuckDBBigIntVector;
|
|
481
|
+
class DuckDBUTinyIntVector extends DuckDBVector {
|
|
482
|
+
items;
|
|
483
|
+
validity;
|
|
484
|
+
constructor(items, validity) {
|
|
485
|
+
super();
|
|
486
|
+
this.items = items;
|
|
487
|
+
this.validity = validity;
|
|
488
|
+
}
|
|
489
|
+
static fromRawVector(vector, itemCount) {
|
|
490
|
+
const data = vectorData(vector, itemCount * Uint8Array.BYTES_PER_ELEMENT);
|
|
491
|
+
const items = new Uint8Array(data.buffer, data.byteOffset, itemCount);
|
|
492
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
493
|
+
return new DuckDBUTinyIntVector(items, validity);
|
|
494
|
+
}
|
|
495
|
+
get type() {
|
|
496
|
+
return DuckDBType_1.DuckDBUTinyIntType.instance;
|
|
497
|
+
}
|
|
498
|
+
get itemCount() {
|
|
499
|
+
return this.items.length;
|
|
500
|
+
}
|
|
501
|
+
getItem(itemIndex) {
|
|
502
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
503
|
+
}
|
|
504
|
+
slice(offset, length) {
|
|
505
|
+
return new DuckDBUTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
exports.DuckDBUTinyIntVector = DuckDBUTinyIntVector;
|
|
509
|
+
class DuckDBUSmallIntVector extends DuckDBVector {
|
|
510
|
+
items;
|
|
511
|
+
validity;
|
|
512
|
+
constructor(items, validity) {
|
|
513
|
+
super();
|
|
514
|
+
this.items = items;
|
|
515
|
+
this.validity = validity;
|
|
516
|
+
}
|
|
517
|
+
static fromRawVector(vector, itemCount) {
|
|
518
|
+
const data = vectorData(vector, itemCount * Uint16Array.BYTES_PER_ELEMENT);
|
|
519
|
+
const items = new Uint16Array(data.buffer, data.byteOffset, itemCount);
|
|
520
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
521
|
+
return new DuckDBUSmallIntVector(items, validity);
|
|
522
|
+
}
|
|
523
|
+
get type() {
|
|
524
|
+
return DuckDBType_1.DuckDBUSmallIntType.instance;
|
|
525
|
+
}
|
|
526
|
+
get itemCount() {
|
|
527
|
+
return this.items.length;
|
|
528
|
+
}
|
|
529
|
+
getItem(itemIndex) {
|
|
530
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
531
|
+
}
|
|
532
|
+
slice(offset, length) {
|
|
533
|
+
return new DuckDBUSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
exports.DuckDBUSmallIntVector = DuckDBUSmallIntVector;
|
|
537
|
+
class DuckDBUIntegerVector extends DuckDBVector {
|
|
538
|
+
items;
|
|
539
|
+
validity;
|
|
540
|
+
constructor(items, validity) {
|
|
541
|
+
super();
|
|
542
|
+
this.items = items;
|
|
543
|
+
this.validity = validity;
|
|
544
|
+
}
|
|
545
|
+
static fromRawVector(vector, itemCount) {
|
|
546
|
+
const data = vectorData(vector, itemCount * Uint32Array.BYTES_PER_ELEMENT);
|
|
547
|
+
const items = new Uint32Array(data.buffer, data.byteOffset, itemCount);
|
|
548
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
549
|
+
return new DuckDBUIntegerVector(items, validity);
|
|
550
|
+
}
|
|
551
|
+
get type() {
|
|
552
|
+
return DuckDBType_1.DuckDBUIntegerType.instance;
|
|
553
|
+
}
|
|
554
|
+
get itemCount() {
|
|
555
|
+
return this.items.length;
|
|
556
|
+
}
|
|
557
|
+
getItem(itemIndex) {
|
|
558
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
559
|
+
}
|
|
560
|
+
slice(offset, length) {
|
|
561
|
+
return new DuckDBUIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
exports.DuckDBUIntegerVector = DuckDBUIntegerVector;
|
|
565
|
+
class DuckDBUBigIntVector extends DuckDBVector {
|
|
566
|
+
items;
|
|
567
|
+
validity;
|
|
568
|
+
constructor(items, validity) {
|
|
569
|
+
super();
|
|
570
|
+
this.items = items;
|
|
571
|
+
this.validity = validity;
|
|
572
|
+
}
|
|
573
|
+
static fromRawVector(vector, itemCount) {
|
|
574
|
+
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT);
|
|
575
|
+
const items = new BigUint64Array(data.buffer, data.byteOffset, itemCount);
|
|
576
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
577
|
+
return new DuckDBUBigIntVector(items, validity);
|
|
578
|
+
}
|
|
579
|
+
get type() {
|
|
580
|
+
return DuckDBType_1.DuckDBUBigIntType.instance;
|
|
581
|
+
}
|
|
582
|
+
get itemCount() {
|
|
583
|
+
return this.items.length;
|
|
584
|
+
}
|
|
585
|
+
getItem(itemIndex) {
|
|
586
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
587
|
+
}
|
|
588
|
+
slice(offset, length) {
|
|
589
|
+
return new DuckDBUBigIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
exports.DuckDBUBigIntVector = DuckDBUBigIntVector;
|
|
593
|
+
class DuckDBFloatVector extends DuckDBVector {
|
|
594
|
+
items;
|
|
595
|
+
validity;
|
|
596
|
+
constructor(items, validity) {
|
|
597
|
+
super();
|
|
598
|
+
this.items = items;
|
|
599
|
+
this.validity = validity;
|
|
600
|
+
}
|
|
601
|
+
static fromRawVector(vector, itemCount) {
|
|
602
|
+
const data = vectorData(vector, itemCount * Float32Array.BYTES_PER_ELEMENT);
|
|
603
|
+
const items = new Float32Array(data.buffer, data.byteOffset, itemCount);
|
|
604
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
605
|
+
return new DuckDBFloatVector(items, validity);
|
|
606
|
+
}
|
|
607
|
+
get type() {
|
|
608
|
+
return DuckDBType_1.DuckDBFloatType.instance;
|
|
609
|
+
}
|
|
610
|
+
get itemCount() {
|
|
611
|
+
return this.items.length;
|
|
612
|
+
}
|
|
613
|
+
getItem(itemIndex) {
|
|
614
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
615
|
+
}
|
|
616
|
+
slice(offset, length) {
|
|
617
|
+
return new DuckDBFloatVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
exports.DuckDBFloatVector = DuckDBFloatVector;
|
|
621
|
+
class DuckDBDoubleVector extends DuckDBVector {
|
|
622
|
+
items;
|
|
623
|
+
validity;
|
|
624
|
+
constructor(items, validity) {
|
|
625
|
+
super();
|
|
626
|
+
this.items = items;
|
|
627
|
+
this.validity = validity;
|
|
628
|
+
}
|
|
629
|
+
static fromRawVector(vector, itemCount) {
|
|
630
|
+
const data = vectorData(vector, itemCount * Float64Array.BYTES_PER_ELEMENT);
|
|
631
|
+
const items = new Float64Array(data.buffer, data.byteOffset, itemCount);
|
|
632
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
633
|
+
return new DuckDBDoubleVector(items, validity);
|
|
634
|
+
}
|
|
635
|
+
get type() {
|
|
636
|
+
return DuckDBType_1.DuckDBDoubleType.instance;
|
|
637
|
+
}
|
|
638
|
+
get itemCount() {
|
|
639
|
+
return this.items.length;
|
|
640
|
+
}
|
|
641
|
+
getItem(itemIndex) {
|
|
642
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
643
|
+
}
|
|
644
|
+
slice(offset, length) {
|
|
645
|
+
return new DuckDBDoubleVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
exports.DuckDBDoubleVector = DuckDBDoubleVector;
|
|
649
|
+
class DuckDBTimestampVector extends DuckDBVector {
|
|
650
|
+
items;
|
|
651
|
+
validity;
|
|
652
|
+
constructor(items, validity) {
|
|
653
|
+
super();
|
|
654
|
+
this.items = items;
|
|
655
|
+
this.validity = validity;
|
|
656
|
+
}
|
|
657
|
+
static fromRawVector(vector, itemCount) {
|
|
658
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
659
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
660
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
661
|
+
return new DuckDBTimestampVector(items, validity);
|
|
662
|
+
}
|
|
663
|
+
get type() {
|
|
664
|
+
return DuckDBType_1.DuckDBTimestampType.instance;
|
|
665
|
+
}
|
|
666
|
+
get itemCount() {
|
|
667
|
+
return this.items.length;
|
|
668
|
+
}
|
|
669
|
+
getItem(itemIndex) {
|
|
670
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
671
|
+
}
|
|
672
|
+
slice(offset, length) {
|
|
673
|
+
return new DuckDBTimestampVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
exports.DuckDBTimestampVector = DuckDBTimestampVector;
|
|
677
|
+
class DuckDBDateVector extends DuckDBVector {
|
|
678
|
+
items;
|
|
679
|
+
validity;
|
|
680
|
+
constructor(items, validity) {
|
|
681
|
+
super();
|
|
682
|
+
this.items = items;
|
|
683
|
+
this.validity = validity;
|
|
684
|
+
}
|
|
685
|
+
static fromRawVector(vector, itemCount) {
|
|
686
|
+
const data = vectorData(vector, itemCount * Int32Array.BYTES_PER_ELEMENT);
|
|
687
|
+
const items = new Int32Array(data.buffer, data.byteOffset, itemCount);
|
|
688
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
689
|
+
return new DuckDBDateVector(items, validity);
|
|
690
|
+
}
|
|
691
|
+
get type() {
|
|
692
|
+
return DuckDBType_1.DuckDBDateType.instance;
|
|
693
|
+
}
|
|
694
|
+
get itemCount() {
|
|
695
|
+
return this.items.length;
|
|
696
|
+
}
|
|
697
|
+
getItem(itemIndex) {
|
|
698
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
699
|
+
}
|
|
700
|
+
slice(offset, length) {
|
|
701
|
+
return new DuckDBDateVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
exports.DuckDBDateVector = DuckDBDateVector;
|
|
705
|
+
class DuckDBTimeVector extends DuckDBVector {
|
|
706
|
+
items;
|
|
707
|
+
validity;
|
|
708
|
+
constructor(items, validity) {
|
|
709
|
+
super();
|
|
710
|
+
this.items = items;
|
|
711
|
+
this.validity = validity;
|
|
712
|
+
}
|
|
713
|
+
static fromRawVector(vector, itemCount) {
|
|
714
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
715
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
716
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
717
|
+
return new DuckDBTimeVector(items, validity);
|
|
718
|
+
}
|
|
719
|
+
get type() {
|
|
720
|
+
return DuckDBType_1.DuckDBTimeType.instance;
|
|
721
|
+
}
|
|
722
|
+
get itemCount() {
|
|
723
|
+
return this.items.length;
|
|
724
|
+
}
|
|
725
|
+
getItem(itemIndex) {
|
|
726
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
727
|
+
}
|
|
728
|
+
slice(offset, length) {
|
|
729
|
+
return new DuckDBTimeVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
exports.DuckDBTimeVector = DuckDBTimeVector;
|
|
733
|
+
class DuckDBInterval {
|
|
734
|
+
months;
|
|
735
|
+
days;
|
|
736
|
+
micros;
|
|
737
|
+
constructor(months, days, micros) {
|
|
738
|
+
this.months = months;
|
|
739
|
+
this.days = days;
|
|
740
|
+
this.micros = micros;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
exports.DuckDBInterval = DuckDBInterval;
|
|
744
|
+
class DuckDBIntervalVector extends DuckDBVector {
|
|
745
|
+
dataView;
|
|
746
|
+
validity;
|
|
747
|
+
_itemCount;
|
|
748
|
+
constructor(dataView, validity, itemCount) {
|
|
749
|
+
super();
|
|
750
|
+
this.dataView = dataView;
|
|
751
|
+
this.validity = validity;
|
|
752
|
+
this._itemCount = itemCount;
|
|
753
|
+
}
|
|
754
|
+
static fromRawVector(vector, itemCount) {
|
|
755
|
+
const data = vectorData(vector, itemCount * 16);
|
|
756
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
757
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
758
|
+
return new DuckDBIntervalVector(dataView, validity, itemCount);
|
|
759
|
+
}
|
|
760
|
+
get type() {
|
|
761
|
+
return DuckDBType_1.DuckDBIntervalType.instance;
|
|
762
|
+
}
|
|
763
|
+
get itemCount() {
|
|
764
|
+
return this._itemCount;
|
|
765
|
+
}
|
|
766
|
+
getItem(itemIndex) {
|
|
767
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
770
|
+
const itemStart = itemIndex * 16;
|
|
771
|
+
const months = getInt32(this.dataView, itemStart);
|
|
772
|
+
const days = getInt32(this.dataView, itemStart + 4);
|
|
773
|
+
const micros = getInt64(this.dataView, itemStart + 8);
|
|
774
|
+
return new DuckDBInterval(months, days, micros);
|
|
775
|
+
}
|
|
776
|
+
slice(offset, length) {
|
|
777
|
+
return new DuckDBIntervalVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
exports.DuckDBIntervalVector = DuckDBIntervalVector;
|
|
781
|
+
class DuckDBHugeIntVector extends DuckDBVector {
|
|
782
|
+
dataView;
|
|
783
|
+
validity;
|
|
784
|
+
_itemCount;
|
|
785
|
+
constructor(dataView, validity, itemCount) {
|
|
786
|
+
super();
|
|
787
|
+
this.dataView = dataView;
|
|
788
|
+
this.validity = validity;
|
|
789
|
+
this._itemCount = itemCount;
|
|
790
|
+
}
|
|
791
|
+
static fromRawVector(vector, itemCount) {
|
|
792
|
+
const data = vectorData(vector, itemCount * 16);
|
|
793
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
794
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
795
|
+
return new DuckDBHugeIntVector(dataView, validity, itemCount);
|
|
796
|
+
}
|
|
797
|
+
get type() {
|
|
798
|
+
return DuckDBType_1.DuckDBHugeIntType.instance;
|
|
799
|
+
}
|
|
800
|
+
get itemCount() {
|
|
801
|
+
return this._itemCount;
|
|
802
|
+
}
|
|
803
|
+
getItem(itemIndex) {
|
|
804
|
+
return this.validity.itemValid(itemIndex) ? getInt128(this.dataView, itemIndex * 16) : null;
|
|
805
|
+
}
|
|
806
|
+
slice(offset, length) {
|
|
807
|
+
return new DuckDBHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
exports.DuckDBHugeIntVector = DuckDBHugeIntVector;
|
|
811
|
+
class DuckDBUHugeIntVector extends DuckDBVector {
|
|
812
|
+
dataView;
|
|
813
|
+
validity;
|
|
814
|
+
_itemCount;
|
|
815
|
+
constructor(dataView, validity, itemCount) {
|
|
816
|
+
super();
|
|
817
|
+
this.dataView = dataView;
|
|
818
|
+
this.validity = validity;
|
|
819
|
+
this._itemCount = itemCount;
|
|
820
|
+
}
|
|
821
|
+
static fromRawVector(vector, itemCount) {
|
|
822
|
+
const data = vectorData(vector, itemCount * 16);
|
|
823
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
824
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
825
|
+
return new DuckDBUHugeIntVector(dataView, validity, itemCount);
|
|
826
|
+
}
|
|
827
|
+
get type() {
|
|
828
|
+
return DuckDBType_1.DuckDBUHugeIntType.instance;
|
|
829
|
+
}
|
|
830
|
+
get itemCount() {
|
|
831
|
+
return this._itemCount;
|
|
832
|
+
}
|
|
833
|
+
getItem(itemIndex) {
|
|
834
|
+
return this.validity.itemValid(itemIndex) ? getUInt128(this.dataView, itemIndex * 16) : null;
|
|
835
|
+
}
|
|
836
|
+
slice(offset, length) {
|
|
837
|
+
return new DuckDBUHugeIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
exports.DuckDBUHugeIntVector = DuckDBUHugeIntVector;
|
|
841
|
+
class DuckDBVarCharVector extends DuckDBVector {
|
|
842
|
+
dataView;
|
|
843
|
+
validity;
|
|
844
|
+
_itemCount;
|
|
845
|
+
constructor(dataView, validity, itemCount) {
|
|
846
|
+
super();
|
|
847
|
+
this.dataView = dataView;
|
|
848
|
+
this.validity = validity;
|
|
849
|
+
this._itemCount = itemCount;
|
|
850
|
+
}
|
|
851
|
+
static fromRawVector(vector, itemCount) {
|
|
852
|
+
const data = vectorData(vector, itemCount * 16);
|
|
853
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
854
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
855
|
+
return new DuckDBVarCharVector(dataView, validity, itemCount);
|
|
856
|
+
}
|
|
857
|
+
get type() {
|
|
858
|
+
return DuckDBType_1.DuckDBVarCharType.instance;
|
|
859
|
+
}
|
|
860
|
+
get itemCount() {
|
|
861
|
+
return this._itemCount;
|
|
862
|
+
}
|
|
863
|
+
getItem(itemIndex) {
|
|
864
|
+
return this.validity.itemValid(itemIndex) ? getString(this.dataView, itemIndex * 16) : null;
|
|
865
|
+
}
|
|
866
|
+
slice(offset, length) {
|
|
867
|
+
return new DuckDBVarCharVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
exports.DuckDBVarCharVector = DuckDBVarCharVector;
|
|
871
|
+
class DuckDBBlobVector extends DuckDBVector {
|
|
872
|
+
dataView;
|
|
873
|
+
validity;
|
|
874
|
+
_itemCount;
|
|
875
|
+
constructor(dataView, validity, itemCount) {
|
|
876
|
+
super();
|
|
877
|
+
this.dataView = dataView;
|
|
878
|
+
this.validity = validity;
|
|
879
|
+
this._itemCount = itemCount;
|
|
880
|
+
}
|
|
881
|
+
static fromRawVector(vector, itemCount) {
|
|
882
|
+
const data = vectorData(vector, itemCount * 16);
|
|
883
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
884
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
885
|
+
return new DuckDBBlobVector(dataView, validity, itemCount);
|
|
886
|
+
}
|
|
887
|
+
get type() {
|
|
888
|
+
return DuckDBType_1.DuckDBBlobType.instance;
|
|
889
|
+
}
|
|
890
|
+
get itemCount() {
|
|
891
|
+
return this._itemCount;
|
|
892
|
+
}
|
|
893
|
+
getItem(itemIndex) {
|
|
894
|
+
return this.validity.itemValid(itemIndex) ? getBuffer(this.dataView, itemIndex * 16) : null;
|
|
895
|
+
}
|
|
896
|
+
slice(offset, length) {
|
|
897
|
+
return new DuckDBBlobVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
exports.DuckDBBlobVector = DuckDBBlobVector;
|
|
901
|
+
class DuckDBDecimal2Vector extends DuckDBVector {
|
|
902
|
+
decimalType;
|
|
903
|
+
dataView;
|
|
904
|
+
validity;
|
|
905
|
+
_itemCount;
|
|
906
|
+
constructor(decimalType, dataView, validity, itemCount) {
|
|
907
|
+
super();
|
|
908
|
+
this.decimalType = decimalType;
|
|
909
|
+
this.dataView = dataView;
|
|
910
|
+
this.validity = validity;
|
|
911
|
+
this._itemCount = itemCount;
|
|
912
|
+
}
|
|
913
|
+
static fromRawVector(decimalType, vector, itemCount) {
|
|
914
|
+
const data = vectorData(vector, itemCount * 2);
|
|
915
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
916
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
917
|
+
return new DuckDBDecimal2Vector(decimalType, dataView, validity, itemCount);
|
|
918
|
+
}
|
|
919
|
+
get type() {
|
|
920
|
+
return this.decimalType;
|
|
921
|
+
}
|
|
922
|
+
get itemCount() {
|
|
923
|
+
return this._itemCount;
|
|
924
|
+
}
|
|
925
|
+
getItem(itemIndex) {
|
|
926
|
+
return this.validity.itemValid(itemIndex) ? getDecimal2(this.dataView, itemIndex * 2, this.decimalType) : null;
|
|
927
|
+
}
|
|
928
|
+
getScaledValue(itemIndex) {
|
|
929
|
+
return this.validity.itemValid(itemIndex) ? getInt16(this.dataView, itemIndex * 2) : null;
|
|
930
|
+
}
|
|
931
|
+
slice(offset, length) {
|
|
932
|
+
return new DuckDBDecimal2Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 2, length * 2), this.validity.slice(offset), length);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
exports.DuckDBDecimal2Vector = DuckDBDecimal2Vector;
|
|
936
|
+
class DuckDBDecimal4Vector extends DuckDBVector {
|
|
937
|
+
decimalType;
|
|
938
|
+
dataView;
|
|
939
|
+
validity;
|
|
940
|
+
_itemCount;
|
|
941
|
+
constructor(decimalType, dataView, validity, itemCount) {
|
|
942
|
+
super();
|
|
943
|
+
this.decimalType = decimalType;
|
|
944
|
+
this.dataView = dataView;
|
|
945
|
+
this.validity = validity;
|
|
946
|
+
this._itemCount = itemCount;
|
|
947
|
+
}
|
|
948
|
+
static fromRawVector(decimalType, vector, itemCount) {
|
|
949
|
+
const data = vectorData(vector, itemCount * 4);
|
|
950
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
951
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
952
|
+
return new DuckDBDecimal4Vector(decimalType, dataView, validity, itemCount);
|
|
953
|
+
}
|
|
954
|
+
get type() {
|
|
955
|
+
return this.decimalType;
|
|
956
|
+
}
|
|
957
|
+
get itemCount() {
|
|
958
|
+
return this._itemCount;
|
|
959
|
+
}
|
|
960
|
+
getItem(itemIndex) {
|
|
961
|
+
return this.validity.itemValid(itemIndex) ? getDecimal4(this.dataView, itemIndex * 4, this.decimalType) : null;
|
|
962
|
+
}
|
|
963
|
+
getScaledValue(itemIndex) {
|
|
964
|
+
return this.validity.itemValid(itemIndex) ? getInt32(this.dataView, itemIndex * 4) : null;
|
|
965
|
+
}
|
|
966
|
+
slice(offset, length) {
|
|
967
|
+
return new DuckDBDecimal4Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 4, length * 4), this.validity.slice(offset), length);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
exports.DuckDBDecimal4Vector = DuckDBDecimal4Vector;
|
|
971
|
+
class DuckDBDecimal8Vector extends DuckDBVector {
|
|
972
|
+
decimalType;
|
|
973
|
+
dataView;
|
|
974
|
+
validity;
|
|
975
|
+
_itemCount;
|
|
976
|
+
constructor(decimalType, dataView, validity, itemCount) {
|
|
977
|
+
super();
|
|
978
|
+
this.decimalType = decimalType;
|
|
979
|
+
this.dataView = dataView;
|
|
980
|
+
this.validity = validity;
|
|
981
|
+
this._itemCount = itemCount;
|
|
982
|
+
}
|
|
983
|
+
static fromRawVector(decimalType, vector, itemCount) {
|
|
984
|
+
const data = vectorData(vector, itemCount * 8);
|
|
985
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
986
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
987
|
+
return new DuckDBDecimal8Vector(decimalType, dataView, validity, itemCount);
|
|
988
|
+
}
|
|
989
|
+
get type() {
|
|
990
|
+
return this.decimalType;
|
|
991
|
+
}
|
|
992
|
+
get itemCount() {
|
|
993
|
+
return this._itemCount;
|
|
994
|
+
}
|
|
995
|
+
getItem(itemIndex) {
|
|
996
|
+
return this.validity.itemValid(itemIndex) ? getDecimal8(this.dataView, itemIndex * 8, this.decimalType) : null;
|
|
997
|
+
}
|
|
998
|
+
getScaledValue(itemIndex) {
|
|
999
|
+
return this.validity.itemValid(itemIndex) ? getInt64(this.dataView, itemIndex * 8) : null;
|
|
1000
|
+
}
|
|
1001
|
+
slice(offset, length) {
|
|
1002
|
+
return new DuckDBDecimal8Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 8, length * 8), this.validity.slice(offset), length);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
exports.DuckDBDecimal8Vector = DuckDBDecimal8Vector;
|
|
1006
|
+
class DuckDBDecimal16Vector extends DuckDBVector {
|
|
1007
|
+
decimalType;
|
|
1008
|
+
dataView;
|
|
1009
|
+
validity;
|
|
1010
|
+
_itemCount;
|
|
1011
|
+
constructor(decimalType, dataView, validity, itemCount) {
|
|
1012
|
+
super();
|
|
1013
|
+
this.decimalType = decimalType;
|
|
1014
|
+
this.dataView = dataView;
|
|
1015
|
+
this.validity = validity;
|
|
1016
|
+
this._itemCount = itemCount;
|
|
1017
|
+
}
|
|
1018
|
+
static fromRawVector(decimalType, vector, itemCount) {
|
|
1019
|
+
const data = vectorData(vector, itemCount * 16);
|
|
1020
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1021
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1022
|
+
return new DuckDBDecimal16Vector(decimalType, dataView, validity, itemCount);
|
|
1023
|
+
}
|
|
1024
|
+
get type() {
|
|
1025
|
+
return this.decimalType;
|
|
1026
|
+
}
|
|
1027
|
+
get itemCount() {
|
|
1028
|
+
return this._itemCount;
|
|
1029
|
+
}
|
|
1030
|
+
getItem(itemIndex) {
|
|
1031
|
+
return this.validity.itemValid(itemIndex) ? getDecimal16(this.dataView, itemIndex * 16, this.decimalType) : null;
|
|
1032
|
+
}
|
|
1033
|
+
getScaledValue(itemIndex) {
|
|
1034
|
+
return this.validity.itemValid(itemIndex) ? getInt128(this.dataView, itemIndex * 16) : null;
|
|
1035
|
+
}
|
|
1036
|
+
slice(offset, length) {
|
|
1037
|
+
return new DuckDBDecimal16Vector(this.decimalType, new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
exports.DuckDBDecimal16Vector = DuckDBDecimal16Vector;
|
|
1041
|
+
class DuckDBTimestampSecondsVector extends DuckDBVector {
|
|
1042
|
+
items;
|
|
1043
|
+
validity;
|
|
1044
|
+
constructor(items, validity) {
|
|
1045
|
+
super();
|
|
1046
|
+
this.items = items;
|
|
1047
|
+
this.validity = validity;
|
|
1048
|
+
}
|
|
1049
|
+
static fromRawVector(vector, itemCount) {
|
|
1050
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1051
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1052
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1053
|
+
return new DuckDBTimestampSecondsVector(items, validity);
|
|
1054
|
+
}
|
|
1055
|
+
get type() {
|
|
1056
|
+
return DuckDBType_1.DuckDBTimestampSecondsType.instance;
|
|
1057
|
+
}
|
|
1058
|
+
get itemCount() {
|
|
1059
|
+
return this.items.length;
|
|
1060
|
+
}
|
|
1061
|
+
getItem(itemIndex) {
|
|
1062
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
1063
|
+
}
|
|
1064
|
+
slice(offset, length) {
|
|
1065
|
+
return new DuckDBTimestampSecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
exports.DuckDBTimestampSecondsVector = DuckDBTimestampSecondsVector;
|
|
1069
|
+
class DuckDBTimestampMillisecondsVector extends DuckDBVector {
|
|
1070
|
+
items;
|
|
1071
|
+
validity;
|
|
1072
|
+
constructor(items, validity) {
|
|
1073
|
+
super();
|
|
1074
|
+
this.items = items;
|
|
1075
|
+
this.validity = validity;
|
|
1076
|
+
}
|
|
1077
|
+
static fromRawVector(vector, itemCount) {
|
|
1078
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1079
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1080
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1081
|
+
return new DuckDBTimestampMillisecondsVector(items, validity);
|
|
1082
|
+
}
|
|
1083
|
+
get type() {
|
|
1084
|
+
return DuckDBType_1.DuckDBTimestampMillisecondsType.instance;
|
|
1085
|
+
}
|
|
1086
|
+
get itemCount() {
|
|
1087
|
+
return this.items.length;
|
|
1088
|
+
}
|
|
1089
|
+
getItem(itemIndex) {
|
|
1090
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
1091
|
+
}
|
|
1092
|
+
slice(offset, length) {
|
|
1093
|
+
return new DuckDBTimestampMillisecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
exports.DuckDBTimestampMillisecondsVector = DuckDBTimestampMillisecondsVector;
|
|
1097
|
+
class DuckDBTimestampNanosecondsVector extends DuckDBVector {
|
|
1098
|
+
items;
|
|
1099
|
+
validity;
|
|
1100
|
+
constructor(items, validity) {
|
|
1101
|
+
super();
|
|
1102
|
+
this.items = items;
|
|
1103
|
+
this.validity = validity;
|
|
1104
|
+
}
|
|
1105
|
+
static fromRawVector(vector, itemCount) {
|
|
1106
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1107
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1108
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1109
|
+
return new DuckDBTimestampNanosecondsVector(items, validity);
|
|
1110
|
+
}
|
|
1111
|
+
get type() {
|
|
1112
|
+
return DuckDBType_1.DuckDBTimestampNanosecondsType.instance;
|
|
1113
|
+
}
|
|
1114
|
+
get itemCount() {
|
|
1115
|
+
return this.items.length;
|
|
1116
|
+
}
|
|
1117
|
+
getItem(itemIndex) {
|
|
1118
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
1119
|
+
}
|
|
1120
|
+
slice(offset, length) {
|
|
1121
|
+
return new DuckDBTimestampNanosecondsVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
exports.DuckDBTimestampNanosecondsVector = DuckDBTimestampNanosecondsVector;
|
|
1125
|
+
class DuckDBEnum1Vector extends DuckDBVector {
|
|
1126
|
+
enumType;
|
|
1127
|
+
items;
|
|
1128
|
+
validity;
|
|
1129
|
+
constructor(enumType, items, validity) {
|
|
1130
|
+
super();
|
|
1131
|
+
this.enumType = enumType;
|
|
1132
|
+
this.items = items;
|
|
1133
|
+
this.validity = validity;
|
|
1134
|
+
}
|
|
1135
|
+
static fromRawVector(enumType, vector, itemCount) {
|
|
1136
|
+
const data = vectorData(vector, itemCount);
|
|
1137
|
+
const items = new Uint8Array(data.buffer, data.byteOffset, itemCount);
|
|
1138
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1139
|
+
return new DuckDBEnum1Vector(enumType, items, validity);
|
|
1140
|
+
}
|
|
1141
|
+
get type() {
|
|
1142
|
+
return this.enumType;
|
|
1143
|
+
}
|
|
1144
|
+
get itemCount() {
|
|
1145
|
+
return this.items.length;
|
|
1146
|
+
}
|
|
1147
|
+
getItem(itemIndex) {
|
|
1148
|
+
return this.validity.itemValid(itemIndex) ? this.enumType.values[this.items[itemIndex]] : null;
|
|
1149
|
+
}
|
|
1150
|
+
slice(offset, length) {
|
|
1151
|
+
return new DuckDBEnum1Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
exports.DuckDBEnum1Vector = DuckDBEnum1Vector;
|
|
1155
|
+
class DuckDBEnum2Vector extends DuckDBVector {
|
|
1156
|
+
enumType;
|
|
1157
|
+
items;
|
|
1158
|
+
validity;
|
|
1159
|
+
constructor(enumType, items, validity) {
|
|
1160
|
+
super();
|
|
1161
|
+
this.enumType = enumType;
|
|
1162
|
+
this.items = items;
|
|
1163
|
+
this.validity = validity;
|
|
1164
|
+
}
|
|
1165
|
+
static fromRawVector(enumType, vector, itemCount) {
|
|
1166
|
+
const data = vectorData(vector, itemCount * 2);
|
|
1167
|
+
const items = new Uint16Array(data.buffer, data.byteOffset, itemCount);
|
|
1168
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1169
|
+
return new DuckDBEnum2Vector(enumType, items, validity);
|
|
1170
|
+
}
|
|
1171
|
+
get type() {
|
|
1172
|
+
return this.enumType;
|
|
1173
|
+
}
|
|
1174
|
+
get itemCount() {
|
|
1175
|
+
return this.items.length;
|
|
1176
|
+
}
|
|
1177
|
+
getItem(itemIndex) {
|
|
1178
|
+
return this.validity.itemValid(itemIndex) ? this.enumType.values[this.items[itemIndex]] : null;
|
|
1179
|
+
}
|
|
1180
|
+
slice(offset, length) {
|
|
1181
|
+
return new DuckDBEnum2Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
exports.DuckDBEnum2Vector = DuckDBEnum2Vector;
|
|
1185
|
+
class DuckDBEnum4Vector extends DuckDBVector {
|
|
1186
|
+
enumType;
|
|
1187
|
+
items;
|
|
1188
|
+
validity;
|
|
1189
|
+
constructor(enumType, items, validity) {
|
|
1190
|
+
super();
|
|
1191
|
+
this.enumType = enumType;
|
|
1192
|
+
this.items = items;
|
|
1193
|
+
this.validity = validity;
|
|
1194
|
+
}
|
|
1195
|
+
static fromRawVector(enumType, vector, itemCount) {
|
|
1196
|
+
const data = vectorData(vector, itemCount * 4);
|
|
1197
|
+
const items = new Uint32Array(data.buffer, data.byteOffset, itemCount);
|
|
1198
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1199
|
+
return new DuckDBEnum4Vector(enumType, items, validity);
|
|
1200
|
+
}
|
|
1201
|
+
get type() {
|
|
1202
|
+
return this.enumType;
|
|
1203
|
+
}
|
|
1204
|
+
get itemCount() {
|
|
1205
|
+
return this.items.length;
|
|
1206
|
+
}
|
|
1207
|
+
getItem(itemIndex) {
|
|
1208
|
+
return this.validity.itemValid(itemIndex) ? this.enumType.values[this.items[itemIndex]] : null;
|
|
1209
|
+
}
|
|
1210
|
+
slice(offset, length) {
|
|
1211
|
+
return new DuckDBEnum4Vector(this.enumType, this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
exports.DuckDBEnum4Vector = DuckDBEnum4Vector;
|
|
1215
|
+
class DuckDBListVector extends DuckDBVector {
|
|
1216
|
+
listType;
|
|
1217
|
+
entryData;
|
|
1218
|
+
validity;
|
|
1219
|
+
childData;
|
|
1220
|
+
_itemCount;
|
|
1221
|
+
constructor(listType, entryData, validity, childData, itemCount) {
|
|
1222
|
+
super();
|
|
1223
|
+
this.listType = listType;
|
|
1224
|
+
this.entryData = entryData;
|
|
1225
|
+
this.validity = validity;
|
|
1226
|
+
this.childData = childData;
|
|
1227
|
+
this._itemCount = itemCount;
|
|
1228
|
+
}
|
|
1229
|
+
static fromRawVector(listType, vector, itemCount) {
|
|
1230
|
+
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT * 2);
|
|
1231
|
+
const entryData = new BigUint64Array(data.buffer, data.byteOffset, itemCount * 2);
|
|
1232
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1233
|
+
const child_vector = node_bindings_1.default.list_vector_get_child(vector);
|
|
1234
|
+
const child_vector_size = node_bindings_1.default.list_vector_get_size(vector);
|
|
1235
|
+
const childData = DuckDBVector.create(child_vector, child_vector_size, listType.valueType);
|
|
1236
|
+
return new DuckDBListVector(listType, entryData, validity, childData, itemCount);
|
|
1237
|
+
}
|
|
1238
|
+
get type() {
|
|
1239
|
+
return this.listType;
|
|
1240
|
+
}
|
|
1241
|
+
get itemCount() {
|
|
1242
|
+
return this._itemCount;
|
|
1243
|
+
}
|
|
1244
|
+
getItem(itemIndex) {
|
|
1245
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1246
|
+
return null;
|
|
1247
|
+
}
|
|
1248
|
+
const entryDataStartIndex = itemIndex * 2;
|
|
1249
|
+
const offset = Number(this.entryData[entryDataStartIndex]);
|
|
1250
|
+
const length = Number(this.entryData[entryDataStartIndex + 1]);
|
|
1251
|
+
return this.childData.slice(offset, length);
|
|
1252
|
+
}
|
|
1253
|
+
slice(offset, length) {
|
|
1254
|
+
const entryDataStartIndex = offset * 2;
|
|
1255
|
+
return new DuckDBListVector(this.listType, this.entryData.slice(entryDataStartIndex, entryDataStartIndex + length * 2), this.validity.slice(offset), this.childData, length);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
exports.DuckDBListVector = DuckDBListVector;
|
|
1259
|
+
class DuckDBStructVector extends DuckDBVector {
|
|
1260
|
+
structType;
|
|
1261
|
+
_itemCount;
|
|
1262
|
+
entryVectors;
|
|
1263
|
+
validity;
|
|
1264
|
+
constructor(structType, itemCount, entryVectors, validity) {
|
|
1265
|
+
super();
|
|
1266
|
+
this.structType = structType;
|
|
1267
|
+
this._itemCount = itemCount;
|
|
1268
|
+
this.entryVectors = entryVectors;
|
|
1269
|
+
this.validity = validity;
|
|
1270
|
+
}
|
|
1271
|
+
static fromRawVector(structType, vector, itemCount) {
|
|
1272
|
+
const entryCount = structType.entries.length;
|
|
1273
|
+
const entryVectors = [];
|
|
1274
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1275
|
+
const entry = structType.entries[i];
|
|
1276
|
+
const child_vector = node_bindings_1.default.struct_vector_get_child(vector, i);
|
|
1277
|
+
entryVectors.push(DuckDBVector.create(child_vector, itemCount, entry.valueType));
|
|
1278
|
+
}
|
|
1279
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1280
|
+
return new DuckDBStructVector(structType, itemCount, entryVectors, validity);
|
|
1281
|
+
}
|
|
1282
|
+
get type() {
|
|
1283
|
+
return this.structType;
|
|
1284
|
+
}
|
|
1285
|
+
get itemCount() {
|
|
1286
|
+
return this._itemCount;
|
|
1287
|
+
}
|
|
1288
|
+
getItem(itemIndex) {
|
|
1289
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1290
|
+
return null;
|
|
1291
|
+
}
|
|
1292
|
+
const entries = [];
|
|
1293
|
+
const entryCount = this.structType.entries.length;
|
|
1294
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1295
|
+
const entry = this.structType.entries[i];
|
|
1296
|
+
const entryVector = this.entryVectors[i];
|
|
1297
|
+
entries.push({ name: entry.name, value: entryVector.getItem(itemIndex) });
|
|
1298
|
+
}
|
|
1299
|
+
return entries;
|
|
1300
|
+
}
|
|
1301
|
+
getItemValue(itemIndex, entryIndex) {
|
|
1302
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1303
|
+
return null;
|
|
1304
|
+
}
|
|
1305
|
+
const entryVector = this.entryVectors[entryIndex];
|
|
1306
|
+
return entryVector.getItem(itemIndex);
|
|
1307
|
+
}
|
|
1308
|
+
slice(offset, length) {
|
|
1309
|
+
return new DuckDBStructVector(this.structType, length, this.entryVectors.map(entryVector => entryVector.slice(offset, length)), this.validity.slice(offset));
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
exports.DuckDBStructVector = DuckDBStructVector;
|
|
1313
|
+
// MAP = LIST(STRUCT(key KEY_TYPE, value VALUE_TYPE))
|
|
1314
|
+
class DuckDBMapVector extends DuckDBVector {
|
|
1315
|
+
mapType;
|
|
1316
|
+
listVector;
|
|
1317
|
+
constructor(mapType, listVector) {
|
|
1318
|
+
super();
|
|
1319
|
+
this.mapType = mapType;
|
|
1320
|
+
this.listVector = listVector;
|
|
1321
|
+
}
|
|
1322
|
+
static fromRawVector(mapType, vector, itemCount) {
|
|
1323
|
+
const listVectorType = new DuckDBType_1.DuckDBListType(new DuckDBType_1.DuckDBStructType([
|
|
1324
|
+
{ name: 'key', valueType: mapType.keyType },
|
|
1325
|
+
{ name: 'value', valueType: mapType.valueType }
|
|
1326
|
+
]));
|
|
1327
|
+
return new DuckDBMapVector(mapType, DuckDBListVector.fromRawVector(listVectorType, vector, itemCount));
|
|
1328
|
+
}
|
|
1329
|
+
get type() {
|
|
1330
|
+
return this.mapType;
|
|
1331
|
+
}
|
|
1332
|
+
get itemCount() {
|
|
1333
|
+
return this.listVector.itemCount;
|
|
1334
|
+
}
|
|
1335
|
+
getItem(itemIndex) {
|
|
1336
|
+
const itemVector = this.listVector.getItem(itemIndex);
|
|
1337
|
+
if (!itemVector) {
|
|
1338
|
+
return null;
|
|
1339
|
+
}
|
|
1340
|
+
if (!(itemVector instanceof DuckDBStructVector)) {
|
|
1341
|
+
throw new Error('item in map list vector is not a struct');
|
|
1342
|
+
}
|
|
1343
|
+
const entries = [];
|
|
1344
|
+
const itemEntryCount = itemVector.itemCount;
|
|
1345
|
+
for (let i = 0; i < itemEntryCount; i++) {
|
|
1346
|
+
const entry = itemVector.getItem(i);
|
|
1347
|
+
if (!entry) {
|
|
1348
|
+
throw new Error('null entry in map struct');
|
|
1349
|
+
}
|
|
1350
|
+
const keyEntry = entry[0];
|
|
1351
|
+
const valueEntry = entry[1];
|
|
1352
|
+
entries.push({ key: keyEntry.value, value: valueEntry.value });
|
|
1353
|
+
}
|
|
1354
|
+
return entries;
|
|
1355
|
+
}
|
|
1356
|
+
slice(offset, length) {
|
|
1357
|
+
return new DuckDBMapVector(this.mapType, this.listVector.slice(offset, length));
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
exports.DuckDBMapVector = DuckDBMapVector;
|
|
1361
|
+
class DuckDBArrayVector extends DuckDBVector {
|
|
1362
|
+
arrayType;
|
|
1363
|
+
validity;
|
|
1364
|
+
childData;
|
|
1365
|
+
_itemCount;
|
|
1366
|
+
constructor(arrayType, validity, childData, itemCount) {
|
|
1367
|
+
super();
|
|
1368
|
+
this.arrayType = arrayType;
|
|
1369
|
+
this.validity = validity;
|
|
1370
|
+
this.childData = childData;
|
|
1371
|
+
this._itemCount = itemCount;
|
|
1372
|
+
}
|
|
1373
|
+
static fromRawVector(arrayType, vector, itemCount) {
|
|
1374
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1375
|
+
const child_vector = node_bindings_1.default.array_vector_get_child(vector);
|
|
1376
|
+
const childItemsPerArray = DuckDBArrayVector.itemSize(arrayType) * arrayType.length;
|
|
1377
|
+
const childData = DuckDBVector.create(child_vector, itemCount * childItemsPerArray, arrayType.valueType);
|
|
1378
|
+
return new DuckDBArrayVector(arrayType, validity, childData, itemCount);
|
|
1379
|
+
}
|
|
1380
|
+
static itemSize(arrayType) {
|
|
1381
|
+
if (arrayType.valueType instanceof DuckDBType_1.DuckDBArrayType) {
|
|
1382
|
+
return DuckDBArrayVector.itemSize(arrayType.valueType);
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
return 1;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
get type() {
|
|
1389
|
+
return this.arrayType;
|
|
1390
|
+
}
|
|
1391
|
+
get itemCount() {
|
|
1392
|
+
return this._itemCount;
|
|
1393
|
+
}
|
|
1394
|
+
getItem(itemIndex) {
|
|
1395
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1398
|
+
return this.childData.slice(itemIndex * this.arrayType.length, this.arrayType.length);
|
|
1399
|
+
}
|
|
1400
|
+
slice(offset, length) {
|
|
1401
|
+
return new DuckDBArrayVector(this.arrayType, this.validity.slice(offset), this.childData.slice(offset * this.arrayType.length, length * this.arrayType.length), length);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
exports.DuckDBArrayVector = DuckDBArrayVector;
|
|
1405
|
+
class DuckDBUUIDVector extends DuckDBVector {
|
|
1406
|
+
dataView;
|
|
1407
|
+
validity;
|
|
1408
|
+
_itemCount;
|
|
1409
|
+
constructor(dataView, validity, itemCount) {
|
|
1410
|
+
super();
|
|
1411
|
+
this.dataView = dataView;
|
|
1412
|
+
this.validity = validity;
|
|
1413
|
+
this._itemCount = itemCount;
|
|
1414
|
+
}
|
|
1415
|
+
static fromRawVector(vector, itemCount) {
|
|
1416
|
+
const data = vectorData(vector, itemCount * 16);
|
|
1417
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1418
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1419
|
+
return new DuckDBUUIDVector(dataView, validity, itemCount);
|
|
1420
|
+
}
|
|
1421
|
+
get type() {
|
|
1422
|
+
return DuckDBType_1.DuckDBUUIDType.instance;
|
|
1423
|
+
}
|
|
1424
|
+
get itemCount() {
|
|
1425
|
+
return this._itemCount;
|
|
1426
|
+
}
|
|
1427
|
+
getItem(itemIndex) {
|
|
1428
|
+
return this.validity.itemValid(itemIndex) ? getInt128(this.dataView, itemIndex * 16) : null;
|
|
1429
|
+
}
|
|
1430
|
+
slice(offset, length) {
|
|
1431
|
+
return new DuckDBUUIDVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
exports.DuckDBUUIDVector = DuckDBUUIDVector;
|
|
1435
|
+
// UNION = STRUCT with first entry named "tag"
|
|
1436
|
+
class DuckDBUnionVector extends DuckDBVector {
|
|
1437
|
+
unionType;
|
|
1438
|
+
structVector;
|
|
1439
|
+
constructor(unionType, structVector) {
|
|
1440
|
+
super();
|
|
1441
|
+
this.unionType = unionType;
|
|
1442
|
+
this.structVector = structVector;
|
|
1443
|
+
}
|
|
1444
|
+
static fromRawVector(unionType, vector, itemCount) {
|
|
1445
|
+
const structEntryTypes = [{ name: 'tag', valueType: DuckDBType_1.DuckDBUTinyIntType.instance }];
|
|
1446
|
+
for (const alternative of unionType.alternatives) {
|
|
1447
|
+
structEntryTypes.push({ name: alternative.tag, valueType: alternative.valueType });
|
|
1448
|
+
}
|
|
1449
|
+
const structVectorType = new DuckDBType_1.DuckDBStructType(structEntryTypes);
|
|
1450
|
+
return new DuckDBUnionVector(unionType, DuckDBStructVector.fromRawVector(structVectorType, vector, itemCount));
|
|
1451
|
+
}
|
|
1452
|
+
get type() {
|
|
1453
|
+
return this.unionType;
|
|
1454
|
+
}
|
|
1455
|
+
get itemCount() {
|
|
1456
|
+
return this.structVector.itemCount;
|
|
1457
|
+
}
|
|
1458
|
+
getItem(itemIndex) {
|
|
1459
|
+
const tagValue = this.structVector.getItemValue(itemIndex, 0);
|
|
1460
|
+
if (tagValue == null) {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
const alternativeIndex = Number(tagValue);
|
|
1464
|
+
const tag = this.unionType.alternatives[alternativeIndex].tag;
|
|
1465
|
+
const entryIndex = alternativeIndex + 1;
|
|
1466
|
+
const value = this.structVector.getItemValue(itemIndex, entryIndex);
|
|
1467
|
+
return { tag, value };
|
|
1468
|
+
}
|
|
1469
|
+
slice(offset, length) {
|
|
1470
|
+
return new DuckDBUnionVector(this.unionType, this.structVector.slice(offset, length));
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
exports.DuckDBUnionVector = DuckDBUnionVector;
|
|
1474
|
+
class DuckDBBitValue {
|
|
1475
|
+
data;
|
|
1476
|
+
constructor(data) {
|
|
1477
|
+
this.data = data;
|
|
1478
|
+
}
|
|
1479
|
+
static fromString(str) {
|
|
1480
|
+
if (!/^[01]*$/.test(str)) {
|
|
1481
|
+
throw new Error(`input string must only contain '0's and '1's`);
|
|
1482
|
+
}
|
|
1483
|
+
const byteCount = Math.ceil(str.length / 8) + 1;
|
|
1484
|
+
const paddingBitCount = (8 - (str.length % 8)) % 8;
|
|
1485
|
+
const data = new Uint8Array(byteCount);
|
|
1486
|
+
let byteIndex = 0;
|
|
1487
|
+
// first byte contains count of padding bits
|
|
1488
|
+
data[byteIndex++] = paddingBitCount;
|
|
1489
|
+
let byte = 0;
|
|
1490
|
+
let bitIndex = 0;
|
|
1491
|
+
// padding consists of 1s in MSB of second byte
|
|
1492
|
+
while (bitIndex < paddingBitCount) {
|
|
1493
|
+
byte <<= 1;
|
|
1494
|
+
byte |= 1;
|
|
1495
|
+
bitIndex++;
|
|
1496
|
+
}
|
|
1497
|
+
let charIndex = 0;
|
|
1498
|
+
while (byteIndex < byteCount) {
|
|
1499
|
+
while (bitIndex < 8) {
|
|
1500
|
+
byte <<= 1;
|
|
1501
|
+
if (str[charIndex++] === '1') {
|
|
1502
|
+
byte |= 1;
|
|
1503
|
+
}
|
|
1504
|
+
bitIndex++;
|
|
1505
|
+
}
|
|
1506
|
+
data[byteIndex++] = byte;
|
|
1507
|
+
byte = 0;
|
|
1508
|
+
bitIndex = 0;
|
|
1509
|
+
}
|
|
1510
|
+
return new DuckDBBitValue(data);
|
|
1511
|
+
}
|
|
1512
|
+
padding() {
|
|
1513
|
+
return this.data[0];
|
|
1514
|
+
}
|
|
1515
|
+
length() {
|
|
1516
|
+
return (this.data.length - 1) * 8 - this.padding();
|
|
1517
|
+
}
|
|
1518
|
+
getBool(index) {
|
|
1519
|
+
const dataIndex = Math.floor(index / 8) + 1;
|
|
1520
|
+
return (this.data[dataIndex] & (1 << (index % 8))) !== 0;
|
|
1521
|
+
}
|
|
1522
|
+
getBit(index) {
|
|
1523
|
+
return this.getBool(index) ? 1 : 0;
|
|
1524
|
+
}
|
|
1525
|
+
toString() {
|
|
1526
|
+
const chars = Array.from({ length: this.length() });
|
|
1527
|
+
for (let i = 0; i < this.length(); i++) {
|
|
1528
|
+
chars[i] = this.getBool(i) ? '1' : '0';
|
|
1529
|
+
}
|
|
1530
|
+
return chars.join('');
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
exports.DuckDBBitValue = DuckDBBitValue;
|
|
1534
|
+
class DuckDBBitVector extends DuckDBVector {
|
|
1535
|
+
dataView;
|
|
1536
|
+
validity;
|
|
1537
|
+
_itemCount;
|
|
1538
|
+
constructor(dataView, validity, itemCount) {
|
|
1539
|
+
super();
|
|
1540
|
+
this.dataView = dataView;
|
|
1541
|
+
this.validity = validity;
|
|
1542
|
+
this._itemCount = itemCount;
|
|
1543
|
+
}
|
|
1544
|
+
static fromRawVector(vector, itemCount) {
|
|
1545
|
+
const data = vectorData(vector, itemCount * 16);
|
|
1546
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1547
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1548
|
+
return new DuckDBBitVector(dataView, validity, itemCount);
|
|
1549
|
+
}
|
|
1550
|
+
get type() {
|
|
1551
|
+
return DuckDBType_1.DuckDBBitType.instance;
|
|
1552
|
+
}
|
|
1553
|
+
get itemCount() {
|
|
1554
|
+
return this._itemCount;
|
|
1555
|
+
}
|
|
1556
|
+
getItem(itemIndex) {
|
|
1557
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
const bytes = getStringBytes(this.dataView, itemIndex * 16);
|
|
1561
|
+
return bytes ? new DuckDBBitValue(bytes) : null;
|
|
1562
|
+
}
|
|
1563
|
+
slice(offset, length) {
|
|
1564
|
+
return new DuckDBBitVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
exports.DuckDBBitVector = DuckDBBitVector;
|
|
1568
|
+
class DuckDBTimeTZValue {
|
|
1569
|
+
/** Ranges from 0 to 86400000000 (= 24 * 60 * 60 * 1000 * 1000) */
|
|
1570
|
+
microseconds;
|
|
1571
|
+
/** In seconds, ranges from -57599 to 57599 (= 16 * 60 * 60 - 1) */
|
|
1572
|
+
offset;
|
|
1573
|
+
constructor(microseconds, offset) {
|
|
1574
|
+
this.microseconds = microseconds;
|
|
1575
|
+
this.offset = offset;
|
|
1576
|
+
}
|
|
1577
|
+
static TIME_BITS = 40;
|
|
1578
|
+
static OFFSET_BITS = 24;
|
|
1579
|
+
static MAX_OFFSET = 16 * 60 * 60 - 1; // ±15:59:59 = 57599 seconds
|
|
1580
|
+
static fromBits(bits) {
|
|
1581
|
+
const microseconds = Number(BigInt.asUintN(DuckDBTimeTZValue.TIME_BITS, bits >> BigInt(DuckDBTimeTZValue.OFFSET_BITS)));
|
|
1582
|
+
const offset = DuckDBTimeTZValue.MAX_OFFSET - Number(BigInt.asUintN(DuckDBTimeTZValue.OFFSET_BITS, bits));
|
|
1583
|
+
return new DuckDBTimeTZValue(microseconds, offset);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
exports.DuckDBTimeTZValue = DuckDBTimeTZValue;
|
|
1587
|
+
class DuckDBTimeTZVector extends DuckDBVector {
|
|
1588
|
+
items;
|
|
1589
|
+
validity;
|
|
1590
|
+
constructor(items, validity) {
|
|
1591
|
+
super();
|
|
1592
|
+
this.items = items;
|
|
1593
|
+
this.validity = validity;
|
|
1594
|
+
}
|
|
1595
|
+
static fromRawVector(vector, itemCount) {
|
|
1596
|
+
const data = vectorData(vector, itemCount * BigUint64Array.BYTES_PER_ELEMENT);
|
|
1597
|
+
const items = new BigUint64Array(data.buffer, data.byteOffset, itemCount);
|
|
1598
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1599
|
+
return new DuckDBTimeTZVector(items, validity);
|
|
1600
|
+
}
|
|
1601
|
+
get type() {
|
|
1602
|
+
return DuckDBType_1.DuckDBTimeTZType.instance;
|
|
1603
|
+
}
|
|
1604
|
+
get itemCount() {
|
|
1605
|
+
return this.items.length;
|
|
1606
|
+
}
|
|
1607
|
+
getItem(itemIndex) {
|
|
1608
|
+
return this.validity.itemValid(itemIndex) ? DuckDBTimeTZValue.fromBits(this.items[itemIndex]) : null;
|
|
1609
|
+
}
|
|
1610
|
+
slice(offset, length) {
|
|
1611
|
+
return new DuckDBTimeTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
exports.DuckDBTimeTZVector = DuckDBTimeTZVector;
|
|
1615
|
+
class DuckDBTimestampTZVector extends DuckDBVector {
|
|
1616
|
+
items;
|
|
1617
|
+
validity;
|
|
1618
|
+
constructor(items, validity) {
|
|
1619
|
+
super();
|
|
1620
|
+
this.items = items;
|
|
1621
|
+
this.validity = validity;
|
|
1622
|
+
}
|
|
1623
|
+
static fromRawVector(vector, itemCount) {
|
|
1624
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
1625
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
1626
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1627
|
+
return new DuckDBTimestampTZVector(items, validity);
|
|
1628
|
+
}
|
|
1629
|
+
get type() {
|
|
1630
|
+
return DuckDBType_1.DuckDBTimestampTZType.instance;
|
|
1631
|
+
}
|
|
1632
|
+
get itemCount() {
|
|
1633
|
+
return this.items.length;
|
|
1634
|
+
}
|
|
1635
|
+
getItem(itemIndex) {
|
|
1636
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
1637
|
+
}
|
|
1638
|
+
slice(offset, length) {
|
|
1639
|
+
return new DuckDBTimestampTZVector(this.items.slice(offset, offset + length), this.validity.slice(offset));
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
exports.DuckDBTimestampTZVector = DuckDBTimestampTZVector;
|
|
1643
|
+
class DuckDBVarIntVector extends DuckDBVector {
|
|
1644
|
+
dataView;
|
|
1645
|
+
validity;
|
|
1646
|
+
_itemCount;
|
|
1647
|
+
constructor(dataView, validity, itemCount) {
|
|
1648
|
+
super();
|
|
1649
|
+
this.dataView = dataView;
|
|
1650
|
+
this.validity = validity;
|
|
1651
|
+
this._itemCount = itemCount;
|
|
1652
|
+
}
|
|
1653
|
+
static fromRawVector(vector, itemCount) {
|
|
1654
|
+
const data = vectorData(vector, itemCount * 16);
|
|
1655
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1656
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
1657
|
+
return new DuckDBVarIntVector(dataView, validity, itemCount);
|
|
1658
|
+
}
|
|
1659
|
+
get type() {
|
|
1660
|
+
return DuckDBType_1.DuckDBVarIntType.instance;
|
|
1661
|
+
}
|
|
1662
|
+
get itemCount() {
|
|
1663
|
+
return this._itemCount;
|
|
1664
|
+
}
|
|
1665
|
+
getItem(itemIndex) {
|
|
1666
|
+
if (!this.validity.itemValid(itemIndex)) {
|
|
1667
|
+
return null;
|
|
1668
|
+
}
|
|
1669
|
+
const bytes = getStringBytes(this.dataView, itemIndex * 16);
|
|
1670
|
+
return bytes ? getVarIntFromBytes(bytes) : null;
|
|
1671
|
+
}
|
|
1672
|
+
slice(offset, length) {
|
|
1673
|
+
return new DuckDBVarIntVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset), length);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
exports.DuckDBVarIntVector = DuckDBVarIntVector;
|