コード例 #1
0
 @Test
 public void testComplexSerialization() throws Exception {
   try (ChronicleMap<String, A> map =
       ChronicleMapBuilder.of(String.class, A.class)
           .valueMarshaller(AMarshaller.INSTANCE)
           .entries(5)
           .averageKeySize(4)
           .averageValueSize(1000)
           .create()) {
     A obj_A = new A();
     obj_A.str_ = "a";
     obj_A.list_ = new ArrayList<>();
     B b = new B();
     b.str_ = "b";
     obj_A.list_.add(b);
     map.put("KEY1", obj_A);
     map.get("KEY1");
   }
 }
コード例 #2
0
 @NotNull
 @Override
 public A read(Bytes in, A using) {
   if (using == null) using = new A();
   using.str_ = in.readUtf8();
   int size = (int) in.readStopBit();
   if (size >= 0) {
     if (using.list_ == null) {
       using.list_ = new ArrayList<>(size);
     } else {
       using.list_.clear();
       if (using.list_ instanceof ArrayList) ((ArrayList) using.list_).ensureCapacity(size);
     }
     for (int i = 0; i < size; i++) {
       B b = new B();
       b.readMarshallable(in);
       using.list_.add(b);
     }
   } else {
     assert size == -1;
     using.list_ = null;
   }
   return using;
 }