-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the wide-column aware merge API to the stress tests (#11906)
Summary: Pull Request resolved: #11906 The patch adds stress test coverage for the wide-column aware `FullMergeV3` API by implementing a new `DBStressWideMergeOperator`. This operator is similar to `PutOperator` / `PutOperatorV2` in the sense that its result is based on the last merge operand; however, the merge result can be either a plain value or a wide-column entity, depending on the value base encoded into the operand and the value of the `use_put_entity_one_in` stress test parameter. Following the same rule for merge results that we do for writes ensures that the queries issued by the validation logic receive the expected results. The new operator is used instead of `PutOperatorV2` whenever `use_put_entity_one_in` is positive. Note that the patch also makes it possible to set `use_put_entity_one_in` and `use_merge` (but not `use_full_merge_v1`) at the same time, giving `use_put_entity_one_in` precedence, so the stress test will use `PutEntity` for writes passing the `use_put_entity_one_in` check described above and `Merge` for any other writes. Reviewed By: jaykorean Differential Revision: D49760024 fbshipit-source-id: 3893602c3e7935381b484f4f5026f1983e3a04a9
- Loading branch information
1 parent
8b56696
commit 01e2d33
Showing
11 changed files
with
113 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
|
||
#ifdef GFLAGS | ||
|
||
#include "db_stress_tool/db_stress_wide_merge_operator.h" | ||
|
||
#include "db_stress_tool/db_stress_common.h" | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
bool DBStressWideMergeOperator::FullMergeV3( | ||
const MergeOperationInputV3& merge_in, | ||
MergeOperationOutputV3* merge_out) const { | ||
assert(!merge_in.operand_list.empty()); | ||
assert(merge_out); | ||
|
||
const Slice& latest = merge_in.operand_list.back(); | ||
|
||
if (latest.size() < sizeof(uint32_t)) { | ||
return false; | ||
} | ||
|
||
const uint32_t value_base = GetValueBase(latest); | ||
|
||
if (FLAGS_use_put_entity_one_in == 0 || | ||
(value_base % FLAGS_use_put_entity_one_in) != 0) { | ||
merge_out->new_value = latest; | ||
return true; | ||
} | ||
|
||
const auto columns = GenerateWideColumns(value_base, latest); | ||
|
||
merge_out->new_value = MergeOperationOutputV3::NewColumns(); | ||
auto& new_columns = | ||
std::get<MergeOperationOutputV3::NewColumns>(merge_out->new_value); | ||
new_columns.reserve(columns.size()); | ||
|
||
for (const auto& column : columns) { | ||
new_columns.emplace_back(column.name().ToString(), | ||
column.value().ToString()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} // namespace ROCKSDB_NAMESPACE | ||
|
||
#endif // GFLAGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
|
||
#pragma once | ||
|
||
#include "rocksdb/merge_operator.h" | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
// A test merge operator that implements the wide-column aware FullMergeV3 | ||
// interface. Similarly to the simple "put" type merge operators, the merge | ||
// result is based on the last merge operand; however, the merge result can | ||
// potentially be a wide-column entity, depending on the value base encoded into | ||
// the merge operand and the value of the "use_put_entity_one_in" stress test | ||
// option. Following the same rule as for writes ensures that the queries | ||
// issued by the validation logic receive the expected results. | ||
class DBStressWideMergeOperator : public MergeOperator { | ||
public: | ||
bool FullMergeV3(const MergeOperationInputV3& merge_in, | ||
MergeOperationOutputV3* merge_out) const override; | ||
|
||
const char* Name() const override { return "DBStressWideMergeOperator"; } | ||
}; | ||
|
||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters