@@ -175,10 +175,19 @@ typedef enum {
175175} vx_validity_type ;
176176
177177typedef enum {
178- VX_CARD_UNKNOWN = 0 ,
179- VX_CARD_ESTIMATE = 1 ,
180- VX_CARD_MAXIMUM = 2 ,
181- } vx_cardinality ;
178+ /**
179+ * No estimate is available.
180+ */
181+ VX_ESTIMATE_UNKNOWN = 0 ,
182+ /**
183+ * The value in vx_estimate.estimate is exact.
184+ */
185+ VX_ESTIMATE_EXACT = 1 ,
186+ /**
187+ * The value in vx_estimate.estimate is an upper bound.
188+ */
189+ VX_ESTIMATE_INEXACT = 2 ,
190+ } vx_estimate_type ;
182191
183192/**
184193 * Equalities, inequalities, and boolean operations over possibly null values.
@@ -282,21 +291,6 @@ typedef enum {
282291 VX_SELECTION_EXCLUDE_RANGE = 2 ,
283292} vx_scan_selection_include ;
284293
285- typedef enum {
286- /**
287- * No estimate is available.
288- */
289- VX_ESTIMATE_UNKNOWN = 0 ,
290- /**
291- * The value in vx_estimate.estimate is exact.
292- */
293- VX_ESTIMATE_EXACT = 1 ,
294- /**
295- * The value in vx_estimate.estimate is an upper bound.
296- */
297- VX_ESTIMATE_INEXACT = 2 ,
298- } vx_estimate_type ;
299-
300294/**
301295 * Physical type enum, represents the in-memory physical layout but might represent a different logical type.
302296 */
@@ -490,6 +484,10 @@ typedef struct vx_file vx_file;
490484 */
491485typedef struct vx_partition vx_partition ;
492486
487+ /**
488+ * A scan is a single traversal of a data source with projections and
489+ * filters. A scan can be consumed only once.
490+ */
493491typedef struct vx_scan vx_scan ;
494492
495493/**
@@ -537,13 +535,17 @@ typedef struct {
537535 const char * paths ;
538536} vx_data_source_options ;
539537
538+ /**
539+ * Used for estimating number of partitions in a data source or number of rows
540+ * in a partition.
541+ */
540542typedef struct {
541- vx_cardinality cardinality ;
543+ vx_estimate_type type ;
542544 /**
543- * Set only when "cardinality " is not VX_CARD_UNKNOWN
545+ * Set only when "type " is not VX_ESTIMATE_UNKNOWN.
544546 */
545- uint64_t rows ;
546- } vx_data_source_row_count ;
547+ uint64_t estimate ;
548+ } vx_estimate ;
547549
548550/**
549551 * Options supplied for opening a file.
@@ -662,18 +664,6 @@ typedef struct {
662664 bool ordered ;
663665} vx_scan_options ;
664666
665- /**
666- * Used for estimating number of partitions in a data source or number of rows
667- * in a partition.
668- */
669- typedef struct {
670- vx_estimate_type type ;
671- /**
672- * Set only when "type" is not VX_ESTIMATE_UNKNOWN.
673- */
674- uint64_t estimate ;
675- } vx_estimate ;
676-
677667#ifdef __cplusplus
678668extern "C" {
679669#endif // __cplusplus
@@ -921,7 +911,7 @@ const vx_dtype *vx_data_source_dtype(const vx_data_source *ds);
921911/**
922912 * Write data source's row count estimate into "row_count".
923913 */
924- void vx_data_source_get_row_count (const vx_data_source * ds , vx_data_source_row_count * row_count );
914+ void vx_data_source_get_row_count (const vx_data_source * ds , vx_estimate * row_count );
925915
926916/**
927917 * Clone a borrowed [`vx_dtype`], returning an owned [`vx_dtype`].
@@ -1319,6 +1309,17 @@ vx_partition *vx_scan_next_partition(vx_scan *scan, vx_error **err);
13191309 */
13201310int vx_partition_row_count (const vx_partition * partition , vx_estimate * count , vx_error * * err );
13211311
1312+ /**
1313+ * Scan partition to ArrowArrayStream.
1314+ * Consumes partition fully: subsequent calls to vx_partition_scan_arrow or
1315+ * vx_partition_next are undefined behaviour.
1316+ * This call blocks current thread until underlying stream is fully consumed.
1317+ *
1318+ * Caller must not free partition after calling this function.
1319+ *
1320+ * On success, sets "stream" and returns 0.
1321+ * On error, sets "err" and returns 1, freeing the partition.
1322+ */
13221323int vx_partition_scan_arrow (const vx_session * session ,
13231324 vx_partition * partition ,
13241325 FFI_ArrowArrayStream * stream ,
0 commit comments