001: /*
002: * $Id: TestIndexNestedLoopJoinedRowIterator_RightOuterJoinCase.java,v 1.3 2005/04/22 21:34:17 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2004-2005 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb.engine.rowiterators;
042:
043: import java.util.ArrayList;
044: import java.util.List;
045:
046: import junit.framework.Test;
047: import junit.framework.TestSuite;
048:
049: import org.axiondb.Column;
050: import org.axiondb.ColumnIdentifier;
051: import org.axiondb.Index;
052: import org.axiondb.RowIterator;
053: import org.axiondb.Table;
054: import org.axiondb.TableIdentifier;
055: import org.axiondb.engine.indexes.ObjectArrayIndex;
056: import org.axiondb.engine.rows.SimpleRow;
057: import org.axiondb.engine.tables.MemoryTable;
058: import org.axiondb.functions.ConcreteFunction;
059: import org.axiondb.functions.EqualFunction;
060: import org.axiondb.types.StringType;
061:
062: /**
063: * @version $Revision: 1.3 $ $Date: 2005/04/22 21:34:17 $
064: * @author Rodney Waldhoff
065: */
066: public class TestIndexNestedLoopJoinedRowIterator_RightOuterJoinCase
067: extends AbstractRowIteratorTest {
068:
069: //------------------------------------------------------------ Conventional
070:
071: public TestIndexNestedLoopJoinedRowIterator_RightOuterJoinCase(
072: String testName) {
073: super (testName);
074: }
075:
076: public static Test suite() {
077: TestSuite suite = new TestSuite(
078: TestIndexNestedLoopJoinedRowIterator_RightOuterJoinCase.class);
079: return suite;
080: }
081:
082: private List _left;
083: private Table _table;
084: private ConcreteFunction _where;
085: private Index _index;
086: private Column _column;
087:
088: protected void setUp() throws Exception {
089: _left = new ArrayList();
090: {
091: SimpleRow row = new SimpleRow(2);
092: row.set(0, "A");
093: row.set(1, "A");
094: _left.add(row);
095: }
096: {
097: SimpleRow row = new SimpleRow(2);
098: row.set(0, "A");
099: row.set(1, "B");
100: _left.add(row);
101: }
102: {
103: SimpleRow row = new SimpleRow(2);
104: row.set(0, "B");
105: row.set(1, "A");
106: _left.add(row);
107: }
108: _column = new Column("c", StringType.instance());
109: _table = new MemoryTable("x");
110: _table.addColumn(_column);
111: _table.addColumn(new Column("d", StringType.instance()));
112: _index = new ObjectArrayIndex("y", _column, false);
113: _table.addIndex(_index);
114: {
115: SimpleRow row = new SimpleRow(2);
116: row.set(0, "A");
117: row.set(1, "A");
118: _table.addRow(row);
119: }
120: {
121: SimpleRow row = new SimpleRow(2);
122: row.set(0, "A");
123: row.set(1, "B");
124: _table.addRow(row);
125: }
126: {
127: SimpleRow row = new SimpleRow(2);
128: row.set(0, "A");
129: row.set(1, "C");
130: _table.addRow(row);
131: }
132: _where = new EqualFunction();
133: _where.addArgument(new ColumnIdentifier("b"));
134: _where.addArgument(new ColumnIdentifier(
135: new TableIdentifier("x"), "c"));
136: }
137:
138: protected RowIterator makeRowIterator() {
139: try {
140: RowIterator left = new ListRowIterator(_left);
141: ChangingIndexedRowIterator right = new ChangingIndexedRowIterator(
142: _index, _table, new EqualFunction());
143: RowIterator iter = new IndexNestedLoopJoinedRowIterator(
144: left, 1, right, 2, true, true);
145: return iter;
146: } catch (Exception e) {
147: e.printStackTrace();
148: throw new RuntimeException(e.toString());
149: }
150: }
151:
152: protected int getSize() {
153: return 7;
154: }
155:
156: protected List makeRowList() {
157: List list = new ArrayList();
158: {
159: SimpleRow row = new SimpleRow(4);
160: row.set(0, "A");
161: row.set(1, "B");
162: row.set(2, "A");
163: row.set(3, "A");
164: list.add(row);
165: }
166: {
167: SimpleRow row = new SimpleRow(4);
168: row.set(0, "A");
169: row.set(1, "C");
170: row.set(2, "A");
171: row.set(3, "A");
172: list.add(row);
173: }
174: {
175: SimpleRow row = new SimpleRow(4);
176: row.set(0, "A");
177: row.set(1, "A");
178: row.set(2, "A");
179: row.set(3, "A");
180: list.add(row);
181: }
182: {
183: SimpleRow row = new SimpleRow(4);
184: row.set(0, null);
185: row.set(1, null);
186: row.set(2, "A");
187: row.set(3, "B");
188: list.add(row);
189: }
190: {
191: SimpleRow row = new SimpleRow(4);
192: row.set(0, "A");
193: row.set(1, "B");
194: row.set(2, "B");
195: row.set(3, "A");
196: list.add(row);
197: }
198: {
199: SimpleRow row = new SimpleRow(4);
200: row.set(0, "A");
201: row.set(1, "C");
202: row.set(2, "B");
203: row.set(3, "A");
204: list.add(row);
205: }
206: {
207: SimpleRow row = new SimpleRow(4);
208: row.set(0, "A");
209: row.set(1, "A");
210: row.set(2, "B");
211: row.set(3, "A");
212: list.add(row);
213: }
214: return list;
215: }
216:
217: //------------------------------------------------------------------- Tests
218:
219: }
|