/Users/deen/code/yugabyte-db/src/yb/rocksdb/db/db_iterator_wrapper.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) Yugabyte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | |
13 | | #include "yb/rocksdb/db/db_iterator_wrapper.h" |
14 | | |
15 | | #include "yb/util/bytes_formatter.h" |
16 | | #include "yb/util/logging.h" |
17 | | |
18 | | using yb::FormatSliceAsStr; |
19 | | using yb::Format; |
20 | | |
21 | | namespace rocksdb { |
22 | | |
23 | | template<typename Functor> |
24 | | void TransitionLoggingIteratorWrapper::LogBeforeAndAfter( |
25 | 0 | const std::string& action_str, const Functor& action) { |
26 | 0 | std::string before = StateStr(); |
27 | 0 | action(); |
28 | 0 | std::string after = StateStr(); |
29 | 0 | if (before == after) { |
30 | 0 | LOG_WITH_PREFIX(INFO) << action_str << ": state not changed: " << before; |
31 | 0 | } else { |
32 | 0 | LOG_WITH_PREFIX(INFO) << action_str << ": before=" << before << ", after=" << after; |
33 | 0 | } |
34 | 0 | } Unexecuted instantiation: db_iterator_wrapper.cc:void rocksdb::TransitionLoggingIteratorWrapper::LogBeforeAndAfter<rocksdb::TransitionLoggingIteratorWrapper::SeekToFirst()::$_0>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::TransitionLoggingIteratorWrapper::SeekToFirst()::$_0 const&) Unexecuted instantiation: db_iterator_wrapper.cc:void rocksdb::TransitionLoggingIteratorWrapper::LogBeforeAndAfter<rocksdb::TransitionLoggingIteratorWrapper::SeekToLast()::$_1>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::TransitionLoggingIteratorWrapper::SeekToLast()::$_1 const&) Unexecuted instantiation: db_iterator_wrapper.cc:void rocksdb::TransitionLoggingIteratorWrapper::LogBeforeAndAfter<rocksdb::TransitionLoggingIteratorWrapper::Seek(yb::Slice const&)::$_2>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::TransitionLoggingIteratorWrapper::Seek(yb::Slice const&)::$_2 const&) Unexecuted instantiation: db_iterator_wrapper.cc:void rocksdb::TransitionLoggingIteratorWrapper::LogBeforeAndAfter<rocksdb::TransitionLoggingIteratorWrapper::Next()::$_3>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::TransitionLoggingIteratorWrapper::Next()::$_3 const&) Unexecuted instantiation: db_iterator_wrapper.cc:void rocksdb::TransitionLoggingIteratorWrapper::LogBeforeAndAfter<rocksdb::TransitionLoggingIteratorWrapper::Prev()::$_4>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::TransitionLoggingIteratorWrapper::Prev()::$_4 const&) |
35 | | |
36 | 0 | void TransitionLoggingIteratorWrapper::SeekToFirst() { |
37 | 0 | LogBeforeAndAfter(__func__, [this]() { DBIteratorWrapper::SeekToFirst(); }); |
38 | 0 | } |
39 | | |
40 | 0 | void TransitionLoggingIteratorWrapper::SeekToLast() { |
41 | 0 | LogBeforeAndAfter(__func__, [this]() { DBIteratorWrapper::SeekToLast(); }); |
42 | 0 | } |
43 | | |
44 | 0 | void TransitionLoggingIteratorWrapper::Seek(const Slice& target) { |
45 | 0 | LogBeforeAndAfter( |
46 | 0 | Format("Seek($0)", target.ToDebugString()), |
47 | 0 | [this, target]() { DBIteratorWrapper::Seek(target); }); |
48 | 0 | } |
49 | | |
50 | 0 | void TransitionLoggingIteratorWrapper::Next() { |
51 | 0 | LogBeforeAndAfter(__func__, [this]() { DBIteratorWrapper::Next(); }); |
52 | 0 | } |
53 | | |
54 | 0 | void TransitionLoggingIteratorWrapper::Prev() { |
55 | 0 | LogBeforeAndAfter(__func__, [this]() { DBIteratorWrapper::Prev(); }); |
56 | 0 | } |
57 | | |
58 | 0 | std::string TransitionLoggingIteratorWrapper::LogPrefix() const { |
59 | 0 | return StringPrintf("%sIter %p ", rocksdb_log_prefix_.c_str(), wrapped_.get()); |
60 | 0 | } |
61 | | |
62 | 0 | std::string TransitionLoggingIteratorWrapper::StateStr() const { |
63 | 0 | if (!Valid()) { |
64 | 0 | return "<Invalid>"; |
65 | 0 | } |
66 | 0 | return Format("{ key: $0 value $1 }", key().ToDebugString(), value().ToDebugString()); |
67 | 0 | } |
68 | | |
69 | | } // namespace rocksdb |