Search in sources :

Example 6 with BlockValSet

use of com.linkedin.pinot.core.common.BlockValSet in project pinot by linkedin.

the class ChunkIndexCreationDriverImplTest method test2.

@Test
public void test2() throws Exception {
    final IndexSegmentImpl segment = (IndexSegmentImpl) Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
    //    System.out.println("INdex dir:" + INDEX_DIR);
    final DataSource ds = segment.getDataSource("column1");
    final Block bl = ds.nextBlock();
    final BlockValSet valSet = bl.getBlockValueSet();
    final BlockSingleValIterator it = (BlockSingleValIterator) valSet.iterator();
    // TODO: FIXME - load segment with known data and verify that it exists
    while (it.hasNext()) {
        LOGGER.trace(Integer.toString(it.nextIntVal()));
    }
}
Also used : IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) BlockSingleValIterator(com.linkedin.pinot.core.common.BlockSingleValIterator) Block(com.linkedin.pinot.core.common.Block) BlockValSet(com.linkedin.pinot.core.common.BlockValSet) DataSource(com.linkedin.pinot.core.common.DataSource) Test(org.testng.annotations.Test)

Example 7 with BlockValSet

use of com.linkedin.pinot.core.common.BlockValSet in project pinot by linkedin.

the class NoDictionarySingleColumnGroupKeyGenerator method generateKeysForBlock.

@Override
public void generateKeysForBlock(TransformBlock transformBlock, int[] docIdToGroupKey) {
    BlockValSet blockValSet = transformBlock.getBlockValueSet(_groupByColumn);
    FieldSpec.DataType dataType = blockValSet.getValueType();
    int numDocs = transformBlock.getNumDocs();
    switch(dataType) {
        case INT:
            int[] intValues = blockValSet.getIntValuesSV();
            for (int i = 0; i < numDocs; i++) {
                docIdToGroupKey[i] = getKeyForValue(intValues[i]);
            }
            break;
        case LONG:
            long[] longValues = blockValSet.getLongValuesSV();
            for (int i = 0; i < numDocs; i++) {
                docIdToGroupKey[i] = getKeyForValue(longValues[i]);
            }
            break;
        case FLOAT:
            float[] floatValues = blockValSet.getFloatValuesSV();
            for (int i = 0; i < numDocs; i++) {
                docIdToGroupKey[i] = getKeyForValue(floatValues[i]);
            }
            break;
        case DOUBLE:
            double[] doubleValues = blockValSet.getDoubleValuesSV();
            for (int i = 0; i < numDocs; i++) {
                docIdToGroupKey[i] = getKeyForValue(doubleValues[i]);
            }
            break;
        case STRING:
            String[] stringValues = blockValSet.getStringValuesSV();
            for (int i = 0; i < numDocs; i++) {
                docIdToGroupKey[i] = getKeyForValue(stringValues[i]);
            }
            break;
        default:
            throw new IllegalArgumentException("Illegal data type for no-dictionary key generator: " + dataType);
    }
}
Also used : BlockValSet(com.linkedin.pinot.core.common.BlockValSet) FieldSpec(com.linkedin.pinot.common.data.FieldSpec)

Example 8 with BlockValSet

use of com.linkedin.pinot.core.common.BlockValSet in project pinot by linkedin.

the class DefaultExpressionEvaluator method evaluateExpression.

/**
   * Helper (recursive) method that walks the expression tree bottom up evaluating
   * transforms at each level.
   *
   * @param projectionBlock Projection block for which to evaluate the expression for
   * @param expressionTree Expression tree to evaluate
   * @return Result of the expression transform
   */
private BlockValSet evaluateExpression(ProjectionBlock projectionBlock, TransformExpressionTree expressionTree) {
    TransformFunction function = getTransformFunction(expressionTree.getTransformName());
    int numDocs = projectionBlock.getNumDocs();
    String expressionString = expressionTree.toString();
    TransformExpressionTree.ExpressionType expressionType = expressionTree.getExpressionType();
    switch(expressionType) {
        case FUNCTION:
            List<TransformExpressionTree> children = expressionTree.getChildren();
            int numChildren = children.size();
            BlockValSet[] transformArgs = new BlockValSet[numChildren];
            for (int i = 0; i < numChildren; i++) {
                transformArgs[i] = evaluateExpression(projectionBlock, children.get(i));
            }
            return new TransformBlockValSet(function, numDocs, transformArgs);
        case IDENTIFIER:
            return projectionBlock.getBlockValueSet(expressionString);
        case LITERAL:
            return new ConstantBlockValSet(expressionString, numDocs);
        default:
            throw new IllegalArgumentException("Illegal expression type in expression evaluator: " + expressionType);
    }
}
Also used : TransformFunction(com.linkedin.pinot.core.operator.transform.function.TransformFunction) TransformExpressionTree(com.linkedin.pinot.common.request.transform.TransformExpressionTree) BlockValSet(com.linkedin.pinot.core.common.BlockValSet) ConstantBlockValSet(com.linkedin.pinot.core.operator.docvalsets.ConstantBlockValSet) TransformBlockValSet(com.linkedin.pinot.core.operator.docvalsets.TransformBlockValSet) TransformBlockValSet(com.linkedin.pinot.core.operator.docvalsets.TransformBlockValSet) ConstantBlockValSet(com.linkedin.pinot.core.operator.docvalsets.ConstantBlockValSet)

Example 9 with BlockValSet

use of com.linkedin.pinot.core.common.BlockValSet in project pinot by linkedin.

the class TransformExpressionOperator method getNextBlock.

@Override
public Block getNextBlock() {
    ProjectionBlock projectionBlock = _projectionOperator.getNextBlock();
    if (projectionBlock == null) {
        return null;
    }
    Map<String, BlockValSet> expressionResults = (_expressionEvaluator != null) ? _expressionEvaluator.evaluate(projectionBlock) : null;
    return new TransformBlock(projectionBlock, expressionResults);
}
Also used : ProjectionBlock(com.linkedin.pinot.core.operator.blocks.ProjectionBlock) TransformBlock(com.linkedin.pinot.core.operator.blocks.TransformBlock) BlockValSet(com.linkedin.pinot.core.common.BlockValSet)

Example 10 with BlockValSet

use of com.linkedin.pinot.core.common.BlockValSet in project pinot by linkedin.

the class DefaultAggregationExecutor method aggregateColumn.

/**
   * Helper method to perform aggregation for a given column.
   *
   * @param aggrFuncContext aggregation function context.
   * @param resultHolder result holder.
   */
@SuppressWarnings("ConstantConditions")
private void aggregateColumn(TransformBlock transformBlock, AggregationFunctionContext aggrFuncContext, AggregationResultHolder resultHolder) {
    AggregationFunction aggregationFunction = aggrFuncContext.getAggregationFunction();
    String[] aggregationColumns = aggrFuncContext.getAggregationColumns();
    Preconditions.checkState(aggregationColumns.length == 1);
    int length = transformBlock.getNumDocs();
    if (!aggregationFunction.getName().equals(AggregationFunctionFactory.AggregationFunctionType.COUNT.getName())) {
        BlockValSet blockValSet = transformBlock.getBlockValueSet(aggregationColumns[0]);
        aggregationFunction.aggregate(length, resultHolder, blockValSet);
    } else {
        aggregationFunction.aggregate(length, resultHolder);
    }
}
Also used : AggregationFunction(com.linkedin.pinot.core.query.aggregation.function.AggregationFunction) BlockValSet(com.linkedin.pinot.core.common.BlockValSet)

Aggregations

BlockValSet (com.linkedin.pinot.core.common.BlockValSet)15 Block (com.linkedin.pinot.core.common.Block)7 BlockMetadata (com.linkedin.pinot.core.common.BlockMetadata)5 BlockSingleValIterator (com.linkedin.pinot.core.common.BlockSingleValIterator)5 DataSource (com.linkedin.pinot.core.common.DataSource)5 Test (org.testng.annotations.Test)4 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)2 TransformExpressionTree (com.linkedin.pinot.common.request.transform.TransformExpressionTree)2 BlockMultiValIterator (com.linkedin.pinot.core.common.BlockMultiValIterator)2 TransformBlock (com.linkedin.pinot.core.operator.blocks.TransformBlock)2 AggregationFunction (com.linkedin.pinot.core.query.aggregation.function.AggregationFunction)2 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)2 IndexSegmentImpl (com.linkedin.pinot.core.segment.index.IndexSegmentImpl)2 ServerMetrics (com.linkedin.pinot.common.metrics.ServerMetrics)1 SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)1 DataSourceMetadata (com.linkedin.pinot.core.common.DataSourceMetadata)1 Operator (com.linkedin.pinot.core.common.Operator)1 HLRealtimeSegmentDataManager (com.linkedin.pinot.core.data.manager.realtime.HLRealtimeSegmentDataManager)1 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)1 BReusableFilteredDocIdSetOperator (com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator)1