]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/debug.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
8 #include "rocksdb/utilities/debug.h"
10 #include "db/db_impl.h"
14 Status
GetAllKeyVersions(DB
* db
, Slice begin_key
, Slice end_key
,
16 std::vector
<KeyVersion
>* key_versions
) {
17 assert(key_versions
!= nullptr);
18 key_versions
->clear();
20 DBImpl
* idb
= static_cast<DBImpl
*>(db
->GetRootDB());
21 auto icmp
= InternalKeyComparator(idb
->GetOptions().comparator
);
22 RangeDelAggregator
range_del_agg(icmp
, {} /* snapshots */);
24 ScopedArenaIterator
iter(idb
->NewInternalIterator(&arena
, &range_del_agg
));
26 if (!begin_key
.empty()) {
28 ikey
.SetMinPossibleForUserKey(begin_key
);
29 iter
->Seek(ikey
.Encode());
35 for (; iter
->Valid(); iter
->Next()) {
36 ParsedInternalKey ikey
;
37 if (!ParseInternalKey(iter
->key(), &ikey
)) {
38 return Status::Corruption("Internal Key [" + iter
->key().ToString() +
42 if (!end_key
.empty() &&
43 icmp
.user_comparator()->Compare(ikey
.user_key
, end_key
) > 0) {
47 key_versions
->emplace_back(ikey
.user_key
.ToString() /* _user_key */,
48 iter
->value().ToString() /* _value */,
49 ikey
.sequence
/* _sequence */,
50 static_cast<int>(ikey
.type
) /* _type */);
51 if (++num_keys
>= max_num_ikeys
) {
58 } // namespace rocksdb
60 #endif // ROCKSDB_LITE