Quadcap Embeddable Database

com.quadcap.sql.MergeCursor Class Reference

Inheritance diagram for com.quadcap.sql.MergeCursor:

com.quadcap.sql.CursorImpl com.quadcap.sql.TupleImpl com.quadcap.sql.Cursor com.quadcap.sql.Tuple Externalizable com.quadcap.sql.Tuple List of all members.

Detailed Description

Cursor implementing the SQL UNION or INTERSECTION operations.

This cursor shares some functionality with the GroupByCursor class, and factorization should be investigated.

Author:
Stan Bailes

Definition at line 72 of file MergeCursor.java.

Public Member Functions

 MergeCursor (Session session, int op, boolean all, TempTableMerge tempTable) throws SQLException
Row getRow () throws SQLException
 Derived class implements this function to return the current cursor row.

void checkCursor () throws IOException
long getRowId ()
 Some cursors have rows where the rows can be identified by row id, and sometimes the cursors even know the row id for the current row.

void resolveColumns () throws SQLException
 Once all of the column names are available, we can look for duplicates and shortest-unique names, etc.

String getName ()
 Return the tuple's name.

long size () throws SQLException
 If the underlying implementation knows, or can compute cheaply, the actual size of the ResultSet, it should return a non-negative number here.

void afterLast () throws SQLException
 Position the cursor after the last row.

boolean isWritable (int col)
 Return true if the specified column is writable.

boolean next () throws SQLException
 Advance the cursor and return true if we advanced to a valid row.

void updateRow (Row row) throws SQLException
 Replace the current cursor row with the specified row.

void deleteRow () throws SQLException
 Delete the current cursor row.

void beforeFirst () throws SQLException
 Position the cursor before the first row.

void close () throws SQLException
 On close, we release the resources.


Package Functions

boolean nextUnion () throws SQLException, IOException
 Separate from 'nextUnionAll' because we can avoid fetching the data for this case.

boolean nextUnionAll () throws SQLException, IOException
 Fetch the data once when we fetch the counts, then return each row the required number of times.

boolean nextIntersect () throws SQLException, IOException
boolean nextExcept () throws SQLException, IOException

Package Attributes

int op
boolean all
TempTableMerge tempTable
LazyRow row = null
BCursor bc = null
int duplicateCount = 0


Constructor & Destructor Documentation

com.quadcap.sql.MergeCursor.MergeCursor Session  session,
int  op,
boolean  all,
TempTableMerge  tempTable
throws SQLException
 

Definition at line 80 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.all, com.quadcap.sql.MergeCursor.op, and com.quadcap.sql.MergeCursor.tempTable.


Member Function Documentation

void com.quadcap.sql.MergeCursor.afterLast  )  throws SQLException [virtual]
 

Position the cursor after the last row.

Implements com.quadcap.sql.CursorImpl.

Definition at line 122 of file MergeCursor.java.

void com.quadcap.sql.MergeCursor.beforeFirst  )  throws SQLException [virtual]
 

Position the cursor before the first row.

Implements com.quadcap.sql.CursorImpl.

Definition at line 156 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.MergeCursor.checkCursor(), and com.quadcap.sql.MergeCursor.duplicateCount.

Referenced by com.quadcap.sql.MergeCursor.resolveColumns().

void com.quadcap.sql.MergeCursor.checkCursor  )  throws IOException
 

Definition at line 94 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.TempTable.getCursor(), and com.quadcap.sql.MergeCursor.tempTable.

Referenced by com.quadcap.sql.MergeCursor.beforeFirst(), com.quadcap.sql.MergeCursor.next(), and com.quadcap.sql.MergeCursor.size().

void com.quadcap.sql.MergeCursor.close  )  throws SQLException [virtual]
 

On close, we release the resources.

Implements com.quadcap.sql.CursorImpl.

Definition at line 241 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.TempTable.release(), and com.quadcap.sql.MergeCursor.tempTable.

void com.quadcap.sql.MergeCursor.deleteRow  )  throws SQLException [virtual]
 

Delete the current cursor row.

Implements com.quadcap.sql.CursorImpl.

Definition at line 151 of file MergeCursor.java.

String com.quadcap.sql.MergeCursor.getName  ) 
 

Return the tuple's name.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 111 of file MergeCursor.java.

Row com.quadcap.sql.MergeCursor.getRow  )  throws SQLException [virtual]
 

Derived class implements this function to return the current cursor row.

Implementation required.

Implements com.quadcap.sql.CursorImpl.

Definition at line 90 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.row.

long com.quadcap.sql.MergeCursor.getRowId  ) 
 

Some cursors have rows where the rows can be identified by row id, and sometimes the cursors even know the row id for the current row.

If you know, tell us here! If you don't know, just return 0.

Reimplemented from com.quadcap.sql.CursorImpl.

Definition at line 100 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc.

boolean com.quadcap.sql.MergeCursor.isWritable int  col  )  [virtual]
 

Return true if the specified column is writable.

Parameters:
column the (one-based) column number
Exceptions:
SQLException may be thrown

Implements com.quadcap.sql.CursorImpl.

Definition at line 126 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.isWritable().

Referenced by com.quadcap.sql.MergeCursor.isWritable().

boolean com.quadcap.sql.MergeCursor.next  )  throws SQLException [virtual]
 

Advance the cursor and return true if we advanced to a valid row.

Implements com.quadcap.sql.CursorImpl.

Definition at line 128 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.all, com.quadcap.sql.MergeCursor.checkCursor(), com.quadcap.sql.MergeCursor.nextExcept(), com.quadcap.sql.MergeCursor.nextIntersect(), com.quadcap.sql.MergeCursor.nextUnion(), com.quadcap.sql.MergeCursor.nextUnionAll(), and com.quadcap.sql.MergeCursor.op.

boolean com.quadcap.sql.MergeCursor.nextExcept  )  throws SQLException, IOException [package]
 

Definition at line 216 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.all, com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.MergeCursor.duplicateCount, com.quadcap.sql.TempTable.getRow(), com.quadcap.sql.MergeCursor.row, and com.quadcap.sql.MergeCursor.tempTable.

Referenced by com.quadcap.sql.MergeCursor.next().

boolean com.quadcap.sql.MergeCursor.nextIntersect  )  throws SQLException, IOException [package]
 

Definition at line 194 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.all, com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.MergeCursor.duplicateCount, com.quadcap.sql.TempTable.getRow(), com.quadcap.sql.MergeCursor.row, and com.quadcap.sql.MergeCursor.tempTable.

Referenced by com.quadcap.sql.MergeCursor.next().

boolean com.quadcap.sql.MergeCursor.nextUnion  )  throws SQLException, IOException [package]
 

Separate from 'nextUnionAll' because we can avoid fetching the data for this case.

Definition at line 171 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.TempTable.getRow(), com.quadcap.sql.MergeCursor.row, and com.quadcap.sql.MergeCursor.tempTable.

Referenced by com.quadcap.sql.MergeCursor.next().

boolean com.quadcap.sql.MergeCursor.nextUnionAll  )  throws SQLException, IOException [package]
 

Fetch the data once when we fetch the counts, then return each row the required number of times.

Definition at line 181 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, com.quadcap.sql.MergeCursor.duplicateCount, com.quadcap.sql.TempTable.getRow(), com.quadcap.sql.MergeCursor.row, and com.quadcap.sql.MergeCursor.tempTable.

Referenced by com.quadcap.sql.MergeCursor.next().

void com.quadcap.sql.MergeCursor.resolveColumns  )  throws SQLException
 

Once all of the column names are available, we can look for duplicates and shortest-unique names, etc.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 105 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.beforeFirst(), com.quadcap.sql.TupleImpl.getColumnCount(), and com.quadcap.sql.MergeCursor.row.

Referenced by com.quadcap.sql.MergeExpression.getCursor().

long com.quadcap.sql.MergeCursor.size  )  throws SQLException
 

If the underlying implementation knows, or can compute cheaply, the actual size of the ResultSet, it should return a non-negative number here.

If the size is unknown and it would be expensive to compute it (i.e., on the order of while next()) size++), then the implementation should return -1

Implements com.quadcap.sql.Cursor.

Definition at line 113 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.bc, and com.quadcap.sql.MergeCursor.checkCursor().

void com.quadcap.sql.MergeCursor.updateRow Row  row  )  throws SQLException [virtual]
 

Replace the current cursor row with the specified row.

Implements com.quadcap.sql.CursorImpl.

Definition at line 146 of file MergeCursor.java.

References com.quadcap.sql.MergeCursor.updateRow().

Referenced by com.quadcap.sql.MergeCursor.updateRow().


Member Data Documentation

boolean com.quadcap.sql.MergeCursor.all [package]
 

Definition at line 74 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.MergeCursor(), com.quadcap.sql.MergeCursor.next(), com.quadcap.sql.MergeCursor.nextExcept(), and com.quadcap.sql.MergeCursor.nextIntersect().

BCursor com.quadcap.sql.MergeCursor.bc = null [package]
 

Definition at line 77 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.beforeFirst(), com.quadcap.sql.MergeCursor.checkCursor(), com.quadcap.sql.MergeCursor.close(), com.quadcap.sql.MergeCursor.getRowId(), com.quadcap.sql.MergeCursor.nextExcept(), com.quadcap.sql.MergeCursor.nextIntersect(), com.quadcap.sql.MergeCursor.nextUnion(), com.quadcap.sql.MergeCursor.nextUnionAll(), and com.quadcap.sql.MergeCursor.size().

int com.quadcap.sql.MergeCursor.duplicateCount = 0 [package]
 

Definition at line 78 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.beforeFirst(), com.quadcap.sql.MergeCursor.nextExcept(), com.quadcap.sql.MergeCursor.nextIntersect(), and com.quadcap.sql.MergeCursor.nextUnionAll().

int com.quadcap.sql.MergeCursor.op [package]
 

Definition at line 73 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.MergeCursor(), and com.quadcap.sql.MergeCursor.next().

LazyRow com.quadcap.sql.MergeCursor.row = null [package]
 

Definition at line 76 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.getRow(), com.quadcap.sql.MergeCursor.nextExcept(), com.quadcap.sql.MergeCursor.nextIntersect(), com.quadcap.sql.MergeCursor.nextUnion(), com.quadcap.sql.MergeCursor.nextUnionAll(), and com.quadcap.sql.MergeCursor.resolveColumns().

TempTableMerge com.quadcap.sql.MergeCursor.tempTable [package]
 

Definition at line 75 of file MergeCursor.java.

Referenced by com.quadcap.sql.MergeCursor.checkCursor(), com.quadcap.sql.MergeCursor.close(), com.quadcap.sql.MergeCursor.MergeCursor(), com.quadcap.sql.MergeCursor.nextExcept(), com.quadcap.sql.MergeCursor.nextIntersect(), com.quadcap.sql.MergeCursor.nextUnion(), and com.quadcap.sql.MergeCursor.nextUnionAll().