namespace rocksdb {
-// Callback class that control GC of duplicate keys in flush/compaction
+enum class SnapshotCheckerResult : int {
+ kInSnapshot = 0,
+ kNotInSnapshot = 1,
+ // In case snapshot is released and the checker has no clue whether
+ // the given sequence is visible to the snapshot.
+ kSnapshotReleased = 2,
+};
+
+// Callback class that control GC of duplicate keys in flush/compaction.
class SnapshotChecker {
public:
virtual ~SnapshotChecker() {}
- virtual bool IsInSnapshot(SequenceNumber sequence,
- SequenceNumber snapshot_sequence) const = 0;
+ virtual SnapshotCheckerResult CheckInSnapshot(
+ SequenceNumber sequence, SequenceNumber snapshot_sequence) const = 0;
};
class DisableGCSnapshotChecker : public SnapshotChecker {
public:
virtual ~DisableGCSnapshotChecker() {}
- virtual bool IsInSnapshot(
+ virtual SnapshotCheckerResult CheckInSnapshot(
SequenceNumber /*sequence*/,
SequenceNumber /*snapshot_sequence*/) const override {
- // By returning false, we prevent all the values from being GCed
- return false;
+ // By returning kNotInSnapshot, we prevent all the values from being GCed
+ return SnapshotCheckerResult::kNotInSnapshot;
}
static DisableGCSnapshotChecker* Instance() { return &instance_; }
explicit WritePreparedSnapshotChecker(WritePreparedTxnDB* txn_db);
virtual ~WritePreparedSnapshotChecker() {}
- virtual bool IsInSnapshot(SequenceNumber sequence,
- SequenceNumber snapshot_sequence) const override;
+ virtual SnapshotCheckerResult CheckInSnapshot(
+ SequenceNumber sequence, SequenceNumber snapshot_sequence) const override;
private:
#ifndef ROCKSDB_LITE