-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vectorize earliest aggregator for both numeric and string types (#14408)
* Vectorizing earliest for numeric * Vectorizing earliest string aggregator * checkstyle fix * Removing unnecessary exceptions * Ignoring tests in MSQ as earliest is not supported for numeric there * Fixing benchmarks * Updating tests as MSQ does not support earliest for some cases * Addressing review comments by adding the following: 1. Checking capabilities first before creating selectors 2. Removing mockito in tests for numeric first aggs 3. Removing unnecessary tests * Addressing issues for dictionary encoded single string columns where we can use the dictionary ids instead of the entire string * Adding a flag for multi value dimension selector * Addressing comments * 1 more change * Handling review comments part 1 * Handling review comments and correctness fix for latest_by when the time expression need not be in sorted order * Updating numeric first vector agg * Revert "Updating numeric first vector agg" This reverts commit 4291709. * Updating code for correctness issues * fixing an issue with latest agg * Adding more comments and removing an unnecessary check * Addressing null checks for tie selector and only vectorize false for quantile sketches
- Loading branch information
1 parent
9d6ca61
commit 8088a76
Showing
20 changed files
with
1,813 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...g/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstVectorAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 org.apache.druid.query.aggregation.first; | ||
|
||
import org.apache.druid.collections.SerializablePair; | ||
import org.apache.druid.segment.vector.VectorValueSelector; | ||
|
||
import javax.annotation.Nullable; | ||
import java.nio.ByteBuffer; | ||
|
||
public class DoubleFirstVectorAggregator extends NumericFirstVectorAggregator | ||
{ | ||
|
||
public DoubleFirstVectorAggregator(VectorValueSelector timeSelector, VectorValueSelector valueSelector) | ||
{ | ||
super(timeSelector, valueSelector); | ||
} | ||
|
||
@Override | ||
public void initValue(ByteBuffer buf, int position) | ||
{ | ||
buf.putDouble(position, 0); | ||
} | ||
|
||
|
||
@Override | ||
void putValue(ByteBuffer buf, int position, int index) | ||
{ | ||
double firstValue = valueSelector.getDoubleVector()[index]; | ||
buf.putDouble(position, firstValue); | ||
} | ||
|
||
|
||
/** | ||
* @return The object as a pair with the position and the value stored at the position in the buffer. | ||
*/ | ||
@Nullable | ||
@Override | ||
public Object get(ByteBuffer buf, int position) | ||
{ | ||
final boolean rhsNull = isValueNull(buf, position); | ||
return new SerializablePair<>(buf.getLong(position), rhsNull ? null : buf.getDouble(position + VALUE_OFFSET)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ng/src/main/java/org/apache/druid/query/aggregation/first/FloatFirstVectorAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 org.apache.druid.query.aggregation.first; | ||
|
||
import org.apache.druid.collections.SerializablePair; | ||
import org.apache.druid.segment.vector.VectorValueSelector; | ||
|
||
import javax.annotation.Nullable; | ||
import java.nio.ByteBuffer; | ||
|
||
public class FloatFirstVectorAggregator extends NumericFirstVectorAggregator | ||
{ | ||
|
||
public FloatFirstVectorAggregator(VectorValueSelector timeSelector, VectorValueSelector valueSelector) | ||
{ | ||
super(timeSelector, valueSelector); | ||
} | ||
|
||
@Override | ||
public void initValue(ByteBuffer buf, int position) | ||
{ | ||
buf.putFloat(position, 0); | ||
} | ||
|
||
|
||
@Override | ||
void putValue(ByteBuffer buf, int position, int index) | ||
{ | ||
float firstValue = valueSelector.getFloatVector()[index]; | ||
buf.putFloat(position, firstValue); | ||
} | ||
|
||
|
||
/** | ||
* @return The object as a pair with the position and the value stored at the position in the buffer. | ||
*/ | ||
@Nullable | ||
@Override | ||
public Object get(ByteBuffer buf, int position) | ||
{ | ||
final boolean rhsNull = isValueNull(buf, position); | ||
return new SerializablePair<>(buf.getLong(position), rhsNull ? null : buf.getFloat(position + VALUE_OFFSET)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.