01: /*
02: * $Id: NestedLoopJoinedRowIterator.java,v 1.7 2005/04/02 18:23:30 ahimanikya Exp $
03: * =======================================================================
04: * Copyright (c) 2005 Axion Development Team. All rights reserved.
05: *
06: * Redistribution and use in source and binary forms, with or without
07: * modification, are permitted provided that the following conditions
08: * are met:
09: *
10: * 1. Redistributions of source code must retain the above
11: * copyright notice, this list of conditions and the following
12: * disclaimer.
13: *
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in
16: * the documentation and/or other materials provided with the
17: * distribution.
18: *
19: * 3. The names "Tigris", "Axion", nor the names of its contributors may
20: * not be used to endorse or promote products derived from this
21: * software without specific prior written permission.
22: *
23: * 4. Products derived from this software may not be called "Axion", nor
24: * may "Tigris" or "Axion" appear in their names without specific prior
25: * written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38: * =======================================================================
39: */
40:
41: package org.axiondb.engine.rowiterators;
42:
43: import org.axiondb.AxionException;
44: import org.axiondb.RowIterator;
45:
46: /**
47: * A Nested Loop Join is performed by doing a scan over the left subtree and for each row
48: * in it performing a full scan of the right subtree. This is the default join algorithm,
49: * which can be used for any join. However, it is usually less efficient than the other
50: * methods. Usually, either an existing index, or a dynamic index, used in an ANL join,
51: * will cost much less. Occasionally, when subtree cardinalities are very low (possibly
52: * because of index bracketing), nested loop will be the method with the least cost.
53: *
54: * @version $Revision: 1.7 $ $Date: 2005/04/02 18:23:30 $
55: * @author Rodney Waldhoff
56: * @author Ahimanikya Satapathy
57: */
58: public class NestedLoopJoinedRowIterator extends
59: AbstractJoinedRowIterator {
60:
61: public NestedLoopJoinedRowIterator(RowIterator left,
62: RowIterator right, int rightColumnCount,
63: boolean rightOuter, boolean swapLeftAndRight)
64: throws AxionException {
65: setLeftRowIterator(left);
66: _rightRowIterator = right;
67: setRightSideColumnCount(rightColumnCount);
68: setRightOuter(rightOuter);
69: setSwapLeftAndRight(swapLeftAndRight);
70: }
71:
72: public NestedLoopJoinedRowIterator(RowIterator left,
73: RowIterator right, int rightColumnCount)
74: throws AxionException {
75: this (left, right, rightColumnCount, false, false);
76: }
77:
78: protected RowIterator generateRightRowIterator()
79: throws AxionException {
80: _rightRowIterator.reset();
81: return _rightRowIterator;
82: }
83:
84: public void reset() throws AxionException {
85: _rightRowIterator.reset();
86: super .reset();
87: }
88:
89: public String toString() {
90: return "NestedLoop(" + super .toString() + ")";
91: }
92:
93: private RowIterator _rightRowIterator = null;
94: }
|