1 package org.apache.lucene.search.function;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.index.IndexReader;
21 import org.apache.lucene.search.function.DocValues;
23 import java.io.IOException;
24 import java.io.Serializable;
27 * Expert: source of values for basic function queries.
28 * <P>At its default/simplest form, values - one per doc - are used as the score of that doc.
29 * <P>Values are instantiated as
30 * {@link org.apache.lucene.search.function.DocValues DocValues} for a particular reader.
31 * <P>ValueSource implementations differ in RAM requirements: it would always be a factor
32 * of the number of documents, but for each document the number of bytes can be 1, 2, 4, or 8.
34 * @lucene.experimental
38 public abstract class ValueSource implements Serializable {
41 * Return the DocValues used by the function query.
42 * @param reader the IndexReader used to read these values.
43 * If any caching is involved, that caching would also be IndexReader based.
44 * @throws IOException for any error.
46 public abstract DocValues getValues(IndexReader reader) throws IOException;
49 * description of field, used in explain()
51 public abstract String description();
53 /* (non-Javadoc) @see java.lang.Object#toString() */
55 public String toString() {
60 * Needed for possible caching of query results - used by {@link ValueSourceQuery#equals(Object)}.
61 * @see Object#equals(Object)
64 public abstract boolean equals(Object o);
67 * Needed for possible caching of query results - used by {@link ValueSourceQuery#hashCode()}.
68 * @see Object#hashCode()
71 public abstract int hashCode();