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

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

Introduction

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

Prototype

public BooleanWritable(boolean value) 

Source Link

Usage

From source file:com.csiro.hadoop.WritableTest.java

public static void main(String[] args) {
    System.out.println("*** Primitive Writable ***");

    BooleanWritable bool1 = new BooleanWritable(true);
    ByteWritable byte1 = new ByteWritable((byte) 3);
    System.out.printf("Boolean:%s Byte:%d\n", bool1, byte1.get());

    IntWritable int1 = new IntWritable(5);
    IntWritable int2 = new IntWritable(17);
    System.out.printf("I1:%d I2:%d\n", int1.get(), int2.get());

    int1.set(int2.get());
    System.out.printf("I1:%d I2:%d\n", int1.get(), int2.get());

    Integer int3 = new Integer(23);
    int1.set(int3);
    System.out.printf("I1:%d I2:%d\n", int1.get(), int2.get());

    System.out.println("*** Array Writable ***");

    ArrayWritable a = new ArrayWritable(IntWritable.class);
    a.set(new IntWritable[] { new IntWritable(1), new IntWritable(3), new IntWritable(5) });

    IntWritable[] values = (IntWritable[]) a.get();
    for (IntWritable i : values) {
        System.out.println(i);/*from   w  w w  .j  a v  a2  s. c o m*/
    }

    IntArrayWritable ia = new IntArrayWritable();
    ia.set(new IntWritable[] { new IntWritable(1), new IntWritable(3), new IntWritable(5) });

    IntWritable[] ivalues = (IntWritable[]) ia.get();

    ia.set((new LongWritable[] { new LongWritable(10001) }));

    System.out.println("*** Map Writables ***");

    MapWritable m = new MapWritable();
    IntWritable key1 = new IntWritable(5);
    NullWritable value1 = NullWritable.get();

    m.put(key1, value1);
    System.out.println(m.containsKey(key1));
    System.out.println(m.get(key1));
    m.put(new LongWritable(100000000), key1);
    Set<Writable> keys = m.keySet();

    for (Writable k : keys)
        System.out.println(k.getClass());

}

From source file:com.datasalt.pangool.utils.test.AbstractHadoopTestLibrary.java

License:Apache License

public Writable writable(Object obj) {
    if (obj instanceof Integer) {
        return new IntWritable((Integer) obj);
    } else if (obj instanceof Double) {
        return new DoubleWritable((Double) obj);
    } else if (obj instanceof Long) {
        return new LongWritable((Long) obj);
    } else if (obj instanceof String) {
        return new Text((String) obj);
    } else if (obj instanceof Float) {
        return new FloatWritable((Float) obj);
    } else if (obj instanceof Boolean) {
        return new BooleanWritable((Boolean) obj);
    }// www . jav a2 s  .c  o m
    return null;
}

From source file:com.ebay.nest.io.sede.lazy.LazyBoolean.java

License:Apache License

public LazyBoolean(LazyBoolean copy) {
    super(copy);
    data = new BooleanWritable(copy.data.get());
}

From source file:com.ebay.nest.io.sede.lazybinary.LazyBinaryBoolean.java

License:Apache License

public LazyBinaryBoolean(LazyBinaryBoolean copy) {
    super(copy);
    data = new BooleanWritable(copy.data.get());
}

From source file:com.ebay.nest.io.sede.objectinspector.primitive.JavaBooleanObjectInspector.java

License:Apache License

@Override
public Object getPrimitiveWritableObject(Object o) {
    return o == null ? null : new BooleanWritable(((Boolean) o).booleanValue());
}

From source file:com.ebay.nest.io.sede.objectinspector.primitive.WritableBooleanObjectInspector.java

License:Apache License

@Override
public Object copyObject(Object o) {
    return o == null ? null : new BooleanWritable(((BooleanWritable) o).get());
}

From source file:com.ebay.nest.io.sede.objectinspector.primitive.WritableBooleanObjectInspector.java

License:Apache License

@Override
public Object create(boolean value) {
    return new BooleanWritable(value);
}

From source file:com.facebook.hive.orc.lazy.OrcLazyBoolean.java

License:Open Source License

public OrcLazyBoolean(OrcLazyBoolean copy) {
    super(copy);/*  w  w  w.  j  av  a 2 s.c  o m*/
    if (copy.previous != null) {
        previous = new BooleanWritable(((BooleanWritable) copy.previous).get());
    }
}

From source file:com.hotels.corc.DefaultConverterFactoryTest.java

License:Apache License

@Test
public void booleanJava() throws UnexpectedTypeException {
    Converter converter = factory.newConverter(PrimitiveObjectInspectorFactory.javaBooleanObjectInspector);
    assertThat(converter.toJavaObject(new BooleanWritable(true)), is((Object) true));
}

From source file:com.hotels.corc.DefaultConverterFactoryTest.java

License:Apache License

@Test
public void booleanWritable() throws UnexpectedTypeException {
    Converter converter = factory.newConverter(PrimitiveObjectInspectorFactory.javaBooleanObjectInspector);
    assertThat(converter.toWritableObject(true), is((Object) new BooleanWritable(true)));
}