6#include "roo_collections/flat_small_hash_set.h"
7#include "roo_io/data/multipass_input_stream_reader.h"
8#include "roo_io/data/output_stream_writer.h"
9#include "roo_io/fs/filesystem.h"
23 uint16_t
value()
const {
return value_; }
39 : fs_(fs), log_dir_(log_dir), synced_(false) {}
44 entries_.insert(entry);
50 entries_.erase(entry);
54 std::vector<int64_t>
list();
59 roo_io::Filesystem& fs_;
63 roo_collections::FlatSmallHashSet<int64_t> entries_;
76 bool is_open()
const {
return reader_.isOpen(); }
79 void close() { reader_.close(); }
85 bool next(int64_t* timestamp, std::vector<LogSample>* data,
bool is_hot);
89 roo_io::MultipassInputStreamReader reader_;
90 uint8_t lookahead_entry_type_;
104 int64_t
file()
const {
return file_; }
118 Resolution resolution, int64_t hot_file = -1);
135 bool nextSample(int64_t* timestamp, std::vector<LogSample>* data);
138 bool open(int64_t file, uint64_t position);
141 const char* log_dir_;
144 std::vector<int64_t> entries_;
145 std::vector<int64_t>::const_iterator group_begin_;
146 std::vector<int64_t>::const_iterator cursor_;
147 std::vector<int64_t>::const_iterator group_end_;
149 bool reached_hot_file_;
150 int64_t range_floor_;
166 void open(roo_io::FileUpdatePolicy update_policy);
171 void write(int64_t timestamp, uint64_t stream_id, uint16_t datum);
180 const char* log_dir_;
184 roo_io::Filesystem& fs_;
185 roo_io::Mount mount_;
186 roo_io::OutputStreamWriter writer_;
190 roo_collections::FlatSmallHashSet<uint64_t> streams_;
192 int64_t first_timestamp_;
193 int64_t last_timestamp_;
In-memory cache of log directory entries.
void insert(int64_t entry)
Inserts an entry into the cache.
void erase(int64_t entry)
Removes an entry from the cache.
std::vector< int64_t > list()
Returns the cached entries sorted by timestamp.
CachedLogDir(roo_io::Filesystem &fs, const char *log_dir)
Creates a cache for a specific filesystem and log directory.
Cursor used when seeking through multiple log files.
int64_t file() const
Returns the file timestamp associated with the cursor.
LogCursor()
Creates a cursor at the start of the log sequence.
LogCursor(int64_t file, int64_t position)
Creates a cursor for a specific file and position.
int64_t position() const
Returns the byte position within the file.
Reader for a single log file.
void close()
Closes the reader.
int64_t checkpoint() const
Returns the current checkpoint position.
bool next(int64_t *timestamp, std::vector< LogSample > *data, bool is_hot)
Reads the next entry from the file.
bool is_open() const
Returns true if a file is currently open.
LogFileReader(roo_io::Mount &mount)
Creates a reader over the specified mount.
bool open(const char *path, int64_t checkpoint)
Opens the log file at path and seeks to checkpoint.
Reader that walks across a sequence of log files.
LogCursor tell()
Returns the current cursor.
bool seek(LogCursor cursor)
Seeks to the specified cursor.
int64_t range_floor() const
Returns the lower bound of the current range.
bool nextSample(int64_t *timestamp, std::vector< LogSample > *data)
Reads the next sample in the current range.
bool isHotRange()
Returns true if the current range is hot (still being written).
bool nextRange()
Advances to the next time range.
void deleteRange()
Deletes the current range files.
Sample stored in log files before compaction.
LogSample(uint64_t stream_id, uint16_t value)
Creates a log sample for a stream/value pair.
uint64_t stream_id() const
Returns the stream identifier.
uint16_t value() const
Returns the encoded sample value.
Writer for log files at a fixed resolution.
int64_t first_timestamp() const
Returns the first timestamp recorded in the current file.
void open(roo_io::FileUpdatePolicy update_policy)
Opens the log file according to the update policy.
void write(int64_t timestamp, uint64_t stream_id, uint16_t datum)
Writes a single log sample.
void close()
Closes the log file.
Resolution resolution() const
Returns the resolution used for this writer.
bool can_skip_write(int64_t timestamp, uint64_t stream_id)
Returns true if a write can be skipped for this bucket.
Umbrella header for the roo_monitoring module.
Resolution
Time resolution used for log and vault files.
bool operator<(const LogSample &a, const LogSample &b)