Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/src/arrow/compute/api_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <vector>

#include "arrow/compute/exec.h"
#include "arrow/compute/kernels/vector_selection_internal.h"
#include "arrow/datum.h"
#include "arrow/record_batch.h"
#include "arrow/result.h"
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/arrow/compute/api_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ Result<Datum> Filter(const Datum& values, const Datum& filter,
ExecContext* ctx = NULLPTR);

struct ARROW_EXPORT TakeOptions : public FunctionOptions {
static TakeOptions Defaults() { return TakeOptions{}; }
explicit TakeOptions(bool boundscheck = true) : boundscheck(boundscheck) {}

bool boundscheck = true;
static TakeOptions Boundscheck() { return TakeOptions(true); }
static TakeOptions NoBoundscheck() { return TakeOptions(false); }
static TakeOptions Defaults() { return Boundscheck(); }
};

/// \brief Take from an array of values at indices in another array
Expand Down
15 changes: 10 additions & 5 deletions cpp/src/arrow/compute/benchmark_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ void BenchmarkSetArgsWithSizes(benchmark::internal::Benchmark* bench,
const std::vector<int64_t>& sizes = kMemorySizes) {
bench->Unit(benchmark::kMicrosecond);

// 0 is treated as "no nulls"
for (const auto size : sizes) {
for (const auto inverse_null_proportion :
std::vector<ArgsType>({10000, 100, 10, 2, 1})) {
std::vector<ArgsType>({10000, 100, 50, 10, 2, 1, 0})) {
bench->Args({static_cast<ArgsType>(size), inverse_null_proportion});
}
}
Expand All @@ -80,12 +81,16 @@ struct RegressionArgs {
const int64_t size;

// proportion of nulls in generated arrays
const double null_proportion;
double null_proportion;

explicit RegressionArgs(benchmark::State& state)
: size(state.range(0)),
null_proportion(std::min(1., 1. / static_cast<double>(state.range(1)))),
state_(state) {}
: size(state.range(0)), null_proportion(), state_(state) {
if (state.range(1) == 0) {
this->null_proportion = 0.0;
} else {
this->null_proportion = std::min(1., 1. / static_cast<double>(state.range(1)));
}
}

~RegressionArgs() {
state_.counters["size"] = static_cast<double>(size);
Expand Down
82 changes: 81 additions & 1 deletion cpp/src/arrow/compute/kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "arrow/compute/exec.h"
#include "arrow/compute/util_internal.h"
#include "arrow/result.h"
#include "arrow/type_traits.h"
#include "arrow/util/bit_util.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/hash_util.h"
Expand Down Expand Up @@ -96,7 +97,6 @@ class SameTypeIdMatcher : public TypeMatcher {
if (this == &other) {
return true;
}

auto casted = dynamic_cast<const SameTypeIdMatcher*>(&other);
if (casted == nullptr) {
return false;
Expand Down Expand Up @@ -150,6 +150,86 @@ std::shared_ptr<TypeMatcher> TimestampUnit(TimeUnit::type unit) {
return std::make_shared<TimestampUnitMatcher>(unit);
}

class IntegerMatcher : public TypeMatcher {
public:
IntegerMatcher() {}

bool Matches(const DataType& type) const override { return is_integer(type.id()); }

bool Equals(const TypeMatcher& other) const override {
if (this == &other) {
return true;
}
auto casted = dynamic_cast<const IntegerMatcher*>(&other);
return casted != nullptr;
}

std::string ToString() const override { return "integer"; }
};

std::shared_ptr<TypeMatcher> Integer() { return std::make_shared<IntegerMatcher>(); }

class PrimitiveMatcher : public TypeMatcher {
public:
PrimitiveMatcher() {}

bool Matches(const DataType& type) const override { return is_primitive(type.id()); }

bool Equals(const TypeMatcher& other) const override {
if (this == &other) {
return true;
}
auto casted = dynamic_cast<const PrimitiveMatcher*>(&other);
return casted != nullptr;
}

std::string ToString() const override { return "primitive"; }
};

std::shared_ptr<TypeMatcher> Primitive() { return std::make_shared<PrimitiveMatcher>(); }

class BinaryLikeMatcher : public TypeMatcher {
public:
BinaryLikeMatcher() {}

bool Matches(const DataType& type) const override { return is_binary_like(type.id()); }

bool Equals(const TypeMatcher& other) const override {
if (this == &other) {
return true;
}
auto casted = dynamic_cast<const BinaryLikeMatcher*>(&other);
return casted != nullptr;
}
std::string ToString() const override { return "binary-like"; }
};

std::shared_ptr<TypeMatcher> BinaryLike() {
return std::make_shared<BinaryLikeMatcher>();
}

class LargeBinaryLikeMatcher : public TypeMatcher {
public:
LargeBinaryLikeMatcher() {}

bool Matches(const DataType& type) const override {
return is_large_binary_like(type.id());
}

bool Equals(const TypeMatcher& other) const override {
if (this == &other) {
return true;
}
auto casted = dynamic_cast<const LargeBinaryLikeMatcher*>(&other);
return casted != nullptr;
}
std::string ToString() const override { return "large-binary-like"; }
};

std::shared_ptr<TypeMatcher> LargeBinaryLike() {
return std::make_shared<LargeBinaryLikeMatcher>();
}

} // namespace match

// ----------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions cpp/src/arrow/compute/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ ARROW_EXPORT std::shared_ptr<TypeMatcher> SameTypeId(Type::type type_id);
/// zones can be different.
ARROW_EXPORT std::shared_ptr<TypeMatcher> TimestampUnit(TimeUnit::type unit);

// \brief Match any integer type
ARROW_EXPORT std::shared_ptr<TypeMatcher> Integer();

// Match types using 32-bit varbinary representation
ARROW_EXPORT std::shared_ptr<TypeMatcher> BinaryLike();

// Match types using 64-bit varbinary representation
ARROW_EXPORT std::shared_ptr<TypeMatcher> LargeBinaryLike();

// \brief Match any primitive type (boolean or any type representable as a C
// Type)
ARROW_EXPORT std::shared_ptr<TypeMatcher> Primitive();

} // namespace match

/// \brief An object used for type- and shape-checking arguments to be passed
Expand Down
Loading