Package org.apache.hadoop.hbase.util

Examples of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange


    }
  }

  @Test
  public void testSkipSkippable() {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
    for (OrderedString t : new OrderedString[] {
        OrderedString.ASCENDING, OrderedString.DESCENDING
    }) {
      for (byte[] term : TERMINATORS) {
        for (String val : VALUES_STRINGS) {
          buff.setPosition(0);
          DataType<String> type = new TerminatedWrapper<String>(t, term);
          int expected = val.length() + 2 + term.length;
          assertEquals(expected, type.encode(buff, val));
          buff.setPosition(0);
          assertEquals(expected, type.skip(buff));
          assertEquals(expected, buff.getPosition());
        }
      }
    }
  }
View Full Code Here


    }
  }

  @Test
  public void testSkipNonSkippable() {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
    for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
      for (byte[] term : TERMINATORS) {
        for (byte[] val : VALUES_BYTES) {
          buff.setPosition(0);
          DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(ord), term);
          int expected = type.encode(buff, val);
          buff.setPosition(0);
          assertEquals(expected, type.skip(buff));
          assertEquals(expected, buff.getPosition());
        }
      }
    }
  }
View Full Code Here

    }
  }

  @Test(expected = IllegalArgumentException.class)
  public void testInvalidSkip() {
    PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes("foo"));
    DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(), new byte[] { 0x00 });
    type.skip(buff);
  }
View Full Code Here

  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 SimplePositionedMutableByteRange(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());
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.