Apache Arrow C++ 获取数据:table->column(0)->GetScalar(0).ValueOrDie()->Value<int32_t>() 不编译

问题描述 投票:0回答:0

如何获取表中 GetScalar 的值?。这段代码在几年前可以正常工作,但现在发生了一些变化。有人可以告诉我我做错了什么吗?请看下面的代码:

#include <arrow/api.h>

int main() {
  // create an Arrow array of int32_t values
  std::vector<int32_t> values = {1, 2, 3};
  std::shared_ptr<arrow::Array> array;
  arrow::Int32Builder builder;
  builder.AppendValues(values);
  builder.Finish(&array);

  // create an Arrow table with a single column of int32_t values
  std::shared_ptr<arrow::Field> field = arrow::field("col", arrow::int32());
  std::vector<std::shared_ptr<arrow::Field>> fields = {field};
  std::shared_ptr<arrow::Schema> schema = arrow::schema(fields);
  std::vector<std::shared_ptr<arrow::Array>> columns = {array};
  std::shared_ptr<arrow::Table> table = arrow::Table::Make(schema, columns);

  // get the scalar value of the first element in the column
  int32_t value = table->column(0)->GetScalar(0).ValueOrDie()->Value<int32_t>();
  std::cout << "Value: " << value << std::endl;

  return 0;
}
c++ apache
© www.soinside.com 2019 - 2024. All rights reserved.