Skip to content

Commit 67eb576

Browse files
authored
Handle '=' in tiledb config values (#605)
1 parent dc1eba4 commit 67eb576

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ docs:
5858
check-format:
5959
@./ci/run-clang-format.sh . clang-format 0 \
6060
`find libtiledbvcf/src -name "*.cc" -or -name "*.h"`
61+
@./ci/run-clang-format.sh . clang-format 0 \
62+
`find libtiledbvcf/test -name "*.cc" -or -name "*.h"`
6163

6264
.PHONY: format
6365
format:
6466
@./ci/run-clang-format.sh . clang-format 1 \
6567
`find libtiledbvcf/src -name "*.cc" -or -name "*.h"`
68+
@./ci/run-clang-format.sh . clang-format 1 \
69+
`find libtiledbvcf/test -name "*.cc" -or -name "*.h"`
6670

6771
# clean
6872
# -------------------------------------------------------------------

libtiledbvcf/src/utils/utils.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,16 @@ void set_tiledb_config_map(
299299
const std::vector<std::string>& params,
300300
std::unordered_map<std::string, std::string>* cfg) {
301301
for (const auto& s : params) {
302-
auto kv = utils::split(s, '=');
303-
if (kv.size() != 2)
302+
auto pos = s.find('=');
303+
if (pos == std::string::npos) {
304304
throw std::runtime_error(
305305
"Error setting TileDB config parameter; bad value '" + s + "'");
306-
307-
utils::trim(&kv[0]);
308-
utils::trim(&kv[1]);
309-
cfg->emplace(kv[0], kv[1]);
306+
}
307+
auto key = s.substr(0, pos);
308+
auto value = s.substr(pos + 1);
309+
utils::trim(&key);
310+
utils::trim(&value);
311+
cfg->emplace(key, value);
310312
}
311313
}
312314

@@ -319,13 +321,16 @@ void set_tiledb_config(
319321
const std::vector<std::string>& params, tiledb_config_t* cfg) {
320322
tiledb_error_t* err;
321323
for (const auto& s : params) {
322-
auto kv = utils::split(s, '=');
323-
if (kv.size() != 2)
324+
auto pos = s.find('=');
325+
if (pos == std::string::npos) {
324326
throw std::runtime_error(
325327
"Error setting TileDB config parameter; bad value '" + s + "'");
326-
utils::trim(&kv[0]);
327-
utils::trim(&kv[1]);
328-
tiledb_config_set(cfg, kv[0].c_str(), kv[1].c_str(), &err);
328+
}
329+
auto key = s.substr(0, pos);
330+
auto value = s.substr(pos + 1);
331+
utils::trim(&key);
332+
utils::trim(&value);
333+
tiledb_config_set(cfg, key.c_str(), value.c_str(), &err);
329334
tiledb::impl::check_config_error(err);
330335
}
331336
}

libtiledbvcf/test/run-cli-tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ $tilevcf utils vacuum commits -u ${uri} --log-level trace
499499
$tilevcf utils vacuum fragment_meta -u ${uri} --log-level trace
500500
$tilevcf utils vacuum fragments -u ${uri} --log-level trace
501501

502+
# test tiledb-config parsing
503+
# -------------------------------------------------------------------
504+
$tilevcf create -u tmp --tiledb-config vfs.azure.storage_sas_token=?sv=123456789== || exit 1
505+
502506
# Expected failures
503507
echo ""
504508
echo "** Expected failure error messages follow:"

libtiledbvcf/test/src/unit-c-api-reader.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ TEST_CASE("C API: Reader set config", "[capi][query]") {
422422

423423
SECTION("- Valid options") {
424424
const char* config =
425-
"sm.compute_concurrency_level=4, vfs.s3.proxy_host=abc.def.ghi";
425+
"sm.compute_concurrency_level=4, vfs.s3.proxy_host=abc.def.ghi, "
426+
"vfs.azure.storage_sas_token=?sv=123456789==";
426427
REQUIRE(
427428
tiledb_vcf_reader_set_tiledb_config(reader, config) == TILEDB_VCF_OK);
428429
}

0 commit comments

Comments
 (0)