pub struct TraceReader { /* private fields */ }Expand description
Reads the raw, still-encoded records of a trace file one at a time.
This is the low level half of tracing: it hands back the bytes RocksDB
wrote, header and footer records included, and does not decode them into
queries. Use Replayer to run a trace against a DB instead.
Reading is sequential. reset rewinds to the start of the
file.
Implementations§
Source§impl TraceReader
impl TraceReader
Sourcepub fn open<P: AsRef<Path>>(env: &Env, trace_path: P) -> Result<Self, Error>
pub fn open<P: AsRef<Path>>(env: &Env, trace_path: P) -> Result<Self, Error>
Opens an existing trace file for reading through env.
Fails if the file does not exist. Reads use a default EnvOptions. Use
open_with_env_options to control how the
file is read.
Sourcepub fn open_with_env_options<P: AsRef<Path>>(
env: &Env,
env_opts: &EnvOptions,
trace_path: P,
) -> Result<Self, Error>
pub fn open_with_env_options<P: AsRef<Path>>( env: &Env, env_opts: &EnvOptions, trace_path: P, ) -> Result<Self, Error>
Opens an existing trace file for reading through env and env_opts.
env_opts only has to live for the call. RocksDB reads the options while
opening the file and does not carry a rate limiter into the reader, so
unlike SstFileWriter::create_with_env_options there is nothing here
that outlives the borrow.
Sourcepub fn read(&mut self) -> Result<Option<Vec<u8>>, Error>
pub fn read(&mut self) -> Result<Option<Vec<u8>>, Error>
Reads the next record, or Ok(None) at the end of the file.
End of stream is unambiguous here. FileTraceReader::Read reports it as
Status::Incomplete, and rocksdb_trace_reader_read in db/c.cc
translates that specific status into a null return with no error string
set, which is the only way a successful call can produce null: a record
always carries a fixed size header, so a real record is never zero
bytes, and a short read is reported as Corruption instead. Any other
failure comes back as Err.
Returns an error if the reader has been closed, because the C++ Read
dereferences the file handle that close released
without checking it first.