Example usage for org.apache.hadoop.io BytesWritable write

List of usage examples for org.apache.hadoop.io BytesWritable write

Introduction

In this page you can find the example usage for org.apache.hadoop.io BytesWritable write.

Prototype

@Override
    public void write(DataOutput out) throws IOException 

Source Link

Usage

From source file:edu.yale.cs.hadoopdb.connector.DBInputSplit.java

License:Apache License

/**
 * Serializes DBChunk /*  ww  w .j a  v  a 2  s  .c o m*/
 */
private void serializeChunk(DBChunk chunk, DataOutput out) throws IOException {
    ByteArrayOutputStream byte_stream = new ByteArrayOutputStream();
    ObjectOutputStream object_stream = new ObjectOutputStream(byte_stream);
    object_stream.writeObject(chunk);
    object_stream.close();

    byte[] buf = byte_stream.toByteArray();
    BytesWritable bw = new BytesWritable(buf);
    bw.write(out);
}

From source file:in.dream_lab.goffish.ControlMessage.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeEnum(out, transmissionType);
    out.writeInt(extraInfo.size());//from ww w  .j  a  v a 2  s.  c  o  m
    for (BytesWritable info : extraInfo) {
        info.write(out);
    }

    if (isPartitionMessage()) {
        out.writeInt(partitionID);
    } else if (isVertexMessage()) {
        vertexValues.write(out);
    }
}

From source file:in.dream_lab.goffish.hama.ControlMessage.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeEnum(out, transmissionType);
    out.writeInt(extraInfo.size());// w w  w.j ava2  s.c o m
    for (BytesWritable info : extraInfo) {
        info.write(out);
    }

    if (isPartitionMessage()) {
        out.writeInt(sourcePartitionID);
    } else if (isVertexMessage()) {
        vertexValues.write(out);
    }
}

From source file:org.apache.drill.exec.store.sequencefile.TestSequenceFileReader.java

License:Apache License

public static String byteWritableString(String input) throws Exception {
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(bout);
    final BytesWritable writable = new BytesWritable(input.getBytes("UTF-8"));
    writable.write(out);
    return new String(bout.toByteArray());
}