Source Code Cross Referenced for OptimizablePredicateList.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » sql » compile » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.iapi.sql.compile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.sql.compile.OptimizablePredicateList
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.sql.compile;
023:
024:        import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
025:
026:        import org.apache.derby.iapi.services.compiler.MethodBuilder;
027:
028:        import org.apache.derby.iapi.error.StandardException;
029:
030:        import org.apache.derby.iapi.util.JBitSet;
031:
032:        /**
033:         * OptimizablePredicateList provides services for optimizing a table in a query.
034:         * RESOLVE - the methods for this interface need to get defined.
035:         */
036:
037:        public interface OptimizablePredicateList {
038:            /**
039:             *  Return the number of OptimizablePredicates in the list.
040:             *
041:             *  @return integer		The number of OptimizablePredicates in the list.
042:             */
043:            public int size();
044:
045:            /**
046:             *  Return the nth OptimizablePredicate in the list.
047:             *
048:             *  @param n				"index" (0 based) into the list.
049:             *
050:             *  @return OptimizablePredicate		The nth OptimizablePredicate in the list.
051:             */
052:            public OptimizablePredicate getOptPredicate(int n);
053:
054:            /**
055:             * Remove the OptimizablePredicate at the specified index (0-based) from the list.
056:             *
057:             * @param predCtr	The index.
058:             *
059:             * @exception StandardException		Thrown on error
060:             */
061:            void removeOptPredicate(int predCtr) throws StandardException;
062:
063:            /**
064:             * Add the given OptimizablePredicate to the end of this list.
065:             *
066:             * @param optPredicate	The predicate to add
067:             */
068:            void addOptPredicate(OptimizablePredicate optPredicate);
069:
070:            /**
071:             * Return true if this predicate list is useful for limiting the scan on
072:             * the given table using the given conglomerate.
073:             *
074:             * @param optTable An Optimizable for the table in question
075:             * @param cd A ConglomerateDescriptor for the conglomerate in question
076:             *
077:             * @return	true if this predicate list can limit the scan
078:             * @exception StandardException		Thrown on error
079:             */
080:            boolean useful(Optimizable optTable, ConglomerateDescriptor cd)
081:                    throws StandardException;
082:
083:            /**
084:             * Determine which predicates in this list are useful for limiting
085:             * the scan on the given table using its best conglomerate.  Remove
086:             * those predicates from this list and push them down to the given
087:             * Optimizable table.  The predicates are pushed down in the order of
088:             * the index columns that they qualify.  Also, the predicates are
089:             * "marked" as start predicates, stop predicates, or qualifier
090:             * predicates.  Finally, the start and stop operators are set in
091:             * the given Optimizable.
092:             *
093:             * @param optTable	An Optimizable for the table in question
094:             *
095:             * @exception StandardException		Thrown on error
096:             */
097:            void pushUsefulPredicates(Optimizable optTable)
098:                    throws StandardException;
099:
100:            /**
101:             * Classify the predicates in this list according to the given
102:             * table and conglomerate.  Each predicate can be a start key, stop key,
103:             * and/or qualifier, or it can be none of the above.  This method
104:             * also orders the predicates to match the order of the columns
105:             * in a keyed conglomerate.  No ordering is done for heaps.
106:             *
107:             * @param optTable	The Optimizable table for which to classify
108:             *					the predicates in this list.
109:             * @param cd	The ConglomerateDescriptor for which to classify
110:             *				the predicates in this list.
111:             *
112:             * @exception StandardException		Thrown on error
113:             */
114:            void classify(Optimizable optTable, ConglomerateDescriptor cd)
115:                    throws StandardException;
116:
117:            /**
118:             * Mark all of the predicates as Qualifiers and set the numberOfQualifiers
119:             * to reflect this.  This is useful for hash joins where all of the
120:             * predicates in the list to be evaluated during the probe into the
121:             * hash table on a next are qualifiers.
122:             */
123:            public void markAllPredicatesQualifiers();
124:
125:            /**
126:             * Is there an optimizable equality predicate on the specified column?
127:             *
128:             * @param optTable		The optimizable the column comes from.
129:             * @param columnNumber	The column number within the base table.
130:             * @param isNullOkay	boolean, whether or not the IS NULL operator
131:             *						satisfies the search
132:             *
133:             * @return Whether or not there is an optimizable equality predicate on the specified column.
134:             *
135:             * @exception StandardException		Thrown on error
136:             */
137:            boolean hasOptimizableEqualityPredicate(Optimizable optTable,
138:                    int columnNumber, boolean isNullOkay)
139:                    throws StandardException;
140:
141:            /**
142:             * Is there an optimizable equijoin on the specified column?
143:             *
144:             * @param optTable		The optimizable the column comes from.
145:             * @param columnNumber	The column number within the base table.
146:             *
147:             * @return Whether or not there is an optimizable equijoin on the specified column.
148:             *
149:             * @exception StandardException		Thrown on error
150:             */
151:            boolean hasOptimizableEquijoin(Optimizable optTable,
152:                    int columnNumber) throws StandardException;
153:
154:            /**
155:             * Find the optimizable equality predicate on the specified column and make
156:             * it the first predicate in this list.  This is useful for hash joins where
157:             * Qualifier[0] is assumed to be on the hash key.
158:             *
159:             * @param optTable		The optimizable the column comes from.
160:             * @param columnNumber	The column number within the base table.
161:             *
162:             * @exception StandardException		Thrown on error
163:             */
164:            void putOptimizableEqualityPredicateFirst(Optimizable optTable,
165:                    int columnNumber) throws StandardException;
166:
167:            /**
168:             * Transfer the predicates whose referenced set is contained by the
169:             * specified referencedTableMap from this list to the other list.
170:             * This is useful when splitting out a set of predicates from a larger
171:             * set, like when generating a HashScanResultSet.
172:             *
173:             * @param otherList				The predicateList to xfer to
174:             * @param referencedTableMap	The table map to check against
175:             * @param table					The table to order the new predicates
176:             *								against
177:             *
178:             * @exception StandardException		Thrown on error
179:             */
180:            public void transferPredicates(OptimizablePredicateList otherList,
181:                    JBitSet referencedTableMap, Optimizable table)
182:                    throws StandardException;
183:
184:            /**
185:             * Transfer all the predicates from this list to the given list.
186:             *
187:             * @exception StandardException		Thrown on error
188:             */
189:            public void transferAllPredicates(OptimizablePredicateList otherList)
190:                    throws StandardException;
191:
192:            /**
193:             * Non-destructive copy of all of the predicates from this list to the
194:             * other list.
195:             *
196:             * This is useful when splitting out a set of predicates from a larger
197:             * set, like when generating a HashScanResultSet.
198:             *
199:             * @param otherList				The predicateList to xfer to
200:             *
201:             * @exception StandardException		Thrown on error
202:             */
203:            public void copyPredicatesToOtherList(
204:                    OptimizablePredicateList otherList)
205:                    throws StandardException;
206:
207:            /**
208:             * Sets the given list to have the same elements as this one, and
209:             * the same properties as this one (number of qualifiers and start
210:             * and stop predicates.
211:             *
212:             * @param otherList		The list to set the same as this one.
213:             *
214:             * @exception StandardException		Thrown on error
215:             */
216:            public void setPredicatesAndProperties(
217:                    OptimizablePredicateList otherList)
218:                    throws StandardException;
219:
220:            /**
221:             * Return whether or not the specified entry in the list is a redundant
222:             * predicate. This is useful for selectivity calculations because we
223:             * do not want redundant predicates included in the selectivity calculation.
224:             *
225:             * @param predNum	The entry in the list
226:             *
227:             * @return Whether or not the specified entry in the list is a redundant predicate.
228:             */
229:            public boolean isRedundantPredicate(int predNum);
230:
231:            /**
232:             * Get the start operator for the given Optimizable for a heap or
233:             * index scan.
234:             */
235:            int startOperator(Optimizable optTable);
236:
237:            /**
238:             * Get the stop operator for the given Optimizable for a heap or
239:             * index scan.
240:             */
241:            int stopOperator(Optimizable optTable);
242:
243:            /**
244:             * Generate the qualifiers for a scan.  This method generates an array
245:             * of Qualifiers, and fills them in with calls to the factory method
246:             * for generating Qualifiers in the constructor for the activation.
247:             * It stores the array of Qualifiers in a field in the activation, and
248:             * returns a reference to that field.
249:             *
250:             * If there are no qualifiers, it initializes the array of Qualifiers
251:             * to null.
252:             *
253:             * @param acb	The ExpressionClassBuilderInterface for the class we are building
254:             * @param mb	The method the generated code is going into
255:             * @param optTable	The Optimizable table the Qualifiers are on
256:             * @param absolute	Generate absolute column positions if true,
257:             *					else relative column positions (within the underlying
258:             *					row)
259:             *
260:             *
261:             * @exception StandardException		Thrown on error
262:             */
263:            void generateQualifiers(ExpressionClassBuilderInterface acb,
264:                    MethodBuilder mb, Optimizable optTable, boolean absolute)
265:                    throws StandardException;
266:
267:            /**
268:             * Generate the start key for a heap or index scan.
269:             *
270:             * @param acb	The ExpressionClassBuilderInterface for the class we're building
271:             * @param mb	The method the generated code is to go into
272:             * @param optTable	The Optimizable table the start key is for
273:             *
274:             * @exception StandardException		Thrown on error
275:             */
276:            void generateStartKey(ExpressionClassBuilderInterface acb,
277:                    MethodBuilder mb, Optimizable optTable)
278:                    throws StandardException;
279:
280:            /**
281:             * Generate the stop key for a heap or index scan.
282:             *
283:             * @param acb	The ExpressionClassBuilderInterface for the class we're building
284:             * @param mb	the method the generated code is to go into
285:             * @param optTable	The Optimizable table the stop key is for
286:             *
287:             * @exception StandardException		Thrown on error
288:             */
289:            void generateStopKey(ExpressionClassBuilderInterface acb,
290:                    MethodBuilder mb, Optimizable optTable)
291:                    throws StandardException;
292:
293:            /**
294:             * Can we use the same key for both the start and stop key.
295:             * This is possible when doing an exact match on an index
296:             * where there are no other sargable predicates.
297:             *
298:             * @return Whether or not we can use the same key for both the start and stop key.
299:             *
300:             * @exception StandardException		Thrown on error
301:             */
302:            public boolean sameStartStopPosition() throws StandardException;
303:
304:            /**
305:             * calculate the selectivity for a set of predicates. 
306:             * If statistics exist for the predicates this method uses the
307:             * statistics. If statistics do not exist, then simply call 
308:             * selectivity for each of the predicates and return the result.
309:             *
310:             * @param optTable	the Optimizable that the predicate list restricts.
311:             */
312:            public double selectivity(Optimizable optTable)
313:                    throws StandardException;
314:
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.