Example usage for java.io DataInput readInt

List of usage examples for java.io DataInput readInt

Introduction

In this page you can find the example usage for java.io DataInput readInt.

Prototype

int readInt() throws IOException;

Source Link

Document

Reads four input bytes and returns an int value.

Usage

From source file:com.marklogic.mapreduce.DatabaseDocument.java

@Override
public void readFields(DataInput in) throws IOException {
    int ordinal = in.readInt();
    contentType = ContentType.valueOf(ordinal);
    int length = WritableUtils.readVInt(in);
    content = new byte[length];
    in.readFully(content, 0, length);/*from w  ww . j  a  v a  2s.c om*/
}

From source file:cn.ac.ict.htc.tools.ArrayListWritable.java

/**
 * Deserializes the array.//from   w w w . j a  v  a 2  s .c o m
 *
 * @param in source for raw byte representation
 */
@SuppressWarnings("unchecked")
public void readFields(DataInput in) throws IOException {
    this.clear();

    int numFields = in.readInt();
    if (numFields == 0)
        return;
    String className = in.readUTF();
    E obj;
    try {
        Class<E> c = (Class<E>) Class.forName(className);
        for (int i = 0; i < numFields; i++) {
            obj = (E) c.newInstance();
            obj.readFields(in);
            this.add(obj);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.kylinolap.dict.lookup.SnapshotTable.java

void readData(DataInput in) throws IOException {
    int rowNum = in.readInt();
    rows = new ArrayList<String[]>(rowNum);
    if (rowNum > 0) {
        int n = in.readInt();
        for (int i = 0; i < rowNum; i++) {
            String[] row = new String[n];
            rows.add(row);//from  w  w  w.  j  av a 2  s .c o m
            for (int j = 0; j < n; j++) {
                row[j] = in.readUTF();
            }
        }
    }
}

From source file:org.kiji.schema.mapreduce.KijiIncrement.java

/** {@inheritDoc} */
@Override//from ww  w  .j av  a  2  s.c  o  m
public void readFields(DataInput in) throws IOException {
    // EntityId.
    final byte[] bytes = new byte[in.readInt()];
    in.readFully(bytes);
    mEntityId = new RawEntityId(bytes);

    // Family/Qualifier/Timestamp.
    mFamily = in.readUTF();
    mQualifier = in.readUTF();
    mAmount = in.readLong();
}

From source file:org.apache.hadoop.hbase.index.IndexedHTableDescriptor.java

/**
 * @param DataInput stream//from  w ww.  j  ava  2  s . c o  m
 * @throws IOException
 */
public void readFields(DataInput in) throws IOException {
    try {
        super.readFields(in);
        int indicesSize = in.readInt();
        indices.clear();
        for (int i = 0; i < indicesSize; i++) {
            IndexSpecification is = new IndexSpecification();
            is.readFields(in);
            this.indices.add(is);
        }
    } catch (EOFException e) {
        LOG.warn("Error reading feilds from the descriptor " + this.getNameAsString());
        throw e;
    }

}

From source file:org.apache.hadoop.hbase.filter.RowListFilter.java

@Override
public void readFields(DataInput din) throws IOException {
    int pos = din.readInt();
    int sz = din.readInt();
    this.bytesSet = new ArrayList<byte[]>(sz);
    for (int i = 0; i < sz; ++i) {
        short bsz = din.readShort();
        byte[] b = new byte[bsz];
        din.readFully(b);/* ww  w  .j  av  a 2s . c om*/
        bytesSet.add(b);
    }
    log.debug("Size of bytesSet is: " + bytesSet.size());
    this.bytesSetIterator = bytesSet.listIterator(pos);
    if (bytesSetIterator.hasNext()) {
        this.rowComparator = new BinaryComparator(bytesSetIterator.next());
    } else {
        this.hasMoreRows = false;
    }
}

From source file:org.apache.giraph.block_app.reducers.array.ArrayReduce.java

@Override
public void readFields(DataInput in) throws IOException {
    fixedSize = in.readInt();
    elementReduceOp = WritableUtils.readWritableObject(in, null);
    init();/*from  ww w  . j a v  a2  s.c  om*/
}

From source file:com.liveramp.cascading_ext.bloom.BloomFilter.java

@Override
public void readFields(DataInput in) throws IOException {
    numHashes = in.readInt();
    vectorSize = in.readLong();/*from  w  w  w . j a  v  a 2 s.c  o m*/
    numElems = in.readLong();
    byte[] bytes = new byte[FixedSizeBitSet.getNumBytesToStore(vectorSize)];
    in.readFully(bytes);
    bits = new FixedSizeBitSet(vectorSize, bytes);
    byte[] serializedHashFunction = new byte[in.readInt()];
    in.readFully(serializedHashFunction);
    hashFunction = (HashFunction) SerializationUtils.deserialize(serializedHashFunction);
}

From source file:org.apache.mahout.clustering.meanshift.MeanShiftCanopy.java

@Override
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    int numpoints = in.readInt();
    this.boundPoints = new IntArrayList();
    for (int i = 0; i < numpoints; i++) {
        this.boundPoints.add(in.readInt());
    }//from ww  w. ja va2s  .  c  o  m
}

From source file:RandomFileTest.java

/**
   Reads employee data from a data input
   @param in the data input/* ww w.  j a v  a2 s  .c  o  m*/
*/
public void readData(DataInput in) throws IOException {
    name = DataIO.readFixedString(NAME_SIZE, in);
    salary = in.readDouble();
    int y = in.readInt();
    int m = in.readInt();
    int d = in.readInt();
    GregorianCalendar calendar = new GregorianCalendar(y, m - 1, d);
    hireDay = calendar.getTime();
}