The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* 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.
 */

parcel Lucy;

/** Match a range of values.
 *
 * RangeQuery matches documents where the value for a particular field falls
 * within a given range.
 */

public class Lucy::Search::RangeQuery inherits Lucy::Search::Query {

    String   *field;
    Obj      *lower_term;
    Obj      *upper_term;
    bool      include_lower;
    bool      include_upper;

    /** Create a new RangeQuery.
     *
     * Takes 5 parameters; `field` is required, as is at least one of either
     * `lower_term` or `upper_term`.
     *
     * @param field The name of a `sortable` field.
     * @param lower_term Lower delimiter.  If not supplied, all values
     * less than `upper_term` will pass.
     * @param upper_term Upper delimiter.  If not supplied, all values greater
     * than `lower_term` will pass.
     * @param include_lower Indicates whether docs which match
     * `lower_term` should be included in the results.
     * @param include_upper Indicates whether docs which match
     * `upper_term` should be included in the results.
     */
    public inert incremented RangeQuery*
    new(String *field, Obj *lower_term = NULL, Obj *upper_term = NULL,
        bool include_lower = true, bool include_upper = true);

    /** Initialize a RangeQuery.  See [](.new) for a description of the
     * parameters.
     */
    public inert RangeQuery*
    init(RangeQuery *self, String *field,
         Obj *lower_term = NULL, Obj *upper_term = NULL,
         bool include_lower = true, bool include_upper = true);

    public bool
    Equals(RangeQuery *self, Obj *other);

    public incremented String*
    To_String(RangeQuery *self);

    public incremented Compiler*
    Make_Compiler(RangeQuery *self, Searcher *searcher, float boost,
                  bool subordinate = false);

    void
    Serialize(RangeQuery *self, OutStream *outstream);

    incremented RangeQuery*
    Deserialize(decremented RangeQuery *self, InStream *instream);

    public incremented Obj*
    Dump(RangeQuery *self);

    public incremented Obj*
    Load(RangeQuery *self, Obj *dump);

    public void
    Destroy(RangeQuery *self);
}

class Lucy::Search::RangeCompiler inherits Lucy::Search::Compiler {

    inert incremented RangeCompiler*
    new(RangeQuery *parent, Searcher *searcher, float boost);

    inert RangeCompiler*
    init(RangeCompiler *self, RangeQuery *parent, Searcher *searcher,
         float boost);

    public incremented nullable Matcher*
    Make_Matcher(RangeCompiler *self, SegReader *reader, bool need_score);
}