<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_18) on Thu May 12 21:55:00 GMT 2011 --> <TITLE> JoinCursor </TITLE> <META NAME="date" CONTENT="2011-05-12"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="JoinCursor"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/db/JoinConfig.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/db/KeyRange.html" title="class in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?com/sleepycat/db/JoinCursor.html" target="_top"><B>FRAMES</B></A> <A HREF="JoinCursor.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.sleepycat.db</FONT> <BR> Class JoinCursor</H2> <PRE> java.lang.Object <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.db.JoinCursor</B> </PRE> <HR> <DL> <DT><PRE>public class <B>JoinCursor</B><DT>extends java.lang.Object</DL> </PRE> <P> A specialized join cursor for use in performing equality or natural joins on secondary indices. <p> A join cursor is returned when calling <A HREF="../../../com/sleepycat/db/Database.html#join(com.sleepycat.db.Cursor[], com.sleepycat.db.JoinConfig)"><CODE>Database.join</CODE></A>. <p> To open a join cursor using two secondary cursors: <pre> Transaction txn = ... Database primaryDb = ... SecondaryDatabase secondaryDb1 = ... SecondaryDatabase secondaryDb2 = ... <p> SecondaryCursor cursor1 = null; SecondaryCursor cursor2 = null; JoinCursor joinCursor = null; try { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry(); <p> cursor1 = secondaryDb1.openSecondaryCursor(txn, null); cursor2 = secondaryDb2.openSecondaryCursor(txn, null); <p> key.setData(...); // initialize key for secondary index 1 OperationStatus status1 = cursor1.getSearchKey(key, data, LockMode.DEFAULT); key.setData(...); // initialize key for secondary index 2 OperationStatus status2 = cursor2.getSearchKey(key, data, LockMode.DEFAULT); <p> if (status1 == OperationStatus.SUCCESS && status2 == OperationStatus.SUCCESS) { <p> SecondaryCursor[] cursors = {cursor1, cursor2}; joinCursor = primaryDb.join(cursors, null); <p> while (true) { OperationStatus joinStatus = joinCursor.getNext(key, data, LockMode.DEFAULT); if (joinStatus == OperationStatus.SUCCESS) { // Do something with the key and data. } else { break; } } } } finally { if (cursor1 != null) { cursor1.close(); } if (cursor2 != null) { cursor2.close(); } if (joinCursor != null) { joinCursor.close(); } } </pre> <P> <P> <HR> <P> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/db/JoinCursor.html#close()">close</A></B>()</CODE> <BR> Closes the cursors that have been opened by this join cursor.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> <A HREF="../../../com/sleepycat/db/JoinConfig.html" title="class in com.sleepycat.db">JoinConfig</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/db/JoinCursor.html#getConfig()">getConfig</A></B>()</CODE> <BR> Returns this object's configuration.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> <A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/db/JoinCursor.html#getDatabase()">getDatabase</A></B>()</CODE> <BR> Returns the primary database handle associated with this cursor.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> <A HREF="../../../com/sleepycat/db/OperationStatus.html" title="class in com.sleepycat.db">OperationStatus</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/db/JoinCursor.html#getNext(com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.LockMode)">getNext</A></B>(<A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> data, <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A> lockMode)</CODE> <BR> Returns the next primary key and data resulting from the join operation.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> <A HREF="../../../com/sleepycat/db/OperationStatus.html" title="class in com.sleepycat.db">OperationStatus</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/db/JoinCursor.html#getNext(com.sleepycat.db.DatabaseEntry, com.sleepycat.db.LockMode)">getNext</A></B>(<A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A> lockMode)</CODE> <BR> Returns the next primary key resulting from the join operation.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> </TR> </TABLE> <P> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="close()"><!-- --></A><H3> close</H3> <PRE> public void <B>close</B>() throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> <DL> <DD>Closes the cursors that have been opened by this join cursor. <p> The cursors passed to <A HREF="../../../com/sleepycat/db/Database.html#join(com.sleepycat.db.Cursor[], com.sleepycat.db.JoinConfig)"><CODE>Database.join</CODE></A> are not closed by this method, and should be closed by the caller. <p> <p> <P> <DD><DL> <DT><B>Throws:</B> <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> </DD> </DL> <HR> <A NAME="getDatabase()"><!-- --></A><H3> getDatabase</H3> <PRE> public <A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A> <B>getDatabase</B>()</PRE> <DL> <DD>Returns the primary database handle associated with this cursor. <p> <P> <DD><DL> <DT><B>Returns:</B><DD>the primary database handle associated with this cursor.</DL> </DD> </DL> <HR> <A NAME="getConfig()"><!-- --></A><H3> getConfig</H3> <PRE> public <A HREF="../../../com/sleepycat/db/JoinConfig.html" title="class in com.sleepycat.db">JoinConfig</A> <B>getConfig</B>()</PRE> <DL> <DD>Returns this object's configuration. <p> <P> <DD><DL> <DT><B>Returns:</B><DD>this object's configuration.</DL> </DD> </DL> <HR> <A NAME="getNext(com.sleepycat.db.DatabaseEntry, com.sleepycat.db.LockMode)"><!-- --></A><H3> getNext</H3> <PRE> public <A HREF="../../../com/sleepycat/db/OperationStatus.html" title="class in com.sleepycat.db">OperationStatus</A> <B>getNext</B>(<A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A> lockMode) throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> <DL> <DD>Returns the next primary key resulting from the join operation. <p> An entry is returned by the join cursor for each primary key/data pair having all secondary key values that were specified using the array of secondary cursors passed to <A HREF="../../../com/sleepycat/db/Database.html#join(com.sleepycat.db.Cursor[], com.sleepycat.db.JoinConfig)"><CODE>Database.join</CODE></A>. <p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>key</CODE> - the primary key returned as output. Its byte array does not need to be initialized by the caller. <p><DD><CODE>lockMode</CODE> - the locking attributes; if null, default attributes are used. <p> <DT><B>Returns:</B><DD><A HREF="../../../com/sleepycat/db/OperationStatus.html#NOTFOUND"><CODE>OperationStatus.NOTFOUND</CODE></A> if no matching key/data pair is found; <A HREF="../../../com/sleepycat/db/OperationStatus.html#KEYEMPTY"><CODE>OperationStatus.KEYEMPTY</CODE></A> if the database is a Queue or Recno database and the specified key exists, but was never explicitly created by the application or was later deleted; otherwise, <A HREF="../../../com/sleepycat/db/OperationStatus.html#SUCCESS"><CODE>OperationStatus.SUCCESS</CODE></A>. <p> <DT><B>Throws:</B> <DD><CODE>java.lang.NullPointerException</CODE> - if a DatabaseEntry parameter is null or does not contain a required non-null byte array. <p> <DD><CODE><A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db">DeadlockException</A></CODE> - if the operation was selected to resolve a deadlock. <p> <DD><CODE>java.lang.IllegalArgumentException</CODE> - if an invalid parameter was specified. <p> <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> </DD> </DL> <HR> <A NAME="getNext(com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.LockMode)"><!-- --></A><H3> getNext</H3> <PRE> public <A HREF="../../../com/sleepycat/db/OperationStatus.html" title="class in com.sleepycat.db">OperationStatus</A> <B>getNext</B>(<A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> key, <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db">DatabaseEntry</A> data, <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A> lockMode) throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> <DL> <DD>Returns the next primary key and data resulting from the join operation. <p> An entry is returned by the join cursor for each primary key/data pair having all secondary key values that were specified using the array of secondary cursors passed to <A HREF="../../../com/sleepycat/db/Database.html#join(com.sleepycat.db.Cursor[], com.sleepycat.db.JoinConfig)"><CODE>Database.join</CODE></A>. <p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>key</CODE> - the primary key returned as output. Its byte array does not need to be initialized by the caller. <p><DD><CODE>data</CODE> - the primary data returned as output. Its byte array does not need to be initialized by the caller. <p><DD><CODE>lockMode</CODE> - the locking attributes; if null, default attributes are used. <p> <DT><B>Returns:</B><DD><A HREF="../../../com/sleepycat/db/OperationStatus.html#NOTFOUND"><CODE>OperationStatus.NOTFOUND</CODE></A> if no matching key/data pair is found; <A HREF="../../../com/sleepycat/db/OperationStatus.html#KEYEMPTY"><CODE>OperationStatus.KEYEMPTY</CODE></A> if the database is a Queue or Recno database and the specified key exists, but was never explicitly created by the application or was later deleted; otherwise, <A HREF="../../../com/sleepycat/db/OperationStatus.html#SUCCESS"><CODE>OperationStatus.SUCCESS</CODE></A>. <p> <DT><B>Throws:</B> <DD><CODE>java.lang.NullPointerException</CODE> - if a DatabaseEntry parameter is null or does not contain a required non-null byte array. <p> <DD><CODE><A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db">DeadlockException</A></CODE> - if the operation was selected to resolve a deadlock. <p> <DD><CODE>java.lang.IllegalArgumentException</CODE> - if an invalid parameter was specified. <p> <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/db/JoinConfig.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/db/KeyRange.html" title="class in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?com/sleepycat/db/JoinCursor.html" target="_top"><B>FRAMES</B></A> <A HREF="JoinCursor.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>