19 uint64_t initial_offset)
49 if (block_start_location > 0) {
51 if (!skip_status.
ok()) {
69 bool in_fragmented_record =
false;
72 uint64_t prospective_record_offset = 0;
81 uint64_t physical_record_offset =
95 switch (record_type) {
97 if (in_fragmented_record) {
102 if (scratch->empty()) {
103 in_fragmented_record =
false;
108 prospective_record_offset = physical_record_offset;
115 if (in_fragmented_record) {
120 if (scratch->empty()) {
121 in_fragmented_record =
false;
126 prospective_record_offset = physical_record_offset;
127 scratch->assign(fragment.
data(), fragment.
size());
128 in_fragmented_record =
true;
132 if (!in_fragmented_record) {
134 "missing start of fragmented record(1)");
136 scratch->append(fragment.
data(), fragment.
size());
141 if (!in_fragmented_record) {
143 "missing start of fragmented record(2)");
145 scratch->append(fragment.
data(), fragment.
size());
146 *record =
Slice(*scratch);
153 if (in_fragmented_record) {
162 if (in_fragmented_record) {
164 in_fragmented_record =
false;
171 snprintf(buf,
sizeof(buf),
"unknown record type %u", record_type);
173 (fragment.
size() + (in_fragmented_record ? scratch->size() : 0)),
175 in_fragmented_record =
false;
228 const uint32_t a =
static_cast<uint32_t
>(header[4]) & 0xff;
229 const uint32_t b =
static_cast<uint32_t
>(header[5]) & 0xff;
230 const unsigned int type = header[6];
231 const uint32_t length = a | (b << 8);
257 if (actual_crc != expected_crc) {
virtual Status Skip(uint64_t n)=0
Reader(SequentialFile *file, Reporter *reporter, bool checksum, uint64_t initial_offset)
static const int kHeaderSize
Reporter *const reporter_
uint32_t DecodeFixed32(const char *ptr)
uint32_t Unmask(uint32_t masked_crc)
static const int kBlockSize
uint64_t last_record_offset_
static Status Corruption(const Slice &msg, const Slice &msg2=Slice())
bool ReadRecord(Slice *record, std::string *scratch)
bool SkipToInitialBlock()
uint64_t end_of_buffer_offset_
SequentialFile *const file_
void remove_prefix(size_t n)
char *const backing_store_
virtual Status Read(size_t n, Slice *result, char *scratch)=0
uint32_t Value(const char *data, size_t n)
unsigned int ReadPhysicalRecord(Slice *result)
uint64_t const initial_offset_
virtual void Corruption(size_t bytes, const Status &status)=0
const char * data() const
uint64_t LastRecordOffset()
void ReportCorruption(uint64_t bytes, const char *reason)
void ReportDrop(uint64_t bytes, const Status &reason)