bool LeafNode::read_bucket(BlockReader& reader, size_t compressed_length, size_t uncompressed_length, RecordBucket *bucket, Slice buffer) { if (tree_->compressor_) { // 1. uncompress assert(compressed_length <= reader.remain()); assert(uncompressed_length <= buffer.size()); // 1. uncompress if (!tree_->compressor_->uncompress(reader.addr(), compressed_length, (char *)buffer.data())) { return false; } reader.skip(compressed_length); // 2. deserialize Block block(buffer, 0, uncompressed_length); BlockReader rr(&block); return read_bucket(rr, bucket); } else { return read_bucket(reader, bucket); } }
bool InnerNode::read_msgbuf(BlockReader& reader, size_t compressed_length, size_t uncompressed_length, MsgBuf *mb, Slice buffer) { if (tree_->compressor_) { assert(compressed_length <= reader.remain()); assert(uncompressed_length <= buffer.size()); // 1. uncompress if (!tree_->compressor_->uncompress(reader.addr(), compressed_length, (char *)buffer.data())) { return false; } reader.skip(compressed_length); // 2. deserialize Block block(buffer, 0, uncompressed_length); BlockReader rr(&block); return mb->read_from(rr); } else { return mb->read_from(reader); } }