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.terrier.structures.postings.FieldPostingImpl.java

License:Mozilla Public License

/** {@inheritDoc} */
@Override//w  ww . j  ava2  s  .  co m
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    final int l = WritableUtils.readVInt(in);
    fieldFrequencies = new int[l];
    for (int i = 0; i < l; i++)
        fieldFrequencies[i] = WritableUtils.readVInt(in);
}

From source file:org.terrier.structures.postings.PostingIdComparator.java

License:Mozilla Public License

/** Decode Writable postings and compare by id */
public int compare(byte[] arg0, int arg1, int arg2, byte[] arg3, int arg4, int arg5) {
    try {//  w w w  .  ja v  a  2 s.  c o m
        DataInputStream di1 = new DataInputStream(new ByteArrayInputStream(arg0, arg1, arg2));
        DataInputStream di2 = new DataInputStream(new ByteArrayInputStream(arg3, arg4, arg5));
        return WritableUtils.readVInt(di1) - WritableUtils.readVInt(di2);
    } catch (Exception e) {
        return 0;
    }
}

From source file:org.testies.RelativeKey.java

License:Apache License

private void read(DataInput in, MByteSequence mbseq) throws IOException {
    int len = WritableUtils.readVInt(in);
    read(in, mbseq, len);
}

From source file:org.testies.RelativeKey.java

License:Apache License

private byte[] read(DataInput in) throws IOException {
    int len = WritableUtils.readVInt(in);
    byte[] data = new byte[len];
    in.readFully(data);//from  w w w .j  a va2s . c  om
    return data;
}

From source file:parquet.hive.writable.BigDecimalWritable.java

License:Apache License

@Override
public void readFields(final DataInput in) throws IOException {
    scale = WritableUtils.readVInt(in);
    final int byteArrayLen = WritableUtils.readVInt(in);
    if (internalStorage.length != byteArrayLen) {
        internalStorage = new byte[byteArrayLen];
    }//w  ww.  jav a 2s. c  o m
    in.readFully(internalStorage);
}

From source file:redpoll.text.OpenBitSetWritable.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    int wordsNum = WritableUtils.readVInt(in);
    long[] bits = new long[wordsNum];
    for (int i = 0; i < wordsNum; i++) {
        bits[i] = in.readLong();//from   w ww. j  a va  2 s  .com
    }
}

From source file:redpoll.text.TfWritable.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    documentId.readFields(in);
    tf.set(WritableUtils.readVInt(in));
}

From source file:uk.ac.cam.eng.extraction.hadoop.datatypes.FeatureMap.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    instance.clear();/*from w ww .j a va2 s  .co  m*/
    int length = WritableUtils.readVInt(in);
    for (int i = 0; i < length; ++i) {
        int key = WritableUtils.readVInt(in);
        double value = in.readDouble();
        put(key, value);
    }

}

From source file:uk.ac.cam.eng.extraction.hadoop.datatypes.TargetFeatureList.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    instance.clear();/*from  w w  w. j  a v  a 2s  .  co  m*/
    int size = WritableUtils.readVInt(in);
    for (int i = 0; i < size; ++i) {
        Text target = new Text();
        target.readFields(in);
        AlignmentAndFeatureMap alignmentAndFeatures = new AlignmentAndFeatureMap();
        alignmentAndFeatures.readFields(in);
        instance.add(Pair.createPair(target, alignmentAndFeatures));
    }
}