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()));
}
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations