Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
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;
}
Ejemplo 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;
}