@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.11

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 (313) hide show
  1. package/SCAN-README.md +2 -2
  2. package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
  3. package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
  4. package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
  5. package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
  6. package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
  7. package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
  8. package/dist/arrow-geometry/feature-table.cjs +2 -10
  9. package/dist/arrow-geometry/feature-table.cjs.map +2 -2
  10. package/dist/arrow-geometry/feature-table.d.ts +6 -5
  11. package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
  12. package/dist/arrow-geometry/feature-table.js +5 -13
  13. package/dist/arrow-geometry/feature-table.js.map +1 -1
  14. package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
  15. package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
  16. package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
  17. package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
  18. package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
  19. package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
  20. package/dist/arrow-worker-transport.cjs +7 -75
  21. package/dist/arrow-worker-transport.cjs.map +1 -1
  22. package/dist/arrow-worker-transport.d.ts +3 -7
  23. package/dist/arrow-worker-transport.d.ts.map +1 -1
  24. package/dist/arrow-worker-transport.js +15 -89
  25. package/dist/arrow-worker-transport.js.map +1 -1
  26. package/dist/cluster-source.cjs +12 -12
  27. package/dist/cluster-source.cjs.map +1 -1
  28. package/dist/dist.dev.js +71 -60
  29. package/dist/dist.min.js +3 -3
  30. package/dist/federated-table-scan-source.cjs +87 -125
  31. package/dist/federated-table-scan-source.cjs.map +2 -2
  32. package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
  33. package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
  34. package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
  35. package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
  36. package/dist/geoarrow/clustering/cluster-source.js +12 -14
  37. package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
  38. package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
  39. package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
  40. package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
  41. package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
  42. package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
  43. package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
  44. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
  45. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
  46. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
  47. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
  48. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
  49. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
  50. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
  51. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
  52. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
  53. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
  54. package/dist/geoarrow/geoarrow-stream.cjs +10 -11
  55. package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
  56. package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
  57. package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
  58. package/dist/geoarrow/geoarrow-stream.js +9 -12
  59. package/dist/geoarrow/geoarrow-stream.js.map +1 -1
  60. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
  61. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
  62. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
  63. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
  64. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
  65. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
  66. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
  67. package/dist/index.cjs +69 -54
  68. package/dist/index.cjs.map +3 -3
  69. package/dist/index.d.ts +1 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/lib/api/load.d.ts.map +1 -1
  74. package/dist/lib/api/load.js +2 -4
  75. package/dist/lib/api/load.js.map +1 -1
  76. package/dist/lib/api/loader-options.d.ts +6 -0
  77. package/dist/lib/api/loader-options.d.ts.map +1 -1
  78. package/dist/lib/api/loader-options.js +48 -0
  79. package/dist/lib/api/loader-options.js.map +1 -1
  80. package/dist/lib/api/parse-file.d.ts.map +1 -1
  81. package/dist/lib/api/parse-file.js +2 -5
  82. package/dist/lib/api/parse-file.js.map +1 -1
  83. package/dist/lib/api/parse-in-batches.js +6 -10
  84. package/dist/lib/api/parse-in-batches.js.map +1 -1
  85. package/dist/lib/api/parse-sync.d.ts.map +1 -1
  86. package/dist/lib/api/parse-sync.js +2 -5
  87. package/dist/lib/api/parse-sync.js.map +1 -1
  88. package/dist/lib/api/parse.d.ts.map +1 -1
  89. package/dist/lib/api/parse.js +2 -5
  90. package/dist/lib/api/parse.js.map +1 -1
  91. package/dist/lib/init.js +1 -1
  92. package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
  93. package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
  94. package/dist/lib/loader-utils/native-arrow.js +13 -31
  95. package/dist/lib/loader-utils/native-arrow.js.map +1 -1
  96. package/dist/loader-utils/index.cjs +27 -22
  97. package/dist/loader-utils/index.cjs.map +1 -1
  98. package/dist/loader-utils/index.d.ts +1 -1
  99. package/dist/loader-utils/index.d.ts.map +1 -1
  100. package/dist/loader-utils/index.js +1 -1
  101. package/dist/loader-utils/index.js.map +1 -1
  102. package/dist/loader-utils/json-loader.js +1 -1
  103. package/dist/loader-utils/lib/log-utils/log.js +1 -1
  104. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
  105. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
  106. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
  107. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
  108. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
  109. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
  110. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
  111. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
  112. package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
  113. package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
  114. package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
  115. package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
  116. package/dist/loader-utils/loader-types.d.ts +3 -5
  117. package/dist/loader-utils/loader-types.d.ts.map +1 -1
  118. package/dist/null-loader.js +1 -1
  119. package/dist/null-worker-node.js +1 -1
  120. package/dist/null-worker.js +1 -1
  121. package/dist/scan/arrow-execution/expressions.cjs +4 -4
  122. package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
  123. package/dist/scan/arrow-execution/expressions.d.ts +4 -4
  124. package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
  125. package/dist/scan/arrow-execution/expressions.js +4 -4
  126. package/dist/scan/arrow-execution/expressions.js.map +1 -1
  127. package/dist/scan/arrow-query-worker-entry.cjs +121 -0
  128. package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
  129. package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
  130. package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
  131. package/dist/scan/arrow-query-worker-entry.js +7 -0
  132. package/dist/scan/arrow-query-worker-entry.js.map +1 -0
  133. package/dist/scan/arrow-query-worker.cjs +197 -0
  134. package/dist/scan/arrow-query-worker.cjs.map +7 -0
  135. package/dist/scan/arrow-query-worker.d.ts +47 -0
  136. package/dist/scan/arrow-query-worker.d.ts.map +1 -0
  137. package/dist/scan/arrow-query-worker.js +101 -0
  138. package/dist/scan/arrow-query-worker.js.map +1 -0
  139. package/dist/scan/federated-table-scan-source.cjs +12 -13
  140. package/dist/scan/federated-table-scan-source.cjs.map +2 -2
  141. package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
  142. package/dist/scan/federated-table-scan-source.js +14 -15
  143. package/dist/scan/federated-table-scan-source.js.map +1 -1
  144. package/dist/scan/index.cjs +5 -2
  145. package/dist/scan/index.cjs.map +2 -2
  146. package/dist/scan/index.d.ts +2 -1
  147. package/dist/scan/index.d.ts.map +1 -1
  148. package/dist/scan/index.js +2 -1
  149. package/dist/scan/index.js.map +1 -1
  150. package/dist/scan/parse-sql-predicate.cjs +2 -2
  151. package/dist/scan/parse-sql-predicate.cjs.map +2 -2
  152. package/dist/scan/parse-sql-predicate.js +1 -1
  153. package/dist/scan/parse-sql-predicate.js.map +1 -1
  154. package/dist/scan/query-pushdown.cjs +6 -6
  155. package/dist/scan/query-pushdown.cjs.map +2 -2
  156. package/dist/scan/query-pushdown.d.ts +1 -1
  157. package/dist/scan/query-pushdown.d.ts.map +1 -1
  158. package/dist/scan/query-pushdown.js +3 -6
  159. package/dist/scan/query-pushdown.js.map +1 -1
  160. package/dist/scan/query-scales.cjs +140 -0
  161. package/dist/scan/query-scales.cjs.map +7 -0
  162. package/dist/scan/query-scales.d.ts +35 -0
  163. package/dist/scan/query-scales.d.ts.map +1 -0
  164. package/dist/scan/query-scales.js +120 -0
  165. package/dist/scan/query-scales.js.map +1 -0
  166. package/dist/scan/query.cjs +49 -45
  167. package/dist/scan/query.cjs.map +2 -2
  168. package/dist/scan/query.d.ts +7 -4
  169. package/dist/scan/query.d.ts.map +1 -1
  170. package/dist/scan/query.js +35 -52
  171. package/dist/scan/query.js.map +1 -1
  172. package/dist/scan/vector-table-scan-source.cjs +19 -13
  173. package/dist/scan/vector-table-scan-source.cjs.map +3 -3
  174. package/dist/scan/vector-table-scan-source.d.ts +3 -4
  175. package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
  176. package/dist/scan/vector-table-scan-source.js +11 -12
  177. package/dist/scan/vector-table-scan-source.js.map +1 -1
  178. package/dist/schema/categories/category-mesh.d.ts +3 -10
  179. package/dist/schema/categories/category-mesh.d.ts.map +1 -1
  180. package/dist/schema/categories/category-mesh.js.map +1 -1
  181. package/dist/schema/categories/category-table.d.ts +2 -19
  182. package/dist/schema/categories/category-table.d.ts.map +1 -1
  183. package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
  184. package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
  185. package/dist/schema/index.cjs.map +1 -1
  186. package/dist/schema/index.d.ts +2 -2
  187. package/dist/schema/index.d.ts.map +1 -1
  188. package/dist/schema/index.js.map +1 -1
  189. package/dist/schema/types/batch.d.ts +0 -4
  190. package/dist/schema/types/batch.d.ts.map +1 -1
  191. package/dist/schema-utils/index.cjs +419 -502
  192. package/dist/schema-utils/index.cjs.map +3 -3
  193. package/dist/schema-utils/index.d.ts +4 -5
  194. package/dist/schema-utils/index.d.ts.map +1 -1
  195. package/dist/schema-utils/index.js +4 -5
  196. package/dist/schema-utils/index.js.map +1 -1
  197. package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
  198. package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
  199. package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
  200. package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
  201. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
  202. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
  203. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
  204. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
  205. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
  206. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
  207. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
  208. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
  209. package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
  210. package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
  211. package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
  212. package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
  213. package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
  214. package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
  215. package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
  216. package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
  217. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
  218. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
  219. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
  220. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
  221. package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
  222. package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
  223. package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
  224. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
  225. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
  226. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
  227. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
  228. package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
  229. package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
  230. package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
  231. package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
  232. package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
  233. package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
  234. package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +6 -57
  235. package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
  236. package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
  237. package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
  238. package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
  239. package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
  240. package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
  241. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
  242. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
  243. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
  244. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
  245. package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
  246. package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
  247. package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
  248. package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
  249. package/dist/vector-table-scan-source.cjs +16 -10
  250. package/dist/vector-table-scan-source.cjs.map +2 -2
  251. package/dist/worker-utils/index.cjs +2 -2
  252. package/dist/worker-utils/lib/env-utils/version.js +1 -1
  253. package/package.json +23 -8
  254. package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
  255. package/src/arrow-geometry/feature-table.ts +8 -21
  256. package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
  257. package/src/arrow-worker-transport.ts +21 -120
  258. package/src/geoarrow/clustering/cluster-source.ts +16 -23
  259. package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
  260. package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
  261. package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
  262. package/src/geoarrow/geoarrow-stream.ts +15 -15
  263. package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
  264. package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
  265. package/src/index.ts +1 -1
  266. package/src/lib/api/load.ts +2 -12
  267. package/src/lib/api/loader-options.ts +69 -0
  268. package/src/lib/api/parse-file.ts +2 -11
  269. package/src/lib/api/parse-in-batches.ts +8 -12
  270. package/src/lib/api/parse-sync.ts +3 -7
  271. package/src/lib/api/parse.ts +2 -6
  272. package/src/lib/loader-utils/native-arrow.ts +12 -38
  273. package/src/loader-utils/index.ts +0 -1
  274. package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
  275. package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
  276. package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
  277. package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
  278. package/src/loader-utils/loader-types.ts +3 -3
  279. package/src/scan/arrow-execution/expressions.ts +7 -7
  280. package/src/scan/arrow-query-worker-entry.ts +8 -0
  281. package/src/scan/arrow-query-worker.ts +158 -0
  282. package/src/scan/federated-table-scan-source.ts +15 -18
  283. package/src/scan/index.ts +7 -1
  284. package/src/scan/parse-sql-predicate.ts +1 -1
  285. package/src/scan/query-pushdown.ts +7 -7
  286. package/src/scan/query-scales.ts +199 -0
  287. package/src/scan/query.ts +68 -71
  288. package/src/scan/vector-table-scan-source.ts +16 -21
  289. package/src/schema/categories/category-mesh.ts +3 -11
  290. package/src/schema/categories/category-table.ts +2 -28
  291. package/src/schema/geometry/arrow-binary-features.ts +1 -1
  292. package/src/schema/index.ts +1 -3
  293. package/src/schema/types/batch.ts +0 -5
  294. package/src/schema-utils/index.ts +4 -10
  295. package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
  296. package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
  297. package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
  298. package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
  299. package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
  300. package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
  301. package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
  302. package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
  303. package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
  304. package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +9 -72
  305. package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
  306. package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
  307. package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
  308. package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
  309. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
  310. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
  311. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
  312. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
  313. package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
package/src/scan/query.ts CHANGED
@@ -8,8 +8,8 @@ import type {
8
8
  ProgressiveQueryOptions,
9
9
  ProgressiveQuerySnapshot
10
10
  } from './query-progressive';
11
- import type {SQLQuery} from '@math.gl/expressions/sql';
12
- import type {ArrowTable, ArrowTableBatch, TableBatch, Schema} from '@loaders.gl/core/schema';
11
+ import type {SQLQuery} from '@math.gl/sql/parser';
12
+ import type {TableBatch, Schema} from '@loaders.gl/core/schema';
13
13
  import {
14
14
  normalizeTableQuery,
15
15
  getColumnarPredicateColumns,
@@ -85,6 +85,10 @@ export type QueryOptions = TableQueryExecutionOptions &
85
85
  core?: DataSourceOptions['core'];
86
86
  /** Named caller-owned data sources used by FROM and metadata commands. */
87
87
  sources?: readonly DataSource<unknown, DataSourceOptions>[];
88
+ /** Row offset belongs on the logical query. */
89
+ offset?: never;
90
+ /** Row limit belongs on the logical query. */
91
+ limit?: never;
88
92
  /** Parser or lazy parser promise, required only for SQL string input. */
89
93
  sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;
90
94
  /** Append-only batches (default), or complete progressive replacement snapshots. */
@@ -93,7 +97,7 @@ export type QueryOptions = TableQueryExecutionOptions &
93
97
  Readonly<
94
98
  | {
95
99
  /** Already loaded Arrow table or caller-owned table scan source. */
96
- source: arrow.Table | ArrowTable | TableScanSource;
100
+ source: arrow.Table | TableScanSource;
97
101
  /** URL loader selection is only used with URL sources. */
98
102
  loaders?: never;
99
103
  }
@@ -148,9 +152,9 @@ export async function* queryInBatches(
148
152
  if (typeof tableQuery === 'object' && tableQuery && 'aggregates' in tableQuery) {
149
153
  throw new Error('Aggregates require snapshots.');
150
154
  }
151
- for await (const batch of queryAppendBatches(tableQuery as Query | string, options)) {
152
- if (batch.data.batches.length) yield* batch.data.batches;
153
- else yield makeArrowMetadataBatch(batch.data.schema);
155
+ for await (const table of queryAppendBatches(tableQuery as Query | string, options)) {
156
+ if (table.batches.length) yield* table.batches;
157
+ else yield makeArrowMetadataBatch(table.schema);
154
158
  }
155
159
  }
156
160
 
@@ -167,7 +171,7 @@ export async function* queryProgressive(
167
171
  async function* queryAppendBatches(
168
172
  tableQuery: Query | string,
169
173
  options: QueryOptions
170
- ): AsyncIterable<ArrowTableBatch> {
174
+ ): AsyncIterable<arrow.Table> {
171
175
  const startedAt = Date.now();
172
176
  let status: TableQueryExecutionSummary['status'] = 'early-terminated';
173
177
  let rowsRead = 0;
@@ -179,6 +183,15 @@ async function* queryAppendBatches(
179
183
  let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];
180
184
  try {
181
185
  options.signal?.throwIfAborted();
186
+ const scan = options._scan;
187
+ if (
188
+ options.offset !== undefined ||
189
+ options.limit !== undefined ||
190
+ scan?.limit !== undefined ||
191
+ (scan && 'offset' in scan && scan.offset !== undefined)
192
+ ) {
193
+ throw new Error('Put offset and limit in the logical query, not the execution options.');
194
+ }
182
195
  let parsedQuery: Query;
183
196
  if (typeof tableQuery === 'string') {
184
197
  const parser = await options.sqlParser;
@@ -225,12 +238,7 @@ async function* queryAppendBatches(
225
238
  options.signal?.throwIfAborted();
226
239
  if (!source || typeof source !== 'object')
227
240
  throw new Error('Expected an Arrow table or table scan source.');
228
- const inMemory =
229
- 'batches' in source
230
- ? (source as arrow.Table)
231
- : 'shape' in source && source.shape === 'arrow-table'
232
- ? (source as ArrowTable).data
233
- : null;
241
+ const inMemory = 'batches' in source ? (source as arrow.Table) : null;
234
242
  if (
235
243
  !inMemory &&
236
244
  (!('read' in source) ||
@@ -252,6 +260,11 @@ async function* queryAppendBatches(
252
260
  ) {
253
261
  throw new Error('Query source must support table reads.');
254
262
  }
263
+ if (metadata?.hasDefaultRowWindow) {
264
+ throw new Error(
265
+ 'Query source has a default offset or limit. Remove the source defaults and put offset and limit in the logical query.'
266
+ );
267
+ }
255
268
  const sourceSchema = inMemory ? inMemory.schema : convertSchemaToArrow(metadata!.schema);
256
269
  const names = sourceSchema.fields.map(field => field.name);
257
270
  const {select, where, ...controls} = logicalQuery;
@@ -356,7 +369,7 @@ async function* queryAppendBatches(
356
369
  options.signal?.throwIfAborted();
357
370
  let emitted = false;
358
371
  /** Adapts physical batches without pulling ahead of the query consumer. */
359
- async function* inputs(): AsyncIterable<ArrowTableBatch> {
372
+ async function* inputs(): AsyncIterable<arrow.Table> {
360
373
  sourcesRead = 1;
361
374
  const batches: AsyncIterable<unknown> = pushedPlan
362
375
  ? pushedPlan.read({signal: options.signal})
@@ -369,22 +382,27 @@ async function* queryAppendBatches(
369
382
  if (
370
383
  !pushedPlan &&
371
384
  comparisonInputSchema &&
372
- !arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema!))
385
+ !arrow.util.compareSchemas(
386
+ comparisonInputSchema,
387
+ convertSchemaToArrow(convertArrowToSchema(batch.schema))
388
+ )
373
389
  ) {
374
390
  // A source may return a wider or differently ordered projection than requested.
375
- const data = batch.data.select(inputSchema.names);
376
- batch = {...batch, ...wrapBatch(data)};
391
+ batch = batch.select(inputSchema.names);
377
392
  if (
378
- !arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema!))
393
+ !arrow.util.compareSchemas(
394
+ comparisonInputSchema,
395
+ convertSchemaToArrow(convertArrowToSchema(batch.schema))
396
+ )
379
397
  )
380
398
  throw new Error('Query input schema does not match source metadata.');
381
399
  }
382
400
  batchesRead++;
383
- rowsRead += batch.length;
401
+ rowsRead += batch.numRows;
384
402
  yield batch;
385
403
  }
386
404
  }
387
- for await (const value of executeTableScanBatches(
405
+ for await (const value of executeTableScanBatches<arrow.Table>(
388
406
  () => inputs(),
389
407
  {
390
408
  predicate: pushedPlan ? undefined : residual,
@@ -396,46 +414,40 @@ async function* queryAppendBatches(
396
414
  {
397
415
  filter: (batch, predicate, signal) => {
398
416
  if (pushedPlan) return batch;
399
- const input = batch as ArrowTableBatch;
400
- const data = compiledFilter
401
- ? filterArrowRows(
402
- input.data,
403
- batch => {
404
- const matches = compiledFilter.evaluate(batch, {signal});
405
- return index => matches.get(index) === true;
406
- },
407
- {signal}
408
- )
409
- : predicate
410
- ? filterArrowTable(input.data, predicate, {signal})
411
- : input.data;
412
- return {...input, ...wrapBatch(data)};
417
+ if (compiledFilter) {
418
+ return filterArrowRows(
419
+ batch,
420
+ recordBatch => {
421
+ const matches = compiledFilter.evaluate(recordBatch, {signal});
422
+ return index => matches.get(index) === true;
423
+ },
424
+ {signal}
425
+ );
426
+ }
427
+ return predicate ? filterArrowTable(batch, predicate, {signal}) : batch;
413
428
  },
414
- project: batch => {
415
- const input = batch as ArrowTableBatch;
416
- return pushedPlan || computedProjection
417
- ? input
418
- : {...input, ...wrapBatch(project(input.data))};
419
- }
429
+ project: batch => (pushedPlan || computedProjection ? batch : project(batch))
420
430
  }
421
431
  )) {
422
- const input = value as ArrowTableBatch;
423
432
  const finishProjection = pushedPlan
424
433
  ? pushedPlan.project
425
434
  : computedProjection
426
435
  ? project
427
436
  : undefined;
428
- const batch = finishProjection
429
- ? {...input, ...wrapBatch(finishProjection(input.data))}
430
- : input;
431
- if (!arrow.util.compareSchemas(comparisonSchema, convertSchemaToArrow(batch.schema!)))
437
+ const batch = finishProjection ? finishProjection(value) : value;
438
+ if (
439
+ !arrow.util.compareSchemas(
440
+ comparisonSchema,
441
+ convertSchemaToArrow(convertArrowToSchema(batch.schema))
442
+ )
443
+ )
432
444
  throw new Error('Query output schema does not match source metadata.');
433
445
  emitted = true;
434
- rowsReturned += batch.length;
446
+ rowsReturned += batch.numRows;
435
447
  yield batch;
436
448
  }
437
449
  // An empty schema-bearing batch makes collected and streaming empty results identical.
438
- if (!emitted) yield wrapBatch(empty);
450
+ if (!emitted) yield empty;
439
451
  if (normalized.limit !== undefined && rowsReturned >= normalized.limit)
440
452
  earlyTerminationReason = 'limit';
441
453
  status = earlyTerminationReason ? 'early-terminated' : 'completed';
@@ -487,40 +499,25 @@ async function normalizeTypedQuery(query: Query): Promise<SQLQuery | TableQuery>
487
499
  }
488
500
 
489
501
  /** Emits original Arrow RecordBatches without copying their buffers. */
490
- async function* memoryBatches(data: arrow.Table): AsyncIterable<ArrowTableBatch> {
491
- for (const batch of data.batches) yield wrapBatch(new arrow.Table(data.schema, [batch]));
502
+ async function* memoryBatches(data: arrow.Table): AsyncIterable<arrow.Table> {
503
+ for (const batch of data.batches) yield new arrow.Table(data.schema, [batch]);
492
504
  }
493
505
 
494
506
  /** Converts supported native table batches to Arrow while preserving their declared schema. */
495
- function normalizeBatch(value: unknown, fallbackSchema: Schema): ArrowTableBatch {
507
+ function normalizeBatch(value: unknown, fallbackSchema: Schema): arrow.Table {
496
508
  if (!value || typeof value !== 'object') throw new Error('Unsupported query batch.');
497
509
  if ('numRows' in value) {
498
510
  const batch = value as arrow.RecordBatch;
499
- return wrapBatch(new arrow.Table(batch.schema, [batch]));
511
+ return new arrow.Table(batch.schema, [batch]);
500
512
  }
501
513
  if (!('shape' in value)) throw new Error('Unsupported query batch.');
502
514
  const input = value as TableBatch;
503
515
  const batch = {...input, schema: input.schema ?? fallbackSchema} as TableBatch;
504
- if (
505
- !['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape)
506
- )
516
+ if (!['object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape))
507
517
  throw new Error(`Unsupported query batch shape: ${batch.shape}`);
508
- const data =
509
- batch.length === 0 && batch.schema
510
- ? new arrow.Table(convertSchemaToArrow(batch.schema))
511
- : convertTableToArrow(batch);
512
- return {...batch, ...wrapBatch(data)} as ArrowTableBatch;
513
- }
514
-
515
- /** Wraps Arrow data in the standard batch envelope. */
516
- function wrapBatch(data: arrow.Table): ArrowTableBatch {
517
- return {
518
- shape: 'arrow-table',
519
- data,
520
- schema: convertArrowToSchema(data.schema),
521
- batchType: 'data',
522
- length: data.numRows
523
- } as ArrowTableBatch;
518
+ return batch.length === 0 && batch.schema
519
+ ? new arrow.Table(convertSchemaToArrow(batch.schema))
520
+ : convertTableToArrow(batch);
524
521
  }
525
522
 
526
523
  /** Checks predicate tree bounds and detects casts that require Arrow execution. */
@@ -591,7 +588,7 @@ function isUnsupportedQueryExpression(value: unknown): boolean {
591
588
  );
592
589
  }
593
590
 
594
- export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/expressions/sql';
591
+ export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/sql/parser';
595
592
 
596
593
  export {createSQLCatalog} from './sql-catalog';
597
594
  export type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type {RecordBatch, Table} from 'apache-arrow';
6
6
  import {makeArrowMetadataBatch} from '@loaders.gl/core/schema-utils';
7
- import type {ArrowTable} from '@loaders.gl/core/schema';
7
+ import {isArrowTable} from '../lib/loader-utils/native-arrow';
8
8
  import {convertArrowToSchema} from '@loaders.gl/core/schema-utils';
9
9
  import type {
10
10
  GetFeaturesParameters,
@@ -61,7 +61,7 @@ export abstract class AddressedVectorTableScanSource {
61
61
  /** Spatial extent of the bound physical selection. */
62
62
  readonly spatial?: ScanSpatialMetadata;
63
63
 
64
- private tablePromise: Promise<ArrowTable> | null = null;
64
+ private tablePromise: Promise<Table> | null = null;
65
65
 
66
66
  /** Creates a table-scan view over one immutable physical selection. */
67
67
  protected constructor(
@@ -79,12 +79,12 @@ export abstract class AddressedVectorTableScanSource {
79
79
  }
80
80
 
81
81
  /** Loads the physically addressed data as one Arrow table. */
82
- protected abstract loadTable(signal?: AbortSignal): Promise<ArrowTable | null>;
82
+ protected abstract loadTable(signal?: AbortSignal): Promise<Table | null>;
83
83
 
84
84
  /** Discovers the addressed result schema and portable residual-query capabilities. */
85
85
  async getQueryMetadata(options: ScanQueryMetadataOptions = {}): Promise<ScanQueryMetadata> {
86
86
  const table = await this.getTable(options.signal);
87
- const schema = table.schema || convertArrowToSchema(table.data.schema);
87
+ const schema = convertArrowToSchema(table.schema);
88
88
  return createScanQueryMetadata({
89
89
  sourceType: this.sourceType,
90
90
  queryType: 'table',
@@ -99,20 +99,20 @@ export abstract class AddressedVectorTableScanSource {
99
99
  },
100
100
  columnRoles: inferVectorColumnRoles(schema.fields.map(field => field.name)),
101
101
  spatial: this.spatial,
102
- statistics: {rowCount: table.data.numRows}
102
+ statistics: {rowCount: table.numRows}
103
103
  });
104
104
  }
105
105
 
106
106
  /** Applies the portable Arrow query to the addressed feature table. */
107
107
  async query(options: ArrowQueryOptions = {}): Promise<Table> {
108
108
  const table = await this.getTable(options.signal);
109
- return queryArrowTable(table.data, options);
109
+ return queryArrowTable(table, options);
110
110
  }
111
111
 
112
112
  /** Explains the residual Arrow plan after resolving the addressed feature table. */
113
113
  async explain(options: ArrowQueryOptions = {}): Promise<TableQueryExplain<SQLPredicate>> {
114
114
  const table = await this.getTable(options.signal);
115
- return explainArrowTableQuery(table.data, options);
115
+ return explainArrowTableQuery(table, options);
116
116
  }
117
117
 
118
118
  /** Emits the portable query result as one bounded Arrow batch. */
@@ -128,7 +128,7 @@ export abstract class AddressedVectorTableScanSource {
128
128
  }
129
129
 
130
130
  /** Resolves and caches the addressed table while allowing failed loads to be retried. */
131
- private async getTable(signal?: AbortSignal): Promise<ArrowTable> {
131
+ private async getTable(signal?: AbortSignal): Promise<Table> {
132
132
  throwIfAborted(signal);
133
133
  if (!this.tablePromise) {
134
134
  this.tablePromise = this.loadTable()
@@ -136,11 +136,6 @@ export abstract class AddressedVectorTableScanSource {
136
136
  if (!table) {
137
137
  throw new Error('The addressed vector selection did not return a feature table.');
138
138
  }
139
- if (table.shape !== 'arrow-table') {
140
- throw new Error(
141
- 'The addressed vector selection must return an Arrow table. Configure the source with shape "arrow".'
142
- );
143
- }
144
139
  return table;
145
140
  })
146
141
  .catch(error => {
@@ -183,12 +178,12 @@ export class VectorTileTableScanSource extends AddressedVectorTableScanSource {
183
178
  }
184
179
 
185
180
  /** Loads the bound vector tile using the source's requested Arrow output shape. */
186
- protected loadTable(signal?: AbortSignal): Promise<ArrowTable | null> {
187
- return this.source
188
- .getVectorTile({...this.tile, signal})
189
- .then(tile =>
190
- tile && 'numRows' in tile ? {shape: 'arrow-table', data: tile} : (tile as ArrowTable | null)
191
- );
181
+ protected async loadTable(signal?: AbortSignal): Promise<Table | null> {
182
+ const tile = await this.source.getVectorTile({...this.tile, signal});
183
+ if (tile === null || isArrowTable(tile)) return tile;
184
+ throw new Error(
185
+ 'The addressed vector selection must return an Arrow table. Configure the source with shape "arrow".'
186
+ );
192
187
  }
193
188
  }
194
189
 
@@ -232,9 +227,9 @@ export class VectorFeatureTableScanSource extends AddressedVectorTableScanSource
232
227
  }
233
228
 
234
229
  /** Loads the bound service request through the source's Arrow feature output. */
235
- protected async loadTable(signal?: AbortSignal): Promise<ArrowTable | null> {
230
+ protected async loadTable(signal?: AbortSignal): Promise<Table | null> {
236
231
  const data = await this.source.getFeatures({...this.request, format: 'arrow', signal});
237
- return data && !('shape' in data) ? {shape: 'arrow-table', data} : null;
232
+ return isArrowTable(data) ? data : null;
238
233
  }
239
234
  }
240
235
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type {Schema} from '../types/schema';
6
6
  import type {TypedArray} from '../types/types';
7
- import type {ColumnarTable, ArrowTable} from './category-table';
7
+ import type {ColumnarTable} from './category-table';
8
8
  import * as arrow from 'apache-arrow';
9
9
 
10
10
  /** Mesh as columnar table */
@@ -14,16 +14,8 @@ export interface MeshTable extends ColumnarTable {
14
14
  indices?: MeshAttribute;
15
15
  }
16
16
 
17
- /** Mesh as arrow table */
18
- export interface MeshArrowTable extends ArrowTable {
19
- // shape: 'mesh-arrow-table';
20
- /** Mesh topology represented by the Arrow table rows and indices. */
21
- topology: MeshTopology;
22
- /** Optional top-level primitive indices accessor for indexed meshes. */
23
- indices?: MeshAttribute;
24
- /** Raw Apache Arrow table data for Mesh or IndexedMesh columns. */
25
- data: MeshArrowTableData | IndexedMeshArrowTableData;
26
- }
17
+ /** Native Apache Arrow table carrying mesh columns and topology metadata. */
18
+ export type MeshArrowTable = arrow.Table;
27
19
 
28
20
  /** Apache Arrow columns for a mesh vertex table. */
29
21
  export type MeshArrowColumns = {
@@ -5,16 +5,9 @@
5
5
  import type {Schema} from '../types/schema';
6
6
  import type {Batch} from '../types/batch';
7
7
  import type {Feature} from './category-gis';
8
- import type * as arrow from 'apache-arrow';
9
8
 
10
9
  /** A general table */
11
- export type Table =
12
- | RowTable
13
- | ArrayRowTable
14
- | ObjectRowTable
15
- | GeoJSONTable
16
- | ColumnarTable
17
- | ArrowTable;
10
+ export type Table = RowTable | ArrayRowTable | ObjectRowTable | GeoJSONTable | ColumnarTable;
18
11
 
19
12
  /** A table organized as an array of rows */
20
13
  export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
@@ -53,15 +46,6 @@ export type ColumnarTable = {
53
46
  data: {[columnName: string]: ArrayLike<unknown>};
54
47
  };
55
48
 
56
- /**
57
- * A table that wraps an Apache Arrow table
58
- */
59
- export type ArrowTable = {
60
- shape: 'arrow-table';
61
- schema?: Schema;
62
- data: arrow.Table;
63
- };
64
-
65
49
  /** A collection of tables */
66
50
  export type Tables<TableType = Table> = {
67
51
  shape: 'tables';
@@ -75,8 +59,7 @@ export type TableBatch =
75
59
  | ArrayRowTableBatch
76
60
  | ObjectRowTableBatch
77
61
  | GeoJSONTableBatch
78
- | ColumnarTableBatch
79
- | ArrowTableBatch;
62
+ | ColumnarTableBatch;
80
63
 
81
64
  /** Batch for a table organized as an array of rows, each row is an array of values */
82
65
  export type ArrayRowTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
@@ -114,12 +97,3 @@ export type ColumnarTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
114
97
  data: {[columnName: string]: ArrayLike<unknown>};
115
98
  length: number;
116
99
  };
117
-
118
- /** Batch that wraps an Apache Arrow RecordBatch */
119
- export type ArrowTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
120
- shape: 'arrow-table';
121
- schemaType?: 'explicit' | 'deduced';
122
- schema?: Schema;
123
- data: arrow.Table; // RecordBatch wrapped in Table
124
- length: number;
125
- };
@@ -10,7 +10,7 @@ import type {BinaryGeometryType} from './binary-geometries';
10
10
  export type ArrowBinaryFeatureTable = {
11
11
  /** Geometry family stored in this table. */
12
12
  type: BinaryGeometryType;
13
- /** Arrow table wrapper for the family. */
13
+ /** Native Arrow table for the family. */
14
14
  table: arrow.Table;
15
15
  /** Original feature-level properties sidecar from the binary feature collection. */
16
16
  properties: BinaryProperties['properties'];
@@ -62,7 +62,6 @@ export type {
62
62
  ObjectRowTable,
63
63
  GeoJSONTable,
64
64
  ColumnarTable,
65
- ArrowTable,
66
65
  Tables
67
66
  } from './categories/category-table';
68
67
  export type {
@@ -70,8 +69,7 @@ export type {
70
69
  ArrayRowTableBatch,
71
70
  ObjectRowTableBatch,
72
71
  GeoJSONTableBatch,
73
- ColumnarTableBatch,
74
- ArrowTableBatch
72
+ ColumnarTableBatch
75
73
  } from './categories/category-table';
76
74
 
77
75
  // MESH CATEGORY
@@ -3,9 +3,6 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Schema} from './schema';
6
- // import type {RecordBatch} from 'apache-arrow';
7
-
8
- type ApacheRecordBatch = unknown;
9
6
 
10
7
  /**
11
8
  * A batch of data (or metadata/schema), from a streaming loader
@@ -23,8 +20,6 @@ export type Batch<MetadataT = unknown> = {
23
20
  schema?: Schema;
24
21
  /** Data in this batch */
25
22
  data?: unknown;
26
- /** If this is an arrow table. @deprecated Use `data` */
27
- recordBatch?: ApacheRecordBatch;
28
23
  /** Length of data in this batch */
29
24
  length: number;
30
25
 
@@ -29,11 +29,6 @@ export type {
29
29
  export {getArrowViewTypeSupport} from './lib/schema/convert-arrow-schema';
30
30
  export {getDataTypeFromArray} from './lib/schema/data-type';
31
31
 
32
- export {
33
- convertArrowTable,
34
- convertArrowTableBatch
35
- } from './lib/table/tables/convert-arrow-table-wrapper';
36
-
37
32
  // TABLE CATEGORY UTILS
38
33
 
39
34
  export {deduceTableSchema} from './lib/schema/deduce-table-schema';
@@ -67,8 +62,7 @@ export {
67
62
  isArrayRowTable,
68
63
  isObjectRowTable,
69
64
  isColumnarTable,
70
- isGeoJSONTable,
71
- isArrowTable
65
+ isGeoJSONTable
72
66
  } from './lib/table/tables/table-types';
73
67
 
74
68
  export {
@@ -98,7 +92,7 @@ export {ArrowLikeTable} from './lib/table/arrow-api/arrow-like-table';
98
92
  export {getMeshSize, getMeshBoundingBox} from './lib/mesh/mesh-utils';
99
93
  export {
100
94
  convertMeshToTable,
101
- convertMeshToArrowTableWrapper,
95
+ convertMeshToArrowTable,
102
96
  makeMeshArrowTable
103
97
  } from './lib/mesh/convert-mesh-to-table';
104
98
  export type {MeshArrowTableOptions} from './lib/mesh/convert-mesh-to-table';
@@ -171,10 +165,10 @@ export {
171
165
  snapshotArrowSchema,
172
166
  mergeArrowSchemas,
173
167
  updateArrowTableSchema,
174
- updateArrowTableMetadata,
168
+ updateNativeArrowTableMetadata,
175
169
  makeArrowMetadataBatch,
176
170
  makeArrowTableFromBatches
177
171
  } from './lib/arrow/arrow-metadata';
178
172
  export {refineArrowTableBatches} from './lib/arrow/arrow-metadata';
179
173
 
180
- export {isNativeArrowRecordBatch, isNativeArrowTable} from '../lib/loader-utils/native-arrow';
174
+ export {isArrowRecordBatch, isArrowTable} from '../lib/loader-utils/native-arrow';
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import * as arrow from 'apache-arrow';
6
- import type {Field, DataType, ArrowTable} from '@loaders.gl/core/schema';
6
+ import type {Field, DataType} from '@loaders.gl/core/schema';
7
7
  import {serializeArrowSchema, deserializeArrowSchema} from '../schema/convert-arrow-schema';
8
8
 
9
9
  /** Copies a schema, including nested field metadata, without retaining mutable metadata maps. */
@@ -55,13 +55,24 @@ function mergeTypeMetadata(previous: DataType, next: DataType): DataType {
55
55
  return next;
56
56
  }
57
57
 
58
+ /** Snapshots a batch's schema and metadata while retaining its data buffers and row count. */
59
+ function snapshotArrowBatch(batch: arrow.RecordBatch, schema: arrow.Schema): arrow.RecordBatch {
60
+ const snapshot = new arrow.RecordBatch(
61
+ snapshotArrowSchema(schema),
62
+ batch.data,
63
+ new Map(batch.metadata)
64
+ );
65
+ // Arrow reconstructs the Struct length from its columns, which are absent in zero-column batches.
66
+ if (snapshot.numRows !== batch.numRows) {
67
+ Object.defineProperty(snapshot, 'data', {value: batch.data});
68
+ }
69
+ return snapshot;
70
+ }
71
+
58
72
  /** Applies a table schema snapshot to its batches while retaining batch-local custom metadata. */
59
73
  export function updateArrowTableSchema(table: arrow.Table, schema: arrow.Schema): arrow.Table {
60
74
  const snapshot = snapshotArrowSchema(schema);
61
- const batches = table.batches.map(
62
- batch =>
63
- new arrow.RecordBatch(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
64
- );
75
+ const batches = table.batches.map(batch => snapshotArrowBatch(batch, snapshot));
65
76
  // Preserve declared schemas even for schema-only empty tables.
66
77
  return new arrow.Table(
67
78
  snapshot,
@@ -69,17 +80,16 @@ export function updateArrowTableSchema(table: arrow.Table, schema: arrow.Schema)
69
80
  );
70
81
  }
71
82
 
72
- /** Updates an Arrow wrapper and its underlying table together without mutating either input. */
73
- export function updateArrowTableMetadata<T extends ArrowTable>(
74
- table: T,
83
+ /** Updates native Arrow metadata while preserving independent batch snapshots. */
84
+ export function updateNativeArrowTableMetadata(
85
+ table: arrow.Table,
75
86
  metadata: Record<string, string>
76
- ): T {
87
+ ): arrow.Table {
77
88
  const schema = new arrow.Schema(
78
- table.data.schema.fields,
79
- new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
89
+ table.schema.fields,
90
+ new Map([...table.schema.metadata, ...Object.entries(metadata)])
80
91
  );
81
- const data = updateArrowTableSchema(table.data, schema);
82
- return {...table, data, schema: serializeArrowSchema(data.schema)};
92
+ return updateArrowTableSchema(table, schema);
83
93
  }
84
94
 
85
95
  /** Creates a zero-row metadata update retaining the complete declared schema. */
@@ -95,27 +105,20 @@ export async function makeArrowTableFromBatches(
95
105
  const collected: arrow.RecordBatch[] = [];
96
106
  for await (const batch of batches) {
97
107
  schema = mergeArrowSchemas(schema, batch.schema);
98
- collected.push(
99
- new arrow.RecordBatch(snapshotArrowSchema(batch.schema), batch.data, new Map(batch.metadata))
100
- );
108
+ collected.push(snapshotArrowBatch(batch, batch.schema));
101
109
  }
102
110
  return schema ? new arrow.Table(schema, collected) : null;
103
111
  }
104
112
 
105
- /** Refines Arrow wrapper schemas and cumulative bounds while passing non-Arrow outputs through. */
106
- export async function* refineArrowTableBatches<T>(
107
- batches: AsyncIterable<T> | Iterable<T>
108
- ): AsyncIterable<T> {
113
+ /** Snapshots native Arrow schemas, accumulating bounds and retaining local batch bounds. */
114
+ export async function* refineArrowTableBatches(
115
+ batches: AsyncIterable<arrow.Table> | Iterable<arrow.Table>
116
+ ): AsyncIterable<arrow.Table> {
109
117
  let schema: arrow.Schema | undefined;
110
118
  let bounds: number[][] | undefined;
111
- for await (const batch of batches) {
112
- const table = batch as T & ArrowTable;
113
- if (table?.shape !== 'arrow-table') {
114
- yield batch;
115
- continue;
116
- }
117
- const localBounds = table.data.schema.metadata.get('boundingBox');
118
- const nextSchema = snapshotArrowSchema(table.data.schema);
119
+ for await (const table of batches) {
120
+ const localBounds = table.schema.metadata.get('boundingBox');
121
+ const nextSchema = snapshotArrowSchema(table.schema);
119
122
  if (localBounds) {
120
123
  const nextBounds = JSON.parse(localBounds) as number[][];
121
124
  bounds = bounds
@@ -127,10 +130,10 @@ export async function* refineArrowTableBatches<T>(
127
130
  nextSchema.metadata.set('boundingBox', JSON.stringify(bounds));
128
131
  }
129
132
  schema = mergeArrowSchemas(schema, nextSchema);
130
- const data = updateArrowTableSchema(table.data, schema);
133
+ const data = updateArrowTableSchema(table, schema);
131
134
  if (localBounds) {
132
135
  for (const recordBatch of data.batches) recordBatch.metadata.set('boundingBox', localBounds);
133
136
  }
134
- yield {...table, data, schema: serializeArrowSchema(data.schema)} as Awaited<T>;
137
+ yield data;
135
138
  }
136
139
  }