1N/A * See the file LICENSE for redistribution information. 1N/A * Copyright (c) 1998 1N/A * Sleepycat Software. All rights reserved. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A#
endif /* not lint */ 1N/A * This is the duplicate-assisted join functionality. Right now we're 1N/A * going to write it such that we return one item at a time, although 1N/A * I think we may need to optimize it to return them all at once. 1N/A * It should be easier to get it working this way, and I believe that 1N/A * changing it should be fairly straightforward. 1N/A * Right now we do not maintain the number of duplicates so we do 1N/A * not optimize the join. If the caller does, then best performance 1N/A * will be achieved by putting the cursor with the smallest cardinality 1N/A * The first cursor moves sequentially through the duplicate set while 1N/A * the others search explicitly for the duplicate in question. 1N/A * This is the interface to the duplicate-assisted join functionality. 1N/A * In the same way that cursors mark a position in a database, a cursor 1N/A * can mark a position in a join. While most cursors are created by the 1N/A * cursor method of a DB, join cursors are created through an explicit 1N/A * The curslist is an array of existing, intialized cursors and primary 1N/A * is the DB of the primary file. The data item that joins all the 1N/A * cursors in the curslist is used as the key into the primary and that 1N/A * key and data are returned. When no more items are left in the join 1N/A * set, the c_next operation off the join cursor will return DB_NOTFOUND. 1N/A * PUBLIC: int __db_join __P((DB *, DBC **, u_int32_t, DBC **)); 1N/A * We have the first element; now look for it in the 1N/A * If we got out of here with ret != 0, then we failed to 1N/A * find the duplicate in one of the files, so we go on to 1N/A * the next item in the outermost relation. If ret was 1N/A * equal to 0, then we've got something to return. 1N/A * If ret != 0 here, we've exhausted the first file. Otherwise, 1N/A * key and data are set and we need to do the lookup on the 1N/A * Clear the optimization flag in the cursors.