@haybarn/node-api 1.5.6-rc1 → 2.0.0-rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -20
- package/lib/DuckDBAppender.d.ts +8 -2
- package/lib/DuckDBAppender.js +19 -1
- package/lib/DuckDBConnection.d.ts +2 -0
- package/lib/DuckDBConnection.js +4 -1
- package/lib/DuckDBDataChunk.d.ts +30 -0
- package/lib/DuckDBDataChunk.js +94 -1
- package/lib/DuckDBDataChunkWriter.d.ts +74 -0
- package/lib/DuckDBDataChunkWriter.js +109 -0
- package/lib/DuckDBLogicalType.d.ts +5 -1
- package/lib/DuckDBLogicalType.js +18 -1
- package/lib/DuckDBMaterializedResult.d.ts +8 -1
- package/lib/DuckDBMaterializedResult.js +22 -2
- package/lib/DuckDBPendingResult.d.ts +16 -1
- package/lib/DuckDBPendingResult.js +19 -2
- package/lib/DuckDBPreparedStatement.d.ts +4 -1
- package/lib/DuckDBPreparedStatement.js +17 -4
- package/lib/DuckDBResult.d.ts +21 -1
- package/lib/DuckDBResult.js +87 -5
- package/lib/DuckDBResultReader.d.ts +5 -0
- package/lib/DuckDBResultReader.js +9 -2
- package/lib/DuckDBScalarFunction.d.ts +9 -5
- package/lib/DuckDBScalarFunction.js +14 -5
- package/lib/DuckDBScalarFunctionBindInfo.d.ts +16 -0
- package/lib/{DuckDBBindInfo.js → DuckDBScalarFunctionBindInfo.js} +5 -3
- package/lib/DuckDBScalarFunctionInfo.d.ts +16 -0
- package/lib/{DuckDBFunctionInfo.js → DuckDBScalarFunctionInfo.js} +11 -3
- package/lib/{DuckDBBindInfo.d.ts → DuckDBScalarFunctionInitInfo.d.ts} +6 -4
- package/lib/DuckDBScalarFunctionInitInfo.js +39 -0
- package/lib/DuckDBTableFunction.d.ts +41 -0
- package/lib/DuckDBTableFunction.js +83 -0
- package/lib/DuckDBTableFunctionBindInfo.d.ts +21 -0
- package/lib/DuckDBTableFunctionBindInfo.js +54 -0
- package/lib/DuckDBTableFunctionInfo.d.ts +15 -0
- package/lib/DuckDBTableFunctionInfo.js +42 -0
- package/lib/DuckDBTableFunctionInitInfo.d.ts +22 -0
- package/lib/DuckDBTableFunctionInitInfo.js +58 -0
- package/lib/DuckDBType.d.ts +1 -373
- package/lib/DuckDBType.js +14 -927
- package/lib/DuckDBTypeId.d.ts +4 -1
- package/lib/DuckDBTypeId.js +3 -0
- package/lib/DuckDBValueConverter.d.ts +10 -0
- package/lib/DuckDBValueConverters.d.ts +27 -0
- package/lib/DuckDBValueConverters.js +128 -1
- package/lib/DuckDBVector.d.ts +1 -596
- package/lib/DuckDBVector.js +14 -2522
- package/lib/JSDuckDBValueConverter.d.ts +1 -2
- package/lib/JSDuckDBValueConverter.js +5 -2
- package/lib/JSInputTypeForTypeId.d.ts +104 -0
- package/lib/JSInputTypeForTypeId.js +3 -0
- package/lib/JSToDuckDBValueConverter.d.ts +30 -0
- package/lib/JSToDuckDBValueConverter.js +83 -0
- package/lib/JSTypeForTypeId.d.ts +91 -0
- package/lib/JSTypeForTypeId.js +3 -0
- package/lib/JsonDuckDBValueConverter.d.ts +1 -2
- package/lib/JsonDuckDBValueConverter.js +4 -1
- package/lib/JsonTypeForTypeId.d.ts +96 -0
- package/lib/JsonTypeForTypeId.js +3 -0
- package/lib/ToDuckDBValueConverter.d.ts +41 -0
- package/lib/ToDuckDBValueConverter.js +27 -0
- package/lib/ToDuckDBValueConverters.d.ts +54 -0
- package/lib/ToDuckDBValueConverters.js +199 -0
- package/lib/conversion/dateTimeStringConversion.d.ts +2 -2
- package/lib/conversion/dateTimeStringConversion.js +20 -7
- package/lib/conversion/varintDecode.d.ts +18 -0
- package/lib/conversion/varintDecode.js +42 -0
- package/lib/convertColumnsFromChunks.d.ts +1 -1
- package/lib/convertColumnsFromChunks.js +2 -2
- package/lib/createResult.d.ts +2 -1
- package/lib/createResult.js +3 -3
- package/lib/createValue.js +63 -5
- package/lib/duckdb.d.ts +15 -2
- package/lib/duckdb.js +15 -2
- package/lib/getColumnsFromChunks.d.ts +1 -1
- package/lib/getColumnsFromChunks.js +2 -2
- package/lib/getColumnsObjectFromChunks.js +3 -0
- package/lib/readValue.d.ts +22 -0
- package/lib/readValue.js +35 -0
- package/lib/typeForValue.js +21 -2
- package/lib/types/BaseDuckDBType.d.ts +11 -0
- package/lib/types/BaseDuckDBType.js +34 -0
- package/lib/types/DuckDBAnyType.d.ts +8 -0
- package/lib/types/DuckDBAnyType.js +16 -0
- package/lib/types/DuckDBArrayType.d.ts +14 -0
- package/lib/types/DuckDBArrayType.js +38 -0
- package/lib/types/DuckDBBigIntType.d.ts +12 -0
- package/lib/types/DuckDBBigIntType.js +24 -0
- package/lib/types/DuckDBBigNumType.d.ts +12 -0
- package/lib/types/DuckDBBigNumType.js +24 -0
- package/lib/types/DuckDBBitType.d.ts +8 -0
- package/lib/types/DuckDBBitType.js +16 -0
- package/lib/types/DuckDBBlobType.d.ts +8 -0
- package/lib/types/DuckDBBlobType.js +16 -0
- package/lib/types/DuckDBBooleanType.d.ts +8 -0
- package/lib/types/DuckDBBooleanType.js +16 -0
- package/lib/types/DuckDBDateType.d.ts +14 -0
- package/lib/types/DuckDBDateType.js +32 -0
- package/lib/types/DuckDBDecimalType.d.ts +14 -0
- package/lib/types/DuckDBDecimalType.js +45 -0
- package/lib/types/DuckDBDoubleType.d.ts +12 -0
- package/lib/types/DuckDBDoubleType.js +24 -0
- package/lib/types/DuckDBEnumType.d.ts +29 -0
- package/lib/types/DuckDBEnumType.js +100 -0
- package/lib/types/DuckDBFloatType.d.ts +12 -0
- package/lib/types/DuckDBFloatType.js +24 -0
- package/lib/types/DuckDBGeometryType.d.ts +19 -0
- package/lib/types/DuckDBGeometryType.js +38 -0
- package/lib/types/DuckDBHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBHugeIntType.js +24 -0
- package/lib/types/DuckDBIntegerLiteralType.d.ts +8 -0
- package/lib/types/DuckDBIntegerLiteralType.js +16 -0
- package/lib/types/DuckDBIntegerType.d.ts +12 -0
- package/lib/types/DuckDBIntegerType.js +24 -0
- package/lib/types/DuckDBIntervalType.d.ts +8 -0
- package/lib/types/DuckDBIntervalType.js +16 -0
- package/lib/types/DuckDBListType.d.ts +13 -0
- package/lib/types/DuckDBListType.js +35 -0
- package/lib/types/DuckDBMapType.d.ts +14 -0
- package/lib/types/DuckDBMapType.js +38 -0
- package/lib/types/DuckDBSQLNullType.d.ts +10 -0
- package/lib/types/DuckDBSQLNullType.js +20 -0
- package/lib/types/DuckDBSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBSmallIntType.js +24 -0
- package/lib/types/DuckDBStringLiteralType.d.ts +8 -0
- package/lib/types/DuckDBStringLiteralType.js +16 -0
- package/lib/types/DuckDBStructType.d.ts +29 -0
- package/lib/types/DuckDBStructType.js +86 -0
- package/lib/types/DuckDBTimeNSType.d.ts +11 -0
- package/lib/types/DuckDBTimeNSType.js +23 -0
- package/lib/types/DuckDBTimeTZType.d.ts +12 -0
- package/lib/types/DuckDBTimeTZType.js +26 -0
- package/lib/types/DuckDBTimeType.d.ts +11 -0
- package/lib/types/DuckDBTimeType.js +23 -0
- package/lib/types/DuckDBTimestampMillisecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampMillisecondsType.js +32 -0
- package/lib/types/DuckDBTimestampNanosecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampNanosecondsType.js +32 -0
- package/lib/types/DuckDBTimestampSecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampSecondsType.js +32 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.js +35 -0
- package/lib/types/DuckDBTimestampTZType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZType.js +35 -0
- package/lib/types/DuckDBTimestampType.d.ts +16 -0
- package/lib/types/DuckDBTimestampType.js +33 -0
- package/lib/types/DuckDBTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBTinyIntType.js +24 -0
- package/lib/types/DuckDBType.d.ts +43 -0
- package/lib/types/DuckDBType.js +2 -0
- package/lib/types/DuckDBUBigIntType.d.ts +12 -0
- package/lib/types/DuckDBUBigIntType.js +24 -0
- package/lib/types/DuckDBUHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBUHugeIntType.js +24 -0
- package/lib/types/DuckDBUIntegerType.d.ts +12 -0
- package/lib/types/DuckDBUIntegerType.js +24 -0
- package/lib/types/DuckDBUSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBUSmallIntType.js +24 -0
- package/lib/types/DuckDBUTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBUTinyIntType.js +24 -0
- package/lib/types/DuckDBUUIDType.d.ts +11 -0
- package/lib/types/DuckDBUUIDType.js +23 -0
- package/lib/types/DuckDBUnionType.d.ts +18 -0
- package/lib/types/DuckDBUnionType.js +64 -0
- package/lib/types/DuckDBVarCharType.d.ts +8 -0
- package/lib/types/DuckDBVarCharType.js +16 -0
- package/lib/types/DuckDBVariantType.d.ts +8 -0
- package/lib/types/DuckDBVariantType.js +16 -0
- package/lib/types/index.d.ts +44 -0
- package/lib/types/index.js +60 -0
- package/lib/values/DuckDBGeometryValue.d.ts +12 -0
- package/lib/values/DuckDBGeometryValue.js +30 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.d.ts +14 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.js +33 -0
- package/lib/values/DuckDBTupleValue.d.ts +11 -0
- package/lib/values/DuckDBTupleValue.js +22 -0
- package/lib/values/DuckDBUUIDValue.js +5 -1
- package/lib/values/DuckDBValue.d.ts +5 -1
- package/lib/values/DuckDBVariantValue.d.ts +19 -0
- package/lib/values/DuckDBVariantValue.js +30 -0
- package/lib/values/index.d.ts +4 -0
- package/lib/values/index.js +4 -0
- package/lib/vectors/DuckDBArrayVector.d.ts +21 -0
- package/lib/vectors/DuckDBArrayVector.js +79 -0
- package/lib/vectors/DuckDBBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBBigIntVector.js +58 -0
- package/lib/vectors/DuckDBBigNumVector.d.ts +21 -0
- package/lib/vectors/DuckDBBigNumVector.js +70 -0
- package/lib/vectors/DuckDBBitVector.d.ts +22 -0
- package/lib/vectors/DuckDBBitVector.js +74 -0
- package/lib/vectors/DuckDBBlobVector.d.ts +32 -0
- package/lib/vectors/DuckDBBlobVector.js +83 -0
- package/lib/vectors/DuckDBBooleanVector.d.ts +18 -0
- package/lib/vectors/DuckDBBooleanVector.js +58 -0
- package/lib/vectors/DuckDBDateVector.d.ts +18 -0
- package/lib/vectors/DuckDBDateVector.js +64 -0
- package/lib/vectors/DuckDBDecimal128Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal128Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal16Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal16Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal32Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal32Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal64Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal64Vector.js +64 -0
- package/lib/vectors/DuckDBDoubleVector.d.ts +17 -0
- package/lib/vectors/DuckDBDoubleVector.js +54 -0
- package/lib/vectors/DuckDBEnum16Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum16Vector.js +57 -0
- package/lib/vectors/DuckDBEnum32Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum32Vector.js +57 -0
- package/lib/vectors/DuckDBEnum8Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum8Vector.js +57 -0
- package/lib/vectors/DuckDBFloatVector.d.ts +17 -0
- package/lib/vectors/DuckDBFloatVector.js +54 -0
- package/lib/vectors/DuckDBGeometryVector.d.ts +22 -0
- package/lib/vectors/DuckDBGeometryVector.js +69 -0
- package/lib/vectors/DuckDBHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBIntegerVector.js +61 -0
- package/lib/vectors/DuckDBIntervalVector.d.ts +19 -0
- package/lib/vectors/DuckDBIntervalVector.js +67 -0
- package/lib/vectors/DuckDBListVector.d.ts +35 -0
- package/lib/vectors/DuckDBListVector.js +151 -0
- package/lib/vectors/DuckDBMapVector.d.ts +17 -0
- package/lib/vectors/DuckDBMapVector.js +60 -0
- package/lib/vectors/DuckDBSQLNullVector.d.ts +18 -0
- package/lib/vectors/DuckDBSQLNullVector.js +44 -0
- package/lib/vectors/DuckDBSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBStructVector.d.ts +35 -0
- package/lib/vectors/DuckDBStructVector.js +105 -0
- package/lib/vectors/DuckDBTimeNSVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeNSVector.js +61 -0
- package/lib/vectors/DuckDBTimeTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeTZVector.js +61 -0
- package/lib/vectors/DuckDBTimeVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeVector.js +61 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZVector.js +61 -0
- package/lib/vectors/DuckDBTimestampVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampVector.js +61 -0
- package/lib/vectors/DuckDBTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBTupleVector.d.ts +26 -0
- package/lib/vectors/DuckDBTupleVector.js +91 -0
- package/lib/vectors/DuckDBUBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUBigIntVector.js +58 -0
- package/lib/vectors/DuckDBUHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBUHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBUIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBUIntegerVector.js +61 -0
- package/lib/vectors/DuckDBUSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBUTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBUUIDVector.d.ts +19 -0
- package/lib/vectors/DuckDBUUIDVector.js +59 -0
- package/lib/vectors/DuckDBUnionVector.d.ts +17 -0
- package/lib/vectors/DuckDBUnionVector.js +70 -0
- package/lib/vectors/DuckDBValidity.d.ts +12 -0
- package/lib/vectors/DuckDBValidity.js +91 -0
- package/lib/vectors/DuckDBVarCharVector.d.ts +21 -0
- package/lib/vectors/DuckDBVarCharVector.js +74 -0
- package/lib/vectors/DuckDBVariantVector.d.ts +42 -0
- package/lib/vectors/DuckDBVariantVector.js +461 -0
- package/lib/vectors/DuckDBVector.d.ts +14 -0
- package/lib/vectors/DuckDBVector.js +27 -0
- package/lib/vectors/createVector.d.ts +1 -0
- package/lib/vectors/createVector.js +201 -0
- package/lib/vectors/dataAccessors.d.ts +45 -0
- package/lib/vectors/dataAccessors.js +344 -0
- package/lib/vectors/index.d.ts +47 -0
- package/lib/vectors/index.js +65 -0
- package/lib/vectors/vectorRegistry.d.ts +20 -0
- package/lib/vectors/vectorRegistry.js +16 -0
- package/package.json +3 -2
- package/lib/DuckDBFunctionInfo.d.ts +0 -10
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBUIntegerType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
4
|
+
import { DuckDBValidity } from './DuckDBValidity';
|
|
5
|
+
export declare class DuckDBUIntegerVector extends DuckDBVector<number> {
|
|
6
|
+
private readonly items;
|
|
7
|
+
private readonly validity;
|
|
8
|
+
private readonly vector;
|
|
9
|
+
constructor(items: Uint32Array, validity: DuckDBValidity, vector: duckdb.Vector);
|
|
10
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBUIntegerVector;
|
|
11
|
+
get type(): DuckDBUIntegerType;
|
|
12
|
+
get itemCount(): number;
|
|
13
|
+
getItem(itemIndex: number): number | null;
|
|
14
|
+
setItem(itemIndex: number, value: number | null): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
slice(offset: number, length: number): DuckDBUIntegerVector;
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DuckDBUIntegerVector = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
9
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
10
|
+
const DuckDBValidity_1 = require("./DuckDBValidity");
|
|
11
|
+
const dataAccessors_1 = require("./dataAccessors");
|
|
12
|
+
class DuckDBUIntegerVector extends DuckDBVector_1.DuckDBVector {
|
|
13
|
+
items;
|
|
14
|
+
validity;
|
|
15
|
+
vector;
|
|
16
|
+
constructor(items, validity, vector) {
|
|
17
|
+
super();
|
|
18
|
+
this.items = items;
|
|
19
|
+
this.validity = validity;
|
|
20
|
+
this.vector = vector;
|
|
21
|
+
}
|
|
22
|
+
static fromRawVector(vector, itemCount) {
|
|
23
|
+
const data = (0, dataAccessors_1.vectorData)(vector, itemCount * Uint32Array.BYTES_PER_ELEMENT);
|
|
24
|
+
const items = new Uint32Array(data.buffer, data.byteOffset, itemCount);
|
|
25
|
+
const validity = DuckDBValidity_1.DuckDBValidity.fromVector(vector, itemCount);
|
|
26
|
+
return new DuckDBUIntegerVector(items, validity, vector);
|
|
27
|
+
}
|
|
28
|
+
get type() {
|
|
29
|
+
return DuckDBType_1.DuckDBUIntegerType.instance;
|
|
30
|
+
}
|
|
31
|
+
get itemCount() {
|
|
32
|
+
return this.items.length;
|
|
33
|
+
}
|
|
34
|
+
getItem(itemIndex) {
|
|
35
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
36
|
+
}
|
|
37
|
+
setItem(itemIndex, value) {
|
|
38
|
+
if (value != null) {
|
|
39
|
+
// Checked inline for bulk-write throughput; see dataAccessors.ts.
|
|
40
|
+
if (!Number.isInteger(value)) {
|
|
41
|
+
throw new Error(`number is not an integer`);
|
|
42
|
+
}
|
|
43
|
+
if (value < 0 || value > 4294967295) {
|
|
44
|
+
throw new Error(`number out of uint32 range`);
|
|
45
|
+
}
|
|
46
|
+
this.items[itemIndex] = value;
|
|
47
|
+
this.validity.setItemValid(itemIndex, true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.validity.setItemValid(itemIndex, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
flush() {
|
|
54
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
55
|
+
this.validity.flush(this.vector);
|
|
56
|
+
}
|
|
57
|
+
slice(offset, length) {
|
|
58
|
+
return new DuckDBUIntegerVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DuckDBUIntegerVector = DuckDBUIntegerVector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBUSmallIntType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
4
|
+
import { DuckDBValidity } from './DuckDBValidity';
|
|
5
|
+
export declare class DuckDBUSmallIntVector extends DuckDBVector<number> {
|
|
6
|
+
private readonly items;
|
|
7
|
+
private readonly validity;
|
|
8
|
+
private readonly vector;
|
|
9
|
+
constructor(items: Uint16Array, validity: DuckDBValidity, vector: duckdb.Vector);
|
|
10
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBUSmallIntVector;
|
|
11
|
+
get type(): DuckDBUSmallIntType;
|
|
12
|
+
get itemCount(): number;
|
|
13
|
+
getItem(itemIndex: number): number | null;
|
|
14
|
+
setItem(itemIndex: number, value: number | null): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
slice(offset: number, length: number): DuckDBUSmallIntVector;
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DuckDBUSmallIntVector = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
9
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
10
|
+
const DuckDBValidity_1 = require("./DuckDBValidity");
|
|
11
|
+
const dataAccessors_1 = require("./dataAccessors");
|
|
12
|
+
class DuckDBUSmallIntVector extends DuckDBVector_1.DuckDBVector {
|
|
13
|
+
items;
|
|
14
|
+
validity;
|
|
15
|
+
vector;
|
|
16
|
+
constructor(items, validity, vector) {
|
|
17
|
+
super();
|
|
18
|
+
this.items = items;
|
|
19
|
+
this.validity = validity;
|
|
20
|
+
this.vector = vector;
|
|
21
|
+
}
|
|
22
|
+
static fromRawVector(vector, itemCount) {
|
|
23
|
+
const data = (0, dataAccessors_1.vectorData)(vector, itemCount * Uint16Array.BYTES_PER_ELEMENT);
|
|
24
|
+
const items = new Uint16Array(data.buffer, data.byteOffset, itemCount);
|
|
25
|
+
const validity = DuckDBValidity_1.DuckDBValidity.fromVector(vector, itemCount);
|
|
26
|
+
return new DuckDBUSmallIntVector(items, validity, vector);
|
|
27
|
+
}
|
|
28
|
+
get type() {
|
|
29
|
+
return DuckDBType_1.DuckDBUSmallIntType.instance;
|
|
30
|
+
}
|
|
31
|
+
get itemCount() {
|
|
32
|
+
return this.items.length;
|
|
33
|
+
}
|
|
34
|
+
getItem(itemIndex) {
|
|
35
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
36
|
+
}
|
|
37
|
+
setItem(itemIndex, value) {
|
|
38
|
+
if (value != null) {
|
|
39
|
+
// Checked inline for bulk-write throughput; see dataAccessors.ts.
|
|
40
|
+
if (!Number.isInteger(value)) {
|
|
41
|
+
throw new Error(`number is not an integer`);
|
|
42
|
+
}
|
|
43
|
+
if (value < 0 || value > 65535) {
|
|
44
|
+
throw new Error(`number out of uint16 range`);
|
|
45
|
+
}
|
|
46
|
+
this.items[itemIndex] = value;
|
|
47
|
+
this.validity.setItemValid(itemIndex, true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.validity.setItemValid(itemIndex, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
flush() {
|
|
54
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
55
|
+
this.validity.flush(this.vector);
|
|
56
|
+
}
|
|
57
|
+
slice(offset, length) {
|
|
58
|
+
return new DuckDBUSmallIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DuckDBUSmallIntVector = DuckDBUSmallIntVector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBUTinyIntType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
4
|
+
import { DuckDBValidity } from './DuckDBValidity';
|
|
5
|
+
export declare class DuckDBUTinyIntVector extends DuckDBVector<number> {
|
|
6
|
+
private readonly items;
|
|
7
|
+
private readonly validity;
|
|
8
|
+
private readonly vector;
|
|
9
|
+
constructor(items: Uint8Array, validity: DuckDBValidity, vector: duckdb.Vector);
|
|
10
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBUTinyIntVector;
|
|
11
|
+
get type(): DuckDBUTinyIntType;
|
|
12
|
+
get itemCount(): number;
|
|
13
|
+
getItem(itemIndex: number): number | null;
|
|
14
|
+
setItem(itemIndex: number, value: number | null): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
slice(offset: number, length: number): DuckDBUTinyIntVector;
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DuckDBUTinyIntVector = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
9
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
10
|
+
const DuckDBValidity_1 = require("./DuckDBValidity");
|
|
11
|
+
const dataAccessors_1 = require("./dataAccessors");
|
|
12
|
+
class DuckDBUTinyIntVector extends DuckDBVector_1.DuckDBVector {
|
|
13
|
+
items;
|
|
14
|
+
validity;
|
|
15
|
+
vector;
|
|
16
|
+
constructor(items, validity, vector) {
|
|
17
|
+
super();
|
|
18
|
+
this.items = items;
|
|
19
|
+
this.validity = validity;
|
|
20
|
+
this.vector = vector;
|
|
21
|
+
}
|
|
22
|
+
static fromRawVector(vector, itemCount) {
|
|
23
|
+
const data = (0, dataAccessors_1.vectorData)(vector, itemCount * Uint8Array.BYTES_PER_ELEMENT);
|
|
24
|
+
const items = new Uint8Array(data.buffer, data.byteOffset, itemCount);
|
|
25
|
+
const validity = DuckDBValidity_1.DuckDBValidity.fromVector(vector, itemCount);
|
|
26
|
+
return new DuckDBUTinyIntVector(items, validity, vector);
|
|
27
|
+
}
|
|
28
|
+
get type() {
|
|
29
|
+
return DuckDBType_1.DuckDBUTinyIntType.instance;
|
|
30
|
+
}
|
|
31
|
+
get itemCount() {
|
|
32
|
+
return this.items.length;
|
|
33
|
+
}
|
|
34
|
+
getItem(itemIndex) {
|
|
35
|
+
return this.validity.itemValid(itemIndex) ? this.items[itemIndex] : null;
|
|
36
|
+
}
|
|
37
|
+
setItem(itemIndex, value) {
|
|
38
|
+
if (value != null) {
|
|
39
|
+
// Checked inline for bulk-write throughput; see dataAccessors.ts.
|
|
40
|
+
if (!Number.isInteger(value)) {
|
|
41
|
+
throw new Error(`number is not an integer`);
|
|
42
|
+
}
|
|
43
|
+
if (value < 0 || value > 255) {
|
|
44
|
+
throw new Error(`number out of uint8 range`);
|
|
45
|
+
}
|
|
46
|
+
this.items[itemIndex] = value;
|
|
47
|
+
this.validity.setItemValid(itemIndex, true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.validity.setItemValid(itemIndex, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
flush() {
|
|
54
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
55
|
+
this.validity.flush(this.vector);
|
|
56
|
+
}
|
|
57
|
+
slice(offset, length) {
|
|
58
|
+
return new DuckDBUTinyIntVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DuckDBUTinyIntVector = DuckDBUTinyIntVector;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBUUIDType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBUUIDValue } from '../values';
|
|
4
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
5
|
+
import { DuckDBValidity } from './DuckDBValidity';
|
|
6
|
+
export declare class DuckDBUUIDVector extends DuckDBVector<DuckDBUUIDValue> {
|
|
7
|
+
private readonly dataView;
|
|
8
|
+
private readonly validity;
|
|
9
|
+
private readonly vector;
|
|
10
|
+
private readonly _itemCount;
|
|
11
|
+
constructor(dataView: DataView, validity: DuckDBValidity, vector: duckdb.Vector, itemCount: number);
|
|
12
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBUUIDVector;
|
|
13
|
+
get type(): DuckDBUUIDType;
|
|
14
|
+
get itemCount(): number;
|
|
15
|
+
getItem(itemIndex: number): DuckDBUUIDValue | null;
|
|
16
|
+
setItem(itemIndex: number, value: DuckDBUUIDValue | null): void;
|
|
17
|
+
flush(): void;
|
|
18
|
+
slice(offset: number, length: number): DuckDBUUIDVector;
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.DuckDBUUIDVector = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
9
|
+
const values_1 = require("../values");
|
|
10
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
11
|
+
const DuckDBValidity_1 = require("./DuckDBValidity");
|
|
12
|
+
const dataAccessors_1 = require("./dataAccessors");
|
|
13
|
+
class DuckDBUUIDVector extends DuckDBVector_1.DuckDBVector {
|
|
14
|
+
dataView;
|
|
15
|
+
validity;
|
|
16
|
+
vector;
|
|
17
|
+
_itemCount;
|
|
18
|
+
constructor(dataView, validity, vector, itemCount) {
|
|
19
|
+
super();
|
|
20
|
+
this.dataView = dataView;
|
|
21
|
+
this.validity = validity;
|
|
22
|
+
this.vector = vector;
|
|
23
|
+
this._itemCount = itemCount;
|
|
24
|
+
}
|
|
25
|
+
static fromRawVector(vector, itemCount) {
|
|
26
|
+
const data = (0, dataAccessors_1.vectorData)(vector, itemCount * 16);
|
|
27
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
28
|
+
const validity = DuckDBValidity_1.DuckDBValidity.fromVector(vector, itemCount);
|
|
29
|
+
return new DuckDBUUIDVector(dataView, validity, vector, itemCount);
|
|
30
|
+
}
|
|
31
|
+
get type() {
|
|
32
|
+
return DuckDBType_1.DuckDBUUIDType.instance;
|
|
33
|
+
}
|
|
34
|
+
get itemCount() {
|
|
35
|
+
return this._itemCount;
|
|
36
|
+
}
|
|
37
|
+
getItem(itemIndex) {
|
|
38
|
+
return this.validity.itemValid(itemIndex)
|
|
39
|
+
? values_1.DuckDBUUIDValue.fromStoredHugeInt((0, dataAccessors_1.getInt128)(this.dataView, itemIndex * 16))
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
setItem(itemIndex, value) {
|
|
43
|
+
if (value != null) {
|
|
44
|
+
(0, dataAccessors_1.setInt128)(this.dataView, itemIndex * 16, value.hugeint);
|
|
45
|
+
this.validity.setItemValid(itemIndex, true);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.validity.setItemValid(itemIndex, false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
flush() {
|
|
52
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.dataView.buffer, this.dataView.byteOffset, this.dataView.byteLength);
|
|
53
|
+
this.validity.flush(this.vector);
|
|
54
|
+
}
|
|
55
|
+
slice(offset, length) {
|
|
56
|
+
return new DuckDBUUIDVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, length);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.DuckDBUUIDVector = DuckDBUUIDVector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBUnionType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBUnionValue } from '../values';
|
|
4
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
5
|
+
import { DuckDBStructVector } from './DuckDBStructVector';
|
|
6
|
+
export declare class DuckDBUnionVector extends DuckDBVector<DuckDBUnionValue> {
|
|
7
|
+
private readonly unionType;
|
|
8
|
+
private readonly structVector;
|
|
9
|
+
constructor(unionType: DuckDBUnionType, structVector: DuckDBStructVector);
|
|
10
|
+
static fromRawVector(unionType: DuckDBUnionType, vector: duckdb.Vector, itemCount: number): DuckDBUnionVector;
|
|
11
|
+
get type(): DuckDBUnionType;
|
|
12
|
+
get itemCount(): number;
|
|
13
|
+
getItem(itemIndex: number): DuckDBUnionValue | null;
|
|
14
|
+
setItem(itemIndex: number, value: DuckDBUnionValue | null): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
slice(offset: number, length: number): DuckDBUnionVector;
|
|
17
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuckDBUnionVector = void 0;
|
|
4
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
5
|
+
const values_1 = require("../values");
|
|
6
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
7
|
+
const DuckDBStructVector_1 = require("./DuckDBStructVector");
|
|
8
|
+
// UNION = STRUCT with first entry named "tag"
|
|
9
|
+
class DuckDBUnionVector extends DuckDBVector_1.DuckDBVector {
|
|
10
|
+
unionType;
|
|
11
|
+
structVector;
|
|
12
|
+
constructor(unionType, structVector) {
|
|
13
|
+
super();
|
|
14
|
+
this.unionType = unionType;
|
|
15
|
+
this.structVector = structVector;
|
|
16
|
+
}
|
|
17
|
+
static fromRawVector(unionType, vector, itemCount) {
|
|
18
|
+
const entryNames = ['tag'];
|
|
19
|
+
const entryTypes = [DuckDBType_1.DuckDBUTinyIntType.instance];
|
|
20
|
+
const memberCount = unionType.memberCount;
|
|
21
|
+
for (let i = 0; i < memberCount; i++) {
|
|
22
|
+
entryNames.push(unionType.memberTags[i]);
|
|
23
|
+
entryTypes.push(unionType.memberTypes[i]);
|
|
24
|
+
}
|
|
25
|
+
const structVectorType = new DuckDBType_1.DuckDBStructType(entryNames, entryTypes);
|
|
26
|
+
return new DuckDBUnionVector(unionType, DuckDBStructVector_1.DuckDBStructVector.fromRawVector(structVectorType, vector, itemCount));
|
|
27
|
+
}
|
|
28
|
+
get type() {
|
|
29
|
+
return this.unionType;
|
|
30
|
+
}
|
|
31
|
+
get itemCount() {
|
|
32
|
+
return this.structVector.itemCount;
|
|
33
|
+
}
|
|
34
|
+
getItem(itemIndex) {
|
|
35
|
+
const tagValue = this.structVector.getItemValue(itemIndex, 0);
|
|
36
|
+
if (tagValue == null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const memberIndex = Number(tagValue);
|
|
40
|
+
const tag = this.unionType.memberTags[memberIndex];
|
|
41
|
+
const entryIndex = memberIndex + 1;
|
|
42
|
+
const value = this.structVector.getItemValue(itemIndex, entryIndex);
|
|
43
|
+
return new values_1.DuckDBUnionValue(tag, value);
|
|
44
|
+
}
|
|
45
|
+
setItem(itemIndex, value) {
|
|
46
|
+
if (value != null) {
|
|
47
|
+
const memberIndex = this.unionType.memberIndexForTag(value.tag);
|
|
48
|
+
this.structVector.setItemValue(itemIndex, 0, memberIndex);
|
|
49
|
+
const entryIndex = memberIndex + 1;
|
|
50
|
+
this.structVector.setItemValue(itemIndex, entryIndex, value.value);
|
|
51
|
+
for (let i = 1; i <= this.unionType.memberCount; i++) {
|
|
52
|
+
if (i !== entryIndex) {
|
|
53
|
+
this.structVector.setItemValue(itemIndex, i, null);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
for (let i = 0; i <= this.unionType.memberCount; i++) {
|
|
59
|
+
this.structVector.setItemValue(itemIndex, i, null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
flush() {
|
|
64
|
+
this.structVector.flush();
|
|
65
|
+
}
|
|
66
|
+
slice(offset, length) {
|
|
67
|
+
return new DuckDBUnionVector(this.unionType, this.structVector.slice(offset, length));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.DuckDBUnionVector = DuckDBUnionVector;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
export declare class DuckDBValidity {
|
|
3
|
+
private data;
|
|
4
|
+
private readonly offset;
|
|
5
|
+
private readonly itemCount;
|
|
6
|
+
private constructor();
|
|
7
|
+
static fromVector(vector: duckdb.Vector, itemCount: number): DuckDBValidity;
|
|
8
|
+
itemValid(itemIndex: number): boolean;
|
|
9
|
+
setItemValid(itemIndex: number, valid: boolean): void;
|
|
10
|
+
flush(vector: duckdb.Vector): void;
|
|
11
|
+
slice(offset: number, itemCount: number): DuckDBValidity;
|
|
12
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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.DuckDBValidity = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
// This version of DuckDBValidity is almost 10x slower.
|
|
9
|
+
// class DuckDBValidity {
|
|
10
|
+
// private readonly validity_pointer: ddb.uint64_pointer;
|
|
11
|
+
// private readonly offset: number;
|
|
12
|
+
// private constructor(validity_pointer: ddb.uint64_pointer, offset: number = 0) {
|
|
13
|
+
// this.validity_pointer = validity_pointer;
|
|
14
|
+
// this.offset = offset;
|
|
15
|
+
// }
|
|
16
|
+
// public static fromVector(vector: ddb.duckdb_vector, itemCount: number, offset: number = 0): DuckDBValidity {
|
|
17
|
+
// const validity_pointer = ddb.duckdb_vector_get_validity(vector);
|
|
18
|
+
// return new DuckDBValidity(validity_pointer, offset);
|
|
19
|
+
// }
|
|
20
|
+
// public itemValid(itemIndex: number): boolean {
|
|
21
|
+
// return ddb.duckdb_validity_row_is_valid(this.validity_pointer, this.offset + itemIndex);
|
|
22
|
+
// }
|
|
23
|
+
// public slice(offset: number): DuckDBValidity {
|
|
24
|
+
// return new DuckDBValidity(this.validity_pointer, this.offset + offset);
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
class DuckDBValidity {
|
|
28
|
+
data;
|
|
29
|
+
offset;
|
|
30
|
+
itemCount;
|
|
31
|
+
constructor(data, offset, itemCount) {
|
|
32
|
+
this.data = data;
|
|
33
|
+
this.offset = offset;
|
|
34
|
+
this.itemCount = itemCount;
|
|
35
|
+
}
|
|
36
|
+
static fromVector(vector, itemCount) {
|
|
37
|
+
const uint64Count = Math.ceil(itemCount / 64);
|
|
38
|
+
const bytes = node_bindings_1.default.vector_get_validity(vector, uint64Count * 8);
|
|
39
|
+
if (!bytes) {
|
|
40
|
+
return new DuckDBValidity(null, 0, itemCount);
|
|
41
|
+
}
|
|
42
|
+
const bigints = new BigUint64Array(bytes.buffer, bytes.byteOffset, uint64Count);
|
|
43
|
+
return new DuckDBValidity(bigints, 0, itemCount);
|
|
44
|
+
}
|
|
45
|
+
itemValid(itemIndex) {
|
|
46
|
+
if (!this.data) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const bit = this.offset + itemIndex;
|
|
50
|
+
return ((this.data[Math.floor(bit / 64)] & (BigInt(1) << BigInt(bit % 64))) !==
|
|
51
|
+
BigInt(0));
|
|
52
|
+
}
|
|
53
|
+
setItemValid(itemIndex, valid) {
|
|
54
|
+
if (!this.data && !valid) {
|
|
55
|
+
// 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
|
|
56
|
+
// and we don't have a data buffer, then there's nothing to do; a null data buffer indicates all items are valid.
|
|
57
|
+
const uint64Count = Math.ceil(this.itemCount / 64);
|
|
58
|
+
const buffer = new ArrayBuffer(uint64Count * 8);
|
|
59
|
+
this.data = new BigUint64Array(buffer, 0, uint64Count);
|
|
60
|
+
// Initialize to all items to valid.
|
|
61
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
62
|
+
this.data[i] = 0xffffffffffffffffn;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (this.data) {
|
|
66
|
+
const bit = this.offset + itemIndex;
|
|
67
|
+
const uint64Index = Math.floor(bit / 64);
|
|
68
|
+
const uint64WithBitSet = BigInt(1) << BigInt(bit % 64);
|
|
69
|
+
if (valid) {
|
|
70
|
+
if ((this.data[uint64Index] & uint64WithBitSet) === 0n) {
|
|
71
|
+
this.data[uint64Index] |= uint64WithBitSet;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if ((this.data[uint64Index] & uint64WithBitSet) !== 0n) {
|
|
76
|
+
this.data[uint64Index] &= ~uint64WithBitSet;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
flush(vector) {
|
|
82
|
+
if (this.data) {
|
|
83
|
+
node_bindings_1.default.vector_ensure_validity_writable(vector);
|
|
84
|
+
node_bindings_1.default.copy_data_to_vector_validity(vector, 0, this.data.buffer, this.data.byteOffset, this.data.byteLength);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
slice(offset, itemCount) {
|
|
88
|
+
return new DuckDBValidity(this.data, this.offset + offset, itemCount);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.DuckDBValidity = DuckDBValidity;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBVarCharType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
4
|
+
import { DuckDBValidity } from './DuckDBValidity';
|
|
5
|
+
export declare class DuckDBVarCharVector extends DuckDBVector<string> {
|
|
6
|
+
private readonly dataView;
|
|
7
|
+
private readonly validity;
|
|
8
|
+
private readonly vector;
|
|
9
|
+
private readonly itemOffset;
|
|
10
|
+
private readonly _itemCount;
|
|
11
|
+
private readonly itemCache;
|
|
12
|
+
private readonly itemCacheDirty;
|
|
13
|
+
constructor(dataView: DataView, validity: DuckDBValidity, vector: duckdb.Vector, itemOffset: number, itemCount: number);
|
|
14
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBVarCharVector;
|
|
15
|
+
get type(): DuckDBVarCharType;
|
|
16
|
+
get itemCount(): number;
|
|
17
|
+
getItem(itemIndex: number): string | null;
|
|
18
|
+
setItem(itemIndex: number, value: string | null): void;
|
|
19
|
+
flush(): void;
|
|
20
|
+
slice(offset: number, length: number): DuckDBVarCharVector;
|
|
21
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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.DuckDBVarCharVector = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBType_1 = require("../DuckDBType");
|
|
9
|
+
const DuckDBVector_1 = require("./DuckDBVector");
|
|
10
|
+
const DuckDBValidity_1 = require("./DuckDBValidity");
|
|
11
|
+
const dataAccessors_1 = require("./dataAccessors");
|
|
12
|
+
class DuckDBVarCharVector extends DuckDBVector_1.DuckDBVector {
|
|
13
|
+
dataView;
|
|
14
|
+
validity;
|
|
15
|
+
vector;
|
|
16
|
+
itemOffset;
|
|
17
|
+
_itemCount;
|
|
18
|
+
itemCache;
|
|
19
|
+
itemCacheDirty;
|
|
20
|
+
constructor(dataView, validity, vector, itemOffset, itemCount) {
|
|
21
|
+
super();
|
|
22
|
+
this.dataView = dataView;
|
|
23
|
+
this.validity = validity;
|
|
24
|
+
this.vector = vector;
|
|
25
|
+
this.itemOffset = itemOffset;
|
|
26
|
+
this._itemCount = itemCount;
|
|
27
|
+
this.itemCache = [];
|
|
28
|
+
this.itemCacheDirty = [];
|
|
29
|
+
}
|
|
30
|
+
static fromRawVector(vector, itemCount) {
|
|
31
|
+
const data = (0, dataAccessors_1.vectorData)(vector, itemCount * 16);
|
|
32
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
33
|
+
const validity = DuckDBValidity_1.DuckDBValidity.fromVector(vector, itemCount);
|
|
34
|
+
return new DuckDBVarCharVector(dataView, validity, vector, 0, itemCount);
|
|
35
|
+
}
|
|
36
|
+
get type() {
|
|
37
|
+
return DuckDBType_1.DuckDBVarCharType.instance;
|
|
38
|
+
}
|
|
39
|
+
get itemCount() {
|
|
40
|
+
return this._itemCount;
|
|
41
|
+
}
|
|
42
|
+
getItem(itemIndex) {
|
|
43
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
44
|
+
if (cachedItem !== undefined) {
|
|
45
|
+
return cachedItem;
|
|
46
|
+
}
|
|
47
|
+
const item = this.validity.itemValid(itemIndex)
|
|
48
|
+
? (0, dataAccessors_1.getString)(this.dataView, itemIndex * 16)
|
|
49
|
+
: null;
|
|
50
|
+
this.itemCache[itemIndex] = item;
|
|
51
|
+
return item;
|
|
52
|
+
}
|
|
53
|
+
setItem(itemIndex, value) {
|
|
54
|
+
this.itemCache[itemIndex] = value;
|
|
55
|
+
this.validity.setItemValid(itemIndex, value != null);
|
|
56
|
+
this.itemCacheDirty[itemIndex] = true;
|
|
57
|
+
}
|
|
58
|
+
flush() {
|
|
59
|
+
for (let itemIndex = 0; itemIndex < this._itemCount; itemIndex++) {
|
|
60
|
+
if (this.itemCacheDirty[itemIndex]) {
|
|
61
|
+
const cachedItem = this.itemCache[itemIndex];
|
|
62
|
+
if (cachedItem !== undefined && cachedItem !== null) {
|
|
63
|
+
node_bindings_1.default.vector_assign_string_element(this.vector, this.itemOffset + itemIndex, cachedItem);
|
|
64
|
+
}
|
|
65
|
+
this.itemCacheDirty[itemIndex] = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.validity.flush(this.vector);
|
|
69
|
+
}
|
|
70
|
+
slice(offset, length) {
|
|
71
|
+
return new DuckDBVarCharVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.DuckDBVarCharVector = DuckDBVarCharVector;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBVariantType } from '../DuckDBType';
|
|
3
|
+
import { DuckDBVariantValue } from '../values';
|
|
4
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
5
|
+
import { DuckDBStructVector } from './DuckDBStructVector';
|
|
6
|
+
export declare class DuckDBVariantVector extends DuckDBVector<DuckDBVariantValue> {
|
|
7
|
+
private readonly structVec;
|
|
8
|
+
private readonly keysList;
|
|
9
|
+
private readonly childrenList;
|
|
10
|
+
private readonly valuesList;
|
|
11
|
+
private readonly dataBlob;
|
|
12
|
+
private readonly keysEntry;
|
|
13
|
+
private readonly keysIdxVec;
|
|
14
|
+
private readonly valuesIdxVec;
|
|
15
|
+
private readonly typeIdVec;
|
|
16
|
+
private readonly byteOffsetVec;
|
|
17
|
+
constructor(structVec: DuckDBStructVector);
|
|
18
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBVariantVector;
|
|
19
|
+
get type(): DuckDBVariantType;
|
|
20
|
+
get itemCount(): number;
|
|
21
|
+
getItem(itemIndex: number): DuckDBVariantValue | null;
|
|
22
|
+
setItem(_itemIndex: number, value: DuckDBVariantValue | null): void;
|
|
23
|
+
flush(): void;
|
|
24
|
+
slice(offset: number, length: number): DuckDBVariantVector;
|
|
25
|
+
/**
|
|
26
|
+
* Decode one variant node identified by its row-local `valueIndex`
|
|
27
|
+
* (an index into the row's `values` list). Per-row state is bundled in
|
|
28
|
+
* `row`: the data blob plus the row-local list slice extents and the
|
|
29
|
+
* absolute backing-array offsets they begin at. All recursive calls
|
|
30
|
+
* share the same `row`; only `valueIndex` changes.
|
|
31
|
+
*
|
|
32
|
+
* Returns both the decoded value and the `DuckDBType` corresponding to
|
|
33
|
+
* the node's on-disk tag, so the top-level caller can attach the type
|
|
34
|
+
* to the resulting `DuckDBVariantValue` for round-trip fidelity.
|
|
35
|
+
*
|
|
36
|
+
* Throws if any index decoded from the blob falls outside its row-local
|
|
37
|
+
* list slice — guards against malformed or hostile VARIANT payloads.
|
|
38
|
+
*/
|
|
39
|
+
private decodeNode;
|
|
40
|
+
/** Bounds-check an OBJECT / ARRAY's `[childrenIdx, childrenIdx+childCount)` range. */
|
|
41
|
+
private checkChildrenSlice;
|
|
42
|
+
}
|