@query-farm/vgi 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ npm install @query-farm/vgi
41
41
  Requires **Node.js ≥ 22.15** or **Bun**.
42
42
 
43
43
  > **Peer dependencies (since 0.3.0).** `@query-farm/apache-arrow` (`^21.1.1`) and
44
- > `@query-farm/vgi-rpc` (`^0.24.0`) are **peerDependencies** — install them directly
44
+ > `@query-farm/vgi-rpc` (`^0.25.2`) are **peerDependencies** — install them directly
45
45
  > alongside `@query-farm/vgi`:
46
46
  >
47
47
  > ```bash
@@ -999,6 +999,8 @@ function writeCanonicalColumn(type, canonical) {
999
999
  function buildColumnData(values, type) {
1000
1000
  if (DataType2.isList(type))
1001
1001
  return buildListData(values, type);
1002
+ if (DataType2.isFixedSizeList(type))
1003
+ return buildFixedSizeListData(values, type);
1002
1004
  if (DataType2.isMap(type))
1003
1005
  return buildMapData(values, type);
1004
1006
  if (DataType2.isStruct(type))
@@ -1146,6 +1148,38 @@ function buildListData(values, listType) {
1146
1148
  valueOffsets: offsets
1147
1149
  });
1148
1150
  }
1151
+ function buildFixedSizeListData(values, type) {
1152
+ const childField = type.children[0];
1153
+ const listSize = type.listSize;
1154
+ const numRows = values.length;
1155
+ const allItems = [];
1156
+ const nullBitmap = new Uint8Array(Math.ceil(numRows / 8));
1157
+ let nullCount = 0;
1158
+ for (let i = 0;i < numRows; i++) {
1159
+ const row = values[i];
1160
+ if (row == null) {
1161
+ nullCount++;
1162
+ for (let j = 0;j < listSize; j++)
1163
+ allItems.push(null);
1164
+ continue;
1165
+ }
1166
+ nullBitmap[i >> 3] |= 1 << (i & 7);
1167
+ const items = Array.isArray(row) ? row : Array.from(row);
1168
+ if (items.length !== listSize) {
1169
+ throw new TypeError(`fixed_size_list[${listSize}]: row ${i} has ${items.length} items`);
1170
+ }
1171
+ for (const item of items)
1172
+ allItems.push(item);
1173
+ }
1174
+ const childData = allItems.length > 0 ? buildColumnData(allItems, childField.type) : emptyDataForType(childField.type);
1175
+ return makeData2({
1176
+ type,
1177
+ length: numRows,
1178
+ nullCount,
1179
+ nullBitmap: nullCount > 0 ? nullBitmap : undefined,
1180
+ child: childData
1181
+ });
1182
+ }
1149
1183
  function buildMapData(values, mapType) {
1150
1184
  const numRows = values.length;
1151
1185
  const entriesField = mapType.children[0];
@@ -1237,6 +1271,14 @@ function emptyDataForType(type) {
1237
1271
  valueOffsets: new Int32Array([0])
1238
1272
  });
1239
1273
  }
1274
+ if (DataType2.isFixedSizeList(type)) {
1275
+ return makeData2({
1276
+ type,
1277
+ length: 0,
1278
+ nullCount: 0,
1279
+ child: emptyDataForType(type.children[0].type)
1280
+ });
1281
+ }
1240
1282
  if (DataType2.isStruct(type)) {
1241
1283
  const children = type.children.map((cf) => emptyDataForType(cf.type));
1242
1284
  return makeData2({ type, length: 0, nullCount: 0, children });
@@ -1888,6 +1930,8 @@ function unwrapScalar(val) {
1888
1930
  return null;
1889
1931
  if (typeof val !== "object")
1890
1932
  return val;
1933
+ if (val instanceof Date)
1934
+ return val;
1891
1935
  if (typeof val.valueOf === "function") {
1892
1936
  let v;
1893
1937
  try {
@@ -4362,4 +4406,4 @@ export {
4362
4406
  typeSignature
4363
4407
  };
4364
4408
 
4365
- //# debugId=883855CB7A9BD5B664756E2164756E21
4409
+ //# debugId=ED974828A2961DF664756E2164756E21