Exemplo n.º 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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
bool LeafNode::read_buckets_info(BlockReader& reader)
{
    uint32_t nbuckets;
    if (!reader.readUInt32(&nbuckets)) return false;
    buckets_info_.resize(nbuckets);

    buckets_info_size_ = 4;
    for (size_t i = 0; i < nbuckets; i++ ) {
        if (!reader.readSlice(buckets_info_[i].key)) return false;
        if (!reader.readUInt32(&(buckets_info_[i].offset))) return false;
        if (!reader.readUInt32(&(buckets_info_[i].length))) return false;
        if (!reader.readUInt32(&(buckets_info_[i].uncompressed_length))) return false;
        buckets_info_size_ += 4 + buckets_info_[i].key.size() + 4 + 4 + 4;
    }

    // init buckets number
    records_.set_buckets_number(nbuckets);

    status_ = kSkeletonLoaded;
    return true;
}
Exemplo n.º 4
0
bool LeafNode::read_bucket(BlockReader& reader,
                           RecordBucket *bucket)
{
    uint32_t nrecords;
    if (!reader.readUInt32(&nrecords)) return false;

    bucket->resize(nrecords);
    for (size_t i = 0; i < nrecords; i++) {
        if (!(*bucket)[i].read_from(reader)) {
            return false;
        }
    }

    return true;
}
Exemplo n.º 5
0
bool MsgBuf::read_from(BlockReader& reader)
{
    uint32_t cnt = 0;
    if (!reader.readUInt32(&cnt)) return false;
    // container_.resize(cnt);
    // for (size_t i = 0; i < cnt; i++ ) {
    //     if (!container_[i].read_from(reader)) return false;
    //     size_ += container_[i].size();
    // }
    for (size_t i = 0; i < cnt; i++ ) {
        Msg msg;
        if (!msg.read_from(reader)) return false;
        size_ += msg.size();
        container_.push_back(msg);
    }
    return true;
}
Exemplo n.º 6
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;
}