Skip to content

Commit 2e7e171

Browse files
authored
Escape null characters in schema dumps (#825)
* Escape null characters in schema dumps * DESCRIPTION and NEWS.md
1 parent b1803fa commit 2e7e171

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tiledb
22
Type: Package
3-
Version: 0.32.0.2
3+
Version: 0.32.0.3
44
Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays
55
Authors@R: c(
66
person("TileDB, Inc.", role = c("aut", "cph")),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Improvements
44

5+
* Schema-dump output is no longer truncated in the case that there are any null fill values in the schema (@johnkerl in [#825](https://github.com/TileDB-Inc/TileDB-R/pull/825))
56
* `tiledb_attr()` now prints the attribute object as expected and documentation has been corrected (@cgiachalis in [#823](https://github.com/TileDB-Inc/TileDB-R/pull/823))
67

78
## Documentation

src/libtiledb.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,27 @@
2424
#include "tiledb_version.h"
2525

2626
#include <fstream>
27+
#include <algorithm>
2728
#include <unistd.h>
2829

2930
using namespace Rcpp;
3031

32+
// This is an auxiliary method for schema dumps wherein a fill value may include
33+
// the null character. It isn't a general-purpose C++ string-search-and-replace,
34+
// as C++ makes that a surprisingly non-straightforward operation. This suffices
35+
// for our purposes.
36+
std::string denull(const std::string& str) {
37+
std::stringstream ss;
38+
for (char c : str) {
39+
if (c == '\0') {
40+
ss << "\\0";
41+
} else {
42+
ss << c;
43+
}
44+
}
45+
return ss.str();
46+
}
47+
3148
const char *_tiledb_datatype_to_string(tiledb_datatype_t dtype) {
3249
switch (dtype) {
3350
case TILEDB_INT8:
@@ -1302,13 +1319,14 @@ bool libtiledb_domain_has_dimension(XPtr<tiledb::Domain> domain,
13021319
return domain->has_dimension(name.c_str());
13031320
}
13041321

1322+
13051323
// [[Rcpp::export]]
13061324
void libtiledb_domain_dump(XPtr<tiledb::Domain> domain) {
13071325
check_xptr_tag<tiledb::Domain>(domain);
13081326
#if TILEDB_VERSION >= TileDB_Version(2, 25, 0)
13091327
std::stringstream ss;
13101328
ss << *domain;
1311-
Rcpp::Rcout << ss.str();
1329+
Rcpp::Rcout << denull(ss.str());
13121330
#else
13131331
domain->dump();
13141332
#endif
@@ -1624,7 +1642,7 @@ void libtiledb_attribute_dump(XPtr<tiledb::Attribute> attr) {
16241642
#if TILEDB_VERSION >= TileDB_Version(2, 25, 0)
16251643
std::stringstream ss;
16261644
ss << *attr;
1627-
Rcpp::Rcout << ss.str();
1645+
Rcpp::Rcout << denull(ss.str());
16281646
#else
16291647
attr->dump();
16301648
#endif
@@ -2182,7 +2200,7 @@ void libtiledb_array_schema_dump(XPtr<tiledb::ArraySchema> schema) {
21822200
#if TILEDB_VERSION >= TileDB_Version(2, 25, 0)
21832201
std::stringstream ss;
21842202
ss << *schema;
2185-
Rcpp::Rcout << ss.str();
2203+
Rcpp::Rcout << denull(ss.str());
21862204
#else
21872205
schema->dump();
21882206
#endif

0 commit comments

Comments
 (0)