@haybarn/node-api 1.5.6-rc1 → 2.0.0-rc5

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