public boolean isNumeric() { return isNumeric(this); }
aggFlags.add(false); final ValueType type = dimensions.get(dimIndex).getOutputType(); isNumericField.add(ValueType.isNumeric(type)); comparators.add(orderSpec.getDimensionComparator()); } else { aggFlags.add(true); final String typeName = aggregatorFactories[aggIndex].getTypeName(); isNumericField.add(ValueType.isNumeric(ValueType.fromString(typeName))); comparators.add(orderSpec.getDimensionComparator()); needsReverses.add(false); final ValueType type = dimensions.get(i).getOutputType(); isNumericField.add(ValueType.isNumeric(type)); comparators.add(StringComparators.LEXICOGRAPHIC);
public DimensionSelector makeNumericWrappingDimensionSelector( ColumnValueSelector numericColumnValueSelector, @Nullable ExtractionFn extractionFn ) { throw new UnsupportedOperationException("Not a numeric value type: " + name()); }
if (type.isNumeric()) { return type.makeNumericWrappingDimensionSelector(makeColumnValueSelector(dimension), extractionFn);
@Override public String getColumnTypeName(String column) { final String metricType = index.getMetricType(column); if (metricType != null) { return metricType; } ColumnCapabilities columnCapabilities = getColumnCapabilities(column); if (columnCapabilities != null) { return columnCapabilities.getType().toString(); } else { return null; } }
@JsonCreator public static ValueType fromString(String name) { if (name == null) { return null; } return valueOf(StringUtils.toUpperCase(name)); }
@Override public boolean equals(Object o) { if (this == o) { return true; } // LegacyDimensionSpec can be equal to DefaultDimensionSpec if (!(o instanceof DefaultDimensionSpec)) { return false; } DefaultDimensionSpec that = (DefaultDimensionSpec) o; if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) { return false; } if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) { return false; } if (outputType != null ? !outputType.equals(that.outputType) : that.outputType != null) { return false; } return true; }
private static ColumnHolder createColumn(AggregatorFactory aggregatorFactory) { return new TestColumn(ValueType.fromString(aggregatorFactory.getTypeName())); }
@Override public int hashCode() { int result = dimension != null ? dimension.hashCode() : 0; result = 31 * result + (outputName != null ? outputName.hashCode() : 0); result = 31 * result + (outputType != null ? outputType.hashCode() : 0); return result; } }
@Override public SettableColumnValueSelector makeNewSettableColumnValueSelector() { return getCapabilities().getType().makeNewSettableColumnValueSelector(); } }
@Override public byte[] getCacheKey() { return new CacheKeyBuilder(CACHE_TYPE_ID) .appendString(dimension) .appendString(outputType.toString()) .build(); }
private DimensionSelector makeDimensionSelectorUndecorated(DimensionSpec dimensionSpec) { final String dimension = dimensionSpec.getDimension(); final ExtractionFn extractionFn = dimensionSpec.getExtractionFn(); if (dimension.equals(ColumnHolder.TIME_COLUMN_NAME)) { return new SingleScanTimeDimensionSelector(makeColumnValueSelector(dimension), extractionFn, descending); } final IncrementalIndex.DimensionDesc dimensionDesc = index.getDimension(dimensionSpec.getDimension()); if (dimensionDesc == null) { // not a dimension, column may be a metric ColumnCapabilities capabilities = getColumnCapabilities(dimension); if (capabilities == null) { return DimensionSelector.constant(null, extractionFn); } if (capabilities.getType().isNumeric()) { return capabilities.getType().makeNumericWrappingDimensionSelector( makeColumnValueSelector(dimension), extractionFn ); } // if we can't wrap the base column, just return a column of all nulls return DimensionSelector.constant(null, extractionFn); } else { final DimensionIndexer indexer = dimensionDesc.getIndexer(); return indexer.makeDimensionSelector(dimensionSpec, rowHolder, dimensionDesc); } }
private static RowSignature analysisToRowSignature(final SegmentAnalysis analysis) { final RowSignature.Builder rowSignatureBuilder = RowSignature.builder(); for (Map.Entry<String, ColumnAnalysis> entry : analysis.getColumns().entrySet()) { if (entry.getValue().isError()) { // Skip columns with analysis errors. continue; } ValueType valueType; try { valueType = ValueType.valueOf(StringUtils.toUpperCase(entry.getValue().getType())); } catch (IllegalArgumentException e) { // Assume unrecognized types are some flavor of COMPLEX. This throws away information about exactly // what kind of complex column it is, which we may want to preserve some day. valueType = ValueType.COMPLEX; } rowSignatureBuilder.add(entry.getKey(), valueType); } return rowSignatureBuilder.build(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ExtractionDimensionSpec that = (ExtractionDimensionSpec) o; if (extractionFn != null ? !extractionFn.equals(that.extractionFn) : that.extractionFn != null) { return false; } if (dimension != null ? !dimension.equals(that.dimension) : that.dimension != null) { return false; } if (outputName != null ? !outputName.equals(that.outputName) : that.outputName != null) { return false; } if (outputType != null ? !outputType.equals(that.outputType) : that.outputType != null) { return false; } return true; }
@Override public int hashCode() { int result = dimension != null ? dimension.hashCode() : 0; result = 31 * result + (extractionFn != null ? extractionFn.hashCode() : 0); result = 31 * result + (outputName != null ? outputName.hashCode() : 0); result = 31 * result + (outputType != null ? outputType.hashCode() : 0); return result; } }
@Override public SettableColumnValueSelector makeNewSettableColumnValueSelector() { return getCapabilities().getType().makeNewSettableColumnValueSelector(); } }
public static StringComparator getStringComparatorForValueType(ValueType valueType) { if (ValueType.isNumeric(valueType)) { return StringComparators.NUMERIC; } else if (ValueType.STRING == valueType) { return StringComparators.LEXICOGRAPHIC; } else { throw new ISE("Unrecognized valueType[%s]", valueType); } }
@Override public String getColumnTypeName(String columnName) { final ColumnHolder columnHolder = index.getColumnHolder(columnName); try (final BaseColumn col = columnHolder.getColumn()) { if (col instanceof ComplexColumn) { return ((ComplexColumn) col).getTypeName(); } else { return columnHolder.getCapabilities().getType().toString(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
final ValueType valueType = ValueType.fromString(typeName); if (!ValueType.isNumeric(valueType)) { throw new IAE("Cannot order by a non-numeric aggregator[%s]", orderSpec);
if (type.isNumeric()) { return type.makeNumericWrappingDimensionSelector(makeColumnValueSelector(dimension), extractionFn);