Example usage for java.io DataOutput writeInt

List of usage examples for java.io DataOutput writeInt

Introduction

In this page you can find the example usage for java.io DataOutput writeInt.

Prototype

void writeInt(int v) throws IOException;

Source Link

Document

Writes an int value, which is comprised of four bytes, to the output stream.

Usage

From source file:org.apache.hama.ml.perception.SmallMultiLayerPerceptron.java

@Override
public void write(DataOutput output) throws IOException {
    WritableUtils.writeString(output, MLPType);
    output.writeDouble(learningRate);/*from   ww  w  .j  a  va2  s. com*/
    output.writeDouble(regularization);
    output.writeDouble(momentum);
    output.writeInt(numberOfLayers);
    WritableUtils.writeString(output, squashingFunctionName);
    WritableUtils.writeString(output, costFunctionName);

    // write the number of neurons for each layer
    for (int i = 0; i < this.numberOfLayers; ++i) {
        output.writeInt(this.layerSizeArray[i]);
    }
    for (int i = 0; i < numberOfLayers - 1; ++i) {
        MatrixWritable matrixWritable = new MatrixWritable(this.weightMatrice[i]);
        matrixWritable.write(output);
    }

    // serialize the feature transformer
    Class<? extends FeatureTransformer> featureTransformerCls = this.featureTransformer.getClass();
    byte[] featureTransformerBytes = SerializationUtils.serialize(featureTransformerCls);
    output.writeInt(featureTransformerBytes.length);
    output.write(featureTransformerBytes);
}

From source file:org.apache.nutch.crawl.CrawlDatum.java

public void write(DataOutput out) throws IOException {
    out.writeByte(CUR_VERSION); // store current version
    out.writeByte(status);//w  ww  .  j a  v a2  s  .c om
    out.writeLong(fetchTime);
    out.writeByte(retries);
    out.writeInt(fetchInterval);
    out.writeFloat(score);
    out.writeLong(modifiedTime);
    if (signature == null) {
        out.writeByte(0);
    } else {
        out.writeByte(signature.length);
        out.write(signature);
    }
    if (metaData != null && metaData.size() > 0) {
        out.writeBoolean(true);
        metaData.write(out);
    } else {
        out.writeBoolean(false);
    }
}

From source file:com.chinamobile.bcbsp.fault.storage.Fault.java

/**
 * write fault information./*www .j a  va2  s.co m*/
 * @param out
 *        data to output.
 */
@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeEnum(out, this.type);
    WritableUtils.writeEnum(out, this.level);
    Text.writeString(out, this.timeOfFailure);
    Text.writeString(out, this.workerNodeName);
    Text.writeString(out, this.jobName);
    Text.writeString(out, this.staffName);
    Text.writeString(out, this.exceptionMessage);
    out.writeInt(this.superStep_Stage);
}

From source file:org.apache.hadoop.mapred.TaskTrackerStatus.java

public void write(DataOutput out) throws IOException {
    Text.writeString(out, trackerName);
    Text.writeString(out, host);//from  ww  w . java2  s .c  o  m
    out.writeInt(httpPort);
    out.writeInt(failures);
    out.writeInt(maxMapTasks);
    out.writeInt(maxReduceTasks);
    resStatus.write(out);
    out.writeInt(taskReports.size());

    for (TaskStatus taskStatus : taskReports) {
        TaskStatus.writeTaskStatus(out, taskStatus);
    }
    getHealthStatus().write(out);
}

From source file:org.apache.hadoop.raid.protocol.PolicyInfo.java

public void write(DataOutput out) throws IOException {
    if (srcPath == null) {
        Text.writeString(out, "");
    } else {//from ww  w  .j  ava  2 s  .c o m
        Text.writeString(out, srcPath.toString());
    }
    if (fileListPath == null) {
        Text.writeString(out, "");
    } else {
        Text.writeString(out, fileListPath.toString());
    }
    Text.writeString(out, policyName);
    Text.writeString(out, codecId);
    Text.writeString(out, description);
    out.writeInt(properties.size());
    for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
        String name = (String) e.nextElement();
        Text.writeString(out, name);
        Text.writeString(out, properties.getProperty(name));
    }
}

From source file:org.apache.hama.bsp.Counters.java

/**
 * Write the set of groups. The external format is: #groups (groupName group)*
 * // w w w  .  j a  v  a2s.  c om
 * i.e. the number of groups followed by 0 or more groups, where each group is
 * of the form:
 * 
 * groupDisplayName #counters (false | true counter)*
 * 
 * where each counter is of the form:
 * 
 * name (false | true displayName) value
 */
@Override
public synchronized void write(DataOutput out) throws IOException {
    out.writeInt(counters.size());
    for (Group group : counters.values()) {
        Text.writeString(out, group.getName());
        group.write(out);
    }
}

From source file:org.apache.hadoop.mapred.Counters.java

/**
 * Write the set of groups./* ww  w  .  j  ava  2s  . c o  m*/
 * The external format is:
 *     #groups (groupName group)*
 *
 * i.e. the number of groups followed by 0 or more groups, where each 
 * group is of the form:
 *
 *     groupDisplayName #counters (false | true counter)*
 *
 * where each counter is of the form:
 *
 *     name (false | true displayName) value
 */
public synchronized void write(DataOutput out) throws IOException {
    out.writeInt(counters.size());
    for (Group group : counters.values()) {
        Text.writeString(out, group.getName());
        group.write(out);
    }
}

From source file:org.archive.io.hdfs.HDFSWriterDocument.java

/**
 * Writes the fields of this object to <code>out</code>.
 *
 * @param out output object to serialize to
 *///  ww w  .  ja  v  a  2  s.  com
public void write(DataOutput out) throws IOException {
    reconstructDocument();
    out.writeInt(buf.length);
    out.write(buf);
}

From source file:org.apache.tez.mapreduce.hadoop.MRTaskStatus.java

@Override
public void write(DataOutput out) throws IOException {
    taskAttemptId.write(out);//w  w w .  j a  v  a  2  s  .  c o  m
    WritableUtils.writeEnum(out, state);
    out.writeFloat(progress);
    WritableUtils.writeString(out, diagnostics);
    WritableUtils.writeString(out, userStatusInfo);
    WritableUtils.writeEnum(out, phase);

    counters.write(out);

    out.writeLong(localOutputSize);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    out.writeLong(sortFinishTime);
    out.writeLong(mapFinishTime);
    out.writeLong(shuffleFinishTime);

    out.writeInt(failedTaskDependencies.size());
    for (TezTaskAttemptID taskAttemptId : failedTaskDependencies) {
        taskAttemptId.write(out);
    }
}

From source file:com.marklogic.tree.ExpandedTree.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(uriKey);/* ww  w  .j  a  v  a  2 s.c  om*/
    out.writeLong(uniqKey);
    out.writeLong(linkKey);
    out.writeInt(numKeys);
    if (numKeys > 0) {
        for (long key : keys) {
            out.writeLong(key);
        }
    }
    if (atomData != null && atomData.length > 0) {
        out.writeInt(atomData.length);
        for (int i = 0; i < atomData.length; i++) {
            out.writeByte(atomData[i]);
        }
    } else {
        out.writeInt(0);
    }
    out.writeInt(atomLimit);
    if (atomIndex != null && atomIndex.length > 0) {
        for (int i = 0; i < atomIndex.length; i++) {
            out.writeInt(atomIndex[i]);
        }
    }
    if (nodeNameNameAtom != null && nodeNameNameAtom.length > 0) {
        out.writeInt(nodeNameNameAtom.length);
        for (int i = 0; i < nodeNameNameAtom.length; i++) {
            out.writeInt(nodeNameNameAtom[i]);
            out.writeInt(nodeNameNamespaceAtom[i]);
        }
    } else {
        out.writeInt(0);
    }
    out.writeInt(numNodeReps);
    if (numNodeReps > 0) {
        for (int i = 0; i < numNodeReps; i++) {
            out.writeLong(nodeOrdinal[i]);
            out.writeByte(nodeKind[i]);
            out.writeInt(nodeRepID[i]);
            out.writeInt(nodeParentNodeRepID[i]);
        }
    }
    if (elemNodeNodeNameRepID != null && elemNodeNodeNameRepID.length > 0) {
        out.writeInt(elemNodeNodeNameRepID.length);
        for (int i = 0; i < elemNodeNodeNameRepID.length; i++) {
            out.writeInt(elemNodeNodeNameRepID[i]);
            out.writeInt(elemNodeAttrNodeRepID[i]);
            out.writeInt(elemNodeChildNodeRepID[i]);
            out.writeInt(elemNodeElemDeclRepID[i]);
            out.writeInt(elemNodeNumAttributes[i]);
            out.writeInt(elemNodeNumDefaultAttrs[i]);
            out.writeInt(elemNodeNumChildren[i]);
            out.writeInt(elemNodeFlags[i]);
        }
    } else {
        out.writeInt(0);
    }
    if (attrNodeNodeNameRepID != null && attrNodeNodeNameRepID.length > 0) {
        out.writeInt(attrNodeNodeNameRepID.length);
        for (int i = 0; i < attrNodeNodeNameRepID.length; i++) {
            out.writeInt(attrNodeNodeNameRepID[i]);
            out.writeInt(attrNodeTextRepID[i]);
            out.writeInt(attrNodeAttrDeclRepID[i]);
        }
    } else {
        out.writeInt(0);
    }
    out.writeInt(numLinkNodeReps);
    if (numLinkNodeReps > 0) {
        for (int i = 0; i < numLinkNodeReps; i++) {
            out.writeLong(linkNodeKey[i]);
            out.writeLong(linkNodeNodeCount[i]);
            out.writeInt(linkNodeNodeNameRepID[i]);
            out.writeInt(linkNodeNodeRepID[i]);
        }
    }
    if (docNodeTextRepID != null && docNodeTextRepID.length > 0) {
        out.writeInt(docNodeTextRepID.length);
        for (int i = 0; i < docNodeTextRepID.length; i++) {
            out.writeInt(docNodeTextRepID[i]);
            out.writeInt(docNodeChildNodeRepID[i]);
            out.writeInt(docNodeNumChildren[i]);
        }
    } else {
        out.writeInt(0);
    }
    if (piNodeTargetAtom != null && piNodeTargetAtom.length > 0) {
        out.writeInt(piNodeTargetAtom.length);
        for (int i = 0; i < piNodeTargetAtom.length; i++) {
            out.writeInt(piNodeTargetAtom[i]);
            out.writeInt(piNodeTextRepID[i]);
        }
    } else {
        out.writeInt(0);
    }
    out.writeInt(numNSNodeReps);
    if (numNSNodeReps > 0) {
        for (int i = 0; i < numNSNodeReps; i++) {
            out.writeLong(nsNodeOrdinal[i]);
            out.writeInt(nsNodePrevNSNodeRepID[i]);
            out.writeInt(nsNodePrefixAtom[i]);
            out.writeInt(nsNodeUriAtom[i]);
        }
    }
    // skip permission node since it's not exposed to the API
    out.writeInt(uriTextRepID);
    out.writeInt(colsTextRepID);
    out.writeInt(numTextReps);
    if (numTextReps > 0) {
        for (int i = 0; i < numTextReps; i++) {
            out.writeInt(textReps[i]);
        }
    }
    if (arrayNodeTextRepID != null && arrayNodeTextRepID.length > 0) {
        out.writeInt(arrayNodeTextRepID.length);
        for (int i = 0; i < arrayNodeTextRepID.length; i++) {
            out.writeInt(arrayNodeTextRepID[i]);
            out.writeInt(arrayNodeChildNodeRepID[i]);
            out.writeInt(arrayNodeNumChildren[i]);
        }
    } else {
        out.writeInt(0);
    }
    if (doubles != null && doubles.length > 0) {
        out.writeInt(doubles.length);
        for (int i = 0; i < doubles.length; i++) {
            out.writeDouble(doubles[i]);
        }
    } else {
        out.writeInt(0);
    }

}