break; case BYTES: writer.append(Arrays.toString(obj.getBytes(fieldName))); break; case DOUBLE:
@Test public void testDefaultMissingObjectValue() throws IOException { addRecord(1, "one"); addRecord(2, "two"); addRecord(3, "three"); roundTripSnapshot(); GenericHollowObject obj = (GenericHollowObject) GenericHollowRecordHelper.instantiate(readStateEngine, "TestObject", 1); assertEquals(2, obj.getInt("f1")); assertEquals("two", obj.getString("f2")); assertEquals(Long.MIN_VALUE, obj.getLong("f3")); assertEquals(Integer.MIN_VALUE, obj.getInt("f4")); assertTrue(Float.isNaN(obj.getFloat("f5"))); assertTrue(Double.isNaN(obj.getDouble("f6"))); assertEquals(null, obj.getString("f7")); assertFalse(obj.isStringFieldEqual("f7", "not-null")); assertTrue(obj.isStringFieldEqual("f7", null)); assertEquals(null, obj.getBytes("f8")); assertTrue(obj.isNull("f9")); assertFalse(obj.getBoolean("f10")); }
public TypeWithAllFieldTypes(GenericHollowObject obj) { this.bool = obj.getBoolean("bool"); this.i = obj.getInt("i"); this.b = (byte)obj.getInt("b"); this.s = (short)obj.getInt("s"); this.c = (char)obj.getInt("c"); this.l = obj.getLong("l"); this.f = obj.getFloat("f"); this.d = obj.getDouble("d"); this.inlinedBoolean = obj.isNull("inlinedBoolean") ? null : obj.getBoolean("inlinedBoolean"); this.inlinedInt = obj.isNull("inlinedInt") ? null : obj.getInt("inlinedInt"); this.inlinedByte = obj.isNull("inlinedByte") ? null : (byte)obj.getInt("inlinedByte"); this.inlinedShort = obj.isNull("inlinedShort") ? null : (short)obj.getInt("inlinedShort"); this.inlinedChar = obj.isNull("inlinedChar") ? null : (char)obj.getInt("inlinedChar"); this.inlinedLong = obj.isNull("inlinedLong") ? null : obj.getLong("inlinedLong"); this.inlinedFloat = obj.isNull("inlinedFloat") ? null : obj.getFloat("inlinedFloat"); this.inlinedDouble = obj.isNull("inlinedDouble") ? null : obj.getDouble("inlinedDouble"); this.inlinedString = obj.isNull("inlinedString") ? null : obj.getString("inlinedString"); this.charArray = obj.isNull("charArray") ? null : obj.getString("charArray").toCharArray(); this.byteArray = obj.isNull("byteArray") ? null : obj.getBytes("byteArray"); this.nullablePrimitiveBoolean = obj.isNull("nullablePrimitiveBoolean") ? null : obj.getBoolean("nullablePrimitiveBoolean") ? NullablePrimitiveBoolean.TRUE : NullablePrimitiveBoolean.FALSE; this.referencedInteger = obj.isNull("referencedInteger") ? null : obj.getObject("referencedInteger").getInt("value"); }
Assert.assertEquals("three", typeA0.getObject("a3").getString("b1")); Assert.assertNull(typeA0.getSet("a4")); Assert.assertNull(typeA0.getBytes("a5")); Assert.assertEquals("four", typeA1.getObject("a3").getString("b1")); Assert.assertNull(typeA1.getSet("a4")); Assert.assertNull(typeA1.getBytes("a4"));