Skip to content

Commit

Permalink
cpp api and propagations
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbindar committed Oct 23, 2023
1 parent e316393 commit b8fca41
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 41 deletions.
68 changes: 30 additions & 38 deletions test/src/test-cppapi-aggregates.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1390,12 +1390,12 @@ TEMPLATE_LIST_TEST_CASE_METHOD(
CppAggregatesFx<T>::layout_ = layout;
Query query(CppAggregatesFx<T>::ctx_, array, TILEDB_READ);

// TODO: Change to real CPPAPI. Add a mean aggregator to the query.
query.ptr()->query_->add_aggregator_to_default_channel(
"Mean",
std::make_shared<tiledb::sm::MeanAggregator<T>>(
tiledb::sm::FieldInfo(
"a1", false, CppAggregatesFx<T>::nullable_, 1)));
QueryChannel default_channel =
QueryExperimental::get_default_channel(query);
ChannelOperation operation =
QueryExperimental::create_unary_aggregate<MeanOperator>(
query, "a1");
default_channel.apply_aggregate("Mean", operation);

CppAggregatesFx<T>::set_ranges_and_condition_if_needed(
array, query, false);
Expand Down Expand Up @@ -1786,19 +1786,12 @@ TEMPLATE_LIST_TEST_CASE_METHOD(
CppAggregatesFx<T>::layout_ = layout;
Query query(CppAggregatesFx<T>::ctx_, array, TILEDB_READ);

// TODO: Change to real CPPAPI. Add a null count aggregator to the
// query.
uint64_t cell_val_num = std::is_same<T, std::string>::value ?
CppAggregatesFx<T>::STRING_CELL_VAL_NUM :
1;
query.ptr()->query_->add_aggregator_to_default_channel(
"NullCount",
std::make_shared<tiledb::sm::NullCountAggregator>(
tiledb::sm::FieldInfo(
"a1",
false,
CppAggregatesFx<T>::nullable_,
cell_val_num)));
QueryChannel default_channel =
QueryExperimental::get_default_channel(query);
ChannelOperation operation =
QueryExperimental::create_unary_aggregate<NullCountOperator>(
query, "a1");
default_channel.apply_aggregate("NullCount", operation);

CppAggregatesFx<T>::set_ranges_and_condition_if_needed(
array, query, false);
Expand Down Expand Up @@ -1886,13 +1879,12 @@ TEST_CASE_METHOD(
layout_ = layout;
Query query(ctx_, array, TILEDB_READ);

// TODO: Change to real CPPAPI. Add a null count aggregator to the
// query.
query.ptr()->query_->add_aggregator_to_default_channel(
"NullCount",
std::make_shared<tiledb::sm::NullCountAggregator>(
tiledb::sm::FieldInfo(
"a1", true, nullable_, TILEDB_VAR_NUM)));
QueryChannel default_channel =
QueryExperimental::get_default_channel(query);
ChannelOperation operation =
QueryExperimental::create_unary_aggregate<NullCountOperator>(
query, "a1");
default_channel.apply_aggregate("NullCount", operation);

set_ranges_and_condition_if_needed(array, query, true);

Expand Down Expand Up @@ -1982,12 +1974,12 @@ TEST_CASE_METHOD(
layout_ = layout;
Query query(ctx_, array, TILEDB_READ);

// TODO: Change to real CPPAPI. Add a null count aggregator to the
// query.
query.ptr()->query_->add_aggregator_to_default_channel(
"NullCount",
std::make_shared<tiledb::sm::NullCountAggregator>(
tiledb::sm::FieldInfo("a1", true, nullable_, TILEDB_VAR_NUM)));
QueryChannel default_channel =
QueryExperimental::get_default_channel(query);
ChannelOperation operation =
QueryExperimental::create_unary_aggregate<NullCountOperator>(
query, "a1");
default_channel.apply_aggregate("NullCount", operation);

// Add another aggregator on the second attribute. We will make the
// first attribute get a var size overflow, which should not impact the
Expand Down Expand Up @@ -2120,12 +2112,12 @@ TEST_CASE_METHOD(
layout_ = layout;
Query query(ctx_, array, TILEDB_READ);

// TODO: Change to real CPPAPI. Add a null count aggregator to the
// query.
query.ptr()->query_->add_aggregator_to_default_channel(
"NullCount",
std::make_shared<tiledb::sm::NullCountAggregator>(
tiledb::sm::FieldInfo("a1", true, nullable_, TILEDB_VAR_NUM)));
QueryChannel default_channel =
QueryExperimental::get_default_channel(query);
ChannelOperation operation =
QueryExperimental::create_unary_aggregate<NullCountOperator>(
query, "a1");
default_channel.apply_aggregate("NullCount", operation);

// Add another aggregator on the second attribute. We will make this
// attribute get a var size overflow, which should impact the result of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ TEST_CASE_METHOD(
QueryAggregateFx,
"C API: Query aggregates NULL_COUNT test",
"[capi][query_aggregate][null_count]") {
// SECTION("- No serialization") {
// serialize_ = false;
// }
SECTION("- No serialization") {
serialize_ = false;
}
#ifdef TILEDB_SERIALIZATION
SECTION("- Serialization") {
serialize_ = true;
Expand Down
20 changes: 20 additions & 0 deletions tiledb/sm/cpp_api/channel_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ class MaxOperator : public ChannelOperator {
}
};

class MeanOperator : public ChannelOperator {
public:
/* ********************************* */
/* API */
/* ********************************* */
static const tiledb_channel_operator_t* ptr() {
return tiledb_channel_operator_mean;
}
};

class NullCountOperator : public ChannelOperator {
public:
/* ********************************* */
/* API */
/* ********************************* */
static const tiledb_channel_operator_t* ptr() {
return tiledb_channel_operator_null_count;
}
};

} // namespace tiledb

#endif // TILEDB_CPP_API_CHANNEL_OPERATOR_H

0 comments on commit b8fca41

Please sign in to comment.