1 /* 2 3 Derby - Class org.apache.derby.impl.store.access.conglomerate.GenericCostController 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.impl.store.access.conglomerate; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import org.apache.derby.iapi.reference.SQLState; 27 28 import org.apache.derby.iapi.store.access.StoreCostController; 29 import org.apache.derby.iapi.store.access.StoreCostResult; 30 31 import org.apache.derby.iapi.types.DataValueDescriptor; 32 33 import org.apache.derby.impl.sql.execute.RowUtil; 34 35 import org.apache.derby.iapi.services.io.FormatableBitSet; 36 37 38 /** 39 40 A Generic class which implements the basic functionality needed for a cost 41 controller. 42 43 **/ 44 45 public abstract class GenericCostController 46 extends GenericController implements StoreCostController 47 { 48 49 /************************************************************************** 50 * Fields of the class 51 ************************************************************************** 52 */ 53 54 /************************************************************************** 55 * Constructors for This class: 56 ************************************************************************** 57 */ 58 59 /************************************************************************** 60 * Private/Protected methods of This class: 61 ************************************************************************** 62 */ 63 64 /************************************************************************** 65 * Public Methods of This class: 66 ************************************************************************** 67 */ 68 69 /************************************************************************** 70 * Public Methods implementing StoreCostController class: 71 ************************************************************************** 72 */ 73 74 /************************************************************************** 75 * Public Methods implementing StoreCostController class, default impl 76 * just throws exception: 77 ************************************************************************** 78 */ 79 80 81 /** 82 * Return the cost of exact key lookup. 83 * <p> 84 * Return the estimated cost of calling ScanController.fetch() 85 * on the current conglomerate, with start and stop positions set such 86 * that an exact match is expected. 87 * <p> 88 * This call returns the cost of a fetchNext() performed on a scan which 89 * has been positioned with a start position which specifies exact match 90 * on all keys in the row. 91 * <p> 92 * Example: 93 * <p> 94 * In the case of a btree this call can be used to determine the cost of 95 * doing an exact probe into btree, giving all key columns. This cost 96 * can be used if the client knows it will be doing an exact key probe 97 * but does not have the key's at optimize time to use to make a call to 98 * getScanCost() 99 * <p> 100 * 101 * @param validColumns A description of which columns to return from 102 * row on the page into "templateRow." templateRow, 103 * and validColumns work together to 104 * describe the row to be returned by the fetch - 105 * see RowUtil for description of how these three 106 * parameters work together to describe a fetched 107 * "row". 108 * 109 * @param access_type Describe the type of access the query will be 110 * performing to the ScanController. 111 * 112 * STORECOST_CLUSTERED - The location of one scan 113 * is likely clustered "close" to the previous 114 * scan. For instance if the query plan were 115 * to used repeated "reopenScan()'s" to probe 116 * for the next key in an index, then this flag 117 * should be be specified. If this flag is not 118 * set then each scan will be costed independant 119 * of any other predicted scan access. 120 * 121 * @return The cost of the fetch. 122 * 123 * @exception StandardException Standard exception policy. 124 * 125 * @see RowUtil 126 **/ 127 public double getFetchFromFullKeyCost( 128 FormatableBitSet validColumns, 129 int access_type) 130 throws StandardException 131 { 132 // Not implemented in default conglomerate, needs to be overridden. 133 throw StandardException.newException( 134 SQLState.HEAP_UNIMPLEMENTED_FEATURE); 135 } 136 137 138 } 139