| 175 | } |
| 176 | |
| 177 | void TableBuilder::WriteRawBlock(const Slice& block_contents, |
| 178 | CompressionType type, BlockHandle* handle) { |
| 179 | Rep* r = rep_; |
| 180 | handle->set_offset(r->offset); |
| 181 | handle->set_size(block_contents.size()); |
| 182 | r->status = r->file->Append(block_contents); |
| 183 | if (r->status.ok()) { |
| 184 | char trailer[kBlockTrailerSize]; |
| 185 | trailer[0] = type; |
| 186 | uint32_t crc = crc32c::Value(block_contents.data(), block_contents.size()); |
| 187 | crc = crc32c::Extend(crc, trailer, 1); // Extend crc to cover block type |
| 188 | EncodeFixed32(trailer + 1, crc32c::Mask(crc)); |
| 189 | r->status = r->file->Append(Slice(trailer, kBlockTrailerSize)); |
| 190 | if (r->status.ok()) { |
| 191 | r->offset += block_contents.size() + kBlockTrailerSize; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | Status TableBuilder::status() const { return rep_->status; } |
| 197 |
nothing calls this directly
no test coverage detected