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.chinamobile.bcbsp.graph.EdgeManager.java

@Override
public void readFields(DataInput in) throws IOException {
    this.currentEdgesLength = in.readInt();
    if (this.currentEdgesLength < 0 || this.edgelist == null) {
        return;//from  w ww  .  ja  v  a2  s  .c om
    }
    // Note Clear The Edges Info Of Last Instance.
    this.edgelist.clear();
    for (int i = 0; i < this.currentEdgesLength; i++) {
        this.currentEdge = getEdgeFromPool(i);
        this.currentEdge.readFields(in);
        this.edgelist.add(this.currentEdge);
    }
    this.currentEdgesLength = -1;
    this.edgelist = null;
}

From source file:org.apache.hadoop.hbase.master.AssignmentPlan.java

@Override
public void readFields(DataInput in) throws IOException {
    int version = in.readInt();
    if (version != VERSION) {
        throw new IOException("The version mismatch for the assignment plan. " + "The expected versioin is "
                + VERSION + " but the verion from the assigment plan is " + version);
    }/*  w  ww. j  av a 2s.  c o m*/
    // read the favoredAssignmentMap size
    int assignmentMapSize = in.readInt();
    for (int i = 0; i < assignmentMapSize; i++) {
        // read each region info
        HRegionInfo region = new HRegionInfo();
        region.readFields(in);
        // read the size of favored server list
        int serverListSize = in.readInt();
        List<HServerAddress> serverList = new ArrayList<HServerAddress>(serverListSize);
        for (int j = 0; j < serverListSize; j++) {
            HServerAddress addr = new HServerAddress();
            addr.readFields(in);
            serverList.add(addr);
        }

        // add the assignment to favoredAssignmentMap
        this.assignmentMap.put(region, serverList);
    }
}

From source file:edu.umn.cs.spatialHadoop.core.ZCurvePartitioner.java

@Override
public void readFields(DataInput in) throws IOException {
    mbr.readFields(in);//from ww  w. java  2s. c  o m
    int partitionCount = in.readInt();
    zSplits = new long[partitionCount];
    int bufferLength = 8 * partitionCount;
    byte[] buffer = new byte[bufferLength];
    in.readFully(buffer);
    ByteBuffer bbuffer = ByteBuffer.wrap(buffer);
    for (int i = 0; i < partitionCount; i++) {
        zSplits[i] = bbuffer.getLong();
    }
    if (bbuffer.hasRemaining())
        throw new RuntimeException("Error reading STR partitioner");
}

From source file:com.nearinfinity.blur.mapreduce.BlurTask.java

private String readString(DataInput input) throws IOException {
    int length = input.readInt();
    byte[] buf = new byte[length];
    input.readFully(buf);//  ww w  . j  av  a2  s.com
    return new String(buf);
}

From source file:edu.umn.cs.spatialHadoop.core.OGCShape.java

@Override
public void readFields(DataInput in) throws IOException {
    int size = in.readInt();
    byte[] bytes = new byte[size];
    in.readFully(bytes);/*from w  w  w .  j a  v  a 2 s  . c om*/
    geom = OGCGeometry.fromBinary(ByteBuffer.wrap(bytes));
    size = in.readInt();
    if (size == -1) {
        extra = null;
    } else {
        bytes = new byte[size];
        in.readFully(bytes);
        extra = new String(bytes);
    }
}

From source file:org.godhuli.rhipe.RHBytesWritable.java

public void readIntFields(final DataInput in) throws IOException {
    setSize(0); // clear the old data
    final int d = in.readInt();
    setSize(d);//  w w  w  .j  a v  a 2s  .  c  om
    in.readFully(bytes, 0, size);
}

From source file:org.gradoop.common.model.impl.properties.PropertyList.java

@Override
public void readFields(DataInput dataInput) throws IOException {
    int propertyCount = dataInput.readInt();
    properties = Lists.newArrayListWithCapacity(propertyCount);
    for (int i = 0; i < propertyCount; i++) {
        Property p = new Property();
        p.readFields(dataInput);//www  . ja  v a 2s .com
        properties.add(p);
    }
}

From source file:com.chinamobile.bcbsp.action.Directive.java

@Override
public void readFields(DataInput in) throws IOException {
    this.faultSSStep = in.readInt();
    this.timestamp = in.readLong();
    int t = in.readInt();
    if (Directive.Type.Request.value() == t) {
        this.type = Directive.Type.Request;
        int length = WritableUtils.readVInt(in);
        if (length > 0) {
            this.actionList = new ArrayList<WorkerManagerAction>();
            for (int i = 0; i < length; ++i) {
                WorkerManagerAction.ActionType actionType = WritableUtils.readEnum(in,
                        WorkerManagerAction.ActionType.class);
                WorkerManagerAction action = WorkerManagerAction.createAction(actionType);
                action.readFields(in);/*from w w w .j  ava2s. c  o  m*/
                this.actionList.add(action);
            }
        } else {
            this.actionList = null;
        }

        this.workerManagersName = WritableUtils.readCompressedStringArray(in);
    } else if (Directive.Type.Response.value() == t) {
        this.type = Directive.Type.Response;
        this.status = new WorkerManagerStatus();
        this.status.readFields(in);
    } else {
        throw new IllegalStateException("Wrong directive type:" + t);
    }

    /* Zhicheng Liu added */
    this.migrateSSStep = in.readInt();

}

From source file:org.apache.rya.accumulo.mr.RyaStatementWritable.java

/**
 * Read part of a statement from an input stream.
 * @param dataInput Stream for reading serialized statements.
 * @return The next individual field, as a byte array.
 * @throws IOException if reading from the stream fails.
 *///from   ww w.  ja v a2s. co  m
protected byte[] read(DataInput dataInput) throws IOException {
    if (dataInput.readBoolean()) {
        int len = dataInput.readInt();
        byte[] bytes = new byte[len];
        dataInput.readFully(bytes);
        return bytes;
    } else {
        return null;
    }
}

From source file:org.apache.nutch.protocol.Content.java

public final void readFields(DataInput in) throws IOException {
    metadata.clear();/*from www  .  j ava 2  s.c om*/
    int sizeOrVersion = in.readInt();
    if (sizeOrVersion < 0) { // version
        version = sizeOrVersion;
        switch (version) {
        case VERSION:
            url = Text.readString(in);
            base = Text.readString(in);

            content = new byte[in.readInt()];
            in.readFully(content);

            contentType = Text.readString(in);
            metadata.readFields(in);
            break;
        default:
            throw new VersionMismatchException((byte) VERSION, (byte) version);
        }
    } else { // size
        byte[] compressed = new byte[sizeOrVersion];
        in.readFully(compressed, 0, compressed.length);
        ByteArrayInputStream deflated = new ByteArrayInputStream(compressed);
        DataInput inflater = new DataInputStream(new InflaterInputStream(deflated));
        readFieldsCompressed(inflater);
    }
}