Search in sources :

Example 1 with ArrayIndexFunction

use of org.apache.phoenix.expression.function.ArrayIndexFunction in project phoenix by apache.

the class NonAggregateRegionScannerFactory method deserializeArrayPostionalExpressionInfoFromScan.

private Expression[] deserializeArrayPostionalExpressionInfoFromScan(Scan scan, RegionScanner s, Set<KeyValueColumnExpression> arrayKVRefs) {
    byte[] specificArrayIdx = scan.getAttribute(BaseScannerRegionObserver.SPECIFIC_ARRAY_INDEX);
    if (specificArrayIdx == null) {
        return null;
    }
    KeyValueSchema.KeyValueSchemaBuilder builder = new KeyValueSchema.KeyValueSchemaBuilder(0);
    ByteArrayInputStream stream = new ByteArrayInputStream(specificArrayIdx);
    try {
        DataInputStream input = new DataInputStream(stream);
        int arrayKVRefSize = WritableUtils.readVInt(input);
        for (int i = 0; i < arrayKVRefSize; i++) {
            PTable.ImmutableStorageScheme scheme = EncodedColumnsUtil.getImmutableStorageScheme(scan);
            KeyValueColumnExpression kvExp = scheme != PTable.ImmutableStorageScheme.ONE_CELL_PER_COLUMN ? new SingleCellColumnExpression(scheme) : new KeyValueColumnExpression();
            kvExp.readFields(input);
            arrayKVRefs.add(kvExp);
        }
        int arrayKVFuncSize = WritableUtils.readVInt(input);
        Expression[] arrayFuncRefs = new Expression[arrayKVFuncSize];
        for (int i = 0; i < arrayKVFuncSize; i++) {
            ArrayIndexFunction arrayIdxFunc = new ArrayIndexFunction();
            arrayIdxFunc.readFields(input);
            arrayFuncRefs[i] = arrayIdxFunc;
            builder.addField(arrayIdxFunc);
        }
        kvSchema = builder.build();
        kvSchemaBitSet = ValueBitSet.newInstance(kvSchema);
        return arrayFuncRefs;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ArrayIndexFunction(org.apache.phoenix.expression.function.ArrayIndexFunction) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) PTable(org.apache.phoenix.schema.PTable) SingleCellColumnExpression(org.apache.phoenix.expression.SingleCellColumnExpression) ByteArrayInputStream(java.io.ByteArrayInputStream) KeyValueColumnExpression(org.apache.phoenix.expression.KeyValueColumnExpression) Expression(org.apache.phoenix.expression.Expression) SingleCellColumnExpression(org.apache.phoenix.expression.SingleCellColumnExpression) OrderByExpression(org.apache.phoenix.expression.OrderByExpression) KeyValueColumnExpression(org.apache.phoenix.expression.KeyValueColumnExpression) KeyValueSchema(org.apache.phoenix.schema.KeyValueSchema)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 Expression (org.apache.phoenix.expression.Expression)1 KeyValueColumnExpression (org.apache.phoenix.expression.KeyValueColumnExpression)1 OrderByExpression (org.apache.phoenix.expression.OrderByExpression)1 SingleCellColumnExpression (org.apache.phoenix.expression.SingleCellColumnExpression)1 ArrayIndexFunction (org.apache.phoenix.expression.function.ArrayIndexFunction)1 KeyValueSchema (org.apache.phoenix.schema.KeyValueSchema)1 PTable (org.apache.phoenix.schema.PTable)1