Пример #1
0
 @Test
 public void testReadWrite() {
   for (Order ord : new Order[] {Order.ASCENDING, Order.DESCENDING}) {
     RawString type = Order.ASCENDING == ord ? RawString.ASCENDING : RawString.DESCENDING;
     for (String val : VALUES) {
       PositionedByteRange buff = new SimplePositionedByteRange(Bytes.toBytes(val).length);
       assertEquals(buff.getLength(), type.encode(buff, val));
       byte[] expected = Bytes.toBytes(val);
       ord.apply(expected);
       assertArrayEquals(expected, buff.getBytes());
       buff.setPosition(0);
       assertEquals(val, type.decode(buff));
       buff.setPosition(0);
       assertEquals(buff.getLength(), type.skip(buff));
       assertEquals(buff.getLength(), buff.getPosition());
     }
   }
 }
Пример #2
0
 @Test
 public void testEncodedLength() {
   PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
   for (DataType<String> type :
       new OrderedString[] {OrderedString.ASCENDING, OrderedString.DESCENDING}) {
     for (String val : VALUES) {
       buff.setPosition(0);
       type.encode(buff, val);
       assertEquals(
           "encodedLength does not match actual, " + val,
           buff.getPosition(),
           type.encodedLength(val));
     }
   }
 }
Пример #3
0
 @Test
 public void testEncodedLength() {
   PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
   for (DataType<byte[]> type :
       new OrderedBlobVar[] {OrderedBlobVar.ASCENDING, OrderedBlobVar.DESCENDING}) {
     for (byte[] val : VALUES) {
       buff.setPosition(0);
       type.encode(buff, val);
       assertEquals(
           "encodedLength does not match actual, " + Bytes.toStringBinary(val),
           buff.getPosition(),
           type.encodedLength(val));
     }
   }
 }
Пример #4
0
 @Override
 public int skip(PositionedByteRange src) {
   src.setPosition(src.getPosition() + Bytes.SIZEOF_DOUBLE);
   return Bytes.SIZEOF_DOUBLE;
 }
Пример #5
0
 @Override
 public int skip(PositionedByteRange src) {
   src.setPosition(src.getPosition() + this.length);
   return this.length;
 }