add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / src / java / org / apache / lucene / search / function / ValueSource.java
1 package org.apache.lucene.search.function;
2
3 /**
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
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  * @lucene.experimental
35  *
36  *
37  */
38 public abstract class ValueSource implements Serializable {
39
40   /**
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.
45    */
46   public abstract DocValues getValues(IndexReader reader) throws IOException;
47
48   /** 
49    * description of field, used in explain() 
50    */
51   public abstract String description();
52
53   /* (non-Javadoc) @see java.lang.Object#toString() */
54   @Override
55   public String toString() {
56     return description();
57   }
58
59   /**
60    * Needed for possible caching of query results - used by {@link ValueSourceQuery#equals(Object)}.
61    * @see Object#equals(Object)
62    */
63   @Override
64   public abstract boolean equals(Object o);
65
66   /**
67    * Needed for possible caching of query results - used by {@link ValueSourceQuery#hashCode()}.
68    * @see Object#hashCode()
69    */
70   @Override
71   public abstract int hashCode();
72   
73 }