use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class BaseAggregator method evalClientAggs.
ImmutableBytesWritable evalClientAggs(Aggregator clientAgg) {
CountAggregator ca = (CountAggregator) clientAgg;
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
ca.evaluate(null, ptr);
return ptr;
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RowValueConstructorExpression method init.
private void init(boolean isConstant) {
this.ptrs = new ImmutableBytesWritable[children.size()];
if (isConstant) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
this.evaluate(null, ptr);
literalExprPtr = ptr;
}
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class PrefixByteEncoderDecoderTest method testEncodeDecode.
private void testEncodeDecode(boolean useSingleBuffer) throws IOException {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
int maxLength = PrefixByteCodec.encodeBytes(guideposts, ptr);
int encodedSize = ptr.getLength();
int unencodedSize = PrefixByteCodec.calculateSize(guideposts);
assertTrue(encodedSize < unencodedSize);
List<byte[]> listOfBytes = PrefixByteCodec.decodeBytes(ptr, useSingleBuffer ? maxLength : -1);
assertListByteArraysEquals(guideposts, listOfBytes);
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RegexpSplitFunction method init.
private void init() {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
Expression e = getPatternStrExpression();
if (e.isStateless() && e.getDeterminism() == Determinism.ALWAYS && e.evaluate(null, ptr)) {
String pattern = (String) TYPE.toObject(ptr, TYPE, e.getSortOrder());
if (pattern != null) {
initializedSplitter = compilePatternSpec(pattern);
}
}
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class IndexMaintainer method getViewIndexIdFromIndexRowKey.
/*
* return the view index id from the index row key
*/
public byte[] getViewIndexIdFromIndexRowKey(ImmutableBytesWritable indexRowKeyPtr) {
assert (isLocalIndex);
RowKeySchema indexRowKeySchema = getIndexRowKeySchema();
// TODO add logic to skip region start key as well because we cannot find the region startkey in indexhalfstorefilereader.
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
TrustedByteArrayOutputStream stream = new TrustedByteArrayOutputStream(estimatedIndexRowKeyBytes);
DataOutput output = new DataOutputStream(stream);
try {
int indexPosOffset = (!isLocalIndex && nIndexSaltBuckets > 0 ? 1 : 0) + (isMultiTenant ? 1 : 0) + (viewIndexId == null ? 0 : 1);
Boolean hasValue = indexRowKeySchema.iterator(indexRowKeyPtr, ptr, indexPosOffset);
if (Boolean.TRUE.equals(hasValue)) {
output.write(ptr.get(), ptr.getOffset(), ptr.getLength());
}
int length = stream.size();
byte[] dataRowKey = stream.getBuffer();
return dataRowKey.length == length ? dataRowKey : Arrays.copyOf(dataRowKey, length);
} catch (IOException e) {
// Impossible
throw new RuntimeException(e);
} finally {
try {
stream.close();
} catch (IOException e) {
// Impossible
throw new RuntimeException(e);
}
}
}
Aggregations