Пример #1
0
bool InnerNode::read_from(BlockReader& reader, bool skeleton_only)
{
    if (!reader.readBool(&bottom_)) return false;

    uint32_t pn;
    if (!reader.readUInt32(&pn)) return false;

    pivots_.resize(pn);

    if (!reader.readUInt64(&first_child_)) return false;
    if (!reader.readUInt32(&first_msgbuf_offset_)) return false;
    if (!reader.readUInt32(&first_msgbuf_length_)) return false;
    if (!reader.readUInt32(&first_msgbuf_uncompressed_length_)) return false;

    for (size_t i = 0; i < pn; i++) {
        if (!reader.readSlice(pivots_[i].key)) return false;
        pivots_sz_ += pivot_size(pivots_[i].key);
        if (!reader.readUInt64(&(pivots_[i].child))) return false;
        pivots_[i].msgbuf = NULL; // unloaded
        if (!reader.readUInt32(&(pivots_[i].offset))) return false;
        if (!reader.readUInt32(&(pivots_[i].length))) return false;
        if (!reader.readUInt32(&(pivots_[i].uncompressed_length))) return false;
    }

    if (!skeleton_only) {
        if (!load_all_msgbuf(reader)) return false;
    } else {
        status_ = kSkeletonLoaded;
    }

    return true;
}
Пример #2
0
bool SchemaNode::read_from(BlockReader& reader, bool skeleton_only)
{
    if (!reader.readUInt64(&root_node_id)) return false;
    if (!reader.readUInt64(&next_inner_node_id)) return false;
    if (!reader.readUInt64(&next_leaf_node_id)) return false;
    if (!reader.readUInt64(&tree_depth)) return false;

    return true;
}
Пример #3
0
bool Layout::read_block_meta(BlockMeta* meta, BlockReader& reader)
{
    if (!reader.readUInt64(&(meta->offset))) return false;
    if (!reader.readUInt32(&(meta->skeleton_size))) return false;
    if (!reader.readUInt32(&(meta->total_size))) return false;
    if (!reader.readUInt16(&(meta->crc))) return false;
    return true;
}
Пример #4
0
bool LeafNode::read_from(BlockReader& reader, bool skeleton_only)
{
    if (!reader.readUInt64(&left_sibling_)) return false;
    if (!reader.readUInt64(&right_sibling_)) return false;

    if (!read_buckets_info(reader)) {
        LOG_ERROR("read buckets info error, nid " << nid_);
        return false;
    }

    if (!skeleton_only) {
        if (!load_all_buckets(reader)) {
            LOG_ERROR("read all records bucket error, nid " << nid_);
            return false;
        }
    }
    return true;
}
Пример #5
0
bool Layout::read_superblock(BlockReader& reader)
{
    if (!reader.readUInt64(&(superblock_->magic_number0))) return false;
    if (!reader.readUInt8(&(superblock_->major_version))) return false;
    if (!reader.readUInt8(&(superblock_->minor_version))) return false;

    bool has_index_block_meta;
    if (!reader.readBool(&has_index_block_meta)) return false;
    if (has_index_block_meta) {
        superblock_->index_block_meta = new BlockMeta();
        if (!read_block_meta(superblock_->index_block_meta, reader)) return false;
    }

    if (!reader.readUInt64(&(superblock_->magic_number1))) return false;
    if (superblock_->magic_number0 != SUPER_BLOCK_MAGIC_NUM ||
            superblock_->magic_number0 != superblock_->magic_number1) {
         LOG_ERROR("read superblock " "magic_num0:"<< superblock_->magic_number0 
                  << ", magic_num1:" <<  superblock_->magic_number1);
         return false;
    }
    return true;
}
Пример #6
0
bool Layout::read_superblock(BlockReader& reader)
{
    if (!reader.readUInt64(&(superblock_->magic_number))) return false;
    if (!reader.readUInt8(&(superblock_->major_version))) return false;
    if (!reader.readUInt8(&(superblock_->minor_version))) return false;

    bool has_index_block_meta;
    if (!reader.readBool(&has_index_block_meta)) return false;
    if (has_index_block_meta) {
        superblock_->index_block_meta = new BlockMeta();
        if (!read_block_meta(superblock_->index_block_meta, reader)) return false;
    }

    if (!reader.readUInt16(&(superblock_->crc))) return false;
    return true;
}
Пример #7
0
bool Layout::read_index(BlockReader& reader)
{
    ScopedMutex block_index_lock(&block_index_mtx_);
    assert(block_index_.size() == 0);

    uint32_t n;
    if (!reader.readUInt32(&n)) return false;
    for (uint32_t i = 0; i < n; i++ ) {
        bid_t bid;
        BlockMeta* meta = new BlockMeta();
        if (reader.readUInt64(&bid) && read_block_meta(meta, reader)) {
            block_index_[bid] = meta;
            continue;
        }
        delete meta;
        return false;
    }
    return true;
}