* @brief Execute a write on array query_condition_dense array * which then stores the following data in the array. The table * is organized by dimension/attribute. * * index | a | b | c | d * ------------------------------- * 0 | null | alice | 0 | 4.1 * 1 | 2 | bob | 0 | 3.4 * 2 | null | craig | 0 | 5.6 * 3 | 4 | dave | 0 | 3.7 * 4 | null | erin | 0
| 122 | * @param ctx The context. |
| 123 | */ |
| 124 | void write_array(Context& ctx) { |
| 125 | // Create data buffers that store the values to be written in. |
| 126 | std::vector<int32_t> a_data = {0, 2, 0, 4, 0, 6, 0, 8, 0, 10}; |
| 127 | std::vector<uint8_t> a_data_validity = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; |
| 128 | std::vector<std::string> b_strs = { |
| 129 | "alice", |
| 130 | "bob", |
| 131 | "craig", |
| 132 | "dave", |
| 133 | "erin", |
| 134 | "frank", |
| 135 | "grace", |
| 136 | "heidi", |
| 137 | "ivan", |
| 138 | "judy"}; |
| 139 | std::string b_data = ""; |
| 140 | std::vector<uint64_t> b_data_offsets; |
| 141 | for (const auto& elem : b_strs) { |
| 142 | b_data_offsets.push_back(b_data.size()); |
| 143 | b_data += elem; |
| 144 | } |
| 145 | std::vector<int32_t> c_data = {0, 0, 0, 0, 0, 0, 1, 2, 3, 4}; |
| 146 | std::vector<float> d_data = { |
| 147 | 4.1, 3.4, 5.6, 3.7, 2.3, 1.7, 3.8, 4.9, 3.2, 3.1}; |
| 148 | |
| 149 | // Execute the write query. |
| 150 | Array array_w(ctx, array_name, TILEDB_WRITE); |
| 151 | Query query_w(ctx, array_w); |
| 152 | query_w.set_layout(TILEDB_ROW_MAJOR) |
| 153 | .set_data_buffer("a", a_data) |
| 154 | .set_validity_buffer("a", a_data_validity) |
| 155 | .set_data_buffer("b", b_data) |
| 156 | .set_offsets_buffer("b", b_data_offsets) |
| 157 | .set_data_buffer("c", c_data) |
| 158 | .set_data_buffer("d", d_data); |
| 159 | |
| 160 | query_w.submit(); |
| 161 | query_w.finalize(); |
| 162 | array_w.close(); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * @brief Executes the read query for the array created in write_array. |
no test coverage detected