MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / read_array_1d_partial

Function read_array_1d_partial

test/src/unit-cppapi-fill_values.cc:131–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void read_array_1d_partial(
132 const std::string& array_name,
133 bool nullable_attributes = false,
134 int32_t fill_int32 = tiledb::sm::constants::empty_int32,
135 std::string fill_char = std::string() + tiledb::sm::constants::empty_char,
136 std::array<double, 2> fill_double = {
137 {tiledb::sm::constants::empty_float64,
138 tiledb::sm::constants::empty_float64}}) {
139 Context ctx;
140
141 std::vector<int32_t> a1(10);
142 std::vector<uint8_t> a1_validity(10);
143 std::vector<char> a2_val(100);
144 std::vector<uint64_t> a2_off(20);
145 std::vector<uint8_t> a2_validity(20);
146 std::vector<double> a3(20);
147 std::vector<uint8_t> a3_validity(10);
148
149 Array array(ctx, array_name, TILEDB_READ);
150 Query query(ctx, array, TILEDB_READ);
151 if (!nullable_attributes) {
152 CHECK_NOTHROW(query.set_data_buffer("a1", a1));
153 CHECK_NOTHROW(query.set_data_buffer("a2", a2_val));
154 CHECK_NOTHROW(query.set_offsets_buffer("a2", a2_off));
155 CHECK_NOTHROW(query.set_data_buffer("a3", a3));
156 } else {
157 CHECK_NOTHROW(query.set_data_buffer("a1", a1));
158 CHECK_NOTHROW(query.set_validity_buffer("a1", a1_validity));
159 CHECK_NOTHROW(query.set_data_buffer("a2", a2_val));
160 CHECK_NOTHROW(query.set_offsets_buffer("a2", a2_off));
161 CHECK_NOTHROW(query.set_validity_buffer("a2", a2_validity));
162 CHECK_NOTHROW(query.set_data_buffer("a3", a3));
163 CHECK_NOTHROW(query.set_validity_buffer("a3", a3_validity));
164 }
165 CHECK_NOTHROW(
166 query.set_subarray(Subarray(ctx, array).set_subarray<int32_t>({1, 10})));
167
168 REQUIRE(query.submit() == Query::Status::COMPLETE);
169
170 auto res = query.result_buffer_elements_nullable();
171 REQUIRE(std::get<1>(res["a1"]) == 10);
172 REQUIRE(std::get<0>(res["a2"]) == 10);
173 REQUIRE(std::get<1>(res["a2"]) == 5 + 8 * fill_char.size());
174 REQUIRE(std::get<1>(res["a3"]) == 20);
175 if (nullable_attributes) {
176 REQUIRE(std::get<2>(res["a1"]) == 10);
177 REQUIRE(std::get<2>(res["a2"]) == 10);
178 REQUIRE(std::get<2>(res["a3"]) == 10);
179 }
180
181 const uint8_t fill_null = 0;
182 const uint8_t fill_valid = 1;
183
184 uint64_t off = 0;
185 for (size_t i = 0; i < 2; ++i) {
186 CHECK(a1[i] == fill_int32);
187 CHECK(a2_off[i] == off);
188 for (size_t c = 0; c < fill_char.size(); ++c) {

Callers 1

Calls 9

SubarrayClass · 0.50
set_data_bufferMethod · 0.45
set_offsets_bufferMethod · 0.45
set_validity_bufferMethod · 0.45
set_subarrayMethod · 0.45
submitMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected