use of javax.annotation.Nonnull in project pinot by linkedin.
the class IntermediateResultsBlock method getAggregationResultDataTable.
@Nonnull
private DataTable getAggregationResultDataTable() throws Exception {
// Extract each aggregation column name and type from aggregation function context.
int numAggregationFunctions = _aggregationFunctionContexts.length;
String[] columnNames = new String[numAggregationFunctions];
FieldSpec.DataType[] columnTypes = new FieldSpec.DataType[numAggregationFunctions];
for (int i = 0; i < numAggregationFunctions; i++) {
AggregationFunctionContext aggregationFunctionContext = _aggregationFunctionContexts[i];
columnNames[i] = aggregationFunctionContext.getAggregationColumnName();
columnTypes[i] = aggregationFunctionContext.getAggregationFunction().getIntermediateResultDataType();
}
// Build the data table.
DataTableBuilder dataTableBuilder = new DataTableBuilder(new DataSchema(columnNames, columnTypes));
dataTableBuilder.startRow();
for (int i = 0; i < numAggregationFunctions; i++) {
switch(columnTypes[i]) {
case LONG:
dataTableBuilder.setColumn(i, ((Number) _aggregationResult.get(i)).longValue());
break;
case DOUBLE:
dataTableBuilder.setColumn(i, ((Double) _aggregationResult.get(i)).doubleValue());
break;
case OBJECT:
dataTableBuilder.setColumn(i, _aggregationResult.get(i));
break;
default:
throw new UnsupportedOperationException("Unsupported aggregation column data type: " + columnTypes[i] + " for column: " + columnNames[i]);
}
}
dataTableBuilder.finishRow();
DataTable dataTable = dataTableBuilder.build();
return attachMetadataToDataTable(dataTable);
}
use of javax.annotation.Nonnull in project pinot by linkedin.
the class AggregationFunctionUtils method getAggregationFunctionContexts.
@Nonnull
public static AggregationFunctionContext[] getAggregationFunctionContexts(@Nonnull List<AggregationInfo> aggregationInfos, @Nullable SegmentMetadata segmentMetadata) {
int numAggregationFunctions = aggregationInfos.size();
AggregationFunctionContext[] aggregationFunctionContexts = new AggregationFunctionContext[numAggregationFunctions];
for (int i = 0; i < numAggregationFunctions; i++) {
AggregationInfo aggregationInfo = aggregationInfos.get(i);
aggregationFunctionContexts[i] = AggregationFunctionContext.instantiate(aggregationInfo);
}
if (segmentMetadata != null) {
AggregationFunctionInitializer aggregationFunctionInitializer = new AggregationFunctionInitializer(segmentMetadata);
for (AggregationFunctionContext aggregationFunctionContext : aggregationFunctionContexts) {
aggregationFunctionContext.getAggregationFunction().accept(aggregationFunctionInitializer);
}
}
return aggregationFunctionContexts;
}
use of javax.annotation.Nonnull in project pinot by linkedin.
the class SelectionOperatorUtils method extractDataSchema.
/**
* Extract the {@link DataSchema} from sort sequence, selection columns and {@link IndexSegment}. (Inner segment)
* <p>Inside data schema, we just store each column once (de-duplicated).
*
* @param sortSequence sort sequence.
* @param selectionColumns selection columns.
* @param indexSegment index segment.
* @return data schema.
*/
@Nonnull
public static DataSchema extractDataSchema(@Nullable List<SelectionSort> sortSequence, @Nonnull List<String> selectionColumns, @Nonnull IndexSegment indexSegment) {
List<String> columnList = new ArrayList<>();
Set<String> columnSet = new HashSet<>();
if (sortSequence != null) {
for (SelectionSort selectionSort : sortSequence) {
String column = selectionSort.getColumn();
columnList.add(column);
columnSet.add(column);
}
}
for (String column : selectionColumns) {
if (!columnSet.contains(column)) {
columnList.add(column);
columnSet.add(column);
}
}
int numColumns = columnList.size();
String[] columns = new String[numColumns];
DataType[] dataTypes = new DataType[numColumns];
for (int i = 0; i < numColumns; i++) {
String column = columnList.get(i);
columns[i] = column;
DataSourceMetadata columnMetadata = indexSegment.getDataSource(column).getDataSourceMetadata();
if (columnMetadata.isSingleValue()) {
dataTypes[i] = columnMetadata.getDataType();
} else {
dataTypes[i] = columnMetadata.getDataType().toMultiValue();
}
}
return new DataSchema(columns, dataTypes);
}
use of javax.annotation.Nonnull in project pinot by linkedin.
the class AvgPair method toBytes.
@Nonnull
public byte[] toBytes() {
ByteBuffer byteBuffer = ByteBuffer.allocate(V1Constants.Numbers.DOUBLE_SIZE + V1Constants.Numbers.LONG_SIZE);
byteBuffer.putDouble(_sum);
byteBuffer.putLong(_count);
return byteBuffer.array();
}
use of javax.annotation.Nonnull in project pinot by linkedin.
the class MinMaxRangePair method toBytes.
@Nonnull
public byte[] toBytes() {
ByteBuffer byteBuffer = ByteBuffer.allocate(V1Constants.Numbers.DOUBLE_SIZE + V1Constants.Numbers.DOUBLE_SIZE);
byteBuffer.putDouble(_min);
byteBuffer.putDouble(_max);
return byteBuffer.array();
}
Aggregations