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