forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vectorization for druid-histogram extension (apache#10304)
* First draft * Remove redundant code from FixedBucketsHistogramAggregator classes * Add test cases for new classes * Fix tests in sql compatible mode * Typo fix * Fix comment * Add spelling * Vectorize only for supported types * Rename internal aggregator files * Fix tests
- Loading branch information
1 parent
1aa42bc
commit 1a48290
Showing
21 changed files
with
1,267 additions
and
115 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
70 changes: 70 additions & 0 deletions
70
.../apache/druid/query/aggregation/histogram/ApproximateHistogramBufferAggregatorHelper.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,70 @@ | ||
/* | ||
* 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.histogram; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* A helper class used by {@link ApproximateHistogramBufferAggregator} and {@link ApproximateHistogramVectorAggregator} | ||
* for aggregation operations on byte buffers. Getting the object from value selectors is outside this class. | ||
*/ | ||
final class ApproximateHistogramBufferAggregatorHelper | ||
{ | ||
private final int resolution; | ||
|
||
public ApproximateHistogramBufferAggregatorHelper(int resolution) | ||
{ | ||
this.resolution = resolution; | ||
} | ||
|
||
public void init(final ByteBuffer buf, final int position) | ||
{ | ||
ApproximateHistogram histogram = new ApproximateHistogram(resolution); | ||
ByteBuffer mutationBuffer = buf.duplicate(); | ||
mutationBuffer.position(position); | ||
histogram.toBytesDense(mutationBuffer); | ||
} | ||
|
||
public ApproximateHistogram get(final ByteBuffer buf, final int position) | ||
{ | ||
ByteBuffer mutationBuffer = buf.duplicate(); | ||
mutationBuffer.position(position); | ||
return ApproximateHistogram.fromBytesDense(mutationBuffer); | ||
} | ||
|
||
public void put(final ByteBuffer buf, final int position, final ApproximateHistogram histogram) | ||
{ | ||
ByteBuffer mutationBuffer = buf.duplicate(); | ||
mutationBuffer.position(position); | ||
histogram.toBytesDense(mutationBuffer); | ||
} | ||
|
||
public void aggregate(final ByteBuffer buf, final int position, final float value) | ||
{ | ||
ByteBuffer mutationBuffer = buf.duplicate(); | ||
mutationBuffer.position(position); | ||
|
||
ApproximateHistogram h0 = ApproximateHistogram.fromBytesDense(mutationBuffer); | ||
h0.offer(value); | ||
|
||
mutationBuffer.position(position); | ||
h0.toBytesDense(mutationBuffer); | ||
} | ||
} |
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
Oops, something went wrong.