Example usage for org.apache.hadoop.io WritableUtils readVInt

List of usage examples for org.apache.hadoop.io WritableUtils readVInt

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableUtils readVInt.

Prototype

public static int readVInt(DataInput stream) throws IOException 

Source Link

Document

Reads a zero-compressed encoded integer from input stream and returns it.

Usage

From source file:org.apache.mrql.Bag.java

License:Apache License

/** the input serializer for Bag */
public void readFields(DataInput in) throws IOException {
    int n = WritableUtils.readVInt(in);
    mode = Modes.MATERIALIZED;/*  w  w  w. j  a  va  2s  .  c  o  m*/
    iterator = null;
    path = null;
    writer = null;
    if (content == null)
        content = new ArrayList<MRData>(n);
    else {
        content.clear();
        content.ensureCapacity(n);
    }
    ;
    for (int i = 0; i < n; i++)
        add(MRContainer.read(in));
}

From source file:org.apache.mrql.Bag.java

License:Apache License

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    int n = WritableUtils.readVInt(in);
    mode = Modes.MATERIALIZED;/*from   w  w w. jav  a  2 s.  co m*/
    iterator = null;
    path = null;
    writer = null;
    content = new ArrayList<MRData>(n);
    for (int i = 0; i < n; i++)
        add(MRContainer.read(in));
}

From source file:org.apache.mrql.MR_int.java

License:Apache License

final public static MR_int read(DataInput in) throws IOException {
    return new MR_int(WritableUtils.readVInt(in));
}

From source file:org.apache.mrql.Tuple.java

License:Apache License

final public static Tuple read(DataInput in) throws IOException {
    int n = WritableUtils.readVInt(in);
    Tuple t = new Tuple(n);
    for (short i = 0; i < n; i++)
        t.tuple[i] = MRContainer.read(in);
    return t;//w w w  .ja  v a  2s .  c  o m
}

From source file:org.apache.mrql.Tuple.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    int n = WritableUtils.readVInt(in);
    tuple = new Tuple[n];
    for (short i = 0; i < n; i++)
        tuple[i] = MRContainer.read(in);
}

From source file:org.apache.nutch.indexer.IndexDocument.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    fields.clear();//from www. jav  a2 s .  c o  m
    byte version = in.readByte();
    if (version != VERSION) {
        throw new VersionMismatchException(VERSION, version);
    }
    int size = WritableUtils.readVInt(in);
    for (int i = 0; i < size; i++) {
        String name = Text.readString(in);
        IndexField field = new IndexField();
        field.readFields(in);
        fields.put(name, field);
    }
    weight = in.readFloat();
    documentMeta.readFields(in);
}

From source file:org.apache.nutch.indexer.NutchDocument.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    byte version = in.readByte();
    if (version != VERSION) {
        throw new VersionMismatchException(VERSION, version);
    }/*  www .j  ava  2  s .  c  om*/
    int size = WritableUtils.readVInt(in);
    for (int i = 0; i < size; i++) {
        String name = Text.readString(in);
        int numValues = WritableUtils.readVInt(in);
        fields.put(name, new ArrayList<String>());
        for (int j = 0; j < numValues; j++) {
            String value = Text.readString(in);
            addFieldUnprotected(name, value);
        }
    }
    score = in.readFloat();
    documentMeta.readFields(in);
}

From source file:org.apache.nutch.scoring.ScoreDatum.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    score = in.readFloat();//from   w w  w  .j  a v  a  2 s  .com
    url = Text.readString(in);
    anchor = Text.readString(in);
    distance = WritableUtils.readVInt(in);
    metaData.clear();

    int size = WritableUtils.readVInt(in);
    for (int i = 0; i < size; i++) {
        String key = Text.readString(in);
        byte[] value = Bytes.readByteArray(in);
        metaData.put(key, value);
    }
}

From source file:org.apache.nutch.searcher.QueryParams.java

License:Apache License

@Override
public void readFields(DataInput input) throws IOException {
    metadata.readFields(input);//from www  . j  a va2 s.c  o m
    numHits = WritableUtils.readVInt(input);
    maxHitsPerDup = WritableUtils.readVInt(input);
    dedupField = WritableUtils.readString(input);
    sortField = WritableUtils.readString(input);
    reverse = input.readBoolean();
}

From source file:org.apache.phoenix.cache.aggcache.SpillManager.java

License:Apache License

/**
 * Helper method to deserialize the key part from a serialized byte array
 * @param data/*from  ww  w . j a v  a 2  s  .  c  om*/
 * @return
 * @throws IOException
 */
static ImmutableBytesPtr getKey(byte[] data) throws IOException {
    DataInputStream input = null;
    try {
        input = new DataInputStream(new ByteArrayInputStream(data));
        // key length
        int keyLength = WritableUtils.readVInt(input);
        int offset = WritableUtils.getVIntSize(keyLength);
        // key
        return new ImmutableBytesPtr(data, offset, keyLength);
    } finally {
        if (input != null) {
            input.close();
            input = null;
        }
    }
}