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:io.fluo.core.client.Operations.java

License:Apache License

private static void serializeObservers(DataOutputStream dos, Map<Column, ObserverConfiguration> colObservers)
        throws IOException {
    // TODO use a human readable serialized format like json

    Set<Entry<Column, ObserverConfiguration>> es = colObservers.entrySet();

    WritableUtils.writeVInt(dos, colObservers.size());

    for (Entry<Column, ObserverConfiguration> entry : es) {
        entry.getKey().write(dos);//from  w  w w.  ja  v  a  2 s .c o m
        dos.writeUTF(entry.getValue().getClassName());
        Map<String, String> params = entry.getValue().getParameters();
        WritableUtils.writeVInt(dos, params.size());
        for (Entry<String, String> pentry : entry.getValue().getParameters().entrySet()) {
            dos.writeUTF(pentry.getKey());
            dos.writeUTF(pentry.getValue());
        }
    }
}

From source file:io.prestosql.rcfile.TestRcFileDecoderUtils.java

License:Apache License

private static Slice writeVintOld(SliceOutput output, long value) throws IOException {
    output.reset();//from   www.j  ava 2s .c  om
    WritableUtils.writeVLong(output, value);
    Slice vLongOld = Slices.copyOf(output.slice());

    output.reset();
    RcFileDecoderUtils.writeVLong(output, value);
    Slice vLongNew = Slices.copyOf(output.slice());
    assertEquals(vLongNew, vLongOld);

    if (value == (int) value) {
        output.reset();
        WritableUtils.writeVInt(output, (int) value);
        Slice vIntOld = Slices.copyOf(output.slice());
        assertEquals(vIntOld, vLongOld);

        output.reset();
        RcFileDecoderUtils.writeVInt(output, (int) value);
        Slice vIntNew = Slices.copyOf(output.slice());
        assertEquals(vIntNew, vLongOld);
    }
    return vLongOld;
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void authenticate(String digest, String challenge) throws IOException {
    LOG.debug("Sending AUTHENTICATION_REQ, digest=" + digest + ", challenge=" + challenge);
    WritableUtils.writeVInt(stream, MessageType.AUTHENTICATION_REQ.code);
    Text.writeString(stream, digest);
    Text.writeString(stream, challenge);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void start() throws IOException {
    LOG.debug("starting downlink");
    WritableUtils.writeVInt(stream, MessageType.START.code);
    WritableUtils.writeVInt(stream, CURRENT_PROTOCOL_VERSION);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void setJobConf(Configuration conf) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.SET_JOB_CONF.code);
    List<String> list = new ArrayList<String>();
    for (Map.Entry<String, String> itm : conf) {
        list.add(itm.getKey());//from  w  w  w.j  av a2 s  .  c o  m
        list.add(itm.getValue());
    }
    WritableUtils.writeVInt(stream, list.size());
    for (String entry : list) {
        Text.writeString(stream, entry);
    }
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void setInputTypes(String keyType, String valueType) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.SET_INPUT_TYPES.code);
    Text.writeString(stream, keyType);
    Text.writeString(stream, valueType);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void runMap(FileSplit split, int numReduces, boolean pipedInput) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.RUN_MAP.code);
    writeObject(split);//w  ww  . j  ava2s .c om
    WritableUtils.writeVInt(stream, numReduces);
    WritableUtils.writeVInt(stream, pipedInput ? 1 : 0);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void mapItem(Writable key, Writable value) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.MAP_ITEM.code);
    writeObject(key);
    writeObject(value);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void runReduce(int reduce, boolean pipedOutput) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.RUN_REDUCE.code);
    WritableUtils.writeVInt(stream, reduce);
    WritableUtils.writeVInt(stream, pipedOutput ? 1 : 0);
}

From source file:it.crs4.pydoop.mapreduce.pipes.BinaryProtocol.java

License:Apache License

public void reduceKey(Writable key) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.REDUCE_KEY.code);
    writeObject(key);
}