diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-10-30 14:25:28 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-10-30 14:29:43 -0400 |
| commit | ceffd8caf5e4e827e2cc4d6975507a66d88f77a9 (patch) | |
| tree | fa4b463a87cbaefcec6da274a8fb1edba792e8e3 | |
| parent | 39ae3e0441d8297a09197aba98bd494b5ada12c1 (diff) | |
| download | dynamic-extension-ceffd8caf5e4e827e2cc4d6975507a66d88f77a9.tar.gz | |
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.
| -rw-r--r-- | include/framework/DynamicExtension.h | 48 | ||||
| -rw-r--r-- | include/framework/structure/BufferView.h | 4 |
2 files changed, 37 insertions, 15 deletions
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<Shard *> 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; } diff --git a/include/framework/structure/BufferView.h b/include/framework/structure/BufferView.h index 14abedc..8dff2ef 100644 --- a/include/framework/structure/BufferView.h +++ b/include/framework/structure/BufferView.h @@ -116,6 +116,10 @@ public: return m_buffers; } + size_t size() { + return m_buffers.size(); + } + private: std::vector<Buffer *> m_buffers; size_t m_cutoff; |