* Construct and support manipulation of a possibly multiple-range subarray for * optional use with Query object operations. * * @details * See examples for more usage details. * * **Example:** * @code{.cpp} * // Open the array for writing * tiledb::Context ctx; * tiledb::Array array(ctx, "my_dense_array", TILEDB_WRITE); * Query query(ctx, array); * std::vector a1_data = {1, 2, 3}; * q
| 86 | * @endcode |
| 87 | */ |
| 88 | class Subarray { |
| 89 | public: |
| 90 | /** |
| 91 | * Creates a TileDB Subarray object. |
| 92 | * |
| 93 | * **Example:** |
| 94 | * |
| 95 | * @code{.cpp} |
| 96 | * // Open the array for writing |
| 97 | * tiledb::Context ctx; |
| 98 | * tiledb::Array array(ctx, "my_array", TILEDB_WRITE); |
| 99 | * tiledb::Subarray subarray(ctx, array); |
| 100 | * @endcode |
| 101 | * |
| 102 | * @param ctx TileDB context |
| 103 | * @param array Open Array object |
| 104 | * @param coalesce_ranges When enabled, ranges will attempt to coalesce |
| 105 | * with existing ranges as they are added. |
| 106 | */ |
| 107 | Subarray( |
| 108 | const tiledb::Context& ctx, |
| 109 | const tiledb::Array& array, |
| 110 | bool coalesce_ranges = true) |
| 111 | : ctx_(ctx) |
| 112 | , array_(array) |
| 113 | , schema_(array.schema()) { |
| 114 | tiledb_subarray_t* capi_subarray; |
| 115 | ctx.handle_error(tiledb_subarray_alloc( |
| 116 | ctx.ptr().get(), array.ptr().get(), &capi_subarray)); |
| 117 | tiledb_subarray_set_coalesce_ranges( |
| 118 | ctx.ptr().get(), capi_subarray, coalesce_ranges); |
| 119 | subarray_ = std::shared_ptr<tiledb_subarray_t>(capi_subarray, deleter_); |
| 120 | } |
| 121 | |
| 122 | /** Set the coalesce_ranges flag for the subarray. */ |
| 123 | Subarray& set_coalesce_ranges(bool coalesce_ranges) { |
| 124 | ctx_.get().handle_error(tiledb_subarray_set_coalesce_ranges( |
| 125 | ctx_.get().ptr().get(), subarray_.get(), coalesce_ranges)); |
| 126 | return *this; |
| 127 | } |
| 128 | |
| 129 | /** Replace/update -this- Subarray's shared_ptr to data to reference the |
| 130 | * passed subarray. |
| 131 | * |
| 132 | * @param capi_subarray is a c_api subarray to be referenced by this cpp_api |
| 133 | * subarray entity. |
| 134 | */ |
| 135 | |
| 136 | Subarray& replace_subarray_data(tiledb_subarray_t* capi_subarray) { |
| 137 | subarray_ = std::shared_ptr<tiledb_subarray_t>(capi_subarray, deleter_); |
| 138 | return *this; |
| 139 | } |
| 140 | /** |
| 141 | * Adds a 1D range along a subarray dimension index, in the form |
| 142 | * (start, end, stride). The datatype of the range |
| 143 | * must be the same as the dimension datatype. |
| 144 | * |
| 145 | * **Example:** |
no test coverage detected