]>
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 ReadRangeDelAggregator
range_del_agg(&icmp
,
23 kMaxSequenceNumber
/* upper_bound */);
25 ScopedArenaIterator
iter(
26 idb
->NewInternalIterator(&arena
, &range_del_agg
, kMaxSequenceNumber
));
28 if (!begin_key
.empty()) {
30 ikey
.SetMinPossibleForUserKey(begin_key
);
31 iter
->Seek(ikey
.Encode());
37 for (; iter
->Valid(); iter
->Next()) {
38 ParsedInternalKey ikey
;
39 if (!ParseInternalKey(iter
->key(), &ikey
)) {
40 return Status::Corruption("Internal Key [" + iter
->key().ToString() +
44 if (!end_key
.empty() &&
45 icmp
.user_comparator()->Compare(ikey
.user_key
, end_key
) > 0) {
49 key_versions
->emplace_back(ikey
.user_key
.ToString() /* _user_key */,
50 iter
->value().ToString() /* _value */,
51 ikey
.sequence
/* _sequence */,
52 static_cast<int>(ikey
.type
) /* _type */);
53 if (++num_keys
>= max_num_ikeys
) {
60 } // namespace rocksdb
62 #endif // ROCKSDB_LITE