Package org.apache.hadoop.hbase.util

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


    }
  }

  @Test(expected = IllegalArgumentException.class)
  public void testInsufficientRemainingRead() {
    PositionedByteRange buff = new SimplePositionedByteRange(0);
    DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(), 3);
    type.decode(buff);
  }
View Full Code Here


    type.decode(buff);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testInsufficientRemainingWrite() {
    PositionedByteRange buff = new SimplePositionedByteRange(0);
    DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(), 3);
    type.encode(buff, Bytes.toBytes(""));
  }
View Full Code Here

    type.encode(buff, Bytes.toBytes(""));
  }

  @Test(expected = IllegalArgumentException.class)
  public void testOverflowPassthrough() {
    PositionedByteRange buff = new SimplePositionedByteRange(3);
    DataType<byte[]> type = new FixedLengthWrapper<byte[]>(new RawBytes(), 0);
    type.encode(buff, Bytes.toBytes("foo"));
  }
View Full Code Here

    Bytes.toBytes("7777777"), Bytes.toBytes("88888888"), Bytes.toBytes("999999999"),
  };

  @Test
  public void testEncodedLength() {
    PositionedByteRange buff = new SimplePositionedByteRange(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));
      }
    }
  }
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void testEncodedValueContainsTerm() {
    DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(), "foo");
    PositionedByteRange buff = new SimplePositionedByteRange(16);
    type.encode(buff, Bytes.toBytes("hello foobar!"));
  }
View Full Code Here

    type.encode(buff, Bytes.toBytes("hello foobar!"));
  }

  @Test
  public void testReadWriteSkippable() {
    PositionedByteRange buff = new SimplePositionedByteRange(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);
          assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
          buff.setPosition(0);
          assertEquals(val, type.decode(buff));
          assertEquals(val.length() + 2 + term.length, buff.getPosition());
        }
      }
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testReadWriteNonSkippable() {
    PositionedByteRange buff = new SimplePositionedByteRange(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);
          assertEquals(val.length + term.length, type.encode(buff, val));
          buff.setPosition(0);
          assertArrayEquals(val, type.decode(buff));
          assertEquals(val.length + term.length, buff.getPosition());
        }
      }
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testSkipSkippable() {
    PositionedByteRange buff = new SimplePositionedByteRange(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 SimplePositionedByteRange(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 SimplePositionedByteRange(Bytes.toBytes("foo"));
    DataType<byte[]> type = new TerminatedWrapper<byte[]>(new RawBytes(), new byte[] { 0x00 });
    type.skip(buff);
  }
View Full Code Here

TOP

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

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.