From e27d471de90cbcee2837770c41b83b4a90293083 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 19 Sep 2024 14:47:40 +0000 Subject: [PATCH 1/2] remove some unused methods --- libtiledbsoma/test/unit_soma_dataframe.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libtiledbsoma/test/unit_soma_dataframe.cc b/libtiledbsoma/test/unit_soma_dataframe.cc index 45def76e7f..c6dc9fef31 100644 --- a/libtiledbsoma/test/unit_soma_dataframe.cc +++ b/libtiledbsoma/test/unit_soma_dataframe.cc @@ -109,16 +109,6 @@ struct VariouslyIndexedDataFrameFixture { {.name = str_name, .tiledb_datatype = str_datatype}); } - std::vector make_i64_data() { - return std::vector({1, 2}); - } - std::vector make_u32_data() { - return std::vector({1234, 5678}); - } - std::vector make_str_data() { - return std::vector({"apple", "bat"}); - } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Helper methods for create/open/write/etc. From bf78157de345f7b7a64bfe4ffe1d386d0934db15 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 19 Sep 2024 16:21:29 +0000 Subject: [PATCH 2/2] fix unit-test dataframe writes --- libtiledbsoma/test/unit_soma_dataframe.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libtiledbsoma/test/unit_soma_dataframe.cc b/libtiledbsoma/test/unit_soma_dataframe.cc index c6dc9fef31..a5844447f0 100644 --- a/libtiledbsoma/test/unit_soma_dataframe.cc +++ b/libtiledbsoma/test/unit_soma_dataframe.cc @@ -163,14 +163,30 @@ struct VariouslyIndexedDataFrameFixture { auto soma_dataframe = SOMADataFrame::open(uri_, OpenMode::write, ctx_); auto i64_data = std::vector({sjid_base + 1, sjid_base + 2}); + auto u32_data = std::vector({1234, 5678}); - auto str_data = std::vector({"apple", "bat"}); - auto str_offsets = std::vector({0, 5, 8}); + + // We like to think we're writing an array of strings ... + auto strings = std::vector({"apple", "bat"}); + // ... but really we're writing an array of characters along + // with offsets data. + // + // It would be possible here to just hard-code a string "applebat" and + // an offsets array {0, 5, 8}. The following bits simply automate that. + std::string char_data(""); + std::vector char_offsets(0); + uint64_t offset = 0; + for (auto e : strings) { + char_data += e; + char_offsets.push_back(offset); + offset += e.size(); + } + char_offsets.push_back(offset); soma_dataframe->set_column_data( i64_name, i64_data.size(), i64_data.data()); soma_dataframe->set_column_data( - str_name, str_data.size(), str_data.data(), str_offsets.data()); + str_name, strings.size(), char_data.data(), char_offsets.data()); soma_dataframe->set_column_data( u32_name, u32_data.size(), u32_data.data()); soma_dataframe->write();