예제 #1
0
파일: msg.cpp 프로젝트: MissGentoo/cascadb
bool Msg::read_from(BlockReader& reader)
{
    if (!reader.readUInt8((uint8_t*)&type)) return false;
    if (!reader.readSlice(key)) return false;
    if (type == Put) {
        if (!reader.readSlice(value)) return false;
    }
    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;
}