]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/blob_db/blob_log_reader.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
13 #include "file/random_access_file_reader.h"
14 #include "rocksdb/env.h"
15 #include "rocksdb/slice.h"
16 #include "rocksdb/statistics.h"
17 #include "rocksdb/status.h"
18 #include "utilities/blob_db/blob_log_format.h"
20 namespace ROCKSDB_NAMESPACE
{
22 class SequentialFileReader
;
28 * Reader is a general purpose log stream reader implementation. The actual job
29 * of reading from the device is implemented by the SequentialFile interface.
31 * Please see Writer for details on the file and record layout.
41 // Create a reader that will return log records from "*file".
42 // "*file" must remain live while this Reader is in use.
43 Reader(std::unique_ptr
<RandomAccessFileReader
>&& file_reader
, Env
* env
,
44 Statistics
* statistics
);
46 Reader(const Reader
&) = delete;
47 Reader
& operator=(const Reader
&) = delete;
51 Status
ReadHeader(BlobLogHeader
* header
);
53 // Read the next record into *record. Returns true if read
54 // successfully, false if we hit end of the input. May use
55 // "*scratch" as temporary storage. The contents filled in *record
56 // will only be valid until the next mutating operation on this
57 // reader or the next mutation to *scratch.
58 // If blob_offset is non-null, return offset of the blob through it.
59 Status
ReadRecord(BlobLogRecord
* record
, ReadLevel level
= kReadHeader
,
60 uint64_t* blob_offset
= nullptr);
62 void ResetNextByte() { next_byte_
= 0; }
64 uint64_t GetNextByte() const { return next_byte_
; }
67 Status
ReadSlice(uint64_t size
, Slice
* slice
, char* buf
);
69 const std::unique_ptr
<RandomAccessFileReader
> file_
;
71 Statistics
* statistics_
;
74 char header_buf_
[BlobLogRecord::kHeaderSize
];
76 // which byte to read next. For asserting proper usage
80 } // namespace blob_db
81 } // namespace ROCKSDB_NAMESPACE
82 #endif // ROCKSDB_LITE