40 if (offset_in_block > kBlockSize - 6) {
42 block_start_location += kBlockSize;
48 if (block_start_location > 0) {
50 if (!skip_status.
ok()) {
68 bool in_fragmented_record =
false;
71 uint64_t prospective_record_offset = 0;
77 switch (record_type) {
79 if (in_fragmented_record) {
84 if (scratch->empty()) {
85 in_fragmented_record =
false;
90 prospective_record_offset = physical_record_offset;
97 if (in_fragmented_record) {
102 if (scratch->empty()) {
103 in_fragmented_record =
false;
108 prospective_record_offset = physical_record_offset;
109 scratch->assign(fragment.
data(), fragment.
size());
110 in_fragmented_record =
true;
114 if (!in_fragmented_record) {
116 "missing start of fragmented record(1)");
118 scratch->append(fragment.
data(), fragment.
size());
123 if (!in_fragmented_record) {
125 "missing start of fragmented record(2)");
127 scratch->append(fragment.
data(), fragment.
size());
128 *record =
Slice(*scratch);
135 if (in_fragmented_record) {
142 if (in_fragmented_record) {
144 in_fragmented_record =
false;
151 snprintf(buf,
sizeof(buf),
"unknown record type %u", record_type);
153 (fragment.
size() + (in_fragmented_record ? scratch->size() : 0)),
155 in_fragmented_record =
false;
211 const unsigned int type = header[6];
212 const uint32_t length = a | (b << 8);
232 if (actual_crc != expected_crc) {
253 *result =
Slice(header + kHeaderSize, length);
bool ReadRecord(Slice *record, std::string *scratch)
const char * data() const
uint64_t LastRecordOffset()
void ReportCorruption(size_t bytes, const char *reason)
static Status Corruption(const Slice &msg, const Slice &msg2=Slice())
SequentialFile *const file_
unsigned int ReadPhysicalRecord(Slice *result)
uint32_t DecodeFixed32(const char *ptr)
uint32_t Unmask(uint32_t masked_crc)
uint64_t last_record_offset_
virtual void Corruption(size_t bytes, const Status &status)=0
void remove_prefix(size_t n)
Reporter *const reporter_
virtual Status Skip(uint64_t n)=0
char *const backing_store_
unsigned long long uint64_t
Reader(SequentialFile *file, Reporter *reporter, bool checksum, uint64_t initial_offset)
virtual Status Read(size_t n, Slice *result, char *scratch)=0
uint32_t Value(const char *data, size_t n)
uint64_t end_of_buffer_offset_
bool SkipToInitialBlock()
uint64_t const initial_offset_
void ReportDrop(size_t bytes, const Status &reason)