Skip to content

Commit

Permalink
correct domain getter for uint32, uint64, int64 cases (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Jun 25, 2021
1 parent 1e96e25 commit 05c4c14
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/libtiledb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,34 +836,34 @@ SEXP libtiledb_dim_get_domain(XPtr<tiledb::Dimension> dim) {
using DataType = tiledb::impl::tiledb_to_type<TILEDB_UINT32>::type;
auto d1 = dim->domain<DataType>().first;
auto d2 = dim->domain<DataType>().second;
if (d1 > std::numeric_limits<int32_t>::max() ||
d2 > std::numeric_limits<int32_t>::max()) {
Rcpp::stop("tiledb_dim domain UINT32 value not representable as an R integer");
if (d1 > std::numeric_limits<int64_t>::max() ||
d2 > std::numeric_limits<int64_t>::max()) {
Rcpp::stop("tiledb_dim domain UINT32 value not representable as an R integer64 type");
}
return IntegerVector({static_cast<int32_t>(d1),
static_cast<int32_t>(d2)});
std::vector<int64_t> v = { static_cast<int64_t>(d1), static_cast<int64_t>(d2) };
return makeInteger64(v);
}
case TILEDB_INT64: {
using DataType = tiledb::impl::tiledb_to_type<TILEDB_INT64>::type;
auto d1 = dim->domain<DataType>().first;
auto d2 = dim->domain<DataType>().second;
if (d1 <= R_NaInt || d1 > std::numeric_limits<int32_t>::max() ||
d2 <= R_NaInt || d2 > std::numeric_limits<int32_t>::max()) {
Rcpp::stop("tiledb_dim domain INT64 value not representable as an R integer");
if (d1 <= R_NaInt || d1 > std::numeric_limits<int64_t>::max() ||
d2 <= R_NaInt || d2 > std::numeric_limits<int64_t>::max()) {
Rcpp::stop("tiledb_dim domain INT64 value not representable as an R integer64 type");
}
return IntegerVector({static_cast<int32_t>(d1),
static_cast<int32_t>(d2)});
std::vector<int64_t> v = { d1, d2 };
return makeInteger64(v);
}
case TILEDB_UINT64: {
using DataType = tiledb::impl::tiledb_to_type<TILEDB_UINT64>::type;
auto d1 = dim->domain<DataType>().first;
auto d2 = dim->domain<DataType>().second;
if (d1 > std::numeric_limits<int32_t>::max() ||
d2 > std::numeric_limits<int32_t>::max()) {
Rcpp::stop("tiledb_dim domain UINT64 value not representable as an R integer");
if (d1 > std::numeric_limits<int64_t>::max() ||
d2 > std::numeric_limits<int64_t>::max()) {
Rcpp::stop("tiledb_dim domain UINT64 value not representable as an R integer64 type");
}
return IntegerVector({static_cast<int32_t>(d1),
static_cast<int32_t>(d2)});
std::vector<int64_t> v = { static_cast<int64_t>(d1), static_cast<int64_t>(d2) };
return makeInteger64(v);
}
case TILEDB_DATETIME_YEAR:
case TILEDB_DATETIME_MONTH:
Expand Down

0 comments on commit 05c4c14

Please sign in to comment.