@avidian/duckdb-bun 0.0.0-stage → 1.0.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.
Files changed (231) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +286 -2
  3. package/package.json +96 -4
  4. package/src/bindings/api/appender.ts +288 -0
  5. package/src/bindings/api/data-chunk.ts +58 -0
  6. package/src/bindings/api/database.ts +232 -0
  7. package/src/bindings/api/datetime.ts +158 -0
  8. package/src/bindings/api/index.ts +13 -0
  9. package/src/bindings/api/logical-types.ts +227 -0
  10. package/src/bindings/api/query.ts +616 -0
  11. package/src/bindings/api/scalar-function.ts +274 -0
  12. package/src/bindings/api/table-function.ts +339 -0
  13. package/src/bindings/api/values.ts +546 -0
  14. package/src/bindings/api/vector.ts +266 -0
  15. package/src/bindings/generated/capi.ts +695 -0
  16. package/src/bindings/generated/contract.ts +162 -0
  17. package/src/bindings/index.ts +10 -0
  18. package/src/bindings/runtime/convert.ts +307 -0
  19. package/src/bindings/runtime/diagnostics.ts +45 -0
  20. package/src/bindings/runtime/dispatch.ts +213 -0
  21. package/src/bindings/runtime/exception.ts +103 -0
  22. package/src/bindings/runtime/flags.ts +19 -0
  23. package/src/bindings/runtime/handle.ts +217 -0
  24. package/src/bindings/runtime/kinds.ts +53 -0
  25. package/src/bindings/runtime/marshal.ts +190 -0
  26. package/src/bindings/runtime/native.ts +153 -0
  27. package/src/bindings/runtime/ring.ts +54 -0
  28. package/src/bindings/runtime/scope.ts +133 -0
  29. package/src/bindings/runtime/trace.ts +65 -0
  30. package/src/connection.ts +35 -0
  31. package/src/database.ts +27 -0
  32. package/src/errors.ts +30 -0
  33. package/src/file-assets.d.ts +10 -0
  34. package/src/index.ts +17 -0
  35. package/src/library.ts +83 -0
  36. package/src/neo.ts +16 -0
  37. package/src/reader.ts +47 -0
  38. package/src/statement.ts +61 -0
  39. package/src/types.ts +52 -0
  40. package/src/version.ts +6 -0
  41. package/vendor/node-api/LICENSE +7 -0
  42. package/vendor/node-api/PROVENANCE.md +54 -0
  43. package/vendor/node-api/node-bindings.d.ts +1669 -0
  44. package/vendor/node-api/src/DuckDBAppender.ts +237 -0
  45. package/vendor/node-api/src/DuckDBClientContext.ts +13 -0
  46. package/vendor/node-api/src/DuckDBConnection.ts +315 -0
  47. package/vendor/node-api/src/DuckDBDataChunk.ts +412 -0
  48. package/vendor/node-api/src/DuckDBDataChunkWriter.ts +144 -0
  49. package/vendor/node-api/src/DuckDBExtractedStatements.ts +37 -0
  50. package/vendor/node-api/src/DuckDBInstance.ts +35 -0
  51. package/vendor/node-api/src/DuckDBInstanceCache.ts +29 -0
  52. package/vendor/node-api/src/DuckDBLogicalType.ts +446 -0
  53. package/vendor/node-api/src/DuckDBMaterializedResult.ts +39 -0
  54. package/vendor/node-api/src/DuckDBPendingResult.ts +83 -0
  55. package/vendor/node-api/src/DuckDBPreparedStatement.ts +376 -0
  56. package/vendor/node-api/src/DuckDBPreparedStatementCollection.ts +5 -0
  57. package/vendor/node-api/src/DuckDBPreparedStatementWeakRefCollection.ts +31 -0
  58. package/vendor/node-api/src/DuckDBResult.ts +403 -0
  59. package/vendor/node-api/src/DuckDBResultReader.ts +283 -0
  60. package/vendor/node-api/src/DuckDBScalarFunction.ts +149 -0
  61. package/vendor/node-api/src/DuckDBScalarFunctionBindInfo.ts +34 -0
  62. package/vendor/node-api/src/DuckDBScalarFunctionInfo.ts +34 -0
  63. package/vendor/node-api/src/DuckDBScalarFunctionInitInfo.ts +35 -0
  64. package/vendor/node-api/src/DuckDBTableFunction.ts +149 -0
  65. package/vendor/node-api/src/DuckDBTableFunctionBindInfo.ts +56 -0
  66. package/vendor/node-api/src/DuckDBTableFunctionInfo.ts +36 -0
  67. package/vendor/node-api/src/DuckDBTableFunctionInitInfo.ts +52 -0
  68. package/vendor/node-api/src/DuckDBType.ts +1 -0
  69. package/vendor/node-api/src/DuckDBTypeId.ts +46 -0
  70. package/vendor/node-api/src/DuckDBValueConverter.ts +23 -0
  71. package/vendor/node-api/src/DuckDBValueConverters.ts +461 -0
  72. package/vendor/node-api/src/DuckDBVector.ts +1 -0
  73. package/vendor/node-api/src/JS.ts +11 -0
  74. package/vendor/node-api/src/JSDuckDBValueConverter.ts +85 -0
  75. package/vendor/node-api/src/JSInputTypeForTypeId.ts +101 -0
  76. package/vendor/node-api/src/JSToDuckDBValueConverter.ts +136 -0
  77. package/vendor/node-api/src/JSTypeForTypeId.ts +78 -0
  78. package/vendor/node-api/src/Json.ts +7 -0
  79. package/vendor/node-api/src/JsonDuckDBValueConverter.ts +72 -0
  80. package/vendor/node-api/src/JsonTypeForTypeId.ts +86 -0
  81. package/vendor/node-api/src/ToDuckDBValueConverter.ts +68 -0
  82. package/vendor/node-api/src/ToDuckDBValueConverters.ts +303 -0
  83. package/vendor/node-api/src/configurationOptionDescriptions.ts +13 -0
  84. package/vendor/node-api/src/conversion/bytesFromString.ts +5 -0
  85. package/vendor/node-api/src/conversion/dateTimeStringConversion.ts +343 -0
  86. package/vendor/node-api/src/conversion/displayStringForDuckDBValue.ts +12 -0
  87. package/vendor/node-api/src/conversion/stringFromBlob.ts +48 -0
  88. package/vendor/node-api/src/conversion/stringFromDecimal.ts +129 -0
  89. package/vendor/node-api/src/conversion/varintDecode.ts +42 -0
  90. package/vendor/node-api/src/convertColumnsFromChunks.ts +28 -0
  91. package/vendor/node-api/src/convertColumnsObjectFromChunks.ts +29 -0
  92. package/vendor/node-api/src/convertRowObjectsFromChunks.ts +21 -0
  93. package/vendor/node-api/src/convertRowsFromChunks.ts +16 -0
  94. package/vendor/node-api/src/createConfig.ts +14 -0
  95. package/vendor/node-api/src/createDuckDBValueConverter.ts +17 -0
  96. package/vendor/node-api/src/createResult.ts +15 -0
  97. package/vendor/node-api/src/createValue.ts +355 -0
  98. package/vendor/node-api/src/duckdb.ts +51 -0
  99. package/vendor/node-api/src/enums.ts +7 -0
  100. package/vendor/node-api/src/getColumnsFromChunks.ts +13 -0
  101. package/vendor/node-api/src/getColumnsObjectFromChunks.ts +16 -0
  102. package/vendor/node-api/src/getRowObjectsFromChunks.ts +13 -0
  103. package/vendor/node-api/src/getRowsFromChunks.ts +12 -0
  104. package/vendor/node-api/src/index.ts +3 -0
  105. package/vendor/node-api/src/readValue.ts +31 -0
  106. package/vendor/node-api/src/sleep.ts +5 -0
  107. package/vendor/node-api/src/sql.ts +7 -0
  108. package/vendor/node-api/src/tsconfig.json +7 -0
  109. package/vendor/node-api/src/typeForValue.ts +144 -0
  110. package/vendor/node-api/src/types/BaseDuckDBType.ts +31 -0
  111. package/vendor/node-api/src/types/DuckDBAnyType.ts +13 -0
  112. package/vendor/node-api/src/types/DuckDBArrayType.ts +43 -0
  113. package/vendor/node-api/src/types/DuckDBBigIntType.ts +21 -0
  114. package/vendor/node-api/src/types/DuckDBBigNumType.ts +21 -0
  115. package/vendor/node-api/src/types/DuckDBBitType.ts +13 -0
  116. package/vendor/node-api/src/types/DuckDBBlobType.ts +13 -0
  117. package/vendor/node-api/src/types/DuckDBBooleanType.ts +13 -0
  118. package/vendor/node-api/src/types/DuckDBDateType.ts +29 -0
  119. package/vendor/node-api/src/types/DuckDBDecimalType.ts +46 -0
  120. package/vendor/node-api/src/types/DuckDBDoubleType.ts +21 -0
  121. package/vendor/node-api/src/types/DuckDBEnumType.ts +111 -0
  122. package/vendor/node-api/src/types/DuckDBFloatType.ts +21 -0
  123. package/vendor/node-api/src/types/DuckDBGeometryType.ts +36 -0
  124. package/vendor/node-api/src/types/DuckDBHugeIntType.ts +21 -0
  125. package/vendor/node-api/src/types/DuckDBIntegerLiteralType.ts +13 -0
  126. package/vendor/node-api/src/types/DuckDBIntegerType.ts +21 -0
  127. package/vendor/node-api/src/types/DuckDBIntervalType.ts +13 -0
  128. package/vendor/node-api/src/types/DuckDBListType.ts +35 -0
  129. package/vendor/node-api/src/types/DuckDBMapType.ts +47 -0
  130. package/vendor/node-api/src/types/DuckDBSQLNullType.ts +17 -0
  131. package/vendor/node-api/src/types/DuckDBSmallIntType.ts +21 -0
  132. package/vendor/node-api/src/types/DuckDBStringLiteralType.ts +13 -0
  133. package/vendor/node-api/src/types/DuckDBStructType.ts +104 -0
  134. package/vendor/node-api/src/types/DuckDBTimeNSType.ts +20 -0
  135. package/vendor/node-api/src/types/DuckDBTimeTZType.ts +23 -0
  136. package/vendor/node-api/src/types/DuckDBTimeType.ts +20 -0
  137. package/vendor/node-api/src/types/DuckDBTimestampMillisecondsType.ts +29 -0
  138. package/vendor/node-api/src/types/DuckDBTimestampNanosecondsType.ts +29 -0
  139. package/vendor/node-api/src/types/DuckDBTimestampSecondsType.ts +29 -0
  140. package/vendor/node-api/src/types/DuckDBTimestampTZNanosecondsType.ts +32 -0
  141. package/vendor/node-api/src/types/DuckDBTimestampTZType.ts +32 -0
  142. package/vendor/node-api/src/types/DuckDBTimestampType.ts +32 -0
  143. package/vendor/node-api/src/types/DuckDBTinyIntType.ts +21 -0
  144. package/vendor/node-api/src/types/DuckDBType.ts +86 -0
  145. package/vendor/node-api/src/types/DuckDBUBigIntType.ts +21 -0
  146. package/vendor/node-api/src/types/DuckDBUHugeIntType.ts +21 -0
  147. package/vendor/node-api/src/types/DuckDBUIntegerType.ts +21 -0
  148. package/vendor/node-api/src/types/DuckDBUSmallIntType.ts +21 -0
  149. package/vendor/node-api/src/types/DuckDBUTinyIntType.ts +21 -0
  150. package/vendor/node-api/src/types/DuckDBUUIDType.ts +20 -0
  151. package/vendor/node-api/src/types/DuckDBUnionType.ts +74 -0
  152. package/vendor/node-api/src/types/DuckDBVarCharType.ts +13 -0
  153. package/vendor/node-api/src/types/DuckDBVariantType.ts +13 -0
  154. package/vendor/node-api/src/types/index.ts +44 -0
  155. package/vendor/node-api/src/values/DuckDBArrayValue.ts +18 -0
  156. package/vendor/node-api/src/values/DuckDBBitValue.ts +117 -0
  157. package/vendor/node-api/src/values/DuckDBBlobValue.ts +26 -0
  158. package/vendor/node-api/src/values/DuckDBDateValue.ts +43 -0
  159. package/vendor/node-api/src/values/DuckDBDecimalValue.ts +44 -0
  160. package/vendor/node-api/src/values/DuckDBGeometryValue.ts +30 -0
  161. package/vendor/node-api/src/values/DuckDBIntervalValue.ts +22 -0
  162. package/vendor/node-api/src/values/DuckDBListValue.ts +18 -0
  163. package/vendor/node-api/src/values/DuckDBMapValue.ts +25 -0
  164. package/vendor/node-api/src/values/DuckDBStructValue.ts +22 -0
  165. package/vendor/node-api/src/values/DuckDBTimeNSValue.ts +23 -0
  166. package/vendor/node-api/src/values/DuckDBTimeTZValue.ts +96 -0
  167. package/vendor/node-api/src/values/DuckDBTimeValue.ts +34 -0
  168. package/vendor/node-api/src/values/DuckDBTimestampMillisecondsValue.ts +29 -0
  169. package/vendor/node-api/src/values/DuckDBTimestampNanosecondsValue.ts +28 -0
  170. package/vendor/node-api/src/values/DuckDBTimestampSecondsValue.ts +28 -0
  171. package/vendor/node-api/src/values/DuckDBTimestampTZNanosecondsValue.ts +44 -0
  172. package/vendor/node-api/src/values/DuckDBTimestampTZValue.ts +54 -0
  173. package/vendor/node-api/src/values/DuckDBTimestampValue.ts +45 -0
  174. package/vendor/node-api/src/values/DuckDBTupleValue.ts +22 -0
  175. package/vendor/node-api/src/values/DuckDBUUIDValue.ts +48 -0
  176. package/vendor/node-api/src/values/DuckDBUnionValue.ts +22 -0
  177. package/vendor/node-api/src/values/DuckDBValue.ts +53 -0
  178. package/vendor/node-api/src/values/DuckDBVariantValue.ts +34 -0
  179. package/vendor/node-api/src/values/index.ts +24 -0
  180. package/vendor/node-api/src/vectors/DuckDBArrayVector.ts +107 -0
  181. package/vendor/node-api/src/vectors/DuckDBBigIntVector.ts +75 -0
  182. package/vendor/node-api/src/vectors/DuckDBBigNumVector.ts +98 -0
  183. package/vendor/node-api/src/vectors/DuckDBBitVector.ts +102 -0
  184. package/vendor/node-api/src/vectors/DuckDBBlobVector.ts +112 -0
  185. package/vendor/node-api/src/vectors/DuckDBBooleanVector.ts +84 -0
  186. package/vendor/node-api/src/vectors/DuckDBDateVector.ts +80 -0
  187. package/vendor/node-api/src/vectors/DuckDBDecimal128Vector.ts +107 -0
  188. package/vendor/node-api/src/vectors/DuckDBDecimal16Vector.ts +104 -0
  189. package/vendor/node-api/src/vectors/DuckDBDecimal32Vector.ts +104 -0
  190. package/vendor/node-api/src/vectors/DuckDBDecimal64Vector.ts +104 -0
  191. package/vendor/node-api/src/vectors/DuckDBDoubleVector.ts +68 -0
  192. package/vendor/node-api/src/vectors/DuckDBEnum16Vector.ts +75 -0
  193. package/vendor/node-api/src/vectors/DuckDBEnum32Vector.ts +75 -0
  194. package/vendor/node-api/src/vectors/DuckDBEnum8Vector.ts +75 -0
  195. package/vendor/node-api/src/vectors/DuckDBFloatVector.ts +68 -0
  196. package/vendor/node-api/src/vectors/DuckDBGeometryVector.ts +97 -0
  197. package/vendor/node-api/src/vectors/DuckDBHugeIntVector.ts +89 -0
  198. package/vendor/node-api/src/vectors/DuckDBIntegerVector.ts +75 -0
  199. package/vendor/node-api/src/vectors/DuckDBIntervalVector.ts +100 -0
  200. package/vendor/node-api/src/vectors/DuckDBListVector.ts +221 -0
  201. package/vendor/node-api/src/vectors/DuckDBMapVector.ts +88 -0
  202. package/vendor/node-api/src/vectors/DuckDBSQLNullVector.ts +53 -0
  203. package/vendor/node-api/src/vectors/DuckDBSmallIntVector.ts +75 -0
  204. package/vendor/node-api/src/vectors/DuckDBStructVector.ts +138 -0
  205. package/vendor/node-api/src/vectors/DuckDBTimeNSVector.ts +80 -0
  206. package/vendor/node-api/src/vectors/DuckDBTimeTZVector.ts +80 -0
  207. package/vendor/node-api/src/vectors/DuckDBTimeVector.ts +80 -0
  208. package/vendor/node-api/src/vectors/DuckDBTimestampMillisecondsVector.ts +88 -0
  209. package/vendor/node-api/src/vectors/DuckDBTimestampNanosecondsVector.ts +88 -0
  210. package/vendor/node-api/src/vectors/DuckDBTimestampSecondsVector.ts +88 -0
  211. package/vendor/node-api/src/vectors/DuckDBTimestampTZNanosecondsVector.ts +88 -0
  212. package/vendor/node-api/src/vectors/DuckDBTimestampTZVector.ts +86 -0
  213. package/vendor/node-api/src/vectors/DuckDBTimestampVector.ts +83 -0
  214. package/vendor/node-api/src/vectors/DuckDBTinyIntVector.ts +75 -0
  215. package/vendor/node-api/src/vectors/DuckDBTupleVector.ts +125 -0
  216. package/vendor/node-api/src/vectors/DuckDBUBigIntVector.ts +75 -0
  217. package/vendor/node-api/src/vectors/DuckDBUHugeIntVector.ts +89 -0
  218. package/vendor/node-api/src/vectors/DuckDBUIntegerVector.ts +75 -0
  219. package/vendor/node-api/src/vectors/DuckDBUSmallIntVector.ts +75 -0
  220. package/vendor/node-api/src/vectors/DuckDBUTinyIntVector.ts +75 -0
  221. package/vendor/node-api/src/vectors/DuckDBUUIDVector.ts +89 -0
  222. package/vendor/node-api/src/vectors/DuckDBUnionVector.ts +84 -0
  223. package/vendor/node-api/src/vectors/DuckDBValidity.ts +104 -0
  224. package/vendor/node-api/src/vectors/DuckDBVarCharVector.ts +100 -0
  225. package/vendor/node-api/src/vectors/DuckDBVariantVector.ts +609 -0
  226. package/vendor/node-api/src/vectors/DuckDBVector.ts +33 -0
  227. package/vendor/node-api/src/vectors/createVector.ts +269 -0
  228. package/vendor/node-api/src/vectors/dataAccessors.ts +387 -0
  229. package/vendor/node-api/src/vectors/index.ts +50 -0
  230. package/vendor/node-api/src/vectors/vectorRegistry.ts +24 -0
  231. package/vendor/node-api/src/version.ts +5 -0
@@ -0,0 +1,138 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBStructType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBStructValue,
7
+ DuckDBValue,
8
+ } from '../values';
9
+ import { DuckDBVector } from './DuckDBVector';
10
+ import { DuckDBValidity } from './DuckDBValidity';
11
+
12
+ export class DuckDBStructVector extends DuckDBVector<DuckDBStructValue> {
13
+ private readonly structType: DuckDBStructType;
14
+ private readonly _itemCount: number;
15
+ private readonly entryVectors: readonly DuckDBVector[];
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ structType: DuckDBStructType,
20
+ itemCount: number,
21
+ entryVectors: readonly DuckDBVector[],
22
+ validity: DuckDBValidity,
23
+ vector: duckdb.Vector
24
+ ) {
25
+ super();
26
+ this.structType = structType;
27
+ this._itemCount = itemCount;
28
+ this.entryVectors = entryVectors;
29
+ this.validity = validity;
30
+ this.vector = vector;
31
+ }
32
+ static fromRawVector(
33
+ structType: DuckDBStructType,
34
+ vector: duckdb.Vector,
35
+ itemCount: number
36
+ ): DuckDBStructVector {
37
+ const entryCount = structType.entryCount;
38
+ const entryVectors: DuckDBVector[] = [];
39
+ for (let i = 0; i < entryCount; i++) {
40
+ const child_vector = duckdb.struct_vector_get_child(vector, i);
41
+ entryVectors.push(
42
+ DuckDBVector.create(child_vector, itemCount, structType.entryTypes[i])
43
+ );
44
+ }
45
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
46
+ return new DuckDBStructVector(
47
+ structType,
48
+ itemCount,
49
+ entryVectors,
50
+ validity,
51
+ vector
52
+ );
53
+ }
54
+ public override get type(): DuckDBStructType {
55
+ return this.structType;
56
+ }
57
+ public override get itemCount(): number {
58
+ return this._itemCount;
59
+ }
60
+ public override getItem(itemIndex: number): DuckDBStructValue | null {
61
+ if (!this.validity.itemValid(itemIndex)) {
62
+ return null;
63
+ }
64
+ const entries: { [name: string]: DuckDBValue } = {};
65
+ const entryCount = this.structType.entryCount;
66
+ for (let i = 0; i < entryCount; i++) {
67
+ entries[this.structType.entryNames[i]] =
68
+ this.entryVectors[i].getItem(itemIndex);
69
+ }
70
+ return new DuckDBStructValue(entries);
71
+ }
72
+ public getItemValue(
73
+ itemIndex: number,
74
+ entryIndex: number
75
+ ): DuckDBValue | null {
76
+ if (!this.validity.itemValid(itemIndex)) {
77
+ return null;
78
+ }
79
+ return this.entryVectors[entryIndex].getItem(itemIndex);
80
+ }
81
+ /**
82
+ * Returns the underlying child vector for entry `index`. Useful for
83
+ * callers that want direct access to a child's flat backing storage
84
+ * (e.g. when decoding a physical-layout type that overlays a STRUCT).
85
+ */
86
+ public entryVectorAt(index: number): DuckDBVector {
87
+ return this.entryVectors[index];
88
+ }
89
+ /**
90
+ * Returns whether the top-level row at `itemIndex` is non-NULL. Useful
91
+ * for callers overlaying a logical type on a STRUCT vector that need to
92
+ * distinguish a SQL-NULL row from a row whose children just happen to
93
+ * be NULL.
94
+ */
95
+ public isItemValid(itemIndex: number): boolean {
96
+ return this.validity.itemValid(itemIndex);
97
+ }
98
+ public override setItem(itemIndex: number, value: DuckDBStructValue | null) {
99
+ if (value != null) {
100
+ const entryCount = this.structType.entryCount;
101
+ for (let i = 0; i < entryCount; i++) {
102
+ this.entryVectors[i].setItem(
103
+ itemIndex,
104
+ value.entries[this.structType.entryNames[i]]
105
+ );
106
+ }
107
+ this.validity.setItemValid(itemIndex, true);
108
+ } else {
109
+ const entryCount = this.structType.entryCount;
110
+ for (let i = 0; i < entryCount; i++) {
111
+ this.entryVectors[i].setItem(itemIndex, null);
112
+ }
113
+ this.validity.setItemValid(itemIndex, false);
114
+ }
115
+ }
116
+ public setItemValue(
117
+ itemIndex: number,
118
+ entryIndex: number,
119
+ value: DuckDBValue
120
+ ) {
121
+ return this.entryVectors[entryIndex].setItem(itemIndex, value);
122
+ }
123
+ public override flush() {
124
+ for (const entryVector of this.entryVectors) {
125
+ entryVector.flush();
126
+ }
127
+ this.validity.flush(this.vector);
128
+ }
129
+ public override slice(offset: number, length: number): DuckDBStructVector {
130
+ return new DuckDBStructVector(
131
+ this.structType,
132
+ length,
133
+ this.entryVectors.map((entryVector) => entryVector.slice(offset, length)),
134
+ this.validity.slice(offset, length),
135
+ this.vector
136
+ );
137
+ }
138
+ }
@@ -0,0 +1,80 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimeNSType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimeNSValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimeNSVector extends DuckDBVector<DuckDBTimeNSValue> {
15
+ private readonly items: BigInt64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigInt64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimeNSVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigInt64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimeNSVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimeNSType {
41
+ return DuckDBTimeNSType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(itemIndex: number): DuckDBTimeNSValue | null {
47
+ return this.validity.itemValid(itemIndex)
48
+ ? new DuckDBTimeNSValue(this.items[itemIndex])
49
+ : null;
50
+ }
51
+ public override setItem(itemIndex: number, value: DuckDBTimeNSValue | null) {
52
+ if (value != null) {
53
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
54
+ if (BigInt.asIntN(64, value.nanos) !== value.nanos) {
55
+ throw new Error(`bigint out of int64 range`);
56
+ }
57
+ this.items[itemIndex] = value.nanos;
58
+ this.validity.setItemValid(itemIndex, true);
59
+ } else {
60
+ this.validity.setItemValid(itemIndex, false);
61
+ }
62
+ }
63
+ public override flush() {
64
+ duckdb.copy_data_to_vector(
65
+ this.vector,
66
+ 0,
67
+ this.items.buffer as ArrayBuffer,
68
+ this.items.byteOffset,
69
+ this.items.byteLength
70
+ );
71
+ this.validity.flush(this.vector);
72
+ }
73
+ public override slice(offset: number, length: number): DuckDBTimeNSVector {
74
+ return new DuckDBTimeNSVector(
75
+ this.items.slice(offset, offset + length),
76
+ this.validity.slice(offset, length),
77
+ this.vector
78
+ );
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimeTZType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimeTZValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimeTZVector extends DuckDBVector<DuckDBTimeTZValue> {
15
+ private readonly items: BigUint64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigUint64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimeTZVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigUint64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigUint64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimeTZVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimeTZType {
41
+ return DuckDBTimeTZType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(itemIndex: number): DuckDBTimeTZValue | null {
47
+ return this.validity.itemValid(itemIndex)
48
+ ? DuckDBTimeTZValue.fromBits(this.items[itemIndex])
49
+ : null;
50
+ }
51
+ public override setItem(itemIndex: number, value: DuckDBTimeTZValue | null) {
52
+ if (value != null) {
53
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
54
+ if (BigInt.asUintN(64, value.bits) !== value.bits) {
55
+ throw new Error(`bigint out of uint64 range`);
56
+ }
57
+ this.items[itemIndex] = value.bits;
58
+ this.validity.setItemValid(itemIndex, true);
59
+ } else {
60
+ this.validity.setItemValid(itemIndex, false);
61
+ }
62
+ }
63
+ public override flush() {
64
+ duckdb.copy_data_to_vector(
65
+ this.vector,
66
+ 0,
67
+ this.items.buffer as ArrayBuffer,
68
+ this.items.byteOffset,
69
+ this.items.byteLength
70
+ );
71
+ this.validity.flush(this.vector);
72
+ }
73
+ public override slice(offset: number, length: number): DuckDBTimeTZVector {
74
+ return new DuckDBTimeTZVector(
75
+ this.items.slice(offset, offset + length),
76
+ this.validity.slice(offset, length),
77
+ this.vector
78
+ );
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimeType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimeValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimeVector extends DuckDBVector<DuckDBTimeValue> {
15
+ private readonly items: BigInt64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigInt64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimeVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigInt64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimeVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimeType {
41
+ return DuckDBTimeType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(itemIndex: number): DuckDBTimeValue | null {
47
+ return this.validity.itemValid(itemIndex)
48
+ ? new DuckDBTimeValue(this.items[itemIndex])
49
+ : null;
50
+ }
51
+ public override setItem(itemIndex: number, value: DuckDBTimeValue | null) {
52
+ if (value != null) {
53
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
54
+ if (BigInt.asIntN(64, value.micros) !== value.micros) {
55
+ throw new Error(`bigint out of int64 range`);
56
+ }
57
+ this.items[itemIndex] = value.micros;
58
+ this.validity.setItemValid(itemIndex, true);
59
+ } else {
60
+ this.validity.setItemValid(itemIndex, false);
61
+ }
62
+ }
63
+ public override flush() {
64
+ duckdb.copy_data_to_vector(
65
+ this.vector,
66
+ 0,
67
+ this.items.buffer as ArrayBuffer,
68
+ this.items.byteOffset,
69
+ this.items.byteLength
70
+ );
71
+ this.validity.flush(this.vector);
72
+ }
73
+ public override slice(offset: number, length: number): DuckDBTimeVector {
74
+ return new DuckDBTimeVector(
75
+ this.items.slice(offset, offset + length),
76
+ this.validity.slice(offset, length),
77
+ this.vector
78
+ );
79
+ }
80
+ }
@@ -0,0 +1,88 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimestampMillisecondsType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimestampMillisecondsValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimestampMillisecondsVector extends DuckDBVector<DuckDBTimestampMillisecondsValue> {
15
+ private readonly items: BigInt64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigInt64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimestampMillisecondsVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigInt64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimestampMillisecondsVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimestampMillisecondsType {
41
+ return DuckDBTimestampMillisecondsType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(
47
+ itemIndex: number
48
+ ): DuckDBTimestampMillisecondsValue | null {
49
+ return this.validity.itemValid(itemIndex)
50
+ ? new DuckDBTimestampMillisecondsValue(this.items[itemIndex])
51
+ : null;
52
+ }
53
+ public override setItem(
54
+ itemIndex: number,
55
+ value: DuckDBTimestampMillisecondsValue | null
56
+ ) {
57
+ if (value != null) {
58
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
59
+ if (BigInt.asIntN(64, value.millis) !== value.millis) {
60
+ throw new Error(`bigint out of int64 range`);
61
+ }
62
+ this.items[itemIndex] = value.millis;
63
+ this.validity.setItemValid(itemIndex, true);
64
+ } else {
65
+ this.validity.setItemValid(itemIndex, false);
66
+ }
67
+ }
68
+ public override flush() {
69
+ duckdb.copy_data_to_vector(
70
+ this.vector,
71
+ 0,
72
+ this.items.buffer as ArrayBuffer,
73
+ this.items.byteOffset,
74
+ this.items.byteLength
75
+ );
76
+ this.validity.flush(this.vector);
77
+ }
78
+ public override slice(
79
+ offset: number,
80
+ length: number
81
+ ): DuckDBTimestampMillisecondsVector {
82
+ return new DuckDBTimestampMillisecondsVector(
83
+ this.items.slice(offset, offset + length),
84
+ this.validity.slice(offset, length),
85
+ this.vector
86
+ );
87
+ }
88
+ }
@@ -0,0 +1,88 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimestampNanosecondsType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimestampNanosecondsValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimestampNanosecondsVector extends DuckDBVector<DuckDBTimestampNanosecondsValue> {
15
+ private readonly items: BigInt64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigInt64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimestampNanosecondsVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigInt64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimestampNanosecondsVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimestampNanosecondsType {
41
+ return DuckDBTimestampNanosecondsType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(
47
+ itemIndex: number
48
+ ): DuckDBTimestampNanosecondsValue | null {
49
+ return this.validity.itemValid(itemIndex)
50
+ ? new DuckDBTimestampNanosecondsValue(this.items[itemIndex])
51
+ : null;
52
+ }
53
+ public override setItem(
54
+ itemIndex: number,
55
+ value: DuckDBTimestampNanosecondsValue | null
56
+ ) {
57
+ if (value != null) {
58
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
59
+ if (BigInt.asIntN(64, value.nanos) !== value.nanos) {
60
+ throw new Error(`bigint out of int64 range`);
61
+ }
62
+ this.items[itemIndex] = value.nanos;
63
+ this.validity.setItemValid(itemIndex, true);
64
+ } else {
65
+ this.validity.setItemValid(itemIndex, false);
66
+ }
67
+ }
68
+ public override flush() {
69
+ duckdb.copy_data_to_vector(
70
+ this.vector,
71
+ 0,
72
+ this.items.buffer as ArrayBuffer,
73
+ this.items.byteOffset,
74
+ this.items.byteLength
75
+ );
76
+ this.validity.flush(this.vector);
77
+ }
78
+ public override slice(
79
+ offset: number,
80
+ length: number
81
+ ): DuckDBTimestampNanosecondsVector {
82
+ return new DuckDBTimestampNanosecondsVector(
83
+ this.items.slice(offset, offset + length),
84
+ this.validity.slice(offset, length),
85
+ this.vector
86
+ );
87
+ }
88
+ }
@@ -0,0 +1,88 @@
1
+ import duckdb from "../../../../src/bindings/index.ts";
2
+ import {
3
+ DuckDBTimestampSecondsType,
4
+ } from '../DuckDBType';
5
+ import {
6
+ DuckDBTimestampSecondsValue,
7
+ } from '../values';
8
+ import { DuckDBVector } from './DuckDBVector';
9
+ import { DuckDBValidity } from './DuckDBValidity';
10
+ import {
11
+ vectorData,
12
+ } from './dataAccessors';
13
+
14
+ export class DuckDBTimestampSecondsVector extends DuckDBVector<DuckDBTimestampSecondsValue> {
15
+ private readonly items: BigInt64Array;
16
+ private readonly validity: DuckDBValidity;
17
+ private readonly vector: duckdb.Vector;
18
+ constructor(
19
+ items: BigInt64Array,
20
+ validity: DuckDBValidity,
21
+ vector: duckdb.Vector
22
+ ) {
23
+ super();
24
+ this.items = items;
25
+ this.validity = validity;
26
+ this.vector = vector;
27
+ }
28
+ static fromRawVector(
29
+ vector: duckdb.Vector,
30
+ itemCount: number
31
+ ): DuckDBTimestampSecondsVector {
32
+ const data = vectorData(
33
+ vector,
34
+ itemCount * BigInt64Array.BYTES_PER_ELEMENT
35
+ );
36
+ const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
37
+ const validity = DuckDBValidity.fromVector(vector, itemCount);
38
+ return new DuckDBTimestampSecondsVector(items, validity, vector);
39
+ }
40
+ public override get type(): DuckDBTimestampSecondsType {
41
+ return DuckDBTimestampSecondsType.instance;
42
+ }
43
+ public override get itemCount(): number {
44
+ return this.items.length;
45
+ }
46
+ public override getItem(
47
+ itemIndex: number
48
+ ): DuckDBTimestampSecondsValue | null {
49
+ return this.validity.itemValid(itemIndex)
50
+ ? new DuckDBTimestampSecondsValue(this.items[itemIndex])
51
+ : null;
52
+ }
53
+ public override setItem(
54
+ itemIndex: number,
55
+ value: DuckDBTimestampSecondsValue | null
56
+ ) {
57
+ if (value != null) {
58
+ // Checked inline for bulk-write throughput; see dataAccessors.ts.
59
+ if (BigInt.asIntN(64, value.seconds) !== value.seconds) {
60
+ throw new Error(`bigint out of int64 range`);
61
+ }
62
+ this.items[itemIndex] = value.seconds;
63
+ this.validity.setItemValid(itemIndex, true);
64
+ } else {
65
+ this.validity.setItemValid(itemIndex, false);
66
+ }
67
+ }
68
+ public override flush() {
69
+ duckdb.copy_data_to_vector(
70
+ this.vector,
71
+ 0,
72
+ this.items.buffer as ArrayBuffer,
73
+ this.items.byteOffset,
74
+ this.items.byteLength
75
+ );
76
+ this.validity.flush(this.vector);
77
+ }
78
+ public override slice(
79
+ offset: number,
80
+ length: number
81
+ ): DuckDBTimestampSecondsVector {
82
+ return new DuckDBTimestampSecondsVector(
83
+ this.items.slice(offset, offset + length),
84
+ this.validity.slice(offset, length),
85
+ this.vector
86
+ );
87
+ }
88
+ }