Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@
public class DistinctCountAggregator implements Aggregator
{

private final String name;
private final DimensionSelector selector;
private final MutableBitmap mutableBitmap;

public DistinctCountAggregator(
String name,
DimensionSelector selector,
MutableBitmap mutableBitmap
)
{
this.name = name;
this.selector = selector;
this.mutableBitmap = mutableBitmap;
}
Expand Down Expand Up @@ -67,12 +64,6 @@ public float getFloat()
return (float) mutableBitmap.size();
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ public Aggregator factorize(ColumnSelectorFactory columnFactory)
{
DimensionSelector selector = makeDimensionSelector(columnFactory);
if (selector == null) {
return new EmptyDistinctCountAggregator(name);
return new EmptyDistinctCountAggregator();
} else {
return new DistinctCountAggregator(
name,
selector,
bitMapFactory.makeEmptyMutableBitmap()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@

public class EmptyDistinctCountAggregator implements Aggregator
{

private final String name;

public EmptyDistinctCountAggregator(String name)
{
this.name = name;
}

@Override
public void aggregate()
{
Expand All @@ -53,12 +45,6 @@ public float getFloat()
return (float) 0;
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@

public class EmptySketchAggregator implements Aggregator
{
private final String name;

public EmptySketchAggregator(String name)
{
this.name = name;
}

@Override
public void aggregate()
{
Expand Down Expand Up @@ -58,12 +51,6 @@ public long getLong()
throw new UnsupportedOperationException("Not implemented");
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,12 @@ public class SketchAggregator implements Aggregator
private static final Logger logger = new Logger(SketchAggregator.class);

private final ObjectColumnSelector selector;
private final String name;
private final int size;

private Union union;

public SketchAggregator(String name, ObjectColumnSelector selector, int size)
public SketchAggregator(ObjectColumnSelector selector, int size)
{
this.name = name;
this.selector = selector;
this.size = size;
union = new SynchronizedUnion((Union) SetOperation.builder().build(size, Family.UNION));
}

Expand Down Expand Up @@ -89,12 +85,6 @@ public long getLong()
throw new UnsupportedOperationException("Not implemented");
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public Aggregator factorize(ColumnSelectorFactory metricFactory)
{
ObjectColumnSelector selector = metricFactory.makeObjectColumnSelector(fieldName);
if (selector == null) {
return new EmptySketchAggregator(name);
return new EmptySketchAggregator();
} else {
return new SketchAggregator(name, selector, size);
return new SketchAggregator(selector, size);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ static Object combineHistograms(Object lhs, Object rhs)
return ((ApproximateHistogram) lhs).foldFast((ApproximateHistogram) rhs);
}

private final String name;
private final FloatColumnSelector selector;
private final int resolution;
private final float lowerLimit;
Expand All @@ -50,14 +49,12 @@ static Object combineHistograms(Object lhs, Object rhs)
private ApproximateHistogram histogram;

public ApproximateHistogramAggregator(
String name,
FloatColumnSelector selector,
int resolution,
float lowerLimit,
float upperLimit
)
{
this.name = name;
this.selector = selector;
this.resolution = resolution;
this.lowerLimit = lowerLimit;
Expand Down Expand Up @@ -95,12 +92,6 @@ public long getLong()
throw new UnsupportedOperationException("ApproximateHistogramAggregator does not support getLong()");
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public ApproximateHistogramAggregatorFactory(
public Aggregator factorize(ColumnSelectorFactory metricFactory)
{
return new ApproximateHistogramAggregator(
name,
metricFactory.makeFloatColumnSelector(fieldName),
resolution,
lowerLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

public class ApproximateHistogramFoldingAggregator implements Aggregator
{
private final String name;
private final ObjectColumnSelector<ApproximateHistogram> selector;
private final int resolution;
private final float lowerLimit;
Expand All @@ -36,14 +35,12 @@ public class ApproximateHistogramFoldingAggregator implements Aggregator
private long[] tmpBufferB;

public ApproximateHistogramFoldingAggregator(
String name,
ObjectColumnSelector<ApproximateHistogram> selector,
int resolution,
float lowerLimit,
float upperLimit
)
{
this.name = name;
this.selector = selector;
this.resolution = resolution;
this.lowerLimit = lowerLimit;
Expand Down Expand Up @@ -93,12 +90,6 @@ public long getLong()
throw new UnsupportedOperationException("ApproximateHistogramFoldingAggregator does not support getLong()");
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public ApproximateHistogram get()
final Class cls = selector.classOfObject();
if (cls.equals(Object.class) || ApproximateHistogram.class.isAssignableFrom(cls)) {
return new ApproximateHistogramFoldingAggregator(
name,
selector,
resolution,
lowerLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public void testCompute()
ApproximateHistogram ah = buildHistogram(10, VALUES);
final TestFloatColumnSelector selector = new TestFloatColumnSelector(VALUES);

ApproximateHistogramAggregator agg = new ApproximateHistogramAggregator("price", selector, 10, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);
ApproximateHistogramAggregator agg = new ApproximateHistogramAggregator(selector, 10, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);
for (int i = 0; i < VALUES.length; i++) {
agg.aggregate();
selector.increment();
}

Map<String, Object> metricValues = new HashMap<String, Object>();
metricValues.put(agg.getName(), agg.get());
metricValues.put("price", agg.get());

ApproximateHistogramPostAggregator approximateHistogramPostAggregator = new EqualBucketsPostAggregator(
"approxHist",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@
*/
public abstract class VarianceAggregator implements Aggregator
{
protected final String name;

protected final VarianceAggregatorCollector holder = new VarianceAggregatorCollector();

public VarianceAggregator(String name)
{
this.name = name;
}

@Override
public void reset()
{
Expand All @@ -49,12 +42,6 @@ public Object get()
return holder;
}

@Override
public String getName()
{
return name;
}

@Override
public void close()
{
Expand All @@ -76,9 +63,8 @@ public static final class FloatVarianceAggregator extends VarianceAggregator
{
private final FloatColumnSelector selector;

public FloatVarianceAggregator(String name, FloatColumnSelector selector)
public FloatVarianceAggregator(FloatColumnSelector selector)
{
super(name);
this.selector = selector;
}

Expand All @@ -93,9 +79,8 @@ public static final class LongVarianceAggregator extends VarianceAggregator
{
private final LongColumnSelector selector;

public LongVarianceAggregator(String name, LongColumnSelector selector)
public LongVarianceAggregator(LongColumnSelector selector)
{
super(name);
this.selector = selector;
}

Expand All @@ -110,9 +95,8 @@ public static final class ObjectVarianceAggregator extends VarianceAggregator
{
private final ObjectColumnSelector selector;

public ObjectVarianceAggregator(String name, ObjectColumnSelector selector)
public ObjectVarianceAggregator(ObjectColumnSelector selector)
{
super(name);
this.selector = selector;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,14 @@ public Aggregator factorize(ColumnSelectorFactory metricFactory)

if ("float".equalsIgnoreCase(inputType)) {
return new VarianceAggregator.FloatVarianceAggregator(
name,
metricFactory.makeFloatColumnSelector(fieldName)
);
} else if ("long".equalsIgnoreCase(inputType)) {
return new VarianceAggregator.LongVarianceAggregator(
name,
metricFactory.makeLongColumnSelector(fieldName)
);
} else if ("variance".equalsIgnoreCase(inputType)) {
return new VarianceAggregator.ObjectVarianceAggregator(name, selector);
return new VarianceAggregator.ObjectVarianceAggregator(selector);
}
throw new IAE(
"Incompatible type for metric[%s], expected a float, long or variance, got a %s", fieldName, inputType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public void testDoubleVarianceAggregator()
{
VarianceAggregator agg = (VarianceAggregator) aggFactory.factorize(colSelectorFactory);

Assert.assertEquals("billy", agg.getName());

assertValues((VarianceAggregatorCollector) agg.get(), 0, 0d, 0d);
aggregate(selector, agg);
assertValues((VarianceAggregatorCollector) agg.get(), 1, 1.1d, 0d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public InputRow get()
catch (ParseException e) {
// "aggregate" can throw ParseExceptions if a selector expects something but gets something else.
if (reportParseExceptions) {
throw new ParseException(e, "Encountered parse error for aggregator[%s]", agg.getName());
throw new ParseException(e, "Encountered parse error for aggregator[%s]", k);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is k defined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. String k = aggFactory.getName()

}
log.debug(e, "Encountered parse error, skipping aggregator[%s].", agg.getName());
log.debug(e, "Encountered parse error, skipping aggregator[%s].", k);
}

String t = aggFactory.getTypeName();
Expand Down
10 changes: 10 additions & 0 deletions processing/src/main/java/io/druid/query/QueryRunnerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public static Aggregator[] makeAggregators(Cursor cursor, List<AggregatorFactory
return aggregators;
}

public static String[] makeAggregatorNames(List<AggregatorFactory> aggregatorSpecs)
{
String[] aggregators = new String[aggregatorSpecs.size()];
int aggregatorIndex = 0;
for (AggregatorFactory spec : aggregatorSpecs) {
aggregators[aggregatorIndex++] = spec.getName();
}
return aggregators;
}

public static <T> Sequence<Result<T>> makeCursorBasedQuery(
final StorageAdapter adapter,
List<Interval> queryIntervals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public interface Aggregator {
void reset();
Object get();
float getFloat();
String getName();
void close();

long getLong();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ public float getFloat()
return 0;
}

@Override
public String getName()
{
return null;
}

@Override
public void close()
{
Expand Down
Loading