]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
b2f9ed5487cb79da21f0decb57f04929580a8700
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17
18 package com.mysql.clusterj.core.query;
19
20 import com.mysql.clusterj.ClusterJException;
21 import com.mysql.clusterj.core.spi.QueryExecutionContext;
22 import com.mysql.clusterj.core.store.ScanFilter;
23 import com.mysql.clusterj.core.store.ScanOperation;
24 import com.mysql.clusterj.core.store.ScanFilter.Group;
25
26 public class NotPredicateImpl extends PredicateImpl {
27
28     /** The predicate being negated */
29     private PredicateImpl predicate;
30
31     public NotPredicateImpl(PredicateImpl predicate) {
32         super(predicate.dobj);
33         this.predicate = predicate;
34     }
35
36     @Override
37     public void markParameters() {
38         // Nothing to do because "not" can't use indexes
39     }
40
41     @Override
42     public void unmarkParameters() {
43         // Nothing to do because "not" can't use indexes
44     }
45
46     void markBoundsForCandidateIndices(QueryExecutionContext context,
47             CandidateIndexImpl[] candidateIndices) {
48         // Nothing to do because "not" can't use indexes
49     }
50
51     /** Create a filter for the operation. Call the negated predicate to set
52      * the filter values.
53      * @param context the query execution context with the parameter values
54      * @param op the operation
55      */
56     public void filterCmpValue(QueryExecutionContext context,
57             ScanOperation op) {
58         try {
59             ScanFilter filter = op.getScanFilter(context);
60             filter.begin(Group.GROUP_NAND);
61             predicate.filterCmpValue(context, op, filter);
62             filter.end();
63         } catch (ClusterJException ex) {
64             throw ex;
65         } catch (Exception ex) {
66             throw new ClusterJException(
67                     local.message("ERR_Get_NdbFilter"), ex);
68         }
69     }
70
71     /** Use an existing filter for the operation. Call the negated predicate to set
72      * the filter values.
73      * @param context the query execution context with the parameter values
74      * @param op the operation
75      * @param filter the existing filter
76      */
77     public void filterCmpValue(QueryExecutionContext context,
78             ScanOperation op, ScanFilter filter) {
79         try {
80             filter.begin(Group.GROUP_NAND);
81             predicate.filterCmpValue(context, op, filter);
82             filter.end();
83         } catch (ClusterJException ex) {
84             throw ex;
85         } catch (Exception ex) {
86             throw new ClusterJException(
87                     local.message("ERR_Get_NdbFilter"), ex);
88         }
89     }
90
91 }