template <typename ArrayType>
arrow::Status WriteValue(uint8_t* buffer_address, int64_t field_offset,
const std::shared_ptr<ArrayType>& array, int32_t col_index,
int64_t num_rows, std::vector<int64_t>& offsets,
std::vector<int16_t>& type_bytes,
std::vector<int64_t>& buffer_cursor) {
...
// default Numeric type
auto numeric_array = std::static_pointer_cast<ArrayType>(array);
for (auto i = 0; i < num_rows; i++) {
bool is_null = array->IsNull(i);
if (is_null) {
SetNullAt(buffer_address, offsets[i], field_offset, col_index);
} else {
type_bytes.at(array->type_id());
auto value = numeric_array->Value(i);
memcpy(buffer_address + offsets[i] + field_offset, &value, type_bytes.at(array->type_id()));
}
}
...
}
arrow::Status ColumnarToRowConverter::Write() {
for (auto i = 0; i < num_cols_; i++) {
auto array = rb_->column(i);
int64_t field_offset = GetFieldOffset(nullBitsetWidthInBytes_, i);
WriteValue(buffer_address_, field_offset, array, i, num_rows_, offsets_, type_bytes_,
buffer_cursor_);
}
return arrow::Status::OK();
}
/home/shen/benchmark/Gazelle_plugin_benchmark/native-sql-engine/cpp/src/operators/columnar_to_row_converter.cc:736:39: error: ‘using element_type = class arrow::Array {aka class arrow::Array}’ has no member named ‘Value’
auto value = numeric_array->Value(i);
~~~~~~~~~~~~~~~^~~~~
make[2]: *** [src/CMakeFiles/spark_columnar_jni.dir/operators/columnar_to_row_converter.cc.o] Error 1
make[1]: *** [src/CMakeFiles/spark_columnar_jni.dir/all] Error 2
make: *** [all] Error 2
实例
#include <iostream>
using namespace std;
template <typename T1, typename T2>
T1 shiftleft(T1 a, T2 b)
{
return a << b;
}
int main()
{
cout << "Hello World!\n";
int a =2;
long b = 33;
int c = shiftleft<int, long>(2, 33);
std::cout << "c:" << c << std::endl;
return 0;
}