mkhludnev commented on code in PR #13974: URL: https://github.com/apache/lucene/pull/13974#discussion_r1898420567
########## lucene/sandbox/src/java/org/apache/lucene/sandbox/search/DocValuesMultiRangeQuery.java: ########## @@ -0,0 +1,125 @@ +/* + * 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.sandbox.search; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Supplier; +import org.apache.lucene.document.SortedSetDocValuesField; +import org.apache.lucene.search.*; +import org.apache.lucene.util.ArrayUtil; +import org.apache.lucene.util.BytesRef; + +/** A few query builder for doc values multi range queries */ +public final class DocValuesMultiRangeQuery { + + private DocValuesMultiRangeQuery() {} + + /** Representation of a single clause in a MultiRangeQuery */ + static final class Range { + BytesRef lower; + BytesRef upper; + + /** NB: One absolutely must copy ByteRefs before. */ + private Range(BytesRef lowerValue, BytesRef upperValue) { + this.lower = lowerValue; + this.upper = upperValue; + } + + // TODO test equals + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Range that = (Range) o; + return lower.equals(that.lower) && upper.equals(that.upper); + } + + @Override + public int hashCode() { + int result = lower.hashCode(); + result = 31 * result + upper.hashCode(); + return result; + } + } + + /** + * Builder for creating a query for matching multi-range field values. Highlights two key points: + * + * <ul> + * <li>treats multiple or single field value as scalar for range matching + * <li>field values have fixed width + * </ul> + */ + public static class SordedSetFieldValueFixedBuilder Review Comment: @gsmiller what do you think about such a verbose way of constructing query? Is it worth to piggyback on `java.function` nice interfaces? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org