mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
Experimental index management. Uncomment BDB_IDL_MULTI in back-bdb.h
to activate. Needs to check limits in bdb_idl_insert_key, will get to that later.
This commit is contained in:
parent
223fb11840
commit
859e283834
5 changed files with 77 additions and 3 deletions
|
|
@ -16,6 +16,7 @@
|
|||
LDAP_BEGIN_DECL
|
||||
|
||||
#define BDB_FILTER_INDICES 1
|
||||
/* #define BDB_IDL_MULTI 1 */
|
||||
|
||||
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
|
||||
#define DN_ONE_PREFIX '%'
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ bdb_db_cache(
|
|||
}
|
||||
|
||||
rc = db->bdi_db->set_pagesize( db->bdi_db, BDB_PAGESIZE );
|
||||
#ifdef BDB_IDL_MULTI
|
||||
rc = db->bdi_db->set_flags( db->bdi_db, DB_DUPSORT );
|
||||
rc = db->bdi_db->set_dup_compare( db->bdi_db, bdb_bt_compare );
|
||||
#endif
|
||||
|
||||
file = ch_malloc( strlen( name ) + sizeof(BDB_SUFFIX) );
|
||||
sprintf( file, "%s" BDB_SUFFIX, name );
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ bdb_dn2id_delete(
|
|||
DBTzero( &key );
|
||||
key.size = strlen( dn ) + 2;
|
||||
key.data = ch_malloc( key.size );
|
||||
key.flags = DB_DBT_USERMEM;
|
||||
((char *)key.data)[0] = DN_BASE_PREFIX;
|
||||
AC_MEMCPY( &((char *)key.data)[1], dn, key.size - 1 );
|
||||
|
||||
|
|
|
|||
|
|
@ -227,13 +227,44 @@ bdb_idl_fetch_key(
|
|||
assert( ids != NULL );
|
||||
|
||||
DBTzero( &data );
|
||||
|
||||
#ifdef BDB_IDL_MULTI
|
||||
{
|
||||
ID buf[BDB_IDL_UM_SIZE];
|
||||
ID *i, *j;
|
||||
void *ptr;
|
||||
size_t len;
|
||||
data.data = buf;
|
||||
data.ulen = BDB_IDL_UM_SIZEOF;
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
rc = db->get( db, tid, key, &data, bdb->bi_db_opflags |
|
||||
DB_MULTIPLE );
|
||||
if (rc == 0) {
|
||||
DB_MULTIPLE_INIT( ptr, &data );
|
||||
i = ids;
|
||||
while (ptr) {
|
||||
DB_MULTIPLE_NEXT(ptr, &data, j, len);
|
||||
if (j) {
|
||||
++i;
|
||||
AC_MEMCPY( i, j, sizeof(ID) );
|
||||
}
|
||||
}
|
||||
if (ids[1] == 0) {
|
||||
BDB_IDL_RANGE( ids, ids[2], ids[3] );
|
||||
} else {
|
||||
ids[0] = (i - ids);
|
||||
}
|
||||
data.size = BDB_IDL_SIZEOF(ids);
|
||||
}
|
||||
}
|
||||
#else
|
||||
data.data = ids;
|
||||
data.ulen = BDB_IDL_UM_SIZEOF;
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
|
||||
/* fetch it */
|
||||
rc = db->get( db, tid, key, &data, bdb->bi_db_opflags );
|
||||
|
||||
#endif
|
||||
if( rc == DB_NOTFOUND ) {
|
||||
return rc;
|
||||
|
||||
|
|
@ -271,8 +302,10 @@ bdb_idl_insert_key(
|
|||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
int rc;
|
||||
ID ids[BDB_IDL_DB_SIZE];
|
||||
DBT data;
|
||||
#ifndef BDB_IDL_MULTI
|
||||
ID ids[BDB_IDL_DB_SIZE];
|
||||
#endif
|
||||
|
||||
/* for printable keys only */
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
|
|
@ -281,6 +314,12 @@ bdb_idl_insert_key(
|
|||
|
||||
assert( id != NOID );
|
||||
|
||||
DBTzero( &data );
|
||||
#ifdef BDB_IDL_MULTI
|
||||
data.data = &id;
|
||||
data.size = sizeof(id);
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
#else
|
||||
data.data = ids;
|
||||
data.ulen = sizeof ids;
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
|
|
@ -340,10 +379,13 @@ bdb_idl_insert_key(
|
|||
|
||||
data.size = BDB_IDL_SIZEOF( ids );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* store the key */
|
||||
rc = db->put( db, tid, key, &data, 0 );
|
||||
|
||||
if( rc == DB_KEYEXIST ) rc = 0;
|
||||
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
|
||||
"put failed: %s (%d)\n",
|
||||
|
|
@ -362,8 +404,10 @@ bdb_idl_delete_key(
|
|||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
int rc;
|
||||
ID ids[BDB_IDL_DB_SIZE];
|
||||
DBT data;
|
||||
#ifndef BDB_IDL_MULTI
|
||||
ID ids[BDB_IDL_DB_SIZE];
|
||||
#endif
|
||||
|
||||
/* for printable keys only */
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
|
|
@ -372,6 +416,23 @@ bdb_idl_delete_key(
|
|||
|
||||
assert( id != NOID );
|
||||
|
||||
DBTzero( &data );
|
||||
#ifdef BDB_IDL_MULTI
|
||||
{
|
||||
DBC *cursor;
|
||||
|
||||
data.data = &id;
|
||||
data.size = sizeof( id );
|
||||
data.ulen = data.size;
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
|
||||
rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
|
||||
rc = cursor->c_get( cursor, key, &data, bdb->bi_db_opflags |
|
||||
DB_GET_BOTH | DB_RMW );
|
||||
rc = cursor->c_del( cursor, 0 );
|
||||
rc = cursor->c_close( cursor );
|
||||
}
|
||||
#else
|
||||
data.data = ids;
|
||||
data.ulen = sizeof( ids );
|
||||
data.flags = DB_DBT_USERMEM;
|
||||
|
|
@ -429,6 +490,8 @@ bdb_idl_delete_key(
|
|||
/* store the key */
|
||||
rc = db->put( db, tid, key, &data, 0 );
|
||||
|
||||
#endif /* BDB_IDL_MULTI */
|
||||
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_idl_delete_key: put failed: %s (%d)\n",
|
||||
|
|
|
|||
|
|
@ -167,6 +167,11 @@ int bdb_id2entry(
|
|||
*/
|
||||
unsigned bdb_idl_search( ID *ids, ID id );
|
||||
|
||||
int bdb_bt_compare(
|
||||
DB *db,
|
||||
const DBT *a,
|
||||
const DBT *b );
|
||||
|
||||
int bdb_idl_fetch_key(
|
||||
BackendDB *be,
|
||||
DB *db,
|
||||
|
|
|
|||
Loading…
Reference in a new issue