use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestCompoundCriteriaImpl method helpExample.
public static org.teiid.query.sql.lang.CompoundCriteria helpExample(int operator) {
CompareCriteria c1 = TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200);
CompareCriteria c2 = TestCompareCriteriaImpl.helpExample(CompareCriteria.LT, 500, 600);
return new org.teiid.query.sql.lang.CompoundCriteria(operator, c1, c2);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestSearchedCaseExpressionImpl method getWhenCriteria.
public static List getWhenCriteria(int criteria) {
ArrayList list = new ArrayList();
// $NON-NLS-1$ //$NON-NLS-2$
ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1");
for (int i = 0; i < criteria; i++) {
list.add(new CompareCriteria(x, CompareCriteria.EQ, new Constant(new Integer(i))));
}
return list;
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class DependentCriteriaProcessor method replaceDependentCriteria.
public Criteria replaceDependentCriteria(AbstractSetCriteria crit, SetState state) throws TeiidComponentException {
if (state.overMax) {
DependentValueSource originalVs = (DependentValueSource) dependentNode.getContext().getVariableContext().getGlobalValue(((DependentSetCriteria) crit).getContextSymbol());
originalVs.setUnused(true);
return QueryRewriter.TRUE_CRITERIA;
}
if (state.replacement.isEmpty()) {
// No values - return criteria that is always false
return QueryRewriter.FALSE_CRITERIA;
}
int numberOfSets = 1;
int setSize = Integer.MAX_VALUE;
if (this.maxSetSize > 0) {
setSize = (int) Math.max(1, this.maxSetSize / state.valueCount);
numberOfSets = state.replacement.size() / setSize + (state.replacement.size() % setSize != 0 ? 1 : 0);
}
Iterator<Constant> iter = state.replacement.iterator();
ArrayList<Criteria> orCrits = new ArrayList<Criteria>(numberOfSets);
for (int i = 0; i < numberOfSets; i++) {
if (setSize == 1 || i + 1 == state.replacement.size()) {
orCrits.add(new CompareCriteria(crit.getExpression(), CompareCriteria.EQ, iter.next()));
} else {
List<Constant> vals = new ArrayList<Constant>(Math.min(state.replacement.size(), setSize));
for (int j = 0; j < setSize && iter.hasNext(); j++) {
Constant val = iter.next();
vals.add(val);
}
SetCriteria sc = new SetCriteria();
sc.setExpression(crit.getExpression());
sc.setValues(vals);
orCrits.add(sc);
}
}
if (orCrits.size() == 1) {
return orCrits.get(0);
}
return new CompoundCriteria(CompoundCriteria.OR, orCrits);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestCompoundCriteria method testClone2.
public void testClone2() {
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("e1");
// $NON-NLS-1$
CompareCriteria ccrit1 = new CompareCriteria(e1, CompareCriteria.EQ, new Constant("abc"));
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.AND, ccrit1, null);
UnitTestUtil.helpTestEquivalence(0, comp, comp.clone());
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitDelete2.
public void testVisitDelete2() {
Delete delete = new Delete(exampleGroup(true, 0));
delete.setCriteria(new CompareCriteria(exampleElement(true, 0), CompareCriteria.EQ, exampleElement(true, 1)));
helpTest(delete, getSymbolMap());
}
Aggregations