use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithKeyCompoundCritAND.
/**
* Tests that join side with larger cardinality will still have a lower
* cost computed because it has a criteria including a primary key
*/
@Test
public void testCardinalityWithKeyCompoundCritAND() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e2 = getElementSymbol(1, 2, 2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
crits.add(new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2));
Criteria atomicCrit1 = null;
Criteria crit1 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(5)));
Criteria crit2 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(7)));
CompoundCriteria atomicCrit2 = new CompoundCriteria(CompoundCriteria.AND, crit1, crit2);
int expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithKeyComplexCrit.
/**
* Tests that join side with larger cardinality will still have a lower
* cost computed because it has a criteria including a primary key
*/
@Test
public void testCardinalityWithKeyComplexCrit() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e2 = getElementSymbol(1, 2, 2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
crits.add(new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2));
Criteria atomicCrit1 = null;
Criteria crit1 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(5)));
Criteria crit2 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(7)));
CompoundCriteria atomicCrit2 = new CompoundCriteria(CompoundCriteria.AND, crit1, crit2);
// $NON-NLS-1$
Criteria crit3 = new MatchCriteria(g2e1, new Constant(new String("ab")));
atomicCrit2 = new CompoundCriteria(CompoundCriteria.OR, atomicCrit2, crit3);
int expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithKeyNotCrit.
/**
* Tests NotCriteria in the atomic criteria
*/
@Test
public void testCardinalityWithKeyNotCrit() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e2 = getElementSymbol(1, 2, 2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
CompareCriteria crit2 = new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2);
crits.add(crit2);
Criteria atomicCrit1 = null;
Criteria atomicCrit2 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(5)));
atomicCrit2 = new NotCriteria(atomicCrit2);
int expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestRuleChooseDependent method testCardinality.
/**
* Tests that heuristics will take cardinality of a group into account when
* making a dependent join.
*/
@Test
public void testCardinality() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
GroupSymbol group2 = getPhysicalGroup(2, 2);
// Join criteria
ElementSymbol pm1g2e1 = getElementSymbol(1, 2, 1);
ElementSymbol pm2g2e1 = getElementSymbol(2, 2, 1);
CompareCriteria crit = new CompareCriteria(pm2g2e1, CompareCriteria.EQ, pm1g2e1);
ArrayList crits = new ArrayList(2);
crits.add(crit);
ElementSymbol pm1g2e2 = getElementSymbol(1, 2, 2);
ElementSymbol pm2g2e2 = getElementSymbol(2, 2, 2);
CompareCriteria crit2 = new CompareCriteria(pm1g2e2, CompareCriteria.EQ, pm2g2e2);
crits.add(crit2);
Criteria atomicCrit1 = null;
Criteria atomicCrit2 = null;
int expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithNonKeyCrit.
/**
* Tests that join side with larger cardinality and non-key criteria
* will be made dependent
*/
@Test
public void testCardinalityWithNonKeyCrit() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e1 = getElementSymbol(1, 2, 1);
// ElementSymbol g1e2 = getElementSymbol(1,2,2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
CompareCriteria crit2 = new CompareCriteria(g1e1, CompareCriteria.EQ, g2e1);
crits.add(crit2);
Criteria atomicCrit1 = null;
Criteria atomicCrit2 = new CompareCriteria(g2e2, CompareCriteria.EQ, new Constant(new Integer(5)));
int expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
Aggregations