18 package com.mysql.clusterj.core.query;
20 import java.util.List;
22 import com.mysql.clusterj.ClusterJException;
23 import com.mysql.clusterj.ClusterJUserException;
24 import com.mysql.clusterj.core.spi.QueryExecutionContext;
25 import com.mysql.clusterj.core.store.IndexScanOperation;
26 import com.mysql.clusterj.core.store.ScanFilter;
27 import com.mysql.clusterj.core.store.ScanOperation;
28 import com.mysql.clusterj.core.store.IndexScanOperation.BoundType;
29 import com.mysql.clusterj.core.store.ScanFilter.BinaryCondition;
30 import com.mysql.clusterj.core.store.ScanFilter.Group;
45 parameter.setProperty(property);
47 property.setComplexParameter();
63 if (
parameter.getParameterValue(context) == null) {
67 property.markInBound(candidateIndices,
this);
98 QueryExecutionContext context, IndexScanOperation op,
int index, BoundType boundType) {
99 Object parameterValue =
parameter.getParameterValue(context);
100 if (parameterValue == null) {
103 }
else if (parameterValue instanceof
List<?>) {
104 List<?> parameterList = (List<?>)parameterValue;
105 Object value = parameterList.get(index);
106 property.operationSetBounds(value, boundType, op);
107 if (logger.isDetailEnabled()) logger.detail(
"InPredicateImpl.operationSetBound for " +
property.fmd.getName() +
" List index: " + index +
" value: " + value +
" boundType: " + boundType);
108 }
else if (parameterValue.getClass().isArray()) {
109 Object[] parameterArray = (Object[])parameterValue;
110 Object value = parameterArray[
index];
111 property.operationSetBounds(value, boundType, op);
112 if (logger.isDetailEnabled()) logger.detail(
"InPredicateImpl.operationSetBound for " +
property.fmd.getName() +
" array index: " + index +
" value: " + value +
" boundType: " + boundType);
114 throw new ClusterJUserException(
116 parameterValue.getClass().getName(),
"List<?> or Object[]"));
129 Object parameterValue =
parameter.getParameterValue(context);
131 if (parameterValue == null) {
134 }
else if (parameterValue instanceof List<?>) {
135 List<?> parameterList = (List<?>)parameterValue;
136 for (Object value: parameterList) {
137 property.operationSetBounds(value,
BoundType.BoundEQ, op);
138 if (logger.isDetailEnabled()) logger.detail(
"InPredicateImpl.operationSetAllBounds for List index: " + index +
" value: " + value);
139 op.endBound(index++);
141 }
else if (parameterValue.getClass().isArray()) {
142 Object[] parameterArray = (Object[])parameterValue;
143 for (Object value: parameterArray) {
144 property.operationSetBounds(value,
BoundType.BoundEQ, op);
145 if (logger.isDetailEnabled()) logger.detail(
"InPredicateImpl.operationSetAllBounds for array index: " + index +
" value: " + value);
146 op.endBound(index++);
151 parameterValue.getClass().getName(),
"List<?> or Object[]"));
163 ScanFilter filter = op.getScanFilter(context);
167 }
catch (Exception ex) {
169 local.
message(
"ERR_Get_NdbFilter"), ex);
181 filter.begin(
Group.GROUP_OR);
182 Object parameterValue =
parameter.getParameterValue(context);
183 if (parameterValue == null) {
186 }
else if (parameterValue instanceof Iterable<?>) {
187 Iterable<?> iterable = (Iterable<?>)parameterValue;
188 for (Object value: iterable) {
191 }
else if (parameterValue.getClass().isArray()) {
192 Object[] parameterArray = (Object[])parameterValue;
199 parameterValue.getClass().getName(),
"Iterable<?> or Object[]"));
204 }
catch (Exception ex) {
206 local.
message(
"ERR_Get_NdbFilter"), ex);
212 Object parameterValue =
parameter.getParameterValue(context);
213 if (parameterValue instanceof List<?>) {
214 result = ((List<?>)parameterValue).size();
216 Class<?> cls = parameterValue.getClass();
218 if (!Object.class.isAssignableFrom(cls.getComponentType())) {
222 Object[] parameterArray = (Object[])parameterValue;
223 result = parameterArray.length;
226 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Too_Big_For_In",