01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.search.function;
17:
18: import org.apache.lucene.search.Explanation;
19:
20: /**
21: * Represents field values as different types.
22: * Normally created via a {@link ValueSource} for a particular field and reader.
23: *
24: * @author yonik
25: * @version $Id: DocValues.java 472574 2006-11-08 18:25:52Z yonik $
26: */
27:
28: // DocValues is distinct from ValueSource because
29: // there needs to be an object created at query evaluation time that
30: // is not referenced by the query itself because:
31: // - Query objects should be MT safe
32: // - For caching, Query objects are often used as keys... you don't
33: // want the Query carrying around big objects
34: public abstract class DocValues {
35: public float floatVal(int doc) {
36: throw new UnsupportedOperationException();
37: }
38:
39: public int intVal(int doc) {
40: throw new UnsupportedOperationException();
41: }
42:
43: public long longVal(int doc) {
44: throw new UnsupportedOperationException();
45: }
46:
47: public double doubleVal(int doc) {
48: throw new UnsupportedOperationException();
49: }
50:
51: public String strVal(int doc) {
52: throw new UnsupportedOperationException();
53: }
54:
55: public abstract String toString(int doc);
56:
57: public Explanation explain(int doc) {
58: return new Explanation(floatVal(doc), toString(doc));
59: }
60: }
|