List of usage examples for org.apache.hadoop.io BooleanWritable BooleanWritable
public BooleanWritable(boolean value)
From source file:org.elasticsearch.hadoop.serialization.HiveTypeToJsonTest.java
License:Apache License
@Test public void testBoolean() { assertEquals("true", hiveTypeToJson(new MyHiveType(new BooleanWritable(Boolean.TRUE), booleanTypeInfo))); }
From source file:org.elasticsearch.hadoop.serialization.WritableTypeToJsonTest.java
License:Apache License
@Test public void testBoolean() { writableTypeToJson(new BooleanWritable(Boolean.TRUE)); }
From source file:org.elasticsearch.hadoop.serialization.WritableTypeToJsonTest.java
License:Apache License
@Test public void testMap() { LinkedMapWritable map = new LinkedMapWritable(); map.put(new Text("key"), new IntWritable(1)); map.put(new BooleanWritable(Boolean.TRUE), new ArrayWritable(new String[] { "one", "two" })); writableTypeToJson(map);//from w w w . j a va2s .c o m }
From source file:org.elasticsearch.hadoop.serialization.WritableValueReaderTest.java
License:Apache License
@Override public void checkBoolean(Object typeFromJson) { assertEquals(new BooleanWritable(Boolean.TRUE), typeFromJson); }
From source file:org.elasticsearch.hadoop.util.WritableUtils.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Writable toWritable(Object object) { if (object instanceof Writable) { return (Writable) object; }/*from ww w . j ava2s .c om*/ if (object == null) { return NullWritable.get(); } if (object instanceof String) { return new Text((String) object); } if (object instanceof Long) { return new VLongWritable((Long) object); } if (object instanceof Integer) { return new VIntWritable((Integer) object); } if (object instanceof Byte) { return new ByteWritable((Byte) object); } if (object instanceof Short) { return WritableCompatUtil.availableShortWritable((Short) object); } if (object instanceof Double) { return new DoubleWritable((Double) object); } if (object instanceof Float) { return new FloatWritable((Float) object); } if (object instanceof Boolean) { return new BooleanWritable((Boolean) object); } if (object instanceof byte[]) { return new BytesWritable((byte[]) object); } if (object instanceof List) { List<Object> list = (List<Object>) object; if (!list.isEmpty()) { Object first = list.get(0); Writable[] content = new Writable[list.size()]; for (int i = 0; i < content.length; i++) { content[i] = toWritable(list.get(i)); } return new ArrayWritable(toWritable(first).getClass(), content); } return new ArrayWritable(NullWritable.class, new Writable[0]); } if (object instanceof SortedSet) { SortedMapWritable smap = new SortedMapWritable(); SortedSet<Object> set = (SortedSet) object; for (Object obj : set) { smap.put((WritableComparable) toWritable(obj), NullWritable.get()); } return smap; } if (object instanceof Set) { MapWritable map = new MapWritable(); Set<Object> set = (Set) object; for (Object obj : set) { map.put(toWritable(obj), NullWritable.get()); } return map; } if (object instanceof SortedMap) { SortedMapWritable smap = new SortedMapWritable(); Map<Object, Object> map = (Map) object; for (Map.Entry<?, ?> entry : map.entrySet()) { smap.put((WritableComparable) toWritable(entry.getKey()), toWritable(entry.getValue())); } return smap; } if (object instanceof Map) { MapWritable result = new MapWritable(); Map<Object, Object> map = (Map) object; for (Map.Entry<?, ?> entry : map.entrySet()) { result.put(toWritable(entry.getKey()), toWritable(entry.getValue())); } return result; } // fall-back to bytearray return new BytesWritable(object.toString().getBytes(StringUtils.UTF_8)); }
From source file:org.goldenorb.types.message.BooleanMessage.java
License:Apache License
/** * Constructor//from www . j a v a 2 s .c om * * @param destinationVertex * - String * @param value * - boolean */ public BooleanMessage(String destinationVertex, boolean value) { super(BooleanWritable.class); this.setDestinationVertex(destinationVertex); this.setMessageValue(new BooleanWritable(value)); }
From source file:org.goldenorb.types.message.SampleBooleanMessageTest.java
License:Apache License
/** * Constructor * */ public SampleBooleanMessageTest() { bm0.setMessageValue(new BooleanWritable(MESSAGE_VALUE)); bm0.setDestinationVertex(DESTINATION_VALUE); }
From source file:org.goldenorb.types.message.SampleBooleanMessageTest.java
License:Apache License
@Test public void testRPC() { BooleanMessage bm1 = client.sendAndReceiveMessage(bm0, DESTINATION_VALUE, new BooleanWritable(MESSAGE_VALUE)); assertEquals(bm0.get(), client.getMessage().get()); assertEquals(bm0.getDestinationVertex(), client.getMessage().getDestinationVertex()); assertEquals(bm1.getDestinationVertex(), DESTINATION_VALUE); assertEquals(((BooleanWritable) bm1.getMessageValue()).get(), MESSAGE_VALUE); }
From source file:org.huahinframework.core.io.RecordTest.java
License:Apache License
@Test public void testGroupingBooleanWritable() { Record record = new Record(); BooleanWritable o = new BooleanWritable(true); record.addGrouping("Object", o); assertEquals(record.getGroupingBooleanWritable("Object"), o); assertEquals(record.getGroupingBooleanWritable("Object2"), null); try {/*from w w w .jav a2 s .c o m*/ record.getGroupingInteger("Object"); fail("fail ClassCastException"); } catch (Exception e) { assertTrue(e instanceof ClassCastException); } }
From source file:org.huahinframework.core.io.RecordTest.java
License:Apache License
@Test public void testValueBooleanWritable() { Record record = new Record(); BooleanWritable o = new BooleanWritable(true); record.addValue("Object", o); assertEquals(record.getValueBooleanWritable("Object"), o); assertEquals(record.getValueBooleanWritable("Object2"), null); try {//from w w w. j ava 2s . co m record.getValueIntWritable("Object"); fail("fail ClassCastException"); } catch (Exception e) { assertTrue(e instanceof ClassCastException); } }