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.mahout.classifier.df.node.CategoricalNode.java

@Override
protected void writeNode(DataOutput out) throws IOException {
    out.writeInt(attr);
    DFUtils.writeArray(out, values);// ww  w.j  a  v a2  s  .co  m
    DFUtils.writeArray(out, childs);
}

From source file:com.chinamobile.bcbsp.examples.semicluster.SemiClusterMessage.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(messageId);
    value.write(out);
}

From source file:com.zimbra.common.util.ByteUtil.java

public static void writeUTF8(DataOutput out, String str) throws IOException {
    // Special case: Null string is serialized as length of -1.
    if (str == null) {
        out.writeInt(-1);
        return;/*w  w  w  .  j  a  v a 2 s. c o m*/
    }

    int len = str.length();
    if (len > MAX_STRING_LEN)
        throw new IOException(
                "String length " + len + " is too long in ByteUtil.writeUTF8(); max=" + MAX_STRING_LEN);
    if (len > 0) {
        byte[] buf = str.getBytes("UTF-8");
        out.writeInt(buf.length);
        out.write(buf);
    } else {
        out.writeInt(0);
    }
}

From source file:org.mrgeo.tile.TileIdZoomWritable.java

@Override
public void write(final DataOutput out) throws IOException {
    super.write(out);
    out.writeInt(zoom);
}

From source file:com.vmware.demo.sgf.tests.domain.Person.java

@Override
public void toData(DataOutput out) throws IOException {
    out.writeInt(Id);
    out.writeUTF(firstname);//www.java 2  s.c om
    out.writeUTF(surname);
    out.writeUTF(zipcode);
    DataSerializer.writeDate(dateofBirth, out);
}

From source file:com.chinamobile.bcbsp.examples.bytearray.pagerank.PRVertexLiteNew.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.vertexID);
    out.writeFloat(this.vertexValue);
}

From source file:org.apache.hadoop.hdfs.server.datanode.BlockCrcInfoWritable.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(blockId);/* w ww.  j  a  va2  s. c  o  m*/
    out.writeLong(blockGenStamp);
    out.writeInt(blockCrc);
}

From source file:org.cloudata.core.common.io.CObjectWritable.java

private static void writeColumnValue(DataOutput out, Object instance, Class declaredClass, CloudataConf conf,
        int length) throws IOException {
    int shortByteSize = CWritableUtils.getShortByteSize();
    int intByteSize = CWritableUtils.getIntByteSize();

    int totalByteSize = 0;

    long startTime = System.currentTimeMillis();
    for (int i = 0; i < length; i++) {
        ColumnValue columnValue = (ColumnValue) Array.get(instance, i);
        totalByteSize += shortByteSize;//from w w  w  . ja v  a 2  s. c o  m
        totalByteSize += columnValue.size();
    }
    //    long endTime = System.currentTimeMillis();
    //LOG.fatal("writeColumnValue1:length=" + length + ",bytes=" + totalByteSize + ",time=" + (endTime - startTime));

    out.writeInt(totalByteSize);

    //    startTime = System.currentTimeMillis();
    for (int i = 0; i < length; i++) {
        writeObject(out, Array.get(instance, i), declaredClass.getComponentType(), conf, true);
    }
    long endTime = System.currentTimeMillis();
    //LOG.fatal("writeColumnValue2:time=" + (endTime - startTime));
}

From source file:com.chinamobile.bcbsp.examples.connectedcomponent.CCVertexLiteNew.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.vertexID);
    out.writeInt(this.vertexValue);
}

From source file:cn.ac.ict.htc.tools.ArrayListWritable.java

/**
 * Serializes this array./*from   ww w  . j a va2  s.c o  m*/
 *
 * @param out where to write the raw byte representation
 */
public void write(DataOutput out) throws IOException {
    out.writeInt(this.size());
    //      logger.info("write " + this.size() + " elements");
    if (size() == 0)
        return;
    E obj = get(0);

    out.writeUTF(obj.getClass().getCanonicalName());

    //      for (int i = 0; i < size(); i++) {
    //         obj = get(i);
    //         if (obj == null) {
    //            throw new IOException("Cannot serialize null fields!");
    //         }
    //         obj.write(out);
    //      }
}