Add support for getting a dtype of ndrectangle.#5229
Conversation
89d6a98 to
d91f05d
Compare
| * @param dim_idx The dimension index. | ||
| * @return The datatype of the range. | ||
| */ | ||
| tiledb_datatype_t range_dtype(unsigned dim_idx) { |
There was a problem hiding this comment.
There are other accessors that double up everything in terms of dimension index and name. Could we have an accessor that uses name too as I wrote the rest of my implementation in terms of the dimension name. (Yes, I know, I could wrap this but while we are at making this complete may as well make it fully complete.)
johnkerl
left a comment
There was a problem hiding this comment.
LGTM, and I second @eddelbuettel 's request for a by-name accessor (either on this PR, or a subsequent PR, makes no difference to me)
There was a problem hiding this comment.
As bonus it wouldn't hurt to drop examples into
examples/c_api/current_domain.c
examples/cpp_api/current_domain.cc
such as (for example in the C++ case)
diff --git a/examples/cpp_api/current_domain.cc b/examples/cpp_api/current_domain.cc
index 0ba8f3373..a1626478b 100644
--- a/examples/cpp_api/current_domain.cc
+++ b/examples/cpp_api/current_domain.cc
@@ -107,6 +107,15 @@ void print_current_domain(Context& ctx) {
// Get the current domain's NDRectangle
NDRectangle ndrect = current_domain.ndrectangle();
+ tiledb_datatype_t dtype = ndrect.range_dtype(0);
+ const char* name;
+ auto st = tiledb_datatype_to_str(dtype, &name);
+ if (st == TILEDB_OK) {
+ std::cout << "Current domain dtype: " << name << std::endl;
+ } else {
+ std::cout << "Could not retrieve dtype name for" << dtype << std::endl;
+ }
+
// Get the range of the rectangle's first dimension
std::array<int32_t, 2> range = ndrect.range<int32_t>("d1");| * @param dim_name The dimension name. | ||
| * @return The datatype of the range. | ||
| */ | ||
| tiledb_datatype_t range_dtype_from_name(const std::string& dim_name) { |
fcc96b4 to
29de8cb
Compare
29de8cb to
6c0b6f5
Compare
teo-tsirpanis
left a comment
There was a problem hiding this comment.
This is very likely sufficient for the C# API, thanks!
The term dtype is nowhere else being used in the C or C++ API, we should better call it just get_type for consistency.
|
I think |
|
Indeed, but function names use TileDB/tiledb/sm/cpp_api/attribute.h Lines 151 to 158 in 523f84f TileDB/tiledb/sm/cpp_api/dimension.h Lines 143 to 150 in 523f84f TileDB/tiledb/sm/cpp_api/domain.h Lines 171 to 178 in 523f84f |
| * @param dim_idx The dimension index. | ||
| * @return The datatype of the range. | ||
| */ | ||
| tiledb_datatype_t range_dtype(unsigned dim_idx) { |
There was a problem hiding this comment.
Should we actually make the C++ APIs public? Are there use cases for them outside of helping with type validation in the range getters and setters? I think those should be better served by an API to get the whole domain.
There was a problem hiding this comment.
@teo-tsirpanis in Slack/Shortcut our discussion was to not expose the entire domain, but rather, subaccessors such as range_dtype and ndim individually.
There was a problem hiding this comment.
You should also update range and set_range to use the new APIs.
@teo-tsirpanis |
|
But $ grep dtype tiledb/sm/cpp_api/*
tiledb/sm/cpp_api/enumeration_experimental.h: tiledb_datatype_t dtype = type.value_or(DataT::tiledb_type);
tiledb/sm/cpp_api/enumeration_experimental.h: dtype,
tiledb/sm/cpp_api/enumeration_experimental.h: dtype,
tiledb/sm/cpp_api/enumeration_experimental.h: tiledb_datatype_t dtype = type.value_or(DataT::tiledb_type);
tiledb/sm/cpp_api/enumeration_experimental.h: dtype,
$ I would find |
|
@robertbindar could we beef up the description of the PR here? More precisely, I'd like to include the motivations that lead to us needing the extra API. |
|
I cannot change the feeling that naming it |
This PR adds capi and cppapi support for querying the number of slots/dimensions/axes of a current domain ndrectangle. Depends on #5229 to be merged first. --- TYPE: FEATURE DESC: Add dim num support for ndrectangle.
|
@eddelbuettel If it's just a naming change, I'm happy to take it before we release. @robertbindar let's open a discussion in the core team channel to choose a name. |
Users wrapping the current domain APIs are requesting:
tiledb_datatype_t NDRectangle::range_dtype(const std::string& dim_name)andtiledb_datatype_t NDRectangle::range_dtype(uint32_t dim_idx)(and the CAPI counterparts)so that the underlying TileDB datatype of a range/dimension can be queried closer to the
call site of functions like e.g. range where a conversion from tiledb_datatype_t to static c++ type is most of the time needed.
[sc-52012]
TYPE: FEATURE
DESC: Add support for getting a dtype of ndrectangle.