@@ -96,9 +96,8 @@ class base_index_group {
9696 tiledb::Context cached_ctx_;
9797 std::string group_uri_;
9898 TemporalPolicy temporal_policy_{TimeTravel, 0 };
99- size_t index_timestamp_{0 };
100- size_t group_timestamp_{0 };
101- size_t timetravel_index_{0 };
99+ size_t base_array_timestamp_{0 };
100+ size_t history_index_{0 };
102101
103102 // std::reference_wrapper<const index_type> index_;
104103 std::string version_;
@@ -151,7 +150,7 @@ class base_index_group {
151150 * @param ctx
152151 */
153152 void init_for_open () {
154- if (!exists (cached_ctx_ )) {
153+ if (!exists ()) {
155154 throw std::runtime_error (
156155 " Group uri " + std::string (group_uri_) + " does not exist." );
157156 }
@@ -196,25 +195,22 @@ class base_index_group {
196195 if (size (metadata_.ingestion_timestamps_ ) == 0 ) {
197196 throw std::runtime_error (" No ingestion timestamps found." );
198197 }
199- if (index_timestamp_ == 0 ) {
200- index_timestamp_ = metadata_.ingestion_timestamps_ .back ();
201- temporal_policy_ = TemporalPolicy{TimeTravel, index_timestamp_ };
198+ if (base_array_timestamp_ == 0 ) {
199+ base_array_timestamp_ = metadata_.ingestion_timestamps_ .back ();
200+ temporal_policy_ = TemporalPolicy{TimeTravel, base_array_timestamp_ };
202201 }
203202
204203 auto timestamp_bound = std::lower_bound (
205204 begin (metadata_.ingestion_timestamps_ ),
206205 end (metadata_.ingestion_timestamps_ ),
207- index_timestamp_ );
206+ base_array_timestamp_ );
208207 if (timestamp_bound == end (metadata_.ingestion_timestamps_ )) {
209208 // We may try to load the index at a timestamp beyond the latest ingestion
210209 // timestamp. In this case, use the last timestamp.
211210 timestamp_bound = end (metadata_.ingestion_timestamps_ ) - 1 ;
212211 }
213- timetravel_index_ =
212+ history_index_ =
214213 std::distance (begin (metadata_.ingestion_timestamps_ ), timestamp_bound);
215-
216- // @todo Or index_timestamp_?
217- group_timestamp_ = metadata_.ingestion_timestamps_ [timetravel_index_];
218214 }
219215
220216 /* *
@@ -233,16 +229,15 @@ class base_index_group {
233229 * @param version
234230 */
235231 void open_for_write () {
236- if (exists (cached_ctx_ )) {
232+ if (exists ()) {
237233 /* * Load the current group metadata */
238234 init_for_open ();
239235 if (!metadata_.ingestion_timestamps_ .empty () &&
240- index_timestamp_ < metadata_.ingestion_timestamps_ .back ()) {
236+ base_array_timestamp_ < metadata_.ingestion_timestamps_ .back ()) {
241237 throw std::runtime_error (
242- " Requested write timestamp " + std::to_string (index_timestamp_) +
243- " is not greater than " +
238+ " Requested write timestamp " +
239+ std::to_string (base_array_timestamp_) + " is not greater than " +
244240 std::to_string (metadata_.ingestion_timestamps_ .back ()));
245- group_timestamp_ = index_timestamp_;
246241 }
247242 } else {
248243 /* * Create a new group */
@@ -308,7 +303,7 @@ class base_index_group {
308303 : cached_ctx_(ctx)
309304 , group_uri_(uri)
310305 , temporal_policy_(temporal_policy)
311- , index_timestamp_ (temporal_policy.timestamp_end())
306+ , base_array_timestamp_ (temporal_policy.timestamp_end())
312307 , version_(version)
313308 , opened_for_(rw) {
314309 switch (opened_for_) {
@@ -347,8 +342,8 @@ class base_index_group {
347342 * @brief Test whether the group exists or not.
348343 * @param ctx
349344 */
350- bool exists (const tiledb::Context& ctx ) const {
351- return tiledb::Object::object (ctx , group_uri_).type () ==
345+ bool exists () const {
346+ return tiledb::Object::object (cached_ctx_ , group_uri_).type () ==
352347 tiledb::Object::Type::Group;
353348 }
354349
@@ -362,16 +357,12 @@ class base_index_group {
362357 return tiledb::Object::remove (ctx, group_uri_);
363358 }
364359
365- /* *************************************************************************
366- * Getters for read and write timestamps and sizes
367- **************************************************************************/
368-
369360 /* * Temporary until time traveling is implemented */
370361 auto get_previous_ingestion_timestamp () const {
371362 return metadata_.ingestion_timestamps_ .back ();
372363 }
373364 auto get_ingestion_timestamp () const {
374- return metadata_.ingestion_timestamps_ [timetravel_index_ ];
365+ return metadata_.ingestion_timestamps_ [history_index_ ];
375366 }
376367 auto append_ingestion_timestamp (size_t timestamp) {
377368 metadata_.ingestion_timestamps_ .push_back (timestamp);
@@ -380,14 +371,11 @@ class base_index_group {
380371 return metadata_.ingestion_timestamps_ ;
381372 }
382373
383- /*
384- * Base size information
385- */
386374 auto get_previous_base_size () const {
387375 return metadata_.base_sizes_ .back ();
388376 }
389377 auto get_base_size () const {
390- return metadata_.base_sizes_ [timetravel_index_ ];
378+ return metadata_.base_sizes_ [history_index_ ];
391379 }
392380 auto append_base_size (size_t size) {
393381 metadata_.base_sizes_ .push_back (size);
@@ -410,40 +398,34 @@ class base_index_group {
410398 metadata_.dimension_ = dim;
411399 }
412400
413- auto get_timetravel_index () const {
414- return timetravel_index_ ;
401+ auto get_history_index () const {
402+ return history_index_ ;
415403 }
416404
417- /* *************************************************************************
418- * Getters for names and uris
419- **************************************************************************/
420-
421405 [[nodiscard]] auto ids_uri () const {
422406 return array_key_to_uri (" ids_array_name" );
423407 }
424408 [[nodiscard]] auto ids_array_name () const {
425409 return array_key_to_array_name (" ids_array_name" );
426410 }
411+
427412 [[nodiscard]] const std::reference_wrapper<const tiledb::Context> cached_ctx ()
428413 const {
429414 return cached_ctx_;
430415 }
431416 [[nodiscard]] std::reference_wrapper<const tiledb::Context> cached_ctx () {
432417 return cached_ctx_;
433418 }
434- [[nodiscard]] auto group_timestamp () const {
435- return group_timestamp_;
436- }
437419
438420 /* *************************************************************************
439421 * Helpful functions for debugging, testing, etc
440422 **************************************************************************/
441423
442424 auto set_ingestion_timestamp (size_t timestamp) {
443- metadata_.ingestion_timestamps_ [timetravel_index_ ] = timestamp;
425+ metadata_.ingestion_timestamps_ [history_index_ ] = timestamp;
444426 }
445427 auto set_base_size (size_t size) {
446- metadata_.base_sizes_ [timetravel_index_ ] = size;
428+ metadata_.base_sizes_ [history_index_ ] = size;
447429 }
448430
449431 auto set_last_ingestion_timestamp (size_t timestamp) {
@@ -485,7 +467,7 @@ class base_index_group {
485467 *
486468 * @param msg Optional message to print before the dump.
487469 */
488- auto dump (const std::string& msg = " " ) {
470+ auto dump (const std::string& msg = " " ) const {
489471 if (!empty (msg)) {
490472 std::cout << " -------------------------------------------------------\n " ;
491473 std::cout << " # " + msg << std::endl;
@@ -502,6 +484,10 @@ class base_index_group {
502484 }
503485 std::cout << *name << " " << member.uri () << std::endl;
504486 }
487+ std::cout << " version_: " << version_ << std::endl;
488+ std::cout << " history_index_: " << history_index_ << std::endl;
489+ std::cout << " base_array_timestamp_: " << base_array_timestamp_
490+ << std::endl;
505491 std::cout << " -------------------------------------------------------\n " ;
506492 std::cout << " # Metadata:" << std::endl;
507493 std::cout << " -------------------------------------------------------\n " ;
0 commit comments