use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestOrderedNumeric method testEncodedNullLength.
@Test
public void testEncodedNullLength() {
final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
final DataType<Number> type = new OrderedNumeric(Order.ASCENDING);
buffer.setPosition(0);
type.encode(buffer, null);
type.encode(new SimplePositionedMutableByteRange(20), null);
assertEquals("encodedLength does not match actual, " + null, buffer.getPosition(), type.encodedLength(null));
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestOrderedNumeric method testEncodedDoubleLength.
@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));
}
}
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestOrderedNumeric method testEncodedLongLength.
@Test
public void testEncodedLongLength() {
final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
for (final OrderedNumeric type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) {
for (final Long val : LONG_VALUES) {
buffer.setPosition(0);
type.encodeLong(buffer, val);
assertEquals("encodedLength does not match actual, " + val, buffer.getPosition(), type.encodedLength(val));
}
}
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestUnion2 method testEncodeDecode.
@Test
public void testEncodeDecode() {
Integer intVal = 10;
String strVal = "hello";
PositionedByteRange buff = new SimplePositionedMutableByteRange(10);
SampleUnion1 type = new SampleUnion1();
type.encode(buff, intVal);
buff.setPosition(0);
assertEquals(0, intVal.compareTo(type.decodeA(buff)));
buff.setPosition(0);
type.encode(buff, strVal);
buff.setPosition(0);
assertEquals(0, strVal.compareTo(type.decodeB(buff)));
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project drill by apache.
the class MaprDBCompareFunctionsProcessor method getByteBuf.
@Override
protected ByteBuf getByteBuf(LogicalExpression valueArg, String encodingType) {
switch(encodingType) {
case "UTF8_OB":
case "UTF8_OBD":
if (valueArg instanceof ValueExpressions.QuotedString) {
int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(Charsets.UTF_8).length;
ByteBuf bb = newByteBuf(stringLen + 2, true);
PositionedByteRange br = new SimplePositionedMutableByteRange(bb.array(), 0, stringLen + 2);
if (encodingType.endsWith("_OBD")) {
org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value, Order.DESCENDING);
setSortOrderAscending(false);
} else {
org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value, Order.ASCENDING);
}
return bb;
}
}
return null;
}
Aggregations