예제 #1
0
파일: node.cpp 프로젝트: jameswei/cascadb
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
파일: layout.cpp 프로젝트: jameswei/cascadb
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;
}
예제 #3
0
파일: layout.cpp 프로젝트: wareseeker/wath
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;
}