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:com.icloud.framework.core.util.FBUtilities.java

public static void writeByteArray(ByteBuffer bytes, DataOutput out) throws IOException {
    out.writeInt(bytes.remaining());
    out.write(bytes.array(), bytes.position() + bytes.arrayOffset(), bytes.remaining());
}

From source file:com.chinamobile.bcbsp.ml.VectorWritable.java

public static void writeVector(DoubleVector vector, DataOutput out) throws IOException {
    if (vector == null) {
        LOG.info("lin test : VectorWritable write Vector is null");
    } else {// www.j  ava2s  . com
        LOG.info("lin test : VectorWritable write Vector is not null");
    }
    out.writeInt(vector.getLength());
    for (int i = 0; i < vector.getDimension(); i++) {
        out.writeDouble(vector.get(i));
    }

    if (vector.isNamed() && vector.getName() != null) {
        out.writeBoolean(true);
        out.writeUTF(vector.getName());
    } else {
        out.writeBoolean(false);
    }
}

From source file:com.wsc.myexample.decisionForest.MyDataset.java

public static void writeStringArray(DataOutput out, String[] s) throws IOException {
    out.writeInt(s.length);
    for (int i = 0; i < s.length; i++) {
        writeString(out, s[i]);// w w  w . j  av a 2  s . c o m
    }
}

From source file:io.mycat.util.ByteBufferUtil.java

public static void writeWithLength(byte[] bytes, DataOutput out) throws IOException {
    out.writeInt(bytes.length);
    out.write(bytes);//from   w w  w .j ava 2  s .  co m
}

From source file:com.aliyun.odps.io.TupleReaderWriter.java

/**
 * Tuple??/* w  ww  .  ja v  a  2  s .c  om*/
 *
 * @param out
 *     Tuple??
 * @param t
 *     Tuple
 * @throws IOException
 *     ?Tuple?field
 */
public static void writeTuple(DataOutput out, Tuple t) throws IOException {
    out.writeByte(TUPLE);
    int sz = t.size();
    out.writeInt(sz);
    for (int i = 0; i < sz; i++) {
        writeDatum(out, t.get(i));
    }
}

From source file:com.bigdata.dastor.utils.FBUtilities.java

public static void writeByteArray(byte[] bytes, DataOutput out) throws IOException {
    out.writeInt(bytes.length);
    out.write(bytes);//from   w  w w  . j  a va  2  s.  c  o m
}

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

public static void writeStringArray(DataOutput out, String[] s) throws IOException {
    if (s == null) {
        out.writeInt(0);
        return;/*from w ww . j a  v  a 2  s  .  co m*/
    }
    out.writeInt(s.length);
    for (int i = 0; i < s.length; i++) {
        writeString(out, s[i]);
    }
}

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

public static void writeCompressedStringArray(DataOutput out, String[] s) throws IOException {
    if (s == null) {
        out.writeInt(-1);
        return;//from   w w  w  .j  a v a 2  s. c om
    }
    out.writeInt(s.length);
    for (int i = 0; i < s.length; i++) {
        writeCompressedString(out, s[i]);
    }
}

From source file:com.wsc.myexample.decisionForest.MyDataset.java

public static void writeString(DataOutput out, String s) throws IOException {
    if (s != null) {
        byte[] buffer = s.getBytes("UTF-8");
        int len = buffer.length;
        out.writeInt(len);
        out.write(buffer, 0, len);/*from w  w w .ja  va 2 s .c  o m*/
    } else {
        out.writeInt(-1);
    }
}

From source file:org.apache.hadoop.hbase.security.access.TestTablePermissions.java

/**
 * Writes a set of permissions as {@link org.apache.hadoop.io.Writable} instances
 * to the given output stream./*w w  w.j a v a  2  s  . c  o  m*/
 * @param out
 * @param perms
 * @param conf
 * @throws IOException
*/
public static void writePermissions(DataOutput out, ListMultimap<String, ? extends Permission> perms,
        Configuration conf) throws IOException {
    Set<String> keys = perms.keySet();
    out.writeInt(keys.size());
    for (String key : keys) {
        Text.writeString(out, key);
        HbaseObjectWritableFor96Migration.writeObject(out, perms.get(key), List.class, conf);
    }
}