From ceffd8caf5e4e827e2cc4d6975507a66d88f77a9 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 30 Oct 2023 14:25:28 -0400 Subject: DynamicExtension: adjusted a few operations to ensure conistency get_memory_usage, get_aux_memory_usage, get_record_count, get_tombstone_count, and create_static_structure have been adjusted to ensure that they pull from a consistent epoch, even if a change-over occurs midway through the function. These functions also now register with the epoch as a job, to ensure that the epoch they are operating own isn't retired midway through the function. Probably not a big issue for the accessors, but I could see it being very important for create_static_structure. --- include/framework/DynamicExtension.h | 48 +++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'include/framework/DynamicExtension.h') diff --git a/include/framework/DynamicExtension.h b/include/framework/DynamicExtension.h index d2a6b7a..eb78d48 100644 --- a/include/framework/DynamicExtension.h +++ b/include/framework/DynamicExtension.h @@ -105,13 +105,20 @@ public: } size_t get_record_count() { - size_t cnt = get_active_epoch()->get_buffer_view().get_record_count(); - return cnt + get_active_epoch()->get_structure()->get_record_count(); + auto epoch = get_active_epoch(); + epoch->start_job(); + auto t = epoch->get_buffer_view().get_record_count() + epoch->get_structure()->get_record_count(); + epoch->end_job(); + + return t; } - size_t get_tombstone_cnt() { - size_t cnt = get_active_epoch()->get_buffer_view().get_tombstone_count(); - return cnt + get_active_epoch()->get_structure()->get_tombstone_cnt(); + size_t get_tombstone_count() { + auto epoch = get_active_epoch(); + epoch->start_job(); + auto t = epoch->get_buffer_view().get_tombstone_count() + epoch->get_structure()->get_tombstone_count(); + epoch->end_job(); + return t; } size_t get_height() { @@ -119,17 +126,21 @@ public: } size_t get_memory_usage() { - auto vers = get_active_epoch()->get_structure()->get_memory_usage(); - auto buffer = get_active_epoch()->get_buffer_view().get_memory_usage(); + auto epoch = get_active_epoch(); + epoch->start_job(); + auto t= epoch->get_buffer_view().get_memory_usage() + epoch->get_structure()->get_memory_usage(); + epoch->end_job(); - return vers + buffer; + return t; } size_t get_aux_memory_usage() { - auto vers = get_active_epoch()->get_structure()->get_aux_memory_usage(); - auto buffer = get_active_epoch()->get_buffer_view().get_aux_memory_usage(); + auto epoch = get_active_epoch(); + epoch->start_job(); + auto t = epoch->get_buffer_view().get_aux_memory_usage() + epoch->get_structure()->get_aux_memory_usage(); + epoch->end_job(); - return vers + buffer; + return t; } size_t get_buffer_capacity() { @@ -137,7 +148,11 @@ public: } Shard *create_static_structure() { - auto vers = get_active_epoch()->get_structure(); + auto epoch = get_active_epoch(); + auto bv = epoch->get_buffer_view(); + epoch->start_job(); + + auto vers = epoch->get_structure(); std::vector shards; if (vers->get_levels().size() > 0) { @@ -148,9 +163,11 @@ public: } } - // FIXME: should use a buffer view--or perhaps some sort of a - // raw record iterator model. - shards.emplace_back(new S(get_active_epoch()->get_buffers()[0])); + // FIXME: With an interface adjustment, this could be done in + // one call, rather than a loop. + for (size_t i=bv.size() - 1; i>=0; i--) { + shards.emplace_back(new S(bv.get_buffers()[i])); + } Shard *shards_array[shards.size()]; @@ -167,6 +184,7 @@ public: delete shard; } + epoch->end_job(); return flattened; } -- cgit v1.2.3