01: package org.apache.lucene.search.function;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * the License. You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
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.
18: */
19:
20: import org.apache.lucene.index.IndexReader;
21: import org.apache.lucene.search.function.DocValues;
22:
23: import java.io.IOException;
24: import java.io.Serializable;
25:
26: /**
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.
33: *
34: * <p><font color="#FF0000">
35: * WARNING: The status of the <b>search.function</b> package is experimental.
36: * The APIs introduced here might change in the future and will not be
37: * supported anymore in such a case.</font>
38: *
39: *
40: */
41: public abstract class ValueSource implements Serializable {
42:
43: /**
44: * Return the DocValues used by the function query.
45: * @param reader the IndexReader used to read these values.
46: * If any caching is involved, that caching would also be IndexReader based.
47: * @throws IOException for any error.
48: */
49: public abstract DocValues getValues(IndexReader reader)
50: throws IOException;
51:
52: /**
53: * description of field, used in explain()
54: */
55: public abstract String description();
56:
57: /* (non-Javadoc) @see java.lang.Object#toString() */
58: public String toString() {
59: return description();
60: }
61:
62: /**
63: * Needed for possible caching of query results - used by {@link ValueSourceQuery#equals(Object)}.
64: * @see Object#equals(Object)
65: */
66: public abstract boolean equals(Object o);
67:
68: /**
69: * Needed for possible caching of query results - used by {@link ValueSourceQuery#hashCode()}.
70: * @see Object#hashCode()
71: */
72: public abstract int hashCode();
73:
74: }
|