Example usage for org.apache.hadoop.io WritableUtils writeVInt

List of usage examples for org.apache.hadoop.io WritableUtils writeVInt

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableUtils writeVInt.

Prototype

public static void writeVInt(DataOutput stream, int i) throws IOException 

Source Link

Document

Serializes an integer to a binary stream with zero-compressed encoding.

Usage

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void runASuperStep() throws IOException {
    WritableUtils.writeVInt(outPutstream, MessageType.COMMAND_RUN_SUPERSTEP.code);
    this.flush();
    LOG.info("Run a superStep  command");
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void sendStaffId(String staffId) throws IOException {
    WritableUtils.writeVInt(outPutstream, MessageType.STAFFID.code);
    LOG.info("the staffid is : " + staffId);
    Text.writeString(outPutstream, staffId);
    LOG.info("Run send staffid command");
    this.flush();
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void sendKeyValue(String key, String value) throws IOException {
    WritableUtils.writeVInt(outPutstream, MessageType.FLAG_GRAPHDATA.code);
    Text.writeString(outPutstream, key);
    Text.writeString(outPutstream, value);
    this.flush();
    // LOG.info("Run a send graph data command key/value");
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
// num = staff num
public void sendKey(String key, int num) throws IOException, InterruptedException {
    WritableUtils.writeVInt(outPutstream, MessageType.COMMAND_PARTITION.code);
    Text.writeString(outPutstream, key);
    WritableUtils.writeVInt(outPutstream, num);
    synchronized (mutex) {
        mutex.wait();/*from   w ww .j a  v  a2s  .c  om*/
    }
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void sendNewAggregateValue(String[] aggregateValue) throws IOException {
    LOG.info("send new aggregateValue!");
    WritableUtils.writeVInt(outPutstream, MessageType.FLAG_AGGREGATE_VALUE.code);
    for (int i = 0; i < aggregateValue.length; i++) {
        WritableUtils.writeVInt(outPutstream, aggregateValue.length);
        Text.writeString(outPutstream, aggregateValue[i]);
    }//from   ww  w  .  j  a va2 s  .c  om
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void saveResult() throws IOException {
    // TODO Auto-generated method stub
    WritableUtils.writeVInt(outPutstream, MessageType.COMMAND_SAVE_RESULT.code);
    this.flush();
}

From source file:com.chinamobile.bcbsp.sync.SuperStepCommand.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.commandType);
    Text.writeString(out, this.initWritePath);
    Text.writeString(out, this.initReadPath);
    out.writeInt(this.ableCheckPoint);
    out.writeInt(this.nextSuperStepNum);
    out.writeInt(this.oldCheckPoint);
    out.writeInt(this.aggValues.length);
    int count = this.aggValues.length;
    for (int i = 0; i < count; i++) {
        Text.writeString(out, this.aggValues[i]);
    }/*from   w  w  w . j  ava  2s  .co  m*/
    if (partitionToWorkerManagerNameAndPort == null) {
        WritableUtils.writeVInt(out, 0);
    } else {
        WritableUtils.writeVInt(out, partitionToWorkerManagerNameAndPort.size());
        String[] partitionToWMName = null;
        for (Integer i : this.partitionToWorkerManagerNameAndPort.keySet()) {
            partitionToWMName[i] = partitionToWorkerManagerNameAndPort.get(i);
        }
        WritableUtils.writeCompressedStringArray(out, partitionToWMName);
    }
    out.writeUTF(this.migrateStaffIDs);
    this.migrateVertexCommand.write(out);
}

From source file:com.cloudera.branchreduce.onezero.PartialSolution.java

License:Open Source License

@Override
public void write(DataOutput out) throws IOException {
    WritableUtils.writeVInt(out, numVariables);
    WritableUtils.writeVInt(out, fixLimit);
    for (int i = 0; i < Math.max(numVariables, fixLimit); i++) {
        out.writeBoolean(values.get(i));
    }/* w w w  .  jav a  2  s  .co m*/
}

From source file:com.cloudera.crunch.type.writable.TextMapWritable.java

License:Open Source License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, valueClazz.getName());
    WritableUtils.writeVInt(out, instance.size());
    for (Map.Entry<Text, T> e : instance.entrySet()) {
        e.getKey().write(out);/*from w w  w  .jav  a 2 s .  co  m*/
        e.getValue().write(out);
    }
}

From source file:com.cloudera.crunch.type.writable.TupleWritable.java

License:Apache License

/**
 * Writes each Writable to <code>out</code>. TupleWritable format:
 * {@code/*from   www. j  a  v  a 2  s .c o  m*/
 *  <count><type1><type2>...<typen><obj1><obj2>...<objn>
 * }
 */
public void write(DataOutput out) throws IOException {
    WritableUtils.writeVInt(out, values.length);
    WritableUtils.writeVLong(out, written);
    for (int i = 0; i < values.length; ++i) {
        if (has(i)) {
            Text.writeString(out, values[i].getClass().getName());
        }
    }
    for (int i = 0; i < values.length; ++i) {
        if (has(i)) {
            values[i].write(out);
        }
    }
}