diff options
author | dgrogan@chromium.org <dgrogan@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-05-21 02:17:43 +0000 |
---|---|---|
committer | dgrogan@chromium.org <dgrogan@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-05-21 02:17:43 +0000 |
commit | da7990950787257cb312ca562ce5977749afc3e9 (patch) | |
tree | 91fe98f6e14e74c794392b22105a47a58499edff /db/log_reader.h | |
parent | 3c111335a760d8d82414b91a54f740df09dd4f8f (diff) |
sync with upstream @ 21409451
Check the NEWS file for details of what changed.
git-svn-id: https://leveldb.googlecode.com/svn/trunk@28 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'db/log_reader.h')
-rw-r--r-- | db/log_reader.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/db/log_reader.h b/db/log_reader.h index baf147560..61cc41496 100644 --- a/db/log_reader.h +++ b/db/log_reader.h @@ -5,6 +5,8 @@ #ifndef STORAGE_LEVELDB_DB_LOG_READER_H_ #define STORAGE_LEVELDB_DB_LOG_READER_H_ +#include <stdint.h> + #include "db/log_format.h" #include "leveldb/slice.h" #include "leveldb/status.h" @@ -35,7 +37,11 @@ class Reader { // live while this Reader is in use. // // If "checksum" is true, verify checksums if available. - Reader(SequentialFile* file, Reporter* reporter, bool checksum); + // + // The Reader will start reading at the first record located at physical + // position >= initial_offset within the file. + Reader(SequentialFile* file, Reporter* reporter, bool checksum, + uint64_t initial_offset); ~Reader(); @@ -46,6 +52,11 @@ class Reader { // reader or the next mutation to *scratch. bool ReadRecord(Slice* record, std::string* scratch); + // Returns the physical offset of the last record returned by ReadRecord. + // + // Undefined before the first call to ReadRecord. + uint64_t LastRecordOffset(); + private: SequentialFile* const file_; Reporter* const reporter_; @@ -54,15 +65,37 @@ class Reader { Slice buffer_; bool eof_; // Last Read() indicated EOF by returning < kBlockSize + // Offset of the last record returned by ReadRecord. + uint64_t last_record_offset_; + // Offset of the first location past the end of buffer_. + uint64_t end_of_buffer_offset_; + + // Offset at which to start looking for the first record to return + uint64_t const initial_offset_; + // Extend record types with the following special values enum { kEof = kMaxRecordType + 1, + // Returned whenever we find an invalid physical record. + // Currently there are three situations in which this happens: + // * The record has an invalid CRC (ReadPhysicalRecord reports a drop) + // * The record is a 0-length record (No drop is reported) + // * The record is below constructor's initial_offset (No drop is reported) kBadRecord = kMaxRecordType + 2 }; + // Skips all blocks that are completely before "initial_offset_". + // + // Returns true on success. Handles reporting. + bool SkipToInitialBlock(); + // Return type, or one of the preceding special values unsigned int ReadPhysicalRecord(Slice* result); - void ReportDrop(size_t bytes, const char* reason); + + // Reports dropped bytes to the reporter. + // buffer_ must be updated to remove the dropped bytes prior to invocation. + void ReportCorruption(size_t bytes, const char* reason); + void ReportDrop(size_t bytes, const Status& reason); // No copying allowed Reader(const Reader&); |