Search in sources :

Example 6 with ComplexMetricSerde

use of org.apache.druid.segment.serde.ComplexMetricSerde in project druid by druid-io.

the class IndexMergerV9 method setupMetricsWriters.

private ArrayList<GenericColumnSerializer> setupMetricsWriters(final SegmentWriteOutMedium segmentWriteOutMedium, final List<String> mergedMetrics, final Map<String, ValueType> metricsValueTypes, final Map<String, String> metricTypeNames, final IndexSpec indexSpec) throws IOException {
    ArrayList<GenericColumnSerializer> metWriters = Lists.newArrayListWithCapacity(mergedMetrics.size());
    for (String metric : mergedMetrics) {
        ValueType type = metricsValueTypes.get(metric);
        GenericColumnSerializer writer;
        switch(type) {
            case LONG:
                writer = createLongColumnSerializer(segmentWriteOutMedium, metric, indexSpec);
                break;
            case FLOAT:
                writer = createFloatColumnSerializer(segmentWriteOutMedium, metric, indexSpec);
                break;
            case DOUBLE:
                writer = createDoubleColumnSerializer(segmentWriteOutMedium, metric, indexSpec);
                break;
            case COMPLEX:
                final String typeName = metricTypeNames.get(metric);
                ComplexMetricSerde serde = ComplexMetrics.getSerdeForType(typeName);
                if (serde == null) {
                    throw new ISE("Unknown type[%s]", typeName);
                }
                writer = serde.getSerializer(segmentWriteOutMedium, metric);
                break;
            default:
                throw new ISE("Unknown type[%s]", type);
        }
        writer.open();
        // we will close these writers in another method after we added all the metrics
        metWriters.add(writer);
    }
    return metWriters;
}
Also used : ComplexMetricSerde(org.apache.druid.segment.serde.ComplexMetricSerde) ValueType(org.apache.druid.segment.column.ValueType) ISE(org.apache.druid.java.util.common.ISE)

Aggregations

ComplexMetricSerde (org.apache.druid.segment.serde.ComplexMetricSerde)6 MapBasedInputRow (org.apache.druid.data.input.MapBasedInputRow)3 ISE (org.apache.druid.java.util.common.ISE)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 InputRow (org.apache.druid.data.input.InputRow)2 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)2 ColumnType (org.apache.druid.segment.column.ColumnType)2 ValueType (org.apache.druid.segment.column.ValueType)2 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)1 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IAE (org.apache.druid.java.util.common.IAE)1 ParseException (org.apache.druid.java.util.common.parsers.ParseException)1 Aggregator (org.apache.druid.query.aggregation.Aggregator)1 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)1 ColumnAnalysis (org.apache.druid.query.metadata.metadata.ColumnAnalysis)1 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)1 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)1