Ejemplo n.º 1
0
 @Test
 public void objectWriteRead() {
   // serialize.registerClass(short[].class);
   // serialize.registerClass(TestClass.class);
   DataOutput out = serialize.getDataOutput(128, true);
   String str = "This is a test";
   int i = 5;
   TestClass c = new TestClass(5, 8, new short[] {1, 2, 3, 4, 5}, TestEnum.Two);
   Number n = new Double(3.555);
   out.writeObjectNotNull(str);
   out.putInt(i);
   out.writeObject(c, TestClass.class);
   out.writeClassAndObject(n);
   ReadBuffer b = out.getStaticBuffer().asReadBuffer();
   if (printStats) log.debug(bufferStats(b));
   String str2 = serialize.readObjectNotNull(b, String.class);
   assertEquals(str, str2);
   if (printStats) log.debug(bufferStats(b));
   assertEquals(b.getInt(), i);
   TestClass c2 = serialize.readObject(b, TestClass.class);
   assertEquals(c, c2);
   if (printStats) log.debug(bufferStats(b));
   assertEquals(n, serialize.readClassAndObject(b));
   if (printStats) log.debug(bufferStats(b));
   assertFalse(b.hasRemaining());
 }
Ejemplo n.º 2
0
 private Object readInline(ByteBuffer read, TitanType type) {
   if (type.isPropertyKey()) {
     TitanKey proptype = ((TitanKey) type);
     if (hasGenericDataType(proptype)) return serializer.readClassAndObject(read);
     else return serializer.readObject(read, proptype.getDataType());
   } else {
     assert type.isEdgeLabel();
     Long id = Long.valueOf(VariableLong.readPositive(read));
     if (id.longValue() == 0) return null;
     else return id;
   }
 }