xxl.relational
Class Join
java.lang.Object
|
+--xxl.relational.AbstractResultSet
|
+--xxl.relational.Join
- Direct Known Subclasses:
- NestedLoopsJoin
- public abstract class Join
- extends AbstractResultSet
This abstract class represents the logical operator "Join" (natural Join).
It provides the methods
- ResultSetMetaData getMetaData()
- int findColumn(String columnName)
cause these methods are equal for all implementations of "Join".
Example:
An implementation of "Join" is a subclass of Join and can use this
line first in its constructor:
super(r1, r2);
So the join of ResultSet r1 and ResultSet r2 is defined.
The metadata are now created as follows:
All columns of r1 are taken with the same column index to the join
result.
Each column of r2 that has the same column name as a column of
r1 is joined to its corresponding column of r1.
Corresponding columns must have the same type, otherwise an Exception is thrown.
Those columns of r2 that have a column name, that does not appear in
r1, are sequentially added to the join result.
For implementors there are two useful attributes of Join:
-
int l1 is the number of columns of r1
-
int[] columnsForm2 is an array and its length is equal
to the number of columns of the join result, and
columnsFrom2[i] == k
means, that column (i+1) of the join result follows (possibly
additionally) from column k of r2.
If column (i+1) follows only from a column of r1,
k is set to 0.
Now column i of the join result is a joined column if and only if
- i is less than or equal to l1
- columnsFrom2[i-1] is not 0
holds.
Then column i is joined from column i of r1 and
column columsFrom2[i-1] from r2.
Further there are three useful methodes for implementors:
int originalResultSet(int column)
returns for a given column index of the join result
- 1 if the column follows only from
r1
- 2 if the column follows only from
r2
- 0 if the column is a joined column.
int originalColumnIndexFrom1(int column)
returns the column index of the column of r1 from which
this given column of the join result follows.
If the given column does not follow from a column of r1, the
behavior of this method is undefined.
int originalColumnIndexFrom1(int column)
behaves exactly like above - except of r2 instead of r1.
|
Field Summary |
protected int[] |
columnsFrom2
|
protected int |
l1
|
protected java.sql.ResultSetMetaData |
metaData
|
protected java.sql.ResultSet |
r1
|
protected java.sql.ResultSet |
r2
|
|
Constructor Summary |
Join(java.sql.ResultSet r1,
java.sql.ResultSet r2)
|
| Methods inherited from class xxl.relational.AbstractResultSet |
absolute,
afterLast,
beforeFirst,
cancelRowUpdates,
clearWarnings,
deleteRow,
first,
getArray,
getArray,
getAsciiStream,
getAsciiStream,
getBigDecimal,
getBigDecimal,
getBigDecimal,
getBigDecimal,
getBinaryStream,
getBinaryStream,
getBlob,
getBlob,
getBoolean,
getBoolean,
getByte,
getByte,
getBytes,
getCharacterStream,
getCharacterStream,
getClob,
getClob,
getColumnCount,
getConcurrency,
getCursorName,
getDate,
getDate,
getDate,
getDate,
getDouble,
getDouble,
getFetchDirection,
getFetchSize,
getFloat,
getFloat,
getInt,
getInt,
getLong,
getLong,
getObject,
getObject,
getObject,
getRef,
getRef,
getRow,
getShort,
getShort,
getStatement,
getString,
getString,
getTime,
getTime,
getTime,
getTime,
getTimestamp,
getTimestamp,
getTimestamp,
getTimestamp,
getType,
getUnicodeStream,
getUnicodeStream,
getWarnings,
insertRow,
isAfterLast,
isBeforeFirst,
isFirst,
isLast,
last,
moveToCurrentRow,
moveToInsertRow,
previous,
refreshRow,
relative,
rowDeleted,
rowInserted,
rowUpdated,
setFetchDirection,
setFetchSize,
updateAsciiStream,
updateAsciiStream,
updateBigDecimal,
updateBigDecimal,
updateBinaryStream,
updateBinaryStream,
updateBoolean,
updateBoolean,
updateByte,
updateByte,
updateBytes,
updateBytes,
updateCharacterStream,
updateCharacterStream,
updateDate,
updateDate,
updateDouble,
updateDouble,
updateFloat,
updateFloat,
updateInt,
updateInt,
updateLong,
updateLong,
updateNull,
updateNull,
updateObject,
updateObject,
updateObject,
updateObject,
updateRow,
updateShort,
updateShort,
updateString,
updateString,
updateTime,
updateTime,
updateTimestamp,
updateTimestamp |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
r1
protected java.sql.ResultSet r1
r2
protected java.sql.ResultSet r2
metaData
protected java.sql.ResultSetMetaData metaData
columnsFrom2
protected int[] columnsFrom2
l1
protected int l1
Join
public Join(java.sql.ResultSet r1,
java.sql.ResultSet r2)
next
public abstract boolean next()
throws java.sql.SQLException
- Overrides:
- next in class AbstractResultSet
close
public abstract void close()
throws java.sql.SQLException
- Overrides:
- close in class AbstractResultSet
getObject
public abstract java.lang.Object getObject(int columnIndex)
throws java.sql.SQLException
- Overrides:
- getObject in class AbstractResultSet
getBytes
public abstract byte[] getBytes(int columnIndex)
throws java.sql.SQLException
- Overrides:
- getBytes in class AbstractResultSet
wasNull
public abstract boolean wasNull()
throws java.sql.SQLException
- Overrides:
- wasNull in class AbstractResultSet
originalResultSet
protected int originalResultSet(int column)
throws java.sql.SQLException
originalColumnIndexFrom1
protected int originalColumnIndexFrom1(int column)
originalColumnIndexFrom2
protected int originalColumnIndexFrom2(int column)
equalInJoinedColumns
protected boolean equalInJoinedColumns(Tuple t1,
Tuple t2)
findColumn
public int findColumn(java.lang.String columnName)
throws java.sql.SQLException
- Overrides:
- findColumn in class AbstractResultSet
getMetaData
public java.sql.ResultSetMetaData getMetaData()
throws java.sql.SQLException
- Overrides:
- getMetaData in class AbstractResultSet