Esempio n. 1
0
 @Override
 public void read(Kryo kryo, Input in) {
   this.offset = BYTE_ARRAY_OFFSET;
   this.numBytes = in.readInt();
   this.base = new byte[numBytes];
   in.read((byte[]) base);
 }
Esempio n. 2
0
 public Class read(Kryo kryo, Input input, Class<Class> type) {
   Registration registration = kryo.readClass(input);
   int isPrimitive = input.read();
   Class typ = registration != null ? registration.getType() : null;
   if (typ == null || !typ.isPrimitive()) return typ;
   return (isPrimitive == 1) ? typ : getWrapperClass(typ);
 }
Esempio n. 3
0
 @Override
 public void read(Kryo kryo, Input in) {
   this.baseOffset = BYTE_ARRAY_OFFSET;
   this.sizeInBytes = in.readInt();
   this.numFields = in.readInt();
   this.bitSetWidthInBytes = calculateBitSetWidthInBytes(numFields);
   this.baseObject = new byte[sizeInBytes];
   in.read((byte[]) baseObject);
 }
Esempio n. 4
0
  public void testInputStream() throws IOException {
    byte[] bytes =
        new byte[] { //
          11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
          31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
          51, 52, 53, 54, 55, 56, 57, 58, //
          61, 62, 63, 64, 65
        };
    ByteArrayInputStream buffer = new ByteArrayInputStream(bytes);
    Input input = new Input(buffer, 2);
    byte[] temp = new byte[1024];
    int count = input.read(temp, 512, bytes.length);
    assertEquals(bytes.length, count);
    byte[] temp2 = new byte[count];
    System.arraycopy(temp, 512, temp2, 0, count);
    assertEquals(bytes, temp2);

    input = new Input(bytes);
    count = input.read(temp, 512, 512);
    assertEquals(bytes.length, count);
    temp2 = new byte[count];
    System.arraycopy(temp, 512, temp2, 0, count);
    assertEquals(bytes, temp2);
  }
Esempio n. 5
0
 @Override
 protected int maybeReadBytes(byte[] buffer, int offset, int count) {
   return input.read(buffer, offset, count);
 }