mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 11:43:49 +00:00
e82fe7c0b7
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/12557 Unlike for other sequence containers, the C++ standard allows moving an `std::string` to invalidate pointers/iterators/references. In practice, this happens with short strings which are stored "inline" in the `std::string` object (small string optimization). Since `PinnableSlice` uses `std::string` as its internal buffer, and `PinnableWideColumns` in turn is implemented in terms of `PinnableSlice`, this means that the default compiler-generated move operations can invalidate the column index stored in `PinnableWideColumns::columns_`. The PR fixes this by providing custom move constructor/move assignment implementations for `PinnableWideColumns` that recreate the `columns_` index upon move. Reviewed By: jaykorean Differential Revision: D56275054 fbshipit-source-id: e8648c003dbcf1c39ec122ad229780c28138e730
23 lines
648 B
C++
23 lines
648 B
C++
// 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).
|
|
|
|
#include "rocksdb/wide_columns.h"
|
|
#include "db/wide/wide_column_serialization.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
const Slice kDefaultWideColumnName;
|
|
|
|
const WideColumns kNoWideColumns;
|
|
|
|
Status PinnableWideColumns::CreateIndexForWideColumns() {
|
|
columns_.clear();
|
|
|
|
Slice value_copy = value_;
|
|
return WideColumnSerialization::Deserialize(value_copy, columns_);
|
|
}
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|