<!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> SecondaryMultiKeyCreator </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="SecondaryMultiKeyCreator"; } } </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/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/db/Sequence.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/SecondaryMultiKeyCreator.html" target="_top"><B>FRAMES</B></A> <A HREF="SecondaryMultiKeyCreator.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> Interface SecondaryMultiKeyCreator</H2> <DL> <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../com/sleepycat/persist/impl/PersistKeyCreator.html" title="class in com.sleepycat.persist.impl">PersistKeyCreator</A></DD> </DL> <HR> <DL> <DT><PRE>public interface <B>SecondaryMultiKeyCreator</B></DL> </PRE> <P> The interface implemented for extracting multi-valued secondary keys from primary records. <p> The key creator object is specified by calling <A HREF="../../../com/sleepycat/db/SecondaryConfig.html#setMultiKeyCreator(com.sleepycat.db.SecondaryMultiKeyCreator)"><CODE>SecondaryConfig.setMultiKeyCreator</CODE></A>. The secondary database configuration is specified when calling <A HREF="../../../com/sleepycat/db/Environment.html#openSecondaryDatabase(com.sleepycat.db.Transaction, java.lang.String, java.lang.String, com.sleepycat.db.Database, com.sleepycat.db.SecondaryConfig)"><CODE>Environment.openSecondaryDatabase</CODE></A>. <p> For example: <pre> class MyMultiKeyCreator implements SecondaryMultiKeyCreator { public void createSecondaryKeys(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, Set results) throws DatabaseException { // // DO HERE: Extract the secondary keys from the primary key and // data. For each key extracted, create a DatabaseEntry and add it // to the results set. // } } ... SecondaryConfig secConfig = new SecondaryConfig(); secConfig.setMultiKeyCreator(new MyMultiKeyCreator()); // Now pass secConfig to Environment.openSecondaryDatabase </pre> <p> Use this interface when any number of secondary keys may be present in a single primary record, in other words, for many-to-many and one-to-many relationships. When only zero or one secondary key is present (for many-to-one and one-to-one relationships) you may use the <A HREF="../../../com/sleepycat/db/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryKeyCreator</CODE></A> interface instead. The table below summarizes how to create all four variations of relationships. <div> <table border="yes"> <tr><th>Relationship</th> <th>Interface</th> <th>Duplicates</th> <th>Example</th> </tr> <tr><td>One-to-one</td> <td><A HREF="../../../com/sleepycat/db/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryKeyCreator</CODE></A></td> <td>No</td> <td>A person record with a unique social security number key.</td> </tr> <tr><td>Many-to-one</td> <td><A HREF="../../../com/sleepycat/db/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryKeyCreator</CODE></A></td> <td>Yes</td> <td>A person record with a non-unique employer key.</td> </tr> <tr><td>One-to-many</td> <td><A HREF="../../../com/sleepycat/db/SecondaryMultiKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryMultiKeyCreator</CODE></A></td> <td>No</td> <td>A person record with multiple unique email address keys.</td> </tr> <tr><td>Many-to-many</td> <td><A HREF="../../../com/sleepycat/db/SecondaryMultiKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryMultiKeyCreator</CODE></A></td> <td>Yes</td> <td>A person record with multiple non-unique organization keys.</td> </tr> </table> </div> <p>To configure a database for duplicates. pass true to <A HREF="../../../com/sleepycat/db/DatabaseConfig.html#setSortedDuplicates(boolean)"><CODE>DatabaseConfig.setSortedDuplicates(boolean)</CODE></A>.</p> <p> Note that <code>SecondaryMultiKeyCreator</code> may also be used for single key secondaries (many-to-one and one-to-one); in this case, at most a single key is added to the results set. <code>SecondaryMultiKeyCreator</code> is only slightly less efficient than <A HREF="../../../com/sleepycat/db/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><CODE>SecondaryKeyCreator</CODE></A> in that two or three temporary sets must be created to hold the results. <P> <P> <DL> <DT><B>See Also:</B><DD><A HREF="../../../com/sleepycat/db/SecondaryConfig.html" title="class in com.sleepycat.db"><CODE>SecondaryConfig</CODE></A></DL> <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/SecondaryMultiKeyCreator.html#createSecondaryKeys(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, java.util.Set)">createSecondaryKeys</A></B>(<A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> secondary, <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, java.util.Set results)</CODE> <BR> Creates a secondary key entry, given a primary key and data entry.</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="createSecondaryKeys(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, java.util.Set)"><!-- --></A><H3> createSecondaryKeys</H3> <PRE> void <B>createSecondaryKeys</B>(<A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> secondary, <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, java.util.Set results) throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> <DL> <DD>Creates a secondary key entry, given a primary key and data entry. <p> A secondary key may be derived from the primary key, primary data, or a combination of the primary key and data. Zero or more secondary keys may be derived from the primary record and returned in the results parameter. To ensure the integrity of a secondary database the key creator method must always return the same results for a given set of input parameters. <p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>secondary</CODE> - the database to which the secondary key will be added. This parameter is passed for informational purposes but is not commonly used. <p><DD><CODE>key</CODE> - the primary key entry. This parameter must not be modified by this method. <p><DD><CODE>data</CODE> - the primary data entry. This parameter must not be modified by this method. <p><DD><CODE>results</CODE> - the set to contain the the secondary key DatabaseEntry objects created by this method. <p> <DT><B>Throws:</B> <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if an error occurs attempting to create the secondary key.</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/SecondaryKeyCreator.html" title="interface in com.sleepycat.db"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/db/Sequence.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/SecondaryMultiKeyCreator.html" target="_top"><B>FRAMES</B></A> <A HREF="SecondaryMultiKeyCreator.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>