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:edu.umn.cs.spatialHadoop.core.ZCurvePartitioner.java

@Override
public void write(DataOutput out) throws IOException {
    mbr.write(out);/*from   ww  w .j  a  va  2s.  c o m*/
    out.writeInt(zSplits.length);
    ByteBuffer bbuffer = ByteBuffer.allocate(zSplits.length * 8);
    for (long zSplit : zSplits)
        bbuffer.putLong(zSplit);
    if (bbuffer.hasRemaining())
        throw new RuntimeException("Did not calculate buffer size correctly");
    out.write(bbuffer.array(), bbuffer.arrayOffset(), bbuffer.position());
}

From source file:org.apache.hadoop.hbase.HServerAddress.java

public void write(DataOutput out) throws IOException {
    if (this.address == null) {
        out.writeUTF("");
        out.writeInt(0);
    } else {/*from   ww w.  j  av  a2  s. c om*/
        out.writeUTF(this.address.getAddress().getHostName());
        out.writeInt(this.address.getPort());
    }
}

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

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(VERSION);
    if (this.assignmentMap == null) {
        out.writeInt(0);//from w  w  w  .ja  v a 2 s . c  om
    }
    // write the size of the favored assignment map
    out.writeInt(this.assignmentMap.size());
    for (Map.Entry<HRegionInfo, List<HServerAddress>> entry : assignmentMap.entrySet()) {
        // write the region info
        entry.getKey().write(out);
        // write the list of favored server list
        List<HServerAddress> serverList = entry.getValue();
        // write the size of the list
        out.writeInt(serverList.size());
        for (HServerAddress addr : serverList) {
            // write the element of the list
            addr.write(out);
        }
    }
}

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

/** {@inheritDoc} */
@Override//w w w .  j  a  v a 2 s.  com
public void write(DataOutput out) throws IOException {
    // EntityId.
    final byte[] bytes = mEntityId.getHBaseRowKey();
    out.writeInt(bytes.length);
    out.write(bytes);

    // Family/Qualifier/Timestamp.
    out.writeUTF(mFamily);
    out.writeUTF(mQualifier);
    out.writeLong(mTimestamp);

    // Avro.
    final KijiCellEncoder encoder = new KijiCellEncoder(null);
    final byte[] cellData = encoder.encode(mCell, KijiCellFormat.NONE);
    out.writeUTF(mCell.getWriterSchema().toString());
    out.writeInt(cellData.length);
    out.write(cellData);
}

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

public void write(DataOutput out) throws IOException {
    if (node != null) {
        int type = node.getNodeType();
        out.writeInt(type);
        if (type == Node.ATTRIBUTE_NODE) {
            Text.writeString(out, node.getNodeName());
            Text.writeString(out, node.getNodeValue());
        } else {/*ww w  .  ja  va  2s . co  m*/
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                DomUtil.writeXml(node, baos);
                Text.writeString(out, baos.toString());
            } catch (TransformerException e) {
                LOG.error("error transforming node", e);
                throw new IOException(e);
            }
        }
    } else {
        LOG.error("Node to write is null.");
    }
}

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

@Override
public void write(DataOutput dataOutput) throws IOException {
    dataOutput.writeInt(properties.size());
    for (Property property : properties) {
        property.write(dataOutput);/*from   w w w.  j av a2  s  .  c o m*/
    }
}

From source file:org.mitre.la.mapred.io.DenseVectorWritable.java

/**
 * Serialize the fields of this object to <code>out</code>.
 *
 * @param out <code>DataOuput</code> to serialize this object into.
 * @throws IOException// w w  w .jav a  2 s.  c  o  m
 */
@Override
public void write(DataOutput out) throws IOException {
    int length = this.dv.getCardinality();
    out.writeByte(0); // Space for versioning
    out.writeUTF(this.dv.getLabel());
    out.writeInt(length);
    for (int i = 0; i < length; i++) {
        out.writeDouble(this.dv.get(i));
    }
}

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

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(faultSSStep);
    out.writeLong(this.timestamp);
    out.writeInt(this.type.value());
    if (getType().value() == Directive.Type.Request.value()) {
        if (this.actionList == null) {
            WritableUtils.writeVInt(out, 0);
        } else {/*from   w  w  w . j a va2s  .c o m*/
            WritableUtils.writeVInt(out, actionList.size());
            for (WorkerManagerAction action : this.actionList) {
                WritableUtils.writeEnum(out, action.getActionType());
                action.write(out);
            }
        }

        WritableUtils.writeCompressedStringArray(out, this.workerManagersName);
    } else if (getType().value() == Directive.Type.Response.value()) {
        this.status.write(out);
    } else {
        throw new IllegalStateException("Wrong directive type:" + getType());
    }

    /* Zhicheng Liu added */
    out.writeInt(this.migrateSSStep);

}

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

@Override
public void write(DataOutput out) throws IOException {
    byte[] bytes = geom.asBinary().array();
    out.writeInt(bytes.length);
    out.write(bytes);//from www. jav a  2s .  c om
}

From source file:RandomFileTest.java

/**
   Writes employee data to a data output
   @param out the data output//from   w  w  w  .  ja v  a2s . co m
*/
public void writeData(DataOutput out) throws IOException {
    DataIO.writeFixedString(name, NAME_SIZE, out);
    out.writeDouble(salary);

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(hireDay);
    out.writeInt(calendar.get(Calendar.YEAR));
    out.writeInt(calendar.get(Calendar.MONTH) + 1);
    out.writeInt(calendar.get(Calendar.DAY_OF_MONTH));
}