Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
42c080b
Monomorphic processing of topN queries with simple double aggregators…
leventov Feb 20, 2017
d2d53c5
Add CalledFromHotLoop annocations to specialized methods in SimpleDou…
leventov Mar 18, 2017
719e979
Fix a bug in Historical1SimpleDoubleAggPooledTopNScannerPrototype
leventov Mar 18, 2017
37b04c3
Fix a bug in SpecializationService
leventov Mar 21, 2017
c63901b
In SpecializationService, emit maxSpecializations warning only once
leventov Mar 22, 2017
439c906
Make GenericIndexed.theBuffer final
leventov Mar 24, 2017
19b4fa5
Address comments
leventov Mar 27, 2017
005fa81
Merge remote-tracking branch 'upstream/master' into double-agg-and-hi…
leventov Mar 27, 2017
6b233f2
Newline
leventov Mar 27, 2017
18e9ad0
Reapply 439c906 (Make GenericIndexed.theBuffer final)
leventov Mar 27, 2017
996874d
Remove extra PooledTopNAlgorithm.capabilities field
leventov Mar 28, 2017
10c6735
Improve CachingIndexed.inspectRuntimeShape()
leventov Mar 28, 2017
8ded30c
Fix CompressedVSizeIntsIndexedSupplier.inspectRuntimeShape()
leventov Mar 29, 2017
c9339c9
Don't override inspectRuntimeShape() in subclasses of CompressedVSize…
leventov Mar 29, 2017
de77b76
Annotate methods in specializations of DimensionSelector and FloatCol…
leventov Mar 30, 2017
378f622
Make ValueMatcher to implement HotLoopCallee
leventov Mar 30, 2017
7b89337
Doc fix
leventov Mar 30, 2017
5cc302b
Fix inspectRuntimeShape() impl in ExpressionSelectors
leventov Mar 30, 2017
554a94c
INFO logging of specialization events
leventov Mar 31, 2017
2ec1911
Remove modificator
leventov Mar 31, 2017
5633e97
Fix OrFilter
leventov Apr 1, 2017
d962c86
Fix AndFilter
leventov Apr 1, 2017
bdd0e45
Merge remote-tracking branch 'upstream/master' into double-agg-and-hi…
leventov Apr 17, 2017
9771c3a
Refactor PooledTopNAlgorithm.scanAndAggregate()
leventov May 10, 2017
d405b97
Small refactoring
leventov May 10, 2017
58f0821
Add 'nothing to inspect' messages in empty HotLoopCallee.inspectRunti…
leventov May 11, 2017
f6efc31
Don't care about runtime shape in tests
leventov May 11, 2017
d63b26e
Fix accessor bugs in Historical1SimpleDoubleAggPooledTopNScannerProto…
leventov May 11, 2017
35341a5
Doc wording
leventov May 11, 2017
0a48d89
Address comments
leventov May 12, 2017
331a32a
Remove MagicAccessorBridge and ensure Offset subclasses are public
leventov May 12, 2017
69988b5
Attach error message to element
leventov May 12, 2017
53f77fd
Merge remote-tracking branch 'upstream/master' into double-agg-and-hi…
leventov May 16, 2017
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
@@ -0,0 +1,35 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.druid.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Inherited
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface SubclassesMustBePublic
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.druid.annotations;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.util.Set;

@SupportedAnnotationTypes("io.druid.annotations.SubclassesMustBePublic")
public class SubclassesMustBePublicAnnotationProcessor extends AbstractProcessor
{
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
{
for (TypeElement annotation : annotations) {
Set<? extends Element> elementsAnnotatedWith = roundEnv.getElementsAnnotatedWith(annotation);
for (Element element : elementsAnnotatedWith) {
if (!element.getModifiers().contains(Modifier.PUBLIC)) {
processingEnv.getMessager().printMessage(
Diagnostic.Kind.ERROR,
element.getSimpleName() + " must be public",
element
);
}
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.druid.annotations.SubclassesMustBePublicAnnotationProcessor
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ public void close()
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ public void close()
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
16 changes: 16 additions & 0 deletions processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.druid</groupId>
<artifactId>druid-common</artifactId>
<version>${project.parent.version}</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>io.druid.annotations.SubclassesMustBePublicAnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public interface BufferAggregator extends HotLoopCallee
@Override
default void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public void close()
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
*/
public class DoubleMaxBufferAggregator extends DoubleBufferAggregator
public class DoubleMaxBufferAggregator extends SimpleDoubleBufferAggregator
{

DoubleMaxBufferAggregator(FloatColumnSelector selector)
Expand All @@ -40,8 +40,18 @@ public void init(ByteBuffer buf, int position)
}

@Override
public void aggregate(ByteBuffer buf, int position)
public void putFirst(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, Math.max(buf.getDouble(position), (double) selector.get()));
if (!Double.isNaN(value)) {
buf.putDouble(position, value);
} else {
init(buf, position);
}
}

@Override
public void aggregate(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, Math.max(buf.getDouble(position), value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
*/
public class DoubleMinBufferAggregator extends DoubleBufferAggregator
public class DoubleMinBufferAggregator extends SimpleDoubleBufferAggregator
{

DoubleMinBufferAggregator(FloatColumnSelector selector)
Expand All @@ -40,8 +40,18 @@ public void init(ByteBuffer buf, int position)
}

@Override
public void aggregate(ByteBuffer buf, int position)
public void putFirst(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, Math.min(buf.getDouble(position), (double) selector.get()));
if (!Double.isNaN(value)) {
buf.putDouble(position, value);
} else {
init(buf, position);
}
}

@Override
public void aggregate(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, Math.min(buf.getDouble(position), value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
*/
public class DoubleSumBufferAggregator extends DoubleBufferAggregator
public class DoubleSumBufferAggregator extends SimpleDoubleBufferAggregator
{

DoubleSumBufferAggregator(FloatColumnSelector selector)
Expand All @@ -40,8 +40,14 @@ public void init(ByteBuffer buf, int position)
}

@Override
public void aggregate(ByteBuffer buf, int position)
public void putFirst(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, buf.getDouble(position) + (double) selector.get());
buf.putDouble(position, value);
}

@Override
public void aggregate(ByteBuffer buf, int position, double value)
{
buf.putDouble(position, buf.getDouble(position) + value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ public void close()
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,57 @@

package io.druid.query.aggregation;

import io.druid.query.monomorphicprocessing.CalledFromHotLoop;
import io.druid.query.monomorphicprocessing.RuntimeShapeInspector;
import io.druid.segment.FloatColumnSelector;

import java.nio.ByteBuffer;

public abstract class DoubleBufferAggregator implements BufferAggregator
public abstract class SimpleDoubleBufferAggregator implements BufferAggregator
{
protected final FloatColumnSelector selector;

DoubleBufferAggregator(FloatColumnSelector selector)
SimpleDoubleBufferAggregator(FloatColumnSelector selector)
{
this.selector = selector;
}

public FloatColumnSelector getSelector()
{
return selector;
}

/**
* Faster equivalent to
* aggregator.init(buf, position);
* aggregator.aggregate(buf, position, value);
*/
@CalledFromHotLoop
public abstract void putFirst(ByteBuffer buf, int position, double value);

@CalledFromHotLoop
public abstract void aggregate(ByteBuffer buf, int position, double value);

@Override
public final void aggregate(ByteBuffer buf, int position)
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.

Should this method be annotated with @CalledFromHotLoop?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, because this method is annotated in BufferAggregator

{
aggregate(buf, position, (double) selector.get());
}

@Override
public Object get(ByteBuffer buf, int position)
public final Object get(ByteBuffer buf, int position)
{
return buf.getDouble(position);
}

@Override
public float getFloat(ByteBuffer buf, int position)
public final float getFloat(ByteBuffer buf, int position)
{
return (float) buf.getDouble(position);
}

@Override
public long getLong(ByteBuffer buf, int position)
public final long getLong(ByteBuffer buf, int position)
{
return (long) buf.getDouble(position);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.druid.segment.data.ArrayBasedIndexedInts;
import io.druid.segment.data.IndexedInts;
import io.druid.segment.filter.BooleanValueMatcher;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;

import javax.annotation.Nullable;
import java.util.BitSet;
Expand All @@ -40,14 +40,18 @@ final class ForwardingFilteredDimensionSelector implements DimensionSelector, Id
{
private final DimensionSelector selector;
private final IdLookup baseIdLookup;
private final Int2IntMap forwardMapping;
private final Int2IntOpenHashMap forwardMapping;
private final int[] reverseMapping;

/**
* @param selector must return true from {@link DimensionSelector#nameLookupPossibleInAdvance()}
* @param forwardMapping must have {@link Int2IntMap#defaultReturnValue(int)} configured to -1.
* @param forwardMapping must have {@link Int2IntOpenHashMap#defaultReturnValue(int)} configured to -1.
*/
ForwardingFilteredDimensionSelector(DimensionSelector selector, Int2IntMap forwardMapping, int[] reverseMapping)
ForwardingFilteredDimensionSelector(
DimensionSelector selector,
Int2IntOpenHashMap forwardMapping,
int[] reverseMapping
)
{
this.selector = Preconditions.checkNotNull(selector);
if (!selector.nameLookupPossibleInAdvance()) {
Expand Down Expand Up @@ -106,6 +110,12 @@ public boolean matches()
// null should match empty rows in multi-value columns
return nullRow && value == null;
}

@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("selector", selector);
}
};
} else {
return BooleanValueMatcher.of(false);
Expand Down Expand Up @@ -141,6 +151,12 @@ public boolean matches()
// null should match empty rows in multi-value columns
return nullRow && matchNull;
}

@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("selector", selector);
}
};
}

Expand Down Expand Up @@ -179,6 +195,5 @@ public int lookupId(String name)
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("selector", selector);
inspector.visit("forwardMapping", forwardMapping);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import io.druid.query.filter.DimFilterUtils;
import io.druid.segment.DimensionSelector;
import io.druid.segment.IdLookup;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -93,7 +92,7 @@ private DimensionSelector filterWhiteList(DimensionSelector selector)
}
final int maxPossibleFilteredCardinality = values.size();
int count = 0;
final Int2IntMap forwardMapping = new Int2IntOpenHashMap(maxPossibleFilteredCardinality);
final Int2IntOpenHashMap forwardMapping = new Int2IntOpenHashMap(maxPossibleFilteredCardinality);
forwardMapping.defaultReturnValue(-1);
final int[] reverseMapping = new int[maxPossibleFilteredCardinality];
IdLookup idLookup = selector.idLookup();
Expand Down Expand Up @@ -134,7 +133,7 @@ public boolean apply(@Nullable String input)
}
final int maxPossibleFilteredCardinality = selectorCardinality;
int count = 0;
final Int2IntMap forwardMapping = new Int2IntOpenHashMap(maxPossibleFilteredCardinality);
final Int2IntOpenHashMap forwardMapping = new Int2IntOpenHashMap(maxPossibleFilteredCardinality);
forwardMapping.defaultReturnValue(-1);
final int[] reverseMapping = new int[maxPossibleFilteredCardinality];
for (int i = 0; i < selectorCardinality; i++) {
Expand Down
Loading