@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
@@ -0,0 +1,158 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {TaskRunner, type Task, type TaskWorker} from '@math.gl/tasks';
6
+ import type {Table} from 'apache-arrow';
7
+ import {
8
+ deserializeNativeArrowWorkerResult,
9
+ serializeNativeArrowWorkerResult
10
+ } from '../arrow-worker-transport';
11
+ import {isArrowTable} from '../lib/loader-utils/native-arrow';
12
+ import {queryArrowTable, type ArrowQueryOptions} from './query-arrow-table';
13
+
14
+ type QueryInput =
15
+ | {
16
+ operation: 'query';
17
+ options: Omit<ArrowQueryOptions, 'signal' | 'tables'>;
18
+ tables?: [string, unknown][];
19
+ }
20
+ | {operation: 'get' | 'take'};
21
+
22
+ /** Configuration for the worker that runs Arrow table queries. */
23
+ export type ArrowQueryWorkerOptions = {
24
+ /** Worker module URL or browser worker factory. */
25
+ worker: Pick<TaskWorker, 'url' | 'create'>;
26
+ /** Copy the source by default. Transfer detaches all referenced buffers, including aliases. */
27
+ inputOwnership?: 'copy' | 'transfer';
28
+ /** Cancels initialization. */
29
+ signal?: AbortSignal;
30
+ };
31
+
32
+ /** A worker that retains one source table across calls. */
33
+ export type ArrowQueryWorkerSession = {
34
+ /** Executes a query against the retained table. */
35
+ query(options?: ArrowQueryOptions): Promise<Table>;
36
+ /** Returns a copy of the retained table. The session remains open. */
37
+ getTable(): Promise<Table>;
38
+ /** Transfers the retained table back and closes the session. */
39
+ takeTable(): Promise<Table>;
40
+ /** Drains pending operations and releases the worker. */
41
+ close(): Promise<void>;
42
+ };
43
+
44
+ /** Runs one query in a worker and releases it when the query settles. */
45
+ export async function queryArrowTableInWorker(
46
+ source: Table,
47
+ options: ArrowQueryOptions,
48
+ workerOptions: ArrowQueryWorkerOptions
49
+ ): Promise<Table> {
50
+ const session = await createArrowQueryWorker(source, {
51
+ ...workerOptions,
52
+ signal: options.signal ?? workerOptions.signal
53
+ });
54
+ try {
55
+ return await session.query(options);
56
+ } finally {
57
+ await session.close();
58
+ }
59
+ }
60
+
61
+ /** Opens a worker session and sends the source table once. */
62
+ export async function createArrowQueryWorker(
63
+ source: Table,
64
+ {worker, inputOwnership, signal}: ArrowQueryWorkerOptions
65
+ ): Promise<ArrowQueryWorkerSession> {
66
+ signal?.throwIfAborted();
67
+ const runner = new TaskRunner();
68
+ try {
69
+ const task = await runner.initializeTask(
70
+ createArrowQueryTask({...worker, capabilities: {atomic: true, streaming: false}}),
71
+ {table: serializeNativeArrowWorkerResult(source, {copy: 'none'})},
72
+ {execution: 'worker', inputOwnership, signal}
73
+ );
74
+ let closing = false;
75
+ /** Rejects operations submitted after session shutdown has started. */
76
+ function assertOpen(): void {
77
+ if (closing) throw new Error('Arrow query worker session is closed');
78
+ }
79
+ return {
80
+ async query({signal: querySignal, tables, ...options} = {}) {
81
+ assertOpen();
82
+ querySignal?.throwIfAborted();
83
+ const childTables =
84
+ tables &&
85
+ Object.entries(tables).map(([name, table]): [string, unknown] => [
86
+ name,
87
+ serializeNativeArrowWorkerResult(table, {copy: 'none'})
88
+ ]);
89
+ const result = await task.runTask(
90
+ {operation: 'query', options, tables: childTables},
91
+ {signal: querySignal}
92
+ );
93
+ return deserializeArrowWorkerTable(result.table);
94
+ },
95
+ async getTable() {
96
+ assertOpen();
97
+ const result = await task.runTask({operation: 'get'});
98
+ return deserializeArrowWorkerTable(result.table);
99
+ },
100
+ async takeTable() {
101
+ assertOpen();
102
+ closing = true;
103
+ try {
104
+ const result = await task.runTask({operation: 'take'});
105
+ return deserializeArrowWorkerTable(result.table);
106
+ } finally {
107
+ await runner.close();
108
+ }
109
+ },
110
+ close() {
111
+ closing = true;
112
+ return runner.close();
113
+ }
114
+ };
115
+ } catch (error) {
116
+ await runner.close();
117
+ throw error;
118
+ }
119
+ }
120
+
121
+ /** Defines the shared host and worker task for the Arrow query engine. */
122
+ export function createArrowQueryTask(worker?: TaskWorker): Task<{
123
+ initialization: {table: unknown};
124
+ input: QueryInput;
125
+ output: {table: unknown};
126
+ state: Table;
127
+ }> {
128
+ return {
129
+ id: 'loaders.gl-arrow-query',
130
+ worker,
131
+ initialize: ({table}) => deserializeArrowWorkerTable(table),
132
+ process(input, _options, {state, signal}) {
133
+ let result = state;
134
+ if (input.operation === 'query') {
135
+ const tables =
136
+ input.tables &&
137
+ Object.fromEntries(
138
+ input.tables.map(([name, table]) => [name, deserializeArrowWorkerTable(table)])
139
+ );
140
+ result = queryArrowTable(state, {...input.options, tables, signal});
141
+ }
142
+ return {
143
+ // Query results can alias the retained source, including through slices and dictionaries.
144
+ table:
145
+ input.operation === 'take'
146
+ ? serializeNativeArrowWorkerResult(result, {copy: 'none'})
147
+ : serializeNativeArrowWorkerResult(result)
148
+ };
149
+ }
150
+ };
151
+ }
152
+
153
+ /** Hydrates a table from the query worker protocol. */
154
+ function deserializeArrowWorkerTable(value: unknown): Table {
155
+ const result = deserializeNativeArrowWorkerResult(value);
156
+ if (!isArrowTable(result)) throw new Error('Arrow query workers require an Arrow table');
157
+ return result;
158
+ }
@@ -6,7 +6,6 @@ import * as arrow from 'apache-arrow';
6
6
  import {
7
7
  createScanQueryMetadata,
8
8
  emitQueryComplete,
9
- makeTableScanBatch,
10
9
  explainTableQuery,
11
10
  getColumnarPredicateColumns,
12
11
  planTableQuery,
@@ -221,7 +220,8 @@ export class FederatedTableScanSource
221
220
  description: this.description,
222
221
  schema: plan.schema,
223
222
  capabilities: {table: FEDERATED_TABLE_QUERY_CAPABILITIES},
224
- statistics: getFederatedStatistics(plan.sources)
223
+ statistics: getFederatedStatistics(plan.sources),
224
+ hasDefaultRowWindow: plan.sources.some(({metadata}) => metadata.hasDefaultRowWindow)
225
225
  });
226
226
  } finally {
227
227
  this.dataSourceManager.unsubscribe({consumerId});
@@ -321,28 +321,25 @@ export class FederatedTableScanSource
321
321
  let sourceBatchIndex = 0;
322
322
  try {
323
323
  for await (const input of resolvedSource.source.read(sourceReadOptions)) {
324
- const batch =
325
- 'shape' in input
326
- ? input
327
- : makeTableScanBatch({
328
- shape: 'arrow-table',
329
- data: new arrow.Table(input.schema, [input])
330
- });
324
+ const native = !('shape' in input);
325
+ const batchLength = native ? input.numRows : input.length;
331
326
  throwIfAborted(options.signal);
332
327
  if (remaining <= 0) {
333
328
  telemetry.earlyTerminationReason = 'limit';
334
329
  return;
335
330
  }
336
331
  if (sourceRemaining <= 0) break;
337
- if (batch.batchType !== 'data') continue;
332
+ if (!native && input.batchType !== 'data') continue;
338
333
  telemetry.batchesRead++;
339
- telemetry.rowsRead += batch.length;
334
+ telemetry.rowsRead += batchLength;
340
335
  sourceBatchesDecoded++;
341
- sourceRowsRead += batch.length;
342
- if (batch.length <= 0) continue;
343
- const physicalTable = convertTableToArrow(
344
- batch.schema ? batch : {...batch, schema: resolvedSource.metadata.schema}
345
- );
336
+ sourceRowsRead += batchLength;
337
+ if (batchLength <= 0) continue;
338
+ const physicalTable = native
339
+ ? new arrow.Table(input.schema, [input])
340
+ : convertTableToArrow(
341
+ input.schema ? input : {...input, schema: resolvedSource.metadata.schema}
342
+ );
346
343
  const sourceResult = queryArrowTable(physicalTable, {
347
344
  predicate: sourceResidualPredicate,
348
345
  limit: Number.isFinite(sourceRemaining) ? sourceRemaining : undefined,
@@ -376,13 +373,13 @@ export class FederatedTableScanSource
376
373
  sourceId: resolvedSource.entry.dataSourceId,
377
374
  sourceIndex: resolvedSource.sourceIndex,
378
375
  sourceBatchIndex: currentSourceBatchIndex,
379
- sourceMetadata: 'shape' in input ? batch.metadata : Object.fromEntries(input.metadata)
376
+ sourceMetadata: native ? Object.fromEntries(input.metadata) : input.metadata
380
377
  });
381
378
  telemetry.rowsReturned += resultLength;
382
379
  sourceRowsReturned += resultLength;
383
380
  for (const recordBatch of result.batches) {
384
381
  const metadata = new Map(
385
- resultLength === batch.length && !('shape' in input) ? input.metadata : undefined
382
+ native && resultLength === batchLength ? input.metadata : undefined
386
383
  );
387
384
  metadata.set('loaders.gl.federation', JSON.stringify(provenance));
388
385
  yield new arrow.RecordBatch(recordBatch.schema, recordBatch.data, metadata);
package/src/scan/index.ts CHANGED
@@ -8,7 +8,6 @@ export {createScanEngine, registerScanBackend} from './scan-engine';
8
8
  export {
9
9
  executeTableScanBatches,
10
10
  filterTableBatch,
11
- makeTableScanBatch,
12
11
  projectTableBatch,
13
12
  projectTableSchema,
14
13
  truncateTableBatch
@@ -164,3 +163,10 @@ export type {
164
163
  TableQueryCapabilities,
165
164
  QueryPushdownCapabilityHints
166
165
  } from '@loaders.gl/core/loader-utils';
166
+
167
+ export {
168
+ createArrowQueryWorker,
169
+ queryArrowTableInWorker,
170
+ type ArrowQueryWorkerOptions,
171
+ type ArrowQueryWorkerSession
172
+ } from './arrow-query-worker';
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {parseSQLPredicate as parseMathSQLPredicate} from '@math.gl/expressions/sql';
5
+ import {parseSQLPredicate as parseMathSQLPredicate} from '@math.gl/sql/parser';
6
6
  import {validateSQLPredicate} from './sql-predicate-schema';
7
7
  import type {
8
8
  BoundSQLPredicate,
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Table, util, type Schema} from 'apache-arrow';
6
- import type {SQLQuery} from '@math.gl/expressions/sql';
6
+ import type {SQLQuery} from '@math.gl/sql/parser';
7
7
  import {convertArrowToSchema, convertSchemaToArrow} from '@loaders.gl/core/schema-utils';
8
8
  import type {
9
9
  TableQueryCapabilities,
@@ -57,19 +57,19 @@ function validatePushdownPlan(
57
57
  let rowsReturned = 0;
58
58
  for await (const batch of plan.read(options)) {
59
59
  options.signal?.throwIfAborted();
60
- const native = !('shape' in batch);
61
- const schema = native ? batch.schema : batch.data.schema;
62
- const rowCount = native ? batch.numRows : batch.data.numRows;
63
60
  if (
64
- !util.compareSchemas(outputSchema, convertSchemaToArrow(convertArrowToSchema(schema)))
61
+ !util.compareSchemas(
62
+ outputSchema,
63
+ convertSchemaToArrow(convertArrowToSchema(batch.schema))
64
+ )
65
65
  ) {
66
66
  throw new Error('Query pushdown batch schema does not match the logical output schema.');
67
67
  }
68
- rowsReturned += rowCount;
68
+ rowsReturned += batch.numRows;
69
69
  if (limit !== undefined && rowsReturned > limit) {
70
70
  throw new Error('Query pushdown returned more rows than the requested limit.');
71
71
  }
72
- yield native ? batch : {...batch, length: rowCount};
72
+ yield batch;
73
73
  }
74
74
  }
75
75
  };
@@ -0,0 +1,199 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Table, type RecordBatch, type Vector} from 'apache-arrow';
6
+ import {
7
+ compileArrowScale,
8
+ compileArrowScales,
9
+ createStreamingDomainAccumulator,
10
+ type CompiledArrowScale
11
+ } from '@math.gl/sql/arrow-scales';
12
+ import {
13
+ parseSQLScaleExpression,
14
+ type ParsedSQLScale,
15
+ type ResolvedScale
16
+ } from '@math.gl/sql/scales';
17
+ import {makeArrowTableFromBatches} from '@loaders.gl/core/schema-utils';
18
+ import {query, queryInBatches, type Query, type QueryOptions} from './query';
19
+
20
+ /** Named row-preserving scale expressions applied to an input query result. */
21
+ export type ScaleProjections<Name extends string = string> = Readonly<
22
+ Record<Name, string | ParsedSQLScale>
23
+ >;
24
+
25
+ /** Filtered input rows and scale outputs in the same row order. */
26
+ export type ScaleQueryResult<Name extends string = string> = Readonly<{
27
+ /** Input rows after applying the table query, including any filter and row window. */
28
+ table: Table;
29
+ /** Arrow vectors keyed by scale projection name. */
30
+ columns: Readonly<Record<Name, Vector>>;
31
+ /** Scale evaluators and serializable descriptors shared with legend consumers. */
32
+ scales: Readonly<Record<Name, ResolvedScale>>;
33
+ }>;
34
+
35
+ /** Resolves data-derived domains jointly, then evaluates each scale over the same rows. */
36
+ export async function queryScales<Name extends string>(
37
+ input: Query | string,
38
+ projections: ScaleProjections<Name>,
39
+ options: QueryOptions
40
+ ): Promise<ScaleQueryResult<Name>> {
41
+ options.signal?.throwIfAborted();
42
+ const parsed = parseScaleProjections(projections);
43
+ const table = await query(input, options);
44
+ options.signal?.throwIfAborted();
45
+ return evaluateScaleProjections(table, compileArrowScales(table, parsed), options.signal);
46
+ }
47
+
48
+ /** Evaluates pre-bound scales and exposes their authoritative descriptors. */
49
+ function evaluateScaleProjections<Name extends string>(
50
+ table: Table,
51
+ compiled: Record<Name, CompiledArrowScale>,
52
+ signal?: AbortSignal
53
+ ): ScaleQueryResult<Name> {
54
+ const names = Object.keys(compiled) as Name[];
55
+ const columns = {} as Record<Name, Vector>;
56
+ const scales = {} as Record<Name, ResolvedScale>;
57
+ for (const name of names) {
58
+ signal?.throwIfAborted();
59
+ const scale = compiled[name];
60
+ Object.defineProperty(columns, name, {value: scale.evaluate(table), enumerable: true});
61
+ Object.defineProperty(scales, name, {value: scale.scale, enumerable: true});
62
+ }
63
+ return {table, columns, scales};
64
+ }
65
+
66
+ /** Parses scale expressions before starting a read and preserves projection names. */
67
+ function parseScaleProjections<Name extends string>(
68
+ projections: ScaleProjections<Name>
69
+ ): Record<Name, ParsedSQLScale> {
70
+ return Object.fromEntries(
71
+ Object.entries<string | ParsedSQLScale>(projections).map(([name, expression]) => [
72
+ name,
73
+ typeof expression === 'string' ? parseSQLScaleExpression(expression) : expression
74
+ ])
75
+ ) as Record<Name, ParsedSQLScale>;
76
+ }
77
+
78
+ /** Emits append-only scale projections using caller-supplied fixed domains. */
79
+ export async function* queryScalesInBatches<Name extends string>(
80
+ input: Query | string,
81
+ projections: ScaleProjections<Name>,
82
+ options: QueryOptions
83
+ ): AsyncIterable<ScaleQueryResult<Name>> {
84
+ options.signal?.throwIfAborted();
85
+ const parsed = parseScaleProjections(projections);
86
+ if (Object.values<ParsedSQLScale>(parsed).some(({scale}) => scale.domain.type !== 'fixed')) {
87
+ throw new Error('Append-only scale projections require fixed domains.');
88
+ }
89
+ /** Scales compiled once, using the schema from the first batch. */
90
+ let compiled: Record<Name, CompiledArrowScale> | undefined;
91
+ for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {
92
+ options.signal?.throwIfAborted();
93
+ compiled ??= compileArrowScales(new Table(batch.schema), parsed);
94
+ yield evaluateScaleProjections(new Table(batch.schema, [batch]), compiled, options.signal);
95
+ }
96
+ }
97
+
98
+ /** Controls the cadence and retained row count of complete scale snapshots. */
99
+ export type ProgressiveScaleQueryOptions = QueryOptions &
100
+ Readonly<{
101
+ /** Emit a provisional snapshot after this many nonempty batches. Defaults to 16. */
102
+ emitEveryBatches?: number;
103
+ /** Maximum retained input rows for recoloring. Defaults to 100,000. */
104
+ maxRetainedRows?: number;
105
+ /** Retained samples per percentile column in the upstream quantile sketch. */
106
+ quantileCapacity?: number;
107
+ }>;
108
+
109
+ /** Complete scale outputs that replace the previous snapshot. */
110
+ export type ProgressiveScaleSnapshot<Name extends string = string> = ScaleQueryResult<Name> &
111
+ Readonly<{
112
+ /** Whether the source finished and the resolved domains are final. */
113
+ final: boolean;
114
+ }>;
115
+
116
+ /** Resolves progressive domains from one source pass and recolors retained rows on publication. */
117
+ export async function* queryScalesProgressive<Name extends string>(
118
+ input: Query | string,
119
+ projections: ScaleProjections<Name>,
120
+ options: ProgressiveScaleQueryOptions
121
+ ): AsyncIterable<ProgressiveScaleSnapshot<Name>> {
122
+ const {emitEveryBatches = 16, maxRetainedRows = 100_000, quantileCapacity, signal} = options;
123
+ signal?.throwIfAborted();
124
+ if (
125
+ !Number.isSafeInteger(emitEveryBatches) ||
126
+ emitEveryBatches < 1 ||
127
+ !Number.isSafeInteger(maxRetainedRows) ||
128
+ maxRetainedRows < 1
129
+ ) {
130
+ throw new Error('Scale snapshot interval and row limit must be positive integers.');
131
+ }
132
+ const parsed = parseScaleProjections(projections);
133
+ const entries = Object.entries<ParsedSQLScale>(parsed) as [Name, ParsedSQLScale][];
134
+ if (entries.some(([, {scale}]) => scale.type === 'quantile')) {
135
+ throw new Error('Progressive quantile classification requires a resolved Arrow scale binder.');
136
+ }
137
+ const accumulator = createStreamingDomainAccumulator(
138
+ entries.map(([, {scale}]) => scale.domain),
139
+ {quantileCapacity}
140
+ );
141
+ const batches: RecordBatch[] = [];
142
+ let retainedRows = 0;
143
+ let batchesSinceEmission = 0;
144
+ let last: ScaleQueryResult<Name> | undefined;
145
+
146
+ /** Binds the current statistics and evaluates the selected snapshot. */
147
+ async function snapshot(final = false): Promise<ScaleQueryResult<Name> | undefined> {
148
+ const domains = accumulator.result();
149
+ if (domains.some(domain => domain.length === 0)) return undefined;
150
+ // math.gl beta.11 cannot bind repeated quantize breaks. Defer publication
151
+ // until the extent grows, while still surfacing final domain errors.
152
+ if (
153
+ !final &&
154
+ entries.some(
155
+ ([, {scale}], index) =>
156
+ scale.type === 'quantize' &&
157
+ scale.range.type === 'palette' &&
158
+ (scale.range.count ?? 0) > 2 &&
159
+ domains[index][0] === domains[index][1]
160
+ )
161
+ )
162
+ return undefined;
163
+
164
+ const table = await makeArrowTableFromBatches(batches);
165
+ signal?.throwIfAborted();
166
+ if (!table) return undefined;
167
+ const schemaOnly = new Table(table.schema);
168
+ const compiled = Object.fromEntries(
169
+ entries.map(([name, expression], index) => [
170
+ name,
171
+ compileArrowScale(schemaOnly, expression, domains[index])
172
+ ])
173
+ ) as Record<Name, CompiledArrowScale>;
174
+ return evaluateScaleProjections(table, compiled, signal);
175
+ }
176
+
177
+ for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {
178
+ signal?.throwIfAborted();
179
+ retainedRows += batch.numRows;
180
+ if (retainedRows > maxRetainedRows) {
181
+ throw new Error(
182
+ `Progressive scale query exceeded its retained row limit (${maxRetainedRows}).`
183
+ );
184
+ }
185
+ batches.push(batch);
186
+ if (batch.numRows === 0) continue;
187
+ accumulator.update(batch);
188
+ if (++batchesSinceEmission < emitEveryBatches) continue;
189
+ last = await snapshot();
190
+ if (last) {
191
+ batchesSinceEmission = 0;
192
+ yield {...last, final: false};
193
+ }
194
+ }
195
+ signal?.throwIfAborted();
196
+ const final = last && batchesSinceEmission === 0 ? last : await snapshot(true);
197
+ if (!final) throw new Error('Progressive scale query could not resolve its domain.');
198
+ yield {...final, final: true};
199
+ }