Search in sources :

Example 51 with ImmutableBytesWritable

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;
}
Also used : ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable)

Example 52 with ImmutableBytesWritable

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;
    }
}
Also used : ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable)

Example 53 with ImmutableBytesWritable

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);
}
Also used : ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable)

Example 54 with ImmutableBytesWritable

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);
        }
    }
}
Also used : ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable) Expression(org.apache.phoenix.expression.Expression)

Example 55 with ImmutableBytesWritable

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);
        }
    }
}
Also used : DataOutput(java.io.DataOutput) ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable) DataOutputStream(java.io.DataOutputStream) RowKeySchema(org.apache.phoenix.schema.RowKeySchema) TrustedByteArrayOutputStream(org.apache.phoenix.util.TrustedByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)296 Test (org.junit.Test)86 Expression (org.apache.phoenix.expression.Expression)36 IOException (java.io.IOException)33 PhoenixArray (org.apache.phoenix.schema.types.PhoenixArray)30 ArrayList (java.util.ArrayList)28 Configuration (org.apache.hadoop.conf.Configuration)28 Result (org.apache.hadoop.hbase.client.Result)28 Cell (org.apache.hadoop.hbase.Cell)27 KeyValue (org.apache.hadoop.hbase.KeyValue)27 LiteralExpression (org.apache.phoenix.expression.LiteralExpression)27 PTable (org.apache.phoenix.schema.PTable)27 PDataType (org.apache.phoenix.schema.types.PDataType)26 PSmallint (org.apache.phoenix.schema.types.PSmallint)25 PTinyint (org.apache.phoenix.schema.types.PTinyint)23 Put (org.apache.hadoop.hbase.client.Put)20 PUnsignedSmallint (org.apache.phoenix.schema.types.PUnsignedSmallint)20 PUnsignedTinyint (org.apache.phoenix.schema.types.PUnsignedTinyint)20 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)19 List (java.util.List)18