Esempio n. 1
0
  void checkKeyClone(GroupSerializer ser, Object[] keys) throws IOException {
    DataOutput2 out = new DataOutput2();
    ser.valueArraySerialize(out, ser.valueArrayFromArray(keys));
    DataInput2.ByteArray in = new DataInput2.ByteArray(out.copyBytes());

    Object[] keys2 = ser.valueArrayToArray(ser.valueArrayDeserialize(in, keys.length));
    assertEquals(in.pos, out.pos);

    assertArrayEquals(keys, keys2);
  }
Esempio n. 2
0
  @Test
  public void testUUID() throws IOException {
    List<java.util.UUID> ids = new ArrayList<java.util.UUID>();
    for (int i = 0; i < 100; i++) ids.add(java.util.UUID.randomUUID());

    long[] vv = (long[]) Serializer.UUID.valueArrayFromArray(ids.toArray());

    int i = 0;
    for (java.util.UUID u : ids) {
      assertEquals(u.getMostSignificantBits(), vv[i++]);
      assertEquals(u.getLeastSignificantBits(), vv[i++]);
    }

    // clone
    DataOutput2 out = new DataOutput2();
    Serializer.UUID.valueArraySerialize(out, vv);

    DataInput2 in = new DataInput2.ByteArray(out.copyBytes());
    long[] nn = (long[]) Serializer.UUID.valueArrayDeserialize(in, ids.size());

    assertArrayEquals(vv, nn);

    // test key addition
    java.util.UUID r = java.util.UUID.randomUUID();
    ids.add(10, r);
    long[] vv2 = (long[]) Serializer.UUID.valueArrayPut(vv, 10, r);
    i = 0;
    for (java.util.UUID u : ids) {
      assertEquals(u.getMostSignificantBits(), vv2[i++]);
      assertEquals(u.getLeastSignificantBits(), vv2[i++]);
    }

    vv2 = (long[]) Serializer.UUID.valueArrayDeleteValue(vv2, 10 + 1);

    assertArrayEquals(vv, vv2);
  }
Esempio n. 3
0
 @Override
 public void serialize(DataOutput2 out, Byte value) throws IOException {
   out.writeByte(value);
 }