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:io.dstream.hadoop.TypeAwareWritable.java

/**
 * /*ww w  .  jav  a  2  s.  co  m*/
 */
@Override
public void readFields(DataInput in) throws IOException {
    this.valueType = in.readByte();
    switch (this.valueType) {
    case INTEGER:
        this.value = (T) Integer.valueOf(in.readInt());
        break;
    case LONG:
        this.value = (T) Long.valueOf(in.readLong());
        break;
    case NULL:
        this.value = null;
        break;
    case OBJECT:
        try {
            ObjectInputStream ois = new ObjectInputStream((DataInputStream) in);
            T value = (T) ois.readObject();
            this.value = (T) value;
        } catch (Exception e) {
            throw new IllegalStateException("Failed to deserialize value", e);
        }
        break;
    default:
        throw new IllegalStateException("Unsupported or unrecognized value type: " + this.valueType);
    }
}

From source file:parquet.hadoop.ParquetInputSplit.java

private Map<String, String> readKeyValues(DataInput in) throws IOException {
    int size = in.readInt();
    Map<String, String> map = new HashMap<String, String>(size);
    for (int i = 0; i < size; i++) {
        String key = in.readUTF().intern();
        String value = in.readUTF().intern();
        map.put(key, value);/*from  w ww .  j  ava  2 s .  co m*/
    }
    return map;
}

From source file:io.dstream.tez.io.TypeAwareWritable.java

/**
 *
 *///  www .  j  a va 2 s  .  c  o  m
@Override
public void readFields(DataInput in) throws IOException {
    this.valueType = in.readByte();
    switch (this.valueType) {
    case INTEGER:
        this.value = (T) Integer.valueOf(in.readInt());
        break;
    case LONG:
        this.value = (T) Long.valueOf(in.readLong());
        break;
    case NULL:
        this.value = null;
        break;
    case OBJECT:
        try {
            ObjectInputStream ois = new ObjectInputStream((DataInputStream) in);
            T value = (T) ois.readObject();
            this.value = value;
        } catch (Exception e) {
            throw new IllegalStateException("Failed to deserialize value", e);
        }
        break;
    default:
        throw new IllegalStateException("Unsupported or unrecognized value type: " + this.valueType);
    }
}

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

@Override
public void readFields(DataInput in) throws IOException {
    fixedSize = in.readInt();
    typeOps = TypeOpsUtils.readTypeOps(in);
    elementReduceOp = WritableUtils.readWritableObject(in, null);
    init();/*from w  ww.ja v a2s  . c  o  m*/
}

From source file:org.apache.kylin.dict.lookup.SnapshotTable.java

void readData(DataInput in) throws IOException {
    int rowNum = in.readInt();
    if (rowNum > 0) {
        int n = in.readInt();
        rowIndices = new ArrayList<int[]>(rowNum);

        if (this.useDictionary == true) {
            this.dict = new TrieDictionary<String>();
            dict.readFields(in);//w  w  w. j a va 2s .c  om

            for (int i = 0; i < rowNum; i++) {
                int[] row = new int[n];
                this.rowIndices.add(row);
                for (int j = 0; j < n; j++) {
                    row[j] = in.readInt();
                }
            }
        } else {
            List<String[]> rows = new ArrayList<String[]>(rowNum);
            TrieDictionaryBuilder<String> b = new TrieDictionaryBuilder<String>(new StringBytesConverter());

            for (int i = 0; i < rowNum; i++) {
                String[] row = new String[n];
                rows.add(row);
                for (int j = 0; j < n; j++) {
                    row[j] = in.readUTF();
                    // NULL_STR is tricky, but we don't want to break the current snapshots
                    if (row[j].equals(NULL_STR))
                        row[j] = null;

                    b.addValue(row[j]);
                }
            }
            this.dict = b.build(0);
            for (String[] row : rows) {
                int[] rowIndex = new int[n];
                for (int i = 0; i < n; i++) {
                    rowIndex[i] = dict.getIdFromValue(row[i]);
                }
                this.rowIndices.add(rowIndex);
            }
        }
    } else {
        rowIndices = new ArrayList<int[]>();
        dict = new TrieDictionary<String>();
    }
}

From source file:edu.umn.cs.spatialHadoop.indexing.GridPartitioner.java

@Override
public void readFields(DataInput in) throws IOException {
    this.x = in.readDouble();
    this.y = in.readDouble();
    this.tileWidth = in.readDouble();
    this.tileHeight = in.readDouble();
    this.numTiles = in.readInt();
    this.numColumns = (int) Math.round(Math.sqrt(numTiles));
    this.numRows = (int) Math.ceil(numTiles / numColumns);
}

From source file:com.blackberry.logdriver.boom.LogLineData.java

@Override
public void readFields(DataInput in) throws IOException {
    timestamp = in.readLong();/*from ww  w .ja v a  2 s.  c  o  m*/
    createTime = in.readLong();
    blockNumber = in.readLong();
    lineNumber = in.readLong();
    eventId = in.readInt();
}

From source file:IndexService.IColumnInputSplit.java

@Override
public void readFields(DataInput in) throws IOException {
    this.file = new Path(in.readUTF());
    this.splitbyline = in.readBoolean();
    this.wholefileASasplit = in.readBoolean();
    if (splitbyline) {
        if (!wholefileASasplit) {
            this.beginline = in.readInt();
            this.recnum = in.readInt();
        }//from www .j av  a  2 s. co  m
    } else {
        this.beginkey = new IRecord.IFValue();
        beginkey.readFields(in);
        this.recnum = in.readInt();
    }
}

From source file:org.apache.giraph.graph.VertexMutations.java

@Override
public void readFields(DataInput input) throws IOException {
    addedVertexList.clear();/*from ww  w.ja v  a2 s.c  om*/
    addedEdgeList.clear();
    removedEdgeList.clear();

    int addedVertexListSize = input.readInt();
    for (int i = 0; i < addedVertexListSize; ++i) {
        BasicVertex<I, V, E, M> vertex = BspUtils.createVertex(conf);
        vertex.readFields(input);
        addedVertexList.add(vertex);
    }
    removedVertexCount = input.readInt();
    int addedEdgeListSize = input.readInt();
    for (int i = 0; i < addedEdgeListSize; ++i) {
        I destVertex = BspUtils.<I>createVertexIndex(conf);
        destVertex.readFields(input);
        E edgeValue = BspUtils.<E>createEdgeValue(conf);
        edgeValue.readFields(input);
        addedEdgeList.add(new Edge<I, E>(destVertex, edgeValue));
    }
    int removedEdgeListSize = input.readInt();
    for (int i = 0; i < removedEdgeListSize; ++i) {
        I removedEdge = BspUtils.<I>createVertexIndex(conf);
        removedEdge.readFields(input);
        removedEdgeList.add(removedEdge);
    }
}

From source file:IndexService.IndexMergeIFormatSplit.java

@Override
public void readFields(DataInput in) throws IOException {
    this.file = new Path(in.readUTF());
    this.splitbyline = in.readBoolean();
    this.wholefileASasplit = in.readBoolean();
    if (splitbyline) {
        if (!wholefileASasplit) {
            this.beginline = in.readInt();
            this.recnum = in.readInt();
        }/*from  w w  w  . j a  va 2s . c  om*/
    } else {
        this.beginkey = new IRecord.IFValue();
        beginkey.readFields(in);
        this.recnum = in.readInt();
    }

}