Example usage for org.apache.hadoop.io VLongWritable VLongWritable

List of usage examples for org.apache.hadoop.io VLongWritable VLongWritable

Introduction

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

Prototype

public VLongWritable(long value) 

Source Link

Usage

From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.TestJsonNodeWritableUtils.java

License:Apache License

@Test
public void test_transform() {
    final ObjectMapper mapper = BeanTemplateUtils.configureMapper(Optional.empty());
    new JsonNodeWritableUtils(); //coverage!

    assertEquals(NullNode.instance, JsonNodeWritableUtils.transform("banana", JsonNodeFactory.instance));
    assertEquals(null, JsonNodeWritableUtils.transform(null, JsonNodeFactory.instance));
    assertEquals(NullNode.instance,//from  w  ww . j  a va2  s. co  m
            JsonNodeWritableUtils.transform(NullWritable.get(), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(true, JsonNode.class),
            JsonNodeWritableUtils.transform(new BooleanWritable(true), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue("test", JsonNode.class),
            JsonNodeWritableUtils.transform(new Text("test"), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(new byte[] { (byte) 0xFF }, JsonNode.class),
            JsonNodeWritableUtils.transform(new ByteWritable((byte) 0xFF), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(4, JsonNode.class),
            JsonNodeWritableUtils.transform(new IntWritable(4), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(4, JsonNode.class),
            JsonNodeWritableUtils.transform(new VIntWritable(4), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(4L, JsonNode.class),
            JsonNodeWritableUtils.transform(new LongWritable(4), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(4L, JsonNode.class),
            JsonNodeWritableUtils.transform(new VLongWritable(4), JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(new byte[] { (byte) 0xFF, (byte) 0xFE }, JsonNode.class),
            JsonNodeWritableUtils.transform(new BytesWritable(new byte[] { (byte) 0xFF, (byte) 0xFE }),
                    JsonNodeFactory.instance));
    assertEquals(mapper.convertValue(4.0, JsonNode.class),
            JsonNodeWritableUtils.transform(new DoubleWritable(4), JsonNodeFactory.instance));
    //(had real trouble creating a float node!)
    assertEquals(JsonNodeFactory.instance.numberNode(Float.valueOf((float) 4.0)),
            JsonNodeWritableUtils.transform(new FloatWritable(4), JsonNodeFactory.instance));

    // will test object writable and array writable below      
}

From source file:com.placeiq.piqconnect.Runner1Test.java

License:Apache License

@Test
public void reduce() throws IOException {
    reduceDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 3);

    int block_col = 0;

    BlockWritable e1 = blockVector(0, 1, 2);
    BlockWritable e2 = blockMatrix(block_col, 0, 1, 1, 0, 1, 2, 2, 1);

    reduceDriver.addInput(new IterationStage1.JoinKey(true, block_col), Arrays.asList(e1, e2));

    BlockWritable v1 = blockVector(BlockWritable.TYPE.VECTOR_INITIAL, 0, 1, 2);
    BlockWritable v2 = blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, 1, 0, 1);

    reduceDriver.addOutput(new VLongWritable(block_col), v1); // initial vector
    reduceDriver.addOutput(new VLongWritable(block_col), v2); // after multiplication
    reduceDriver.runTest();//from   w  ww . j  a va  2  s .co m
}

From source file:com.placeiq.piqconnect.Runner1Test.java

License:Apache License

@Test
public void mapReduce() throws IOException {
    mrDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 3);

    mrDriver.addInput(blockIndex(0), blockVector(0, 1, 2));
    mrDriver.addInput(blockIndex(0, 0), blockMatrix(1, 0, 1, 1, 0, 1, 2, 2, 1));

    mrDriver.addOutput(new VLongWritable(0), blockVector(BlockWritable.TYPE.VECTOR_INITIAL, 0, 1, 2));
    mrDriver.addOutput(new VLongWritable(0), blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, 1, 0, 1));
    mrDriver.runTest();//from  ww w.ja  va  2  s. co m
}

From source file:com.placeiq.piqconnect.Runner1Test.java

License:Apache License

@Test
public void reduce2() throws IOException {
    reduceDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 3);

    int block_col = 0;

    BlockWritable e1 = blockVector(1, -1, -1);
    BlockWritable e2 = blockMatrix(block_col, 2, 0);

    reduceDriver.addInput(new IterationStage1.JoinKey(true, block_col), Arrays.asList(e1, e2));

    BlockWritable v1 = blockVector(BlockWritable.TYPE.VECTOR_INITIAL, 1, -1, -1);
    BlockWritable v2 = blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, -1, -1, 1);

    reduceDriver.addOutput(new VLongWritable(block_col), v1); // initial vector
    reduceDriver.addOutput(new VLongWritable(block_col), v2); // after multiplication
    reduceDriver.runTest();//w w w . ja v  a  2s.co  m
}

From source file:com.placeiq.piqconnect.Runner1Test.java

License:Apache License

@Test
public void mapReduce2() throws IOException {
    mrDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 2);

    mrDriver.addInput(blockIndex(0), blockVector(0, 1));
    mrDriver.addInput(blockIndex(1), blockVector(2, 3));

    mrDriver.addInput(blockIndex(0, 0), blockMatrix(0L, 0, 1, 1, 0));
    mrDriver.addInput(blockIndex(0, 1), blockMatrix(1L, 1, 0));
    mrDriver.addInput(blockIndex(1, 0), blockMatrix(0L, 0, 1));
    mrDriver.addInput(blockIndex(1, 1), blockMatrix(1L, 1, 1));

    mrDriver.addOutput(new VLongWritable(0), blockVector(BlockWritable.TYPE.VECTOR_INITIAL, 0, 1));
    mrDriver.addOutput(new VLongWritable(0), blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, 1, 0));
    mrDriver.addOutput(new VLongWritable(1), blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, 1, -1));
    mrDriver.addOutput(new VLongWritable(1), blockVector(BlockWritable.TYPE.VECTOR_INITIAL, 2, 3));
    mrDriver.addOutput(new VLongWritable(0), blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, -1, 2));
    mrDriver.addOutput(new VLongWritable(1), blockVector(BlockWritable.TYPE.VECTOR_INCOMPLETE, -1, 3));

    mrDriver.runTest();/*  w  w w.j av  a 2 s  .co  m*/
}

From source file:com.placeiq.piqconnect.Runner2Test.java

License:Apache License

@Test
public void reduce1() throws IOException {
    reduceDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 2);

    reduceDriver.addInput(new VLongWritable(0), Arrays.asList(blockVector(TYPE.VECTOR_INITIAL, 0, 1),
            blockVector(TYPE.VECTOR_INCOMPLETE, 0, 0), blockVector(TYPE.VECTOR_INCOMPLETE, 2, 2)));

    reduceDriver.addInput(new VLongWritable(1), Arrays.asList(blockVector(TYPE.VECTOR_INITIAL, 2, 3),
            blockVector(TYPE.VECTOR_INCOMPLETE, 0, 1), blockVector(TYPE.VECTOR_INCOMPLETE, 2, 3)));

    reduceDriver.addOutput(blockIndex(0), blockVector(TYPE.VECTOR_INCOMPLETE, 0, 0));
    reduceDriver.addOutput(blockIndex(1), blockVector(TYPE.VECTOR_INCOMPLETE, 0, 1));

    reduceDriver.runTest();/*from   ww  w .j  a v  a  2s.c  o  m*/
}

From source file:com.placeiq.piqconnect.Runner2Test.java

License:Apache License

@Test
public void reduce2() throws IOException {
    reduceDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 3);

    reduceDriver.addInput(new VLongWritable(0), Arrays.asList(blockVector(TYPE.VECTOR_INITIAL, 0, 1, 3),
            blockVector(TYPE.VECTOR_INCOMPLETE, 1, 0, 2), blockVector(TYPE.VECTOR_INCOMPLETE, 3, -1, -1)));

    reduceDriver.addOutput(blockIndex(0), blockVector(TYPE.VECTOR_INCOMPLETE, 0, 0, 2));

    reduceDriver.runTest();//  www  . j av a 2s.  c  o  m
}

From source file:com.placeiq.piqconnect.Runner2Test.java

License:Apache License

@Test
public void reduce3() throws IOException {
    reduceDriver.getConfiguration().setInt(Constants.PROP_BLOCK_SIZE, 3);

    reduceDriver.addInput(new VLongWritable(0), Arrays.asList(blockVector(TYPE.VECTOR_INITIAL, 3, -1, -1),
            blockVector(TYPE.VECTOR_INCOMPLETE, 2, 1, 2)));

    reduceDriver.addOutput(blockIndex(0), blockVector(TYPE.VECTOR_INCOMPLETE, 2, -1, -1));

    reduceDriver.runTest();/*  w  w w  . j  a  v a2s.c o m*/
}

From source file:com.toshiba.mwcloud.gs.hadoop.io.GSRowWritable.java

License:Apache License

private void writeColumn(DataOutput out, int i) throws IOException {
    switch (types_[i]) {
    case BLOB:/*from w w w  .j a v  a2 s. c o m*/
        out.writeByte(BLOB);
        writeBlob(out, (Blob) values_[i]);
        break;
    case BOOL:
        out.writeByte(BOOL);
        out.writeBoolean((Boolean) values_[i]);
        break;
    case BYTE:
        out.writeByte(BYTE);
        out.writeByte((Byte) values_[i]);
        break;
    case DOUBLE:
        out.writeByte(DOUBLE);
        out.writeDouble((Double) values_[i]);
        break;
    case FLOAT:
        out.writeByte(FLOAT);
        out.writeFloat((Float) values_[i]);
        break;
    case INTEGER:
        out.writeByte(INTEGER);
        new VIntWritable((Integer) values_[i]).write(out);
        break;
    case LONG:
        out.writeByte(LONG);
        new VLongWritable((Long) values_[i]).write(out);
        break;
    case SHORT:
        out.writeByte(SHORT);
        out.writeShort((Short) values_[i]);
        break;
    case STRING:
        out.writeByte(STRING);
        writeString(out, (String) values_[i]);
        break;
    case TIMESTAMP:
        out.writeByte(TIMESTAMP);
        out.writeLong(((Date) values_[i]).getTime());
        break;
    case BOOL_ARRAY:
        out.writeByte(BOOL_ARRAY);
        writeBoolArray(out, (boolean[]) values_[i]);
        break;
    case BYTE_ARRAY:
        out.writeByte(BYTE_ARRAY);
        writeByteArray(out, (byte[]) values_[i]);
        break;
    case DOUBLE_ARRAY:
        out.writeByte(DOUBLE_ARRAY);
        writeDoubleArray(out, (double[]) values_[i]);
        break;
    case FLOAT_ARRAY:
        out.writeByte(FLOAT_ARRAY);
        writeFloatArray(out, (float[]) values_[i]);
        break;
    case INTEGER_ARRAY:
        out.writeByte(INTEGER_ARRAY);
        writeIntegerArray(out, (int[]) values_[i]);
        break;
    case LONG_ARRAY:
        out.writeByte(LONG_ARRAY);
        writeLongArray(out, (long[]) values_[i]);
        break;
    case SHORT_ARRAY:
        out.writeByte(SHORT_ARRAY);
        writeShortArray(out, (short[]) values_[i]);
        break;
    case STRING_ARRAY:
        out.writeByte(STRING_ARRAY);
        writeStringArray(out, (String[]) values_[i]);
        break;
    case TIMESTAMP_ARRAY:
        out.writeByte(TIMESTAMP_ARRAY);
        writeTimestampArray(out, (Date[]) values_[i]);
        break;
    default:
        throw new IOException();
    }
}

From source file:crunch.MaxTemperature.java

License:Apache License

@Test
    public void test() throws IOException {
        assertThat(serializeToString(new VLongWritable(1)), is("01")); // 1 byte
        assertThat(serializeToString(new VLongWritable(127)), is("7f")); // 1 byte
        assertThat(serializeToString(new VLongWritable(128)), is("8f80")); // 2 byte
        assertThat(serializeToString(new VLongWritable(163)), is("8fa3")); // 2 byte
        assertThat(serializeToString(new VLongWritable(Long.MAX_VALUE)), is("887fffffffffffffff")); // 9 byte
        assertThat(serializeToString(new VLongWritable(Long.MIN_VALUE)), is("807fffffffffffffff")); // 9 byte
    }/*from  ww  w  . j  a  v a  2s  .c  o  m*/