从 Apache Arrow Parquet CPP 库版本 11.0.0 读取十进制数据类型时出错

Error reading decimal datatype from Apache Arrow Parquet CPP library version 11.0.0

提问人:Anamika Ahmed 提问时间:8/9/2023 最后编辑:Olaf KockAnamika Ahmed 更新时间:8/9/2023 访问量:33

问:

我正在尝试读取一个镶木地板文件并将其存储在自定义 C 结构中,以便在我的 C 代码中进一步使用

case arrow::Type::DECIMAL:
{
    const arrow::Decimal128Type* decimal_type = static_cast<const arrow::Decimal128Type*>(arrow_table_->column(i)->type().get());
    int32_t precision = decimal_type->precision();
    int32_t scale = decimal_type->scale();
    pArrowTableDef->columns[i].array->type = DECIMAL_TYPE;
    pArrowTableDef->columns[i].array->length = pArrowTableDef->num_rows;
    pArrowTableDef->columns[i].array->data = new ArrowDecimal[pArrowTableDef->num_rows];
    for (int row_index = 0; row_index < pArrowTableDef->num_rows; ++row_index) {
        std::shared_ptr<arrow::Decimal128Array> decimal_array = std::static_pointer_cast<arrow::Decimal128Array>(chunked_array->chunk(row_index / chunk_length));
        arrow::Decimal128 value = decimal_array->Value(row_index % chunk_length);
        ArrowDecimal& arrow_decimal = static_cast<ArrowDecimal*>(pArrowTableDef->columns[i].array->data)[row_index];
        arrow_decimal.value = value.low_bits();
        arrow_decimal.precision = precision;
        arrow_decimal.scale = scale;
    }
}

获取错误:** 错误:请求从“const uint8_t* {aka const unsigned char*}”转换为非标量类型“arrow::D ecimal128”**

自定义 C 结构:

typedef struct {
    int64_t value;     // Store the raw integer value of the decimal
    int precision;     // Store the precision of the decimal
    int scale;         // Store the scale of the decimal
} ArrowDecimal;

typedef struct {
    FieldType type;
    void *data;
    int length;
    int precision;
    int scale;
} ArrowArray;
typedef struct {
    char *name;
    ArrowArray *array;
} ArrowColumn;
typedef struct {
    int num_rows;
    int num_cols;
    ArrowColumn *columns;
} ArrowTableDef;

我也尝试使用arrow::Buffer,但没有用

镶木地板 箭头函数 apache-arrow apache-arrow-cpp

评论


答: 暂无答案