2018-08-01 09:14:43 +02:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "rocksdb/trace_reader_writer.h"
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2018-08-01 09:14:43 +02:00
|
|
|
|
|
|
|
class RandomAccessFileReader;
|
|
|
|
class WritableFileWriter;
|
|
|
|
|
|
|
|
// FileTraceReader allows reading RocksDB traces from a file.
|
|
|
|
class FileTraceReader : public TraceReader {
|
|
|
|
public:
|
|
|
|
explicit FileTraceReader(std::unique_ptr<RandomAccessFileReader>&& reader);
|
|
|
|
~FileTraceReader();
|
|
|
|
|
|
|
|
virtual Status Read(std::string* data) override;
|
|
|
|
virtual Status Close() override;
|
2021-08-12 04:31:44 +02:00
|
|
|
virtual Status Reset() override;
|
2018-08-01 09:14:43 +02:00
|
|
|
|
|
|
|
private:
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<RandomAccessFileReader> file_reader_;
|
2018-08-01 09:14:43 +02:00
|
|
|
Slice result_;
|
|
|
|
size_t offset_;
|
|
|
|
char* const buffer_;
|
|
|
|
|
|
|
|
static const unsigned int kBufferSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
// FileTraceWriter allows writing RocksDB traces to a file.
|
|
|
|
class FileTraceWriter : public TraceWriter {
|
|
|
|
public:
|
2021-09-10 18:59:05 +02:00
|
|
|
explicit FileTraceWriter(std::unique_ptr<WritableFileWriter>&& file_writer);
|
2018-08-01 09:14:43 +02:00
|
|
|
~FileTraceWriter();
|
|
|
|
|
|
|
|
virtual Status Write(const Slice& data) override;
|
|
|
|
virtual Status Close() override;
|
2018-11-27 23:24:24 +01:00
|
|
|
virtual uint64_t GetFileSize() override;
|
2018-08-01 09:14:43 +02:00
|
|
|
|
|
|
|
private:
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<WritableFileWriter> file_writer_;
|
2018-08-01 09:14:43 +02:00
|
|
|
};
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|