-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add SIMD-accelerated bulk range evaluation for dense numeric doc values #16050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
77ec451
5b2e742
ecaba41
be25c03
2154dc7
dab75fc
d75ce13
ce3cde7
e053cd6
afa00a6
d9cfe96
c592193
35bfcba
b08d5a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * 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.lucene.internal.vectorization; | ||
|
|
||
| import org.apache.lucene.util.FixedBitSet; | ||
| import org.apache.lucene.util.LongValues; | ||
|
|
||
| /** Scalar (non-SIMD) implementation of {@link DocValuesRangeSupport}. */ | ||
| final class DefaultDocValuesRangeSupport implements DocValuesRangeSupport { | ||
|
|
||
| static final DefaultDocValuesRangeSupport INSTANCE = new DefaultDocValuesRangeSupport(); | ||
|
|
||
| private DefaultDocValuesRangeSupport() {} | ||
|
|
||
| @Override | ||
| public void rangeIntoBitSet( | ||
| LongValues values, | ||
| int fromDoc, | ||
| int toDoc, | ||
| long minValue, | ||
| long maxValue, | ||
| FixedBitSet bitSet, | ||
| int offset) { | ||
| // Scalar fallback implementation | ||
| for (int d = fromDoc; d < toDoc; d++) { | ||
| long v = values.get(d); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this tells me we eventually might actually want a That is a larger change, but I suspect there is perf to be gained lower level just decoding the long values.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benwtrent |
||
| if (v >= minValue && v <= maxValue) { | ||
| bitSet.set(d - offset); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * 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.lucene.internal.vectorization; | ||
|
|
||
| import org.apache.lucene.util.FixedBitSet; | ||
| import org.apache.lucene.util.LongValues; | ||
|
|
||
| /** | ||
| * Interface for SIMD-accelerated doc values range operations. | ||
| * | ||
| * <p>Implementations fill a {@link FixedBitSet} with the doc IDs in a range whose values satisfy a | ||
| * numeric range predicate. The default scalar implementation is used when the Panama Vector API is | ||
| * unavailable; a SIMD-accelerated implementation is used otherwise. | ||
| * | ||
| * @lucene.internal | ||
| */ | ||
| public interface DocValuesRangeSupport { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this support path, etc. all matches our existing patterns. Seems OK to me. |
||
|
|
||
| /** | ||
| * Fills {@code bitSet} with the doc IDs in {@code [fromDoc, toDoc)} whose values (read via {@code | ||
| * values}) are in {@code [minValue, maxValue]}. | ||
| * | ||
| * @param values random-access reader for the doc values | ||
| * @param fromDoc first doc ID to evaluate (inclusive) | ||
| * @param toDoc last doc ID to evaluate (exclusive) | ||
| * @param minValue lower bound of the range (inclusive) | ||
| * @param maxValue upper bound of the range (inclusive) | ||
| * @param bitSet the bitset to fill | ||
| * @param offset subtracted from each doc ID before setting the bit | ||
| */ | ||
| void rangeIntoBitSet( | ||
| LongValues values, | ||
| int fromDoc, | ||
| int toDoc, | ||
| long minValue, | ||
| long maxValue, | ||
| FixedBitSet bitSet, | ||
| int offset); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an import for FixedBitSet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed