summaryrefslogtreecommitdiffstats
path: root/include/framework/reconstruction/BSMPolicy.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2025-04-08 14:18:32 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2025-04-08 14:18:32 -0400
commit47c8864758399a83b5a80e2a8a31ea316b06505d (patch)
treedc856c65e56ccbf336ed0ed9412bbb6743974331 /include/framework/reconstruction/BSMPolicy.h
parenta9ee3f2f7f557adbe5448e4f4fbf71c23fe808b1 (diff)
downloaddynamic-extension-47c8864758399a83b5a80e2a8a31ea316b06505d.tar.gz
BSM bugfixes
Diffstat (limited to 'include/framework/reconstruction/BSMPolicy.h')
-rw-r--r--include/framework/reconstruction/BSMPolicy.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/include/framework/reconstruction/BSMPolicy.h b/include/framework/reconstruction/BSMPolicy.h
index 42ae506..65554fb 100644
--- a/include/framework/reconstruction/BSMPolicy.h
+++ b/include/framework/reconstruction/BSMPolicy.h
@@ -36,7 +36,7 @@ public:
ReconstructionVector reconstructions;
auto levels = version->get_structure()->get_level_vector();
- level_index target_level = find_reconstruction_target(levels);
+ level_index target_level = find_reconstruction_target(levels, version->get_structure()->get_record_count());
assert(target_level != -1);
level_index source_level = 0;
@@ -48,22 +48,17 @@ public:
ReconstructionTask task;
task.target = target_level;
- if (target_level == 1 &&
- (levels.size() == 1 || levels[1]->get_record_count() == 0)) {
- /* if the first level is empty, then we just append the buffer to it */
- task.type = ReconstructionType::Append;
- } else {
- /* otherwise, we'll need to do a merge of at least two shards */
- task.type = ReconstructionType::Merge;
- }
-
size_t reccnt = 0;
if (target_level < (ssize_t)levels.size() && levels[target_level]->get_record_count() > 0) {
task.sources.push_back({target_level, all_shards_idx});
+ task.type = ReconstructionType::Merge;
+ } else {
+ task.type = ReconstructionType::Append;
}
for (level_index i = target_level - 1; i >= source_level; i--) {
assert(i < (ssize_t)levels.size());
+ assert(levels[i]->get_record_count() > 0 || i == 0);
task.sources.push_back({i, all_shards_idx});
reccnt += levels[i]->get_record_count();
}
@@ -76,11 +71,11 @@ public:
}
private:
- level_index find_reconstruction_target(LevelVector &levels) const {
+ level_index find_reconstruction_target(LevelVector &levels, size_t reccnt) const {
level_index target_level = invalid_level_idx;
for (level_index i = 1; i < (level_index)levels.size(); i++) {
- if (levels[i]->get_record_count() == 0) {
+ if (levels[i]->get_record_count() < capacity(i, reccnt)) {
target_level = i;
break;
}