fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.2 KiB
77 lines
2.2 KiB
8 years ago
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||
7 years ago
|
// 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).
|
||
8 years ago
|
//
|
||
|
#pragma once
|
||
|
|
||
|
#include <memory>
|
||
|
|
||
5 years ago
|
#include "db/blob/blob_log_format.h"
|
||
8 years ago
|
#include "rocksdb/slice.h"
|
||
|
|
||
5 years ago
|
namespace ROCKSDB_NAMESPACE {
|
||
8 years ago
|
|
||
4 years ago
|
class RandomAccessFileReader;
|
||
|
class Env;
|
||
|
class Statistics;
|
||
|
class Status;
|
||
8 years ago
|
|
||
|
/**
|
||
4 years ago
|
* BlobLogSequentialReader is a general purpose log stream reader
|
||
|
* implementation. The actual job of reading from the device is implemented by
|
||
|
* the RandomAccessFileReader interface.
|
||
8 years ago
|
*
|
||
4 years ago
|
* Please see BlobLogWriter for details on the file and record layout.
|
||
8 years ago
|
*/
|
||
4 years ago
|
|
||
|
class BlobLogSequentialReader {
|
||
8 years ago
|
public:
|
||
|
enum ReadLevel {
|
||
7 years ago
|
kReadHeader,
|
||
|
kReadHeaderKey,
|
||
|
kReadHeaderKeyBlob,
|
||
8 years ago
|
};
|
||
|
|
||
4 years ago
|
// Create a reader that will return log records from "*file_reader".
|
||
|
BlobLogSequentialReader(std::unique_ptr<RandomAccessFileReader>&& file_reader,
|
||
|
Env* env, Statistics* statistics);
|
||
|
|
||
7 years ago
|
// No copying allowed
|
||
4 years ago
|
BlobLogSequentialReader(const BlobLogSequentialReader&) = delete;
|
||
|
BlobLogSequentialReader& operator=(const BlobLogSequentialReader&) = delete;
|
||
8 years ago
|
|
||
4 years ago
|
~BlobLogSequentialReader();
|
||
5 years ago
|
|
||
8 years ago
|
Status ReadHeader(BlobLogHeader* header);
|
||
|
|
||
|
// Read the next record into *record. Returns true if read
|
||
4 years ago
|
// successfully, false if we hit end of the input. The contents filled in
|
||
|
// *record will only be valid until the next mutating operation on this
|
||
|
// reader.
|
||
7 years ago
|
// If blob_offset is non-null, return offset of the blob through it.
|
||
7 years ago
|
Status ReadRecord(BlobLogRecord* record, ReadLevel level = kReadHeader,
|
||
7 years ago
|
uint64_t* blob_offset = nullptr);
|
||
8 years ago
|
|
||
4 years ago
|
Status ReadFooter(BlobLogFooter* footer);
|
||
|
|
||
8 years ago
|
void ResetNextByte() { next_byte_ = 0; }
|
||
|
|
||
|
uint64_t GetNextByte() const { return next_byte_; }
|
||
|
|
||
|
private:
|
||
6 years ago
|
Status ReadSlice(uint64_t size, Slice* slice, char* buf);
|
||
|
|
||
7 years ago
|
const std::unique_ptr<RandomAccessFileReader> file_;
|
||
7 years ago
|
Env* env_;
|
||
|
Statistics* statistics_;
|
||
8 years ago
|
|
||
|
Slice buffer_;
|
||
6 years ago
|
char header_buf_[BlobLogRecord::kHeaderSize];
|
||
8 years ago
|
|
||
4 years ago
|
// which byte to read next
|
||
8 years ago
|
uint64_t next_byte_;
|
||
|
};
|
||
|
|
||
5 years ago
|
} // namespace ROCKSDB_NAMESPACE
|