Java Code Examples for org.apache.hadoop.hbase.util.Order#DESCENDING
The following examples show how to use
org.apache.hadoop.hbase.util.Order#DESCENDING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRawString.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadWrite() { for (final Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) { final RawString type = Order.ASCENDING == ord ? new RawString(Order.ASCENDING) : new RawString(Order.DESCENDING); for (final String val : VALUES) { final PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes(val).length); assertEquals(buff.getLength(), type.encode(buff, val)); final 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()); } } }
Example 2
Source File: TestTerminatedWrapper.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testSkipSkippable() { final PositionedByteRange buff = new SimplePositionedMutableByteRange(14); for (final OrderedString t : new OrderedString[] { new OrderedString(Order.ASCENDING), new OrderedString(Order.DESCENDING) }) { for (final byte[] term : TERMINATORS) { for (final String val : VALUES_STRINGS) { buff.setPosition(0); final DataType<String> type = new TerminatedWrapper<>(t, term); final 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()); } } } }
Example 3
Source File: TestTerminatedWrapper.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadWriteNonSkippable() { 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<>(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()); } } } }
Example 4
Source File: TestTerminatedWrapper.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadWriteSkippable() { final PositionedByteRange buff = new SimplePositionedMutableByteRange(14); for (final OrderedString t : new OrderedString[] { new OrderedString(Order.ASCENDING), new OrderedString(Order.DESCENDING) }) { for (final byte[] term : TERMINATORS) { for (final String val : VALUES_STRINGS) { buff.setPosition(0); final DataType<String> type = new TerminatedWrapper<>(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()); } } } }
Example 5
Source File: TestFixedLengthWrapper.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReadWrite() { for (int limit : limits) { PositionedByteRange buff = new SimplePositionedMutableByteRange(limit); for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) { for (byte[] val : VALUES) { buff.setPosition(0); DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(ord), limit); assertEquals(limit, type.encode(buff, val)); buff.setPosition(0); byte[] actual = type.decode(buff); assertTrue("Decoding output differs from expected", Bytes.equals(val, 0, val.length, actual, 0, val.length)); buff.setPosition(0); assertEquals(limit, type.skip(buff)); } } } }
Example 6
Source File: TestOrderedInt16.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedFloatLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedInt16 type : new OrderedInt16[] { new OrderedInt16(Order.ASCENDING), new OrderedInt16(Order.DESCENDING) }) { for (final Short val : VALUES) { buffer.setPosition(0); type.encodeShort(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 7
Source File: TestOrderedNumeric.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Number> type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) { for (final Number val : DOUBLE_VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 8
Source File: TestOrderedInt64.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedFloatLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedInt64 type : new OrderedInt64[] { new OrderedInt64(Order.ASCENDING), new OrderedInt64(Order.DESCENDING) }) { for (final Long val : VALUES) { buffer.setPosition(0); type.encodeLong(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 9
Source File: TestOrderedInt64.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Long> type : new OrderedInt64[] { new OrderedInt64(Order.ASCENDING), new OrderedInt64(Order.DESCENDING) }) { for (final Long val : VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 10
Source File: TestOrderedInt8.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedFloatLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedInt8 type : new OrderedInt8[] { new OrderedInt8(Order.ASCENDING), new OrderedInt8(Order.DESCENDING) }) { for (final Byte val : VALUES) { buffer.setPosition(0); type.encodeByte(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 11
Source File: TestOrderedInt8.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Byte> type : new OrderedInt8[] { new OrderedInt8(Order.ASCENDING), new OrderedInt8(Order.DESCENDING) }) { for (final Byte val : VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 12
Source File: TestOrderedBlob.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { PositionedByteRange buff = new SimplePositionedMutableByteRange(20); for (final DataType<byte[]> type : new OrderedBlob[] { new OrderedBlob(Order.ASCENDING), new OrderedBlob(Order.DESCENDING) }) { for (final byte[] val : VALUES) { buff.setPosition(0); type.encode(buff, val); assertEquals("encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val)); } } }
Example 13
Source File: TestOrderedInt32.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Integer> type : new OrderedInt32[] { new OrderedInt32(Order.ASCENDING), new OrderedInt32(Order.DESCENDING) }) { for (final Integer val : VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals( "encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 14
Source File: TestOrderedNumeric.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedDoubleLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedNumeric type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) { for (final Double val : DOUBLE_VALUES) { buffer.setPosition(0); type.encodeDouble(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 15
Source File: TestOrderedInt32.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedFloatLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedInt32 type : new OrderedInt32[] { new OrderedInt32(Order.ASCENDING), new OrderedInt32(Order.DESCENDING) }) { for (final Integer val : VALUES) { buffer.setPosition(0); type.encodeInt(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 16
Source File: TestOrderedFloat32.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Float> type : new OrderedFloat32[] { new OrderedFloat32(Order.ASCENDING), new OrderedFloat32(Order.DESCENDING) }) { for (final Float val : VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 17
Source File: TestOrderedNumeric.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedBigDecimalLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Number> type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) { for (final Number val : BIG_DECIMAL_VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 18
Source File: TestOrderedFloat64.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedFloatLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final OrderedFloat64 type : new OrderedFloat64[] { new OrderedFloat64(Order.ASCENDING), new OrderedFloat64(Order.DESCENDING) }) { for (final Double val : VALUES) { buffer.setPosition(0); type.encodeDouble(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 19
Source File: TestOrderedFloat64.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testEncodedLength() { final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20); for (final DataType<Double> type : new OrderedFloat64[] { new OrderedFloat64(Order.ASCENDING), new OrderedFloat64(Order.DESCENDING) }) { for (final Double val : VALUES) { buffer.setPosition(0); type.encode(buffer, val); assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val)); } } }
Example 20
Source File: TestUnion2.java From hbase with Apache License 2.0 | 4 votes |
public SampleUnion1() { super(new RawInteger(), new RawStringTerminated(Order.DESCENDING, ".")); }