#pragma once
+#include <chrono>
#include <memory>
#include <string>
#include <unordered_map>
Status status;
};
+struct FileOperationInfo {
+ using TimePoint = std::chrono::time_point<std::chrono::system_clock,
+ std::chrono::nanoseconds>;
+
+ const std::string& path;
+ uint64_t offset;
+ size_t length;
+ const TimePoint& start_timestamp;
+ const TimePoint& finish_timestamp;
+ Status status;
+ FileOperationInfo(const std::string& _path, const TimePoint& start,
+ const TimePoint& finish)
+ : path(_path), start_timestamp(start), finish_timestamp(finish) {}
+};
+
struct FlushJobInfo {
+ // the id of the column family
+ uint32_t cf_id;
// the name of the column family
std::string cf_name;
// the path to the newly created file
struct CompactionJobInfo {
CompactionJobInfo() = default;
- explicit CompactionJobInfo(const CompactionJobStats& _stats) :
- stats(_stats) {}
+ explicit CompactionJobInfo(const CompactionJobStats& _stats)
+ : stats(_stats) {}
+ // the id of the column family where the compaction happened.
+ uint32_t cf_id;
// the name of the column family where the compaction happened.
std::string cf_name;
// the status indicating whether the compaction was successful or not.
uint64_t num_entries;
// Total number of deletes in memtable
uint64_t num_deletes;
-
};
struct ExternalFileIngestionInfo {
// returned value.
virtual void OnTableFileDeleted(const TableFileDeletionInfo& /*info*/) {}
+ // A callback function to RocksDB which will be called before a
+ // RocksDB starts to compact. The default implementation is
+ // no-op.
+ //
+ // Note that the this function must be implemented in a way such that
+ // it should not run for an extended period of time before the function
+ // returns. Otherwise, RocksDB may be blocked.
+ virtual void OnCompactionBegin(DB* /*db*/, const CompactionJobInfo& /*ci*/) {}
+
// A callback function for RocksDB which will be called whenever
// a registered RocksDB compacts a file. The default implementation
// is a no-op.
// Note that if applications would like to use the passed reference
// outside this function call, they should make copies from these
// returned value.
- virtual void OnMemTableSealed(
- const MemTableInfo& /*info*/) {}
+ virtual void OnMemTableSealed(const MemTableInfo& /*info*/) {}
// A callback function for RocksDB which will be called before
// a column family handle is deleted.
// returns. Otherwise, RocksDB may be blocked.
virtual void OnStallConditionsChanged(const WriteStallInfo& /*info*/) {}
+ // A callback function for RocksDB which will be called whenever a file read
+ // operation finishes.
+ virtual void OnFileReadFinish(const FileOperationInfo& /* info */) {}
+
+ // A callback function for RocksDB which will be called whenever a file write
+ // operation finishes.
+ virtual void OnFileWriteFinish(const FileOperationInfo& /* info */) {}
+
+ // If true, the OnFileReadFinish and OnFileWriteFinish will be called. If
+ // false, then they won't be called.
+ virtual bool ShouldBeNotifiedOnFileIO() { return false; }
+
// A callback function for RocksDB which will be called just before
// starting the automatic recovery process for recoverable background
// errors, such as NoSpace(). The callback can suppress the automatic
#else
-class EventListener {
-};
+class EventListener {};
#endif // ROCKSDB_LITE