Created
September 19, 2023 15:07
-
-
Save ianmcook/25bb0c82b8af4fc1bde0768863607355 to your computer and use it in GitHub Desktop.
Standalone test of the Arrow C++ `is_in` kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <arrow/api.h> | |
#include <arrow/compute/api.h> | |
int main(int, char**) { | |
// lookup set | |
std::shared_ptr<arrow::Array> array; | |
arrow::Int32Builder builder; | |
if (!builder.Append(5).ok()) return 1; | |
if (!builder.AppendNull().ok()) return 1; | |
if (!builder.Finish(&array).ok()) return 1; | |
// input value | |
auto value = arrow::Int32Scalar(1); | |
//auto value = arrow::MakeNullScalar(arrow::int32()); | |
// function options | |
arrow::compute::SetLookupOptions options; | |
options.value_set = arrow::Datum(array); | |
//options.skip_nulls = true; | |
options.null_matching_behavior = | |
arrow::compute::SetLookupOptions::NullMatchingBehavior::MATCH; | |
//arrow::compute::SetLookupOptions::NullMatchingBehavior::SKIP; | |
//arrow::compute::SetLookupOptions::NullMatchingBehavior::EMIT_NULL; | |
//arrow::compute::SetLookupOptions::NullMatchingBehavior::INCONCLUSIVE; | |
auto result = arrow::compute::CallFunction("is_in", {value}, &options); | |
std::cout << result.ValueOrDie().scalar()->ToString() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile and run with
clang++ arrow_is_in.cpp -std=c++17 -I/usr/local/include -L/usr/local/lib -larrow -o test_is_in && ./arrow_is_in