Skip to content

Instantly share code, notes, and snippets.

@ianmcook
Created September 19, 2023 15:07
Show Gist options
  • Save ianmcook/25bb0c82b8af4fc1bde0768863607355 to your computer and use it in GitHub Desktop.
Save ianmcook/25bb0c82b8af4fc1bde0768863607355 to your computer and use it in GitHub Desktop.
Standalone test of the Arrow C++ `is_in` kernel
#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;
}
@ianmcook
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment