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:org.apache.hadoop.mapred.TaskStatus.java

public void readFields(DataInput in) throws IOException {
    this.taskid.readFields(in);
    this.progress = in.readFloat();
    this.numSlots = in.readInt();
    this.runState = WritableUtils.readEnum(in, State.class);
    this.diagnosticInfo = Text.readString(in);
    this.stateString = Text.readString(in);
    this.phase = WritableUtils.readEnum(in, Phase.class);
    this.startTime = in.readLong();
    this.finishTime = in.readLong();
    counters = new Counters();
    this.includeCounters = in.readBoolean();
    this.outputSize = in.readLong();
    if (includeCounters) {
        counters.readFields(in);//w w w  .  j  a v  a2  s .  co m
    }
    nextRecordRange.readFields(in);
}

From source file:org.apache.geode.distributed.internal.StartupMessage.java

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    super.fromData(in);

    this.version = DataSerializer.readString(in);
    this.replyProcessorId = in.readInt();
    this.isMcastEnabled = in.readBoolean();
    this.isTcpDisabled = in.readBoolean();

    int serializerCount = in.readInt();
    for (int i = 0; i < serializerCount; i++) {
        String cName = DataSerializer.readNonPrimitiveClassName(in);

        int id = in.readInt(); // id
        try {/*from   w  ww.  ja va2 s  . com*/
            if (cName != null) {
                InternalDataSerializer.register(cName, false, null, null, id);
            }
        } catch (IllegalArgumentException ex) {
            fromDataProblem(
                    LocalizedStrings.StartupMessage_ILLEGALARGUMENTEXCEPTION_WHILE_REGISTERING_A_DATASERIALIZER_0
                            .toLocalizedString(ex));
        }
    }

    int instantiatorCount = in.readInt();
    for (int i = 0; i < instantiatorCount; i++) {
        String instantiatorClassName = DataSerializer.readNonPrimitiveClassName(in);
        String instantiatedClassName = DataSerializer.readNonPrimitiveClassName(in);
        int id = in.readInt();

        try {
            if (instantiatorClassName != null && instantiatedClassName != null) {
                InternalInstantiator.register(instantiatorClassName, instantiatedClassName, id, false);
            }
        } catch (IllegalArgumentException ex) {
            fromDataProblem(
                    LocalizedStrings.StartupMessage_ILLEGALARGUMENTEXCEPTION_WHILE_REGISTERING_AN_INSTANTIATOR_0
                            .toLocalizedString(ex));
        }
    } // for

    this.interfaces = (Set) DataSerializer.readObject(in);
    this.distributedSystemId = in.readInt();
    this.redundancyZone = DataSerializer.readString(in);
    this.enforceUniqueZone = in.readBoolean();

    StartupMessageData data = new StartupMessageData();
    data.readFrom(in);
    this.hostedLocatorsAll = data.readHostedLocators();
    this.isSharedConfigurationEnabled = data.readIsSharedConfigurationEnabled();
    this.mcastPort = data.readMcastPort();
    this.mcastHostAddress = data.readMcastHostAddress();
}

From source file:com.netflix.aegisthus.input.AegSplit.java

@Override
public void readFields(DataInput in) throws IOException {
    end = in.readLong();/*from w w  w  . j  a v  a  2 s  .  c om*/
    hosts = WritableUtils.readStringArray(in);
    path = new Path(WritableUtils.readString(in));
    compressed = in.readBoolean();
    if (compressed) {
        compressedPath = new Path(WritableUtils.readString(in));
    }
    start = in.readLong();
    type = WritableUtils.readEnum(in, Type.class);
    int size = in.readInt();
    if (type == Type.sstable) {
        convertors = Maps.newHashMap();
        for (int i = 0; i < size; i++) {
            String[] parts = WritableUtils.readStringArray(in);
            try {
                convertors.put(parts[0], TypeParser.parse(parts[1]));
            } catch (ConfigurationException e) {
                throw new IOException(e);
            } catch (SyntaxException e) {
                throw new IOException(e);
            }
        }
    }
}

From source file:org.cloudata.core.client.Row.java

@Override
public void readFields(DataInput in) throws IOException {
    key = new Key();
    key.readFields(in);//from w ww .  j  a  v  a  2s . c  o m
    cells.clear();

    int columnLength = in.readInt();
    for (int i = 0; i < columnLength; i++) {
        String columnName = CWritableUtils.readString(in);

        int columnCellsSize = in.readInt();
        TreeMap<Cell.Key, Cell> columnCells = new TreeMap<Cell.Key, Cell>();
        for (int j = 0; j < columnCellsSize; j++) {
            Cell cell = new Cell();
            cell.readFields(in);
            columnCells.put(cell.key, cell);
        }

        cells.put(columnName, columnCells);
    }
}

From source file:org.apache.nutch.webapp.common.Search.java

public void readFields(DataInput in) throws IOException {
    hits = new Hits();
    hits.readFields(in);/*  w  w  w.ja v a  2 s  . c  o  m*/
    int showlength = in.readInt();
    show = new Hit[showlength];
    for (int i = 0; i < showlength; i++) {
        show[i] = new Hit();
        show[i].readFields(in);
    }

    int detailsLength = in.readInt();
    details = new HitDetails[detailsLength];
    for (int i = 0; i < detailsLength; i++) {
        details[i] = new HitDetails();
        details[i].readFields(in);
    }

    int summariesLength = in.readInt();
    summaries = new Summary[summariesLength];
    for (int i = 0; i < summariesLength; i++) {
        summaries[i] = new Summary();
        summaries[i].readFields(in);
    }
}

From source file:org.apache.hama.ml.ann.SmallLayeredNeuralNetwork.java

@Override
public void readFields(DataInput input) throws IOException {
    super.readFields(input);

    // read squash functions
    int squashingFunctionSize = input.readInt();
    this.squashingFunctionList = Lists.newArrayList();
    for (int i = 0; i < squashingFunctionSize; ++i) {
        this.squashingFunctionList.add(FunctionFactory.createDoubleFunction(WritableUtils.readString(input)));
    }/*  w w w.  jav a2 s.com*/

    // read weights and construct matrices of previous updates
    int numOfMatrices = input.readInt();
    this.weightMatrixList = Lists.newArrayList();
    this.prevWeightUpdatesList = Lists.newArrayList();
    for (int i = 0; i < numOfMatrices; ++i) {
        DoubleMatrix matrix = MatrixWritable.read(input);
        this.weightMatrixList.add(matrix);
        this.prevWeightUpdatesList.add(new DenseDoubleMatrix(matrix.getRowCount(), matrix.getColumnCount()));
    }

}

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

/**
 * Returns the total size of the header (including the index) in bytes.
 * Assume that the input is aligned to the start offset of the tree (header).
 * Note that the part of the header is consumed from the given input to be
 * able to determine header size.//  www . j  av a 2s .com
 * @param in
 * @return
 * @throws IOException
 */
public static int getHeaderSize(DataInput in) throws IOException {
    int header_size = 0;
    /*int treeSize = */in.readInt();
    header_size += 4;
    int height = in.readInt();
    header_size += 4;
    if (height == 0) {
        // Empty tree. No results
        return header_size;
    }
    int degree = in.readInt();
    header_size += 4;
    int nodeCount = (int) ((Math.pow(degree, height) - 1) / (degree - 1));
    /*int elementCount = */in.readInt();
    header_size += 4;
    // Add the size of all nodes
    header_size += nodeCount * NodeSize;
    return header_size;
}

From source file:com.mobicage.rogerthat.registration.RegistrationWizard2.java

@SuppressWarnings("unchecked")
@Override/* ww  w .  ja  v a  2  s  . co m*/
public void readFromPickle(int version, DataInput in) throws IOException, PickleException {
    T.UI();
    super.readFromPickle(version, in);
    boolean set = in.readBoolean();
    if (set)
        mCredentials = new Credentials(new Pickle(in.readInt(), in));
    set = in.readBoolean();
    mEmail = set ? in.readUTF() : null;
    mTimestamp = in.readLong();
    mRegistrationId = in.readUTF();
    mInGoogleAuthenticationProcess = in.readBoolean();
    mInstallationId = in.readUTF();
    // A version bump was forgotten when serializing mDeviceId, so we need a try/catch
    try {
        mDeviceId = in.readUTF();
    } catch (EOFException e) {
        mDeviceId = null;
    }
    if (version >= 2) {
        try {
            set = in.readBoolean();
            mBeaconRegions = set
                    ? new GetBeaconRegionsResponseTO((Map<String, Object>) JSONValue.parse(in.readUTF()))
                    : null;

            set = in.readBoolean();
            if (set) {
                String detectedBeacons = in.readUTF();
                JSONArray db1 = (JSONArray) JSONValue.parse(detectedBeacons);
                if (db1 != null) {
                    mDetectedBeacons = new HashSet<String>();
                    for (int i = 0; i < db1.size(); i++) {
                        mDetectedBeacons.add((String) db1.get(i));
                    }
                } else {
                    mDetectedBeacons = null;
                }
            } else {
                mDetectedBeacons = null;
            }
        } catch (IncompleteMessageException e) {
            L.bug(e);
        }
    }
}

From source file:libra.common.hadoop.io.datatypes.CompressedIntArrayWritable.java

@Override
public void readFields(DataInput in) throws IOException {
    byte flag = in.readByte();
    int count = 0;
    if ((flag & 0x0f) == 0x00) {
        count = in.readByte();//from   w  w w . j  ava 2  s . co  m
    } else if ((flag & 0x0f) == 0x01) {
        count = in.readShort();
    } else if ((flag & 0x0f) == 0x02) {
        count = in.readInt();
    } else {
        throw new IOException("unhandled flag");
    }

    this.positiveEntries = 0;
    this.negativeEntries = 0;

    int[] arr = new int[count];
    if ((flag & 0xf0) == 0x00) {
        for (int i = 0; i < count; i++) {
            arr[i] = in.readByte();
            if (arr[i] >= 0) {
                this.positiveEntries++;
            } else {
                this.negativeEntries++;
            }
        }
    } else if ((flag & 0xf0) == 0x10) {
        for (int i = 0; i < count; i++) {
            arr[i] = in.readShort();
            if (arr[i] >= 0) {
                this.positiveEntries++;
            } else {
                this.negativeEntries++;
            }
        }
    } else if ((flag & 0xf0) == 0x20) {
        for (int i = 0; i < count; i++) {
            arr[i] = in.readInt();
            if (arr[i] >= 0) {
                this.positiveEntries++;
            } else {
                this.negativeEntries++;
            }
        }
    } else {
        throw new IOException("unhandled flag");
    }

    this.intArray = arr;
    this.prevBytes = null;
}

From source file:com.chinamobile.bcbsp.workermanager.WorkerManagerStatus.java

@Override
public void readFields(DataInput in) throws IOException {
    this.workerManagerName = Text.readString(in);
    this.rpc = Text.readString(in);
    // add by cuiLI
    this.host = Text.readString(in);
    // this.host = "192.168.0.211";
    this.httpPort = Text.readString(in);
    this.localIp = Text.readString(in);
    int staffCount = in.readInt();
    StaffStatus status;/*from   w  ww  .  j  a  v a 2  s  .com*/
    this.staffReports.clear();
    for (int i = 0; i < staffCount; i++) {
        status = new StaffStatus();
        status.readFields(in);
        this.staffReports.add(status);
    }
    int workerFaultCount = in.readInt();
    Fault faultTemp;
    this.workerFaultList.clear();
    for (int i = 0; i < workerFaultCount; i++) {
        faultTemp = new Fault();
        faultTemp.readFields(in);
        this.workerFaultList.add(faultTemp);
    }
    this.maxStaffsCount = in.readInt();
    this.runningStaffsCount = in.readInt();
    this.finishedStaffsCount = in.readInt();
    this.failedStaffsCount = in.readInt();
}