mirror of https://github.com/facebook/rocksdb.git
Remove a now-unnecessary WideColumnSerialization::Serialize variant (#11864)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/11864 Reviewed By: jaykorean Differential Revision: D49445163 fbshipit-source-id: a1275112b9f87a3652df5f155bd215db5819326c
This commit is contained in:
parent
f42e70bf56
commit
51b3b7e08c
|
@ -16,11 +16,9 @@
|
|||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
Status WideColumnSerialization::SerializeImpl(const Slice* value_of_default,
|
||||
const WideColumns& columns,
|
||||
std::string& output) {
|
||||
const size_t num_columns =
|
||||
value_of_default ? columns.size() + 1 : columns.size();
|
||||
Status WideColumnSerialization::Serialize(const WideColumns& columns,
|
||||
std::string& output) {
|
||||
const size_t num_columns = columns.size();
|
||||
|
||||
if (num_columns > static_cast<size_t>(std::numeric_limits<uint32_t>::max())) {
|
||||
return Status::InvalidArgument("Too many wide columns");
|
||||
|
@ -31,17 +29,6 @@ Status WideColumnSerialization::SerializeImpl(const Slice* value_of_default,
|
|||
PutVarint32(&output, static_cast<uint32_t>(num_columns));
|
||||
|
||||
const Slice* prev_name = nullptr;
|
||||
if (value_of_default) {
|
||||
if (value_of_default->size() >
|
||||
static_cast<size_t>(std::numeric_limits<uint32_t>::max())) {
|
||||
return Status::InvalidArgument("Wide column value too long");
|
||||
}
|
||||
|
||||
PutLengthPrefixedSlice(&output, kDefaultWideColumnName);
|
||||
PutVarint32(&output, static_cast<uint32_t>(value_of_default->size()));
|
||||
|
||||
prev_name = &kDefaultWideColumnName;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < columns.size(); ++i) {
|
||||
const WideColumn& column = columns[i];
|
||||
|
@ -68,10 +55,6 @@ Status WideColumnSerialization::SerializeImpl(const Slice* value_of_default,
|
|||
prev_name = &name;
|
||||
}
|
||||
|
||||
if (value_of_default) {
|
||||
output.append(value_of_default->data(), value_of_default->size());
|
||||
}
|
||||
|
||||
for (const auto& column : columns) {
|
||||
const Slice& value = column.value();
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ class Slice;
|
|||
class WideColumnSerialization {
|
||||
public:
|
||||
static Status Serialize(const WideColumns& columns, std::string& output);
|
||||
static Status Serialize(const Slice& value_of_default,
|
||||
const WideColumns& other_columns,
|
||||
std::string& output);
|
||||
|
||||
static Status Deserialize(Slice& input, WideColumns& columns);
|
||||
|
||||
|
@ -55,23 +52,6 @@ class WideColumnSerialization {
|
|||
static Status GetValueOfDefaultColumn(Slice& input, Slice& value);
|
||||
|
||||
static constexpr uint32_t kCurrentVersion = 1;
|
||||
|
||||
private:
|
||||
static Status SerializeImpl(const Slice* value_of_default,
|
||||
const WideColumns& columns, std::string& output);
|
||||
};
|
||||
|
||||
inline Status WideColumnSerialization::Serialize(const WideColumns& columns,
|
||||
std::string& output) {
|
||||
constexpr Slice* value_of_default = nullptr;
|
||||
|
||||
return SerializeImpl(value_of_default, columns, output);
|
||||
}
|
||||
|
||||
inline Status WideColumnSerialization::Serialize(
|
||||
const Slice& value_of_default, const WideColumns& other_columns,
|
||||
std::string& output) {
|
||||
return SerializeImpl(&value_of_default, other_columns, output);
|
||||
}
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
|
|
@ -124,25 +124,6 @@ TEST(WideColumnSerializationTest, SerializeDeserialize) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(WideColumnSerializationTest, SerializeWithPrepend) {
|
||||
Slice value_of_default("baz");
|
||||
WideColumns other_columns{{"foo", "bar"}, {"hello", "world"}};
|
||||
|
||||
std::string output;
|
||||
ASSERT_OK(WideColumnSerialization::Serialize(value_of_default, other_columns,
|
||||
output));
|
||||
|
||||
Slice input(output);
|
||||
|
||||
WideColumns deserialized_columns;
|
||||
ASSERT_OK(WideColumnSerialization::Deserialize(input, deserialized_columns));
|
||||
|
||||
WideColumns expected_columns{{kDefaultWideColumnName, value_of_default},
|
||||
other_columns[0],
|
||||
other_columns[1]};
|
||||
ASSERT_EQ(deserialized_columns, expected_columns);
|
||||
}
|
||||
|
||||
TEST(WideColumnSerializationTest, SerializeDuplicateError) {
|
||||
WideColumns columns{{"foo", "bar"}, {"foo", "baz"}};
|
||||
std::string output;
|
||||
|
@ -151,16 +132,6 @@ TEST(WideColumnSerializationTest, SerializeDuplicateError) {
|
|||
WideColumnSerialization::Serialize(columns, output).IsCorruption());
|
||||
}
|
||||
|
||||
TEST(WideColumnSerializationTest, SerializeWithPrependDuplicateError) {
|
||||
Slice value_of_default("baz");
|
||||
WideColumns other_columns{{kDefaultWideColumnName, "dup"}, {"foo", "bar"}};
|
||||
|
||||
std::string output;
|
||||
ASSERT_TRUE(WideColumnSerialization::Serialize(value_of_default,
|
||||
other_columns, output)
|
||||
.IsCorruption());
|
||||
}
|
||||
|
||||
TEST(WideColumnSerializationTest, SerializeOutOfOrderError) {
|
||||
WideColumns columns{{"hello", "world"}, {"foo", "bar"}};
|
||||
std::string output;
|
||||
|
|
Loading…
Reference in New Issue