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/types.h"
14 ReadCallback(SequenceNumber last_visible_seq
)
15 : max_visible_seq_(last_visible_seq
) {}
16 ReadCallback(SequenceNumber last_visible_seq
, SequenceNumber min_uncommitted
)
17 : max_visible_seq_(last_visible_seq
), min_uncommitted_(min_uncommitted
) {}
19 virtual ~ReadCallback() {}
21 // Will be called to see if the seq number visible; if not it moves on to
22 // the next seq number.
23 virtual bool IsVisibleFullCheck(SequenceNumber seq
) = 0;
25 inline bool IsVisible(SequenceNumber seq
) {
26 assert(min_uncommitted_
> 0);
27 assert(min_uncommitted_
>= kMinUnCommittedSeq
);
28 if (seq
< min_uncommitted_
) { // handles seq == 0 as well
29 assert(seq
<= max_visible_seq_
);
31 } else if (max_visible_seq_
< seq
) {
35 assert(seq
!= 0); // already handled in the first if-then clause
36 return IsVisibleFullCheck(seq
);
40 inline SequenceNumber
max_visible_seq() { return max_visible_seq_
; }
42 virtual void Refresh(SequenceNumber seq
) { max_visible_seq_
= seq
; }
44 // Refer to DBIter::CanReseekToSkip
45 virtual bool CanReseekToSkip() { return true; }
48 // The max visible seq, it is usually the snapshot but could be larger if
49 // transaction has its own writes written to db.
50 SequenceNumber max_visible_seq_
= kMaxSequenceNumber
;
51 // Any seq less than min_uncommitted_ is committed.
52 const SequenceNumber min_uncommitted_
= kMinUnCommittedSeq
;
55 } // namespace rocksdb