Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / iapi / sql / compile / OptimizablePredicate.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java
new file mode 100644 (file)
index 0000000..d3bb110
--- /dev/null
@@ -0,0 +1,149 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.iapi.sql.compile.OptimizablePredicate\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.sql.compile;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.types.DataValueDescriptor;\r
+\r
+import org.apache.derby.iapi.util.JBitSet;\r
+\r
+/**\r
+ * OptimizablePredicate provides services for optimizing predicates in a query.\r
+ */\r
+\r
+public interface OptimizablePredicate\r
+{\r
+       /**\r
+        * Get the map of referenced tables for this OptimizablePredicate.\r
+        *\r
+        * @return JBitSet      Referenced table map.\r
+        */\r
+       JBitSet getReferencedMap();\r
+\r
+       /**\r
+        * Return whether or not an OptimizablePredicate contains a subquery.\r
+        *\r
+        * @return boolean      Whether or not an OptimizablePredicate includes a subquery.\r
+        */\r
+       boolean hasSubquery();\r
+\r
+       /**\r
+        * Return whether or not an OptimizablePredicate contains a method call.\r
+        *\r
+        * @return boolean      Whether or not an OptimizablePredicate includes a method call.\r
+        */\r
+       boolean hasMethodCall();\r
+\r
+       /**\r
+        * Tell the predicate that it is to be used as a column in the start key\r
+        * value for an index scan.\r
+        */\r
+       void markStartKey();\r
+\r
+       /** Is this predicate a start key? */\r
+       boolean isStartKey();\r
+\r
+       /**\r
+        * Tell the predicate that it is to be used as a column in the stop key\r
+        * value for an index scan.\r
+        */\r
+       void markStopKey();\r
+\r
+       /** Is this predicate a stop key? */\r
+       boolean isStopKey();\r
+\r
+       /**\r
+        * Tell the predicate that it is to be used as a qualifier in an index\r
+        * scan.\r
+        */\r
+       void markQualifier();\r
+\r
+       /** Is this predicate a qualifier? */\r
+       boolean isQualifier();\r
+\r
+       /**\r
+        * Is this predicate a comparison with a known constant value?\r
+        *\r
+        * @param optTable      The Optimizable that we want to know whether we\r
+        *                                      are comparing to a known constant.\r
+        * @param considerParameters    Whether or not to consider parameters with defaults\r
+        *                                                              as known constants.\r
+        */\r
+       boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters);\r
+\r
+       /**\r
+        * Get an Object representing the known constant value that the given\r
+        * Optimizable is being compared to.\r
+        *\r
+        * @exception StandardException         Thrown on error\r
+        */\r
+       DataValueDescriptor getCompareValue(Optimizable optTable) \r
+        throws StandardException;\r
+\r
+       /**\r
+        * Is this predicate an equality comparison with a constant expression?\r
+        * (IS NULL is considered to be an = comparison with a constant expression).\r
+        *\r
+        * @param optTable      The Optimizable for which we want to know whether\r
+        *                                      it is being equality-compared to a constant expression.\r
+        */\r
+       boolean equalsComparisonWithConstantExpression(Optimizable optTable);\r
+\r
+       \r
+       /**\r
+        * Returns if the predicate involves an equal operator on one of the\r
+        * columns specified in the baseColumnPositions.\r
+        *\r
+        * @param       baseColumnPositions     the column numbers on which the user wants\r
+        * to check if the equality condition exists.\r
+        * @param       optTable the table for which baseColumnPositions are given.\r
+\r
+               @return returns the index into baseColumnPositions of the column that has the\r
+               equality operator.\r
+        */\r
+       int hasEqualOnColumnList(int[] baseColumnPositions,\r
+                                                                Optimizable optTable)\r
+               throws StandardException;\r
+\r
+       /**\r
+        * Get a (crude) estimate of the selectivity of this predicate.\r
+        * This is to be used when no better technique is available for\r
+        * estimating the selectivity - this method's estimate is a hard-\r
+        * wired number based on the type of predicate and the datatype\r
+        * (the selectivity of boolean is always 50%).\r
+        *\r
+        * @param optTable      The Optimizable that this predicate restricts\r
+        */\r
+       double selectivity(Optimizable optTable)\r
+       throws StandardException;\r
+\r
+       /**\r
+        * Get the position of the index column that this predicate restricts.\r
+        * NOTE: This assumes that this predicate is part of an\r
+        * OptimizablePredicateList, and that classify() has been called\r
+        * on the OptimizablePredicateList.\r
+        *\r
+        * @return The index position that this predicate restricts (zero-based)\r
+        */\r
+       int getIndexPosition();\r
+}\r