use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestOrderedInt8 method testEncodeNoSupportForNull.
@Test
public void testEncodeNoSupportForNull() {
exception.expect(IllegalArgumentException.class);
final DataType<Byte> type = new OrderedInt8(Order.ASCENDING);
type.encode(new SimplePositionedMutableByteRange(20), null);
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestOrderedNumeric method testEncodedBigIntegerLength.
@Test
public void testEncodedBigIntegerLength() {
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_INTEGER_VALUES) {
buffer.setPosition(0);
type.encode(buffer, val);
assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val));
}
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestOrderedNumeric method testEncodedLength.
@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));
}
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestStruct method testOrderPreservation.
@Test
@SuppressWarnings("unchecked")
public void testOrderPreservation() throws Exception {
Object[] vals = new Object[constructorArgs.length];
PositionedByteRange[] encodedGeneric = new PositionedByteRange[constructorArgs.length];
PositionedByteRange[] encodedSpecialized = new PositionedByteRange[constructorArgs.length];
Constructor<?> ctor = specialized.encodedClass().getConstructor(Object[].class);
for (int i = 0; i < vals.length; i++) {
vals[i] = ctor.newInstance(new Object[] { constructorArgs[i] });
encodedGeneric[i] = new SimplePositionedMutableByteRange(generic.encodedLength(constructorArgs[i]));
encodedSpecialized[i] = new SimplePositionedMutableByteRange(specialized.encodedLength(vals[i]));
}
// populate our arrays
for (int i = 0; i < vals.length; i++) {
generic.encode(encodedGeneric[i], constructorArgs[i]);
encodedGeneric[i].setPosition(0);
specialized.encode(encodedSpecialized[i], vals[i]);
encodedSpecialized[i].setPosition(0);
assertArrayEquals(encodedGeneric[i].getBytes(), encodedSpecialized[i].getBytes());
}
Arrays.sort(vals);
Arrays.sort(encodedGeneric);
Arrays.sort(encodedSpecialized);
for (int i = 0; i < vals.length; i++) {
assertEquals("Struct encoder does not preserve sort order at position " + i, vals[i], ctor.newInstance(new Object[] { generic.decode(encodedGeneric[i]) }));
assertEquals("Specialized encoder does not preserve sort order at position " + i, vals[i], specialized.decode(encodedSpecialized[i]));
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestOrderedString method testEncodedLength.
@Test
public void testEncodedLength() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
for (final DataType<String> type : new OrderedString[] { new OrderedString(Order.ASCENDING), new OrderedString(Order.DESCENDING) }) {
for (final String val : VALUES) {
buff.setPosition(0);
type.encode(buff, val);
assertEquals("encodedLength does not match actual, " + val, buff.getPosition(), type.encodedLength(val));
}
}
}
Aggregations