@@ -122,26 +122,29 @@ class tdbBlockedMatrix : public MatrixBase {
122122
123123 /* *
124124 * @brief Construct a new tdbBlockedMatrix object, limited to `upper_bound`
125- * vectors. In this case, the `Matrix` is row-major, so the number of vectors
126- * is the number of rows.
125+ * vectors. We read rows from 0 -> row domain length and cols from 0 -> col
126+ * domain length. In this case, the `Matrix` is column-major, so the number of
127+ * vectors is the number of columns.
127128 *
128129 * @param ctx The TileDB context to use.
129130 * @param uri URI of the TileDB array to read.
130131 */
131132 tdbBlockedMatrix (const tiledb::Context& ctx, const std::string& uri) noexcept
132133 requires (std::is_same_v<LayoutPolicy, stdx::layout_left>)
133- : tdbBlockedMatrix(ctx, uri, 0 , 0 , 0 , 0 , 0 , 0 ) {
134+ : tdbBlockedMatrix(ctx, uri, 0 , std:: nullopt , 0 , std:: nullopt , 0 , 0 ) {
134135 }
135136
136137 /* *
137138 * @brief Construct a new tdbBlockedMatrix object, limited to `upper_bound`
138- * vectors. In this case, the `Matrix` is column-major, so the number of
139+ * vectors. We read rows from 0 -> row domain length and cols from 0 -> col
140+ * domain length. In this case, the `Matrix` is column-major, so the number of
139141 * vectors is the number of columns.
140142 *
141143 * @param ctx The TileDB context to use.
142144 * @param uri URI of the TileDB array to read.
143- * @param upper_bound The maximum number of vectors to read.
144- * @param temporal_policy The TemporalPolicy to use for reading the array
145+ * @param upper_bound The maximum number of vectors to read. Set to 0 for no
146+ * upper bound.
147+ * @param timestamp The TemporalPolicy to use for reading the array
145148 * data.
146149 */
147150 tdbBlockedMatrix (
@@ -150,17 +153,33 @@ class tdbBlockedMatrix : public MatrixBase {
150153 size_t upper_bound,
151154 size_t timestamp = 0 )
152155 requires (std::is_same_v<LayoutPolicy, stdx::layout_left>)
153- : tdbBlockedMatrix(ctx, uri, 0 , 0 , 0 , 0 , upper_bound, timestamp) {
156+ : tdbBlockedMatrix(
157+ ctx,
158+ uri,
159+ 0 ,
160+ std::nullopt ,
161+ 0 ,
162+ std::nullopt ,
163+ upper_bound,
164+ timestamp) {
154165 }
155166
156- /* * General constructor */
167+ /* * General constructor
168+ *
169+ * @param first_row The first row to read from.
170+ * @param last_row The last row to read to. Read rows from 0 -> row domain
171+ * length if nullopt is passed.
172+ * @param first_col The first col to read from.
173+ * @param last_col The last col to read to. Read rows from 0 -> col domain
174+ * length if nullopt is passed.
175+ */
157176 tdbBlockedMatrix (
158177 const tiledb::Context& ctx,
159178 const std::string& uri,
160179 size_t first_row,
161- size_t last_row,
180+ std::optional< size_t > last_row,
162181 size_t first_col,
163- size_t last_col,
182+ std::optional< size_t > last_col,
164183 size_t upper_bound,
165184 size_t timestamp)
166185 requires (std::is_same_v<LayoutPolicy, stdx::layout_left>)
@@ -177,14 +196,22 @@ class tdbBlockedMatrix : public MatrixBase {
177196 tiledb::TemporalPolicy(tiledb::TimeTravel, timestamp))) {
178197 }
179198
180- /* * General constructor */
199+ /* * General constructor
200+ *
201+ * @param first_row The first row to read from.
202+ * @param last_row The last row to read to. Read rows from 0 -> row domain
203+ * length if nullopt is passed.
204+ * @param first_col The first col to read from.
205+ * @param last_col The last col to read to. Read rows from 0 -> col domain
206+ * length if nullopt is passed.
207+ */
181208 tdbBlockedMatrix (
182209 const tiledb::Context& ctx,
183210 const std::string& uri,
184211 size_t first_row,
185- size_t last_row,
212+ std::optional< size_t > last_row,
186213 size_t first_col,
187- size_t last_col,
214+ std::optional< size_t > last_col,
188215 size_t upper_bound,
189216 tiledb::TemporalPolicy temporal_policy) // noexcept
190217 requires(std::is_same_v<LayoutPolicy, stdx::layout_left>)
@@ -194,16 +221,14 @@ class tdbBlockedMatrix : public MatrixBase {
194221 ctx, uri, TILEDB_READ, temporal_policy))
195222 , schema_{array_->schema ()}
196223 , first_row_{first_row}
197- , last_row_{last_row}
198- , first_col_{first_col}
199- , last_col_{last_col} {
224+ , first_col_{first_col} {
200225 constructor_timer.stop ();
201226 scoped_timer _{tdb_func__ + " " + uri};
202227
203- if (last_row_ < first_row_) {
228+ if (last_row && *last_row < first_row_) {
204229 throw std::runtime_error (" last_row < first_row" );
205230 }
206- if (last_col_ < first_col_) {
231+ if (last_col && *last_col < first_col_) {
207232 throw std::runtime_error (" last_col < first_col" );
208233 }
209234
@@ -228,15 +253,17 @@ class tdbBlockedMatrix : public MatrixBase {
228253
229254 /* The size of the array may not be the size of domain. Use non-zero value
230255 * if set in constructor */
231- if (last_row_ == 0 ) {
232- last_row_ =
233- (row_domain.template domain <row_domain_type>().second -
234- row_domain.template domain <row_domain_type>().first + 1 );
256+ if (!last_row.has_value ()) {
257+ last_row_ = row_domain.template domain <row_domain_type>().second -
258+ row_domain.template domain <row_domain_type>().first + 1 ;
259+ } else {
260+ last_row_ = *last_row;
235261 }
236- if (last_col_ == 0 ) {
237- last_col_ =
238- (col_domain.template domain <col_domain_type>().second -
239- col_domain.template domain <col_domain_type>().first + 1 );
262+ if (!last_col.has_value ()) {
263+ last_col_ = col_domain.template domain <col_domain_type>().second -
264+ col_domain.template domain <col_domain_type>().first + 1 ;
265+ } else {
266+ last_col_ = *last_col;
240267 }
241268
242269 size_t dimension = last_row_ - first_row_;
@@ -296,7 +323,7 @@ class tdbBlockedMatrix : public MatrixBase {
296323 std::min (load_blocksize_, last_col_ - last_resident_col_);
297324
298325 // Return if we're at the end
299- if (elements_to_load == 0 ) {
326+ if (elements_to_load == 0 || dimension == 0 ) {
300327 return false ;
301328 }
302329
@@ -363,14 +390,15 @@ class tdbPreLoadMatrix : public tdbBlockedMatrix<T, LayoutPolicy, I> {
363390 const std::string& uri,
364391 size_t upper_bound = 0 ,
365392 uint64_t timestamp = 0 )
366- : tdbPreLoadMatrix(ctx, uri, 0 , 0 , upper_bound, timestamp) {
393+ : tdbPreLoadMatrix(
394+ ctx, uri, std::nullopt , std::nullopt , upper_bound, timestamp) {
367395 }
368396
369397 tdbPreLoadMatrix (
370398 const tiledb::Context& ctx,
371399 const std::string& uri,
372- size_t num_array_rows,
373- size_t num_array_cols,
400+ std::optional< size_t > num_array_rows,
401+ std::optional< size_t > num_array_cols,
374402 size_t upper_bound = 0 ,
375403 uint64_t timestamp = 0 )
376404 : Base(
@@ -384,31 +412,6 @@ class tdbPreLoadMatrix : public tdbBlockedMatrix<T, LayoutPolicy, I> {
384412 timestamp) {
385413 Base::load ();
386414 }
387-
388- tdbPreLoadMatrix (
389- const tiledb::Context& ctx,
390- const std::string& uri,
391- size_t upper_bound,
392- const tiledb::TemporalPolicy& temporal_policy)
393- : tdbPreLoadMatrix(ctx, uri, 0 , 0 , upper_bound, temporal_policy) {
394- }
395-
396- tdbPreLoadMatrix (
397- const tiledb::Context& ctx,
398- const std::string& uri,
399- size_t num_array_rows,
400- size_t num_array_cols,
401- size_t upper_bound,
402- const tiledb::TemporalPolicy& temporal_policy)
403- : Base(
404- ctx,
405- uri,
406- num_array_rows,
407- num_array_cols,
408- upper_bound,
409- temporal_policy) {
410- Base::load ();
411- }
412415};
413416
414417/* *
0 commit comments