KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > sql > compile > CostEstimate


1 /*
2
3    Derby - Class org.apache.derby.iapi.sql.compile.CostEstimate
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.sql.compile;
23
24 import org.apache.derby.iapi.store.access.StoreCostResult;
25
26 /**
27  * A CostEstimate represents the cost of getting a ResultSet, along with the
28  * ordering of rows in the ResultSet, and the estimated number of rows in
29  * this ResultSet.
30  *
31  * @author Jeff Lichtman
32  */

33
34 public interface CostEstimate extends StoreCostResult
35 {
36     /**
37      * Set the cost for this cost estimate.
38      */

39     void setCost(double cost, double rowCount, double singleScanRowCount);
40
41     /**
42      * Copy the values from the given cost estimate into this one.
43      */

44     void setCost(CostEstimate other);
45
46     /**
47      * Set the single scan row count.
48      */

49     void setSingleScanRowCount(double singleRowScanCount);
50
51     /**
52      * Compare this cost estimate with the given cost estimate.
53      *
54      * @param other The cost estimate to compare this one with
55      *
56      * @return < 0 if this < other, 0 if this == other, > 0 if this > other
57      */

58     double compare(CostEstimate other);
59
60     /**
61      * Add this cost estimate to another one. This presumes that any row
62      * ordering is destroyed.
63      *
64      * @param addend This cost estimate to add this one to.
65      * @param retval If non-null, put the result here.
66      *
67      * @return this + other.
68      */

69     CostEstimate add(CostEstimate addend, CostEstimate retval);
70
71     /**
72      * Multiply this cost estimate by a scalar, non-dimensional number. This
73      * presumes that any row ordering is destroyed.
74      *
75      * @param multiplicand The value to multiply this CostEstimate by.
76      * @param retval If non-null, put the result here.
77      *
78      * @return this * multiplicand
79      */

80     CostEstimate multiply(double multiplicand, CostEstimate retval);
81
82     /**
83      * Divide this cost estimate by a scalar, non-dimensional number.
84      *
85      * @param divisor The value to divide this CostEstimate by.
86      * @param retval If non-null, put the result here.
87      *
88      * @return this / divisor
89      */

90     CostEstimate divide(double divisor, CostEstimate retval);
91
92     /**
93      * Get the estimated number of rows returned by the ResultSet that this
94      * CostEstimate models.
95      */

96     double rowCount();
97
98     /**
99      * Get the estimated number of rows returned by a single scan of
100      * the ResultSet that this CostEstimate models.
101      */

102     double singleScanRowCount();
103
104     /** Get a copy of this CostEstimate */
105     CostEstimate cloneMe();
106
107     /**
108      * Return whether or not this CostEstimate is uninitialized.
109      *
110      * @return Whether or not this CostEstimate is uninitialized.
111      */

112     public boolean isUninitialized();
113 }
114
Popular Tags