Skip to content

Commit

Permalink
Modify C++ API Query::est_result_size_var
Browse files Browse the repository at this point in the history
This changes the return type and return values for `Query::est_result_size_var`.

Currently, the size estimate for the values are returned in bytes while the size
estimate for the offsets are returned in elements. For consistency, this API
now returns both the size estimates as bytes. This is breaking behavior.

To make the breaking behavior more obvious, we have modified the return type
from an `std::pair` to an `std::array`.

We chose to make both of these size estimates return as bytes rather than
elements to stay consistent with the existing `Query::est_result_size` for
fixed-size attributes.
  • Loading branch information
Joe Maley committed Dec 7, 2020
1 parent e7a1287 commit 8604b82
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Breaking behavior

* The tile extent can now be set to null, in which case internally TileDB sets the extent to the dimension domain range. [#1880](https://github.com/TileDB-Inc/TileDB/pull/1880)
* The C++ API `std::pair<uint64_t, uint64_t> Query::est_result_size_var` has been changed to 1) a return type of `std::array<uint64_t, 2>` and 2) returns the offsets as a size in bytes rather than elements. [#1946](https://github.com/TileDB-Inc/TileDB/pull/1946)

## New features

Expand Down Expand Up @@ -54,6 +55,7 @@
* Added class `FragmentInfo` and functions for getting fragment information. [#1900](https://github.com/TileDB-Inc/TileDB/pull/1900)
* Added function `Dimension::create` that allows not setting a space tile extent. [#1880](https://github.com/TileDB-Inc/TileDB/pull/1880)
* Added APIs for getting and setting ranges of queries using a dimension name. [#1920](https://github.com/TileDB-Inc/TileDB/pull/1920)
* Changed `std::pair<uint64_t, uint64_t> Query::est_result_size_var` to `std::array<uint64_t, 2> Query::est_result_size_var`. Additionally, the size estimate for the offsets have been changed from elements to bytes. [#1946](https://github.com/TileDB-Inc/TileDB/pull/1946)

# TileDB v2.1.0 Release Notes

Expand Down
24 changes: 12 additions & 12 deletions test/src/unit-cppapi-fill_values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 10 * sizeof(int32_t));
CHECK(est_a1 == 10 * sizeof(int32_t));
CHECK(est_a2.first == 10);
CHECK(est_a2.second == 10 * sizeof(char));
CHECK(est_a2[0] == 80);
CHECK(est_a2[1] == 10 * sizeof(char));
CHECK(est_a3 == 10 * 2 * sizeof(double));
}

Expand All @@ -561,8 +561,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 10 * sizeof(int32_t));
CHECK(est_a1 == 10 * sizeof(int32_t));
CHECK(est_a2.first == 10);
CHECK(est_a2.second == 10 * 3 * sizeof(char));
CHECK(est_a2[0] == 80);
CHECK(est_a2[1] == 10 * 3 * sizeof(char));
CHECK(est_a3 == 10 * 2 * sizeof(double));
}

Expand All @@ -579,8 +579,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 4 * sizeof(int32_t));
CHECK(est_a1 == 4 * sizeof(int32_t));
CHECK(est_a2.first == 4);
CHECK(est_a2.second == 4 * sizeof(char));
CHECK(est_a2[0] == 32);
CHECK(est_a2[1] == 4 * sizeof(char));
CHECK(est_a3 == 4 * 2 * sizeof(double));
}

Expand Down Expand Up @@ -610,8 +610,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 10 * sizeof(int32_t));
CHECK(est_a1 == 10 * sizeof(int32_t));
CHECK(est_a2.first == 10);
CHECK(est_a2.second == 10 * sizeof(char));
CHECK(est_a2[0] == 80);
CHECK(est_a2[1] == 10 * sizeof(char));
CHECK(est_a3 == 10 * 2 * sizeof(double));
}

Expand All @@ -628,8 +628,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 10 * sizeof(int32_t));
CHECK(est_a1 == 10 * sizeof(int32_t));
CHECK(est_a2.first == 10);
CHECK(est_a2.second == 10 * 3 * sizeof(char));
CHECK(est_a2[0] == 80);
CHECK(est_a2[1] == 10 * 3 * sizeof(char));
CHECK(est_a3 == 10 * 2 * sizeof(double));
}

Expand All @@ -647,8 +647,8 @@ TEST_CASE(
auto est_d = query.est_result_size("d");
CHECK(est_d == 4 * sizeof(int32_t));
CHECK(est_a1 == 4 * sizeof(int32_t));
CHECK(est_a2.first == 4);
CHECK(est_a2.second == 4 * sizeof(char));
CHECK(est_a2[0] == 32);
CHECK(est_a2[1] == 4 * sizeof(char));
CHECK(est_a3 == 4 * 2 * sizeof(double));
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-cppapi-subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_CASE("C++ API: Test subarray", "[cppapi][sparse][subarray]") {

auto est_size = query.est_result_size("a");
REQUIRE(est_size == 4);
std::pair<uint64_t, uint64_t> est_size_var;
std::array<uint64_t, 2> est_size_var;
CHECK_THROWS(est_size_var = query.est_result_size_var("a"));

std::vector<int> data(est_size);
Expand Down
12 changes: 6 additions & 6 deletions tiledb/sm/cpp_api/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,16 @@ class Query {
* **Example:**
*
* @code{.cpp}
* std::pair<uint64_t, uint64_t> est_size =
* std::array<uint64_t, 2> est_size =
* query.est_result_size_var("attr1");
* @endcode
*
* @param attr_name The attribute name.
* @return A pair with first element containing the estimated number of
* result offsets, and second element containing the estimated number of
* result value bytes.
* @return A pair with first element containing the estimated size of
* the result offsets in bytes, and second element containing the
* estimated size of the result values in bytes.
*/
std::pair<uint64_t, uint64_t> est_result_size_var(
std::array<uint64_t, 2> est_result_size_var(
const std::string& attr_name) const {
auto& ctx = ctx_.get();
uint64_t size_off = 0, size_val = 0;
Expand All @@ -872,7 +872,7 @@ class Query {
attr_name.c_str(),
&size_off,
&size_val));
return std::make_pair(size_off / sizeof(uint64_t), size_val);
return {size_off, size_val};
}

/**
Expand Down

0 comments on commit 8604b82

Please sign in to comment.