Skip to content

Commit eb475d2

Browse files
committed
Add carquet_schema_node_type_length() for FIXED_LEN_BYTE_ARRAY support
1 parent 895354d commit eb475d2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/carquet/carquet.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,20 @@ int16_t carquet_schema_node_max_def_level(const carquet_schema_node_t* node);
742742
CARQUET_API CARQUET_PURE CARQUET_NONNULL(1)
743743
int16_t carquet_schema_node_max_rep_level(const carquet_schema_node_t* node);
744744

745+
/**
746+
* @brief Get the type length for a FIXED_LEN_BYTE_ARRAY column.
747+
*
748+
* Returns the fixed byte length of each value. This is needed to allocate
749+
* correctly sized buffers for carquet_column_read_batch().
750+
*
751+
* @param[in] node Schema node (must be a leaf)
752+
* @return Type length in bytes, or 0 if not a FIXED_LEN_BYTE_ARRAY
753+
*
754+
* @note Thread-safe: Yes (read-only)
755+
*/
756+
CARQUET_API CARQUET_PURE CARQUET_NONNULL(1)
757+
int32_t carquet_schema_node_type_length(const carquet_schema_node_t* node);
758+
745759
/* ============================================================================
746760
* Reader API
747761
* ============================================================================

src/metadata/schema.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,9 @@ int16_t carquet_schema_node_max_rep_level(const carquet_schema_node_t* node) {
299299
const parquet_schema_element_t* elem = (const parquet_schema_element_t*)node;
300300
return (elem->repetition_type == CARQUET_REPETITION_REPEATED) ? 1 : 0;
301301
}
302+
303+
int32_t carquet_schema_node_type_length(const carquet_schema_node_t* node) {
304+
/* node is nonnull per API contract */
305+
const parquet_schema_element_t* elem = (const parquet_schema_element_t*)node;
306+
return elem->type_length;
307+
}

0 commit comments

Comments
 (0)