01: /*
02:
03: Derby - Class org.apache.derby.vti.VTICosting
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (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.vti;
23:
24: import java.sql.SQLException;
25:
26: /**
27: * VTICosting is the interface that the query optimizer uses
28: * to cost VTIs.
29: *
30: The methods on the interface provide the optimizer
31: * with the following information:
32: <UL>
33: <LI> the estimated number of rows returned by the VTI in a single instantiation.
34: <LI> the estimated cost to instantiate and iterate through the VTI.
35: <LI> whether or not the VTI can be instantiated multiple times within a single query execution
36: </UL>
37: * <P>
38: * This class can only be used within an SQL-J statement. Using the methods
39: * in application-side Java code results in Exceptions being thrown.
40: *
41: * @see org.apache.derby.vti.VTIEnvironment
42: */
43: public interface VTICosting {
44: /**
45: * A useful constant: the default estimated number of rows returned by a VTI.
46: */
47: public static final double defaultEstimatedRowCount = 10000d;
48: /**
49: A useful constant: The default estimated cost of instantiating and iterating throught a VTI.
50: */
51: public static final double defaultEstimatedCost = 100000d;
52:
53: /**
54: * Get the estimated row count for a single scan of a VTI.
55: *
56: * @param vtiEnvironment The VTIEnvironment.
57: *
58: * @return The estimated row count for a single scan of a VTI.
59: *
60: * @exception SQLException thrown if the costing fails.
61: */
62: public double getEstimatedRowCount(VTIEnvironment vtiEnvironment)
63: throws SQLException;
64:
65: /**
66: * Get the estimated cost for a single instantiation of a VTI.
67: *
68: * @param vtiEnvironment The VTIEnvironment.
69: *
70: * @return The estimated cost for a single instantiation of a VTI.
71: *
72: * @exception SQLException thrown if the costing fails.
73: */
74: public double getEstimatedCostPerInstantiation(
75: VTIEnvironment vtiEnvironment) throws SQLException;
76:
77: /**
78: Find out if the ResultSet of the VTI can be instantiated multiple times.
79:
80: @param vtiEnvironment The VTIEnvironment.
81:
82: @return True if the ResultSet can be instantiated multiple times, false if
83: can only be instantiated once.
84:
85: @exception SQLException thrown if the costing fails.
86: */
87: public boolean supportsMultipleInstantiations(
88: VTIEnvironment vtiEnvironment) throws SQLException;
89: }
|