mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
replace ALLIDS with RANGE IDLs
This commit is contained in:
parent
21cc085854
commit
077c47c2a6
5 changed files with 42 additions and 18 deletions
|
|
@ -23,7 +23,8 @@ LDAP_BEGIN_DECL
|
|||
#define BDB_IDL_MAX (BDB_IDL_DB_SIZE-32)
|
||||
/* #define BDB_IDL_DB_ALLOC (BDB_IDL_DB_SIZE * sizeof(ID)) */
|
||||
|
||||
#define BDB_IS_ALLIDS(ids) ((ids)[0] == NOID)
|
||||
#define BDB_IDL_RANGE_SIZE (3 * sizeof(ID))
|
||||
#define BDB_IDL_IS_RANGE(ids) ((ids)[0] == NOID)
|
||||
|
||||
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
|
||||
#define DN_ONE_PREFIX '%'
|
||||
|
|
|
|||
|
|
@ -187,6 +187,10 @@ SOURCE=".\proto-bdb.h"
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\referral.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\search.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define IDL_CMP(x,y) ( x < y ? -1 : ( x > y ? 1 : 0 ) )
|
||||
|
||||
int bdb_idl_search( ID *ids, ID id )
|
||||
unsigned bdb_idl_search( ID *ids, ID id )
|
||||
{
|
||||
#if BDB_IDL_BINARY_SEARCH
|
||||
/*
|
||||
|
|
@ -22,10 +22,10 @@ int bdb_idl_search( ID *ids, ID id )
|
|||
* if found, returns position of id
|
||||
* if not found, returns first postion greater than id
|
||||
*/
|
||||
int base = 0;
|
||||
int cursor = 0;
|
||||
unsigned base = 0;
|
||||
unsigned cursor = 0;
|
||||
int val;
|
||||
int n = ids[0];
|
||||
unsigned n = ids[0];
|
||||
|
||||
while( 0 < n ) {
|
||||
int pivot = n >> 1;
|
||||
|
|
@ -64,7 +64,7 @@ int bdb_idl_search( ID *ids, ID id )
|
|||
|
||||
static int idl_insert( ID *ids, ID id )
|
||||
{
|
||||
int x = bdb_idl_search( ids, id );
|
||||
unsigned x = bdb_idl_search( ids, id );
|
||||
|
||||
assert( x > 0 );
|
||||
|
||||
|
|
@ -79,6 +79,14 @@ static int idl_insert( ID *ids, ID id )
|
|||
}
|
||||
|
||||
if ( ++ids[0] >= BDB_IDL_DB_MAX ) {
|
||||
if( id < ids[1] ) {
|
||||
ids[1] = id;
|
||||
ids[2] = ids[ids[0]-1];
|
||||
} else if ( ids[ids[0]-1] < id ) {
|
||||
ids[2] = id;
|
||||
} else {
|
||||
ids[2] = ids[ids[0]-1];
|
||||
}
|
||||
ids[0] = NOID;
|
||||
|
||||
} else {
|
||||
|
|
@ -93,7 +101,7 @@ static int idl_insert( ID *ids, ID id )
|
|||
|
||||
static int idl_delete( ID *ids, ID id )
|
||||
{
|
||||
int x = bdb_idl_search( ids, id );
|
||||
unsigned x = bdb_idl_search( ids, id );
|
||||
|
||||
assert( x > 0 );
|
||||
|
||||
|
|
@ -162,8 +170,14 @@ bdb_idl_insert_key(
|
|||
(long) sizeof( ID ), (long) data.size, 0 );
|
||||
return -1;
|
||||
|
||||
} else if ( BDB_IS_ALLIDS(ids) ) {
|
||||
} else if ( BDB_IDL_IS_RANGE(ids) ) {
|
||||
if( id < ids[1] ) {
|
||||
ids[1] = id;
|
||||
} else if ( ids[2] > id ) {
|
||||
ids[2] = id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else if ( data.size != (1 + ids[0]) * sizeof( ID ) ) {
|
||||
/* size mismatch */
|
||||
|
|
@ -182,8 +196,8 @@ bdb_idl_insert_key(
|
|||
return rc;
|
||||
}
|
||||
|
||||
if( BDB_IS_ALLIDS( ids ) ) {
|
||||
data.size = sizeof( ID );
|
||||
if( BDB_IDL_IS_RANGE( ids ) ) {
|
||||
data.size = BDB_IDL_RANGE_SIZE;
|
||||
} else {
|
||||
data.size = (ids[0]+1) * sizeof( ID );
|
||||
}
|
||||
|
|
@ -239,7 +253,7 @@ bdb_idl_delete_key(
|
|||
(long) sizeof( ID ), (long) data.size, 0 );
|
||||
return -1;
|
||||
|
||||
} else if ( BDB_IS_ALLIDS(ids) ) {
|
||||
} else if ( BDB_IDL_IS_RANGE(ids) ) {
|
||||
return 0;
|
||||
|
||||
} else if ( data.size != (1 + ids[0]) * sizeof( ID ) ) {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ int bdb_id2entry(
|
|||
/*
|
||||
* idl.c
|
||||
*/
|
||||
int bdb_idl_search( ID *ids, ID id );
|
||||
unsigned bdb_idl_search( ID *ids, ID id );
|
||||
|
||||
int bdb_idl_insert_key(
|
||||
BackendDB *be,
|
||||
|
|
|
|||
|
|
@ -381,7 +381,11 @@ static int search_candidates(
|
|||
Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" (0x%08lx)\n",
|
||||
e->e_dn, (long) e->e_id, 0);
|
||||
|
||||
/* return a RANGE IDL for now */
|
||||
ids[0] = NOID;
|
||||
ids[1] = e->e_id;
|
||||
ids[2] = e->e_id+128;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -394,9 +398,10 @@ static ID idl_first( ID *ids, ID *cursor )
|
|||
return NOID;
|
||||
}
|
||||
|
||||
if ( BDB_IS_ALLIDS( ids ) ) {
|
||||
/* XXYYZ: quick hack for testing */
|
||||
ids[1] = 100;
|
||||
if ( BDB_IDL_IS_RANGE( ids ) ) {
|
||||
if( *cursor < ids[1] ) {
|
||||
*cursor = ids[1];
|
||||
}
|
||||
return *cursor;
|
||||
}
|
||||
|
||||
|
|
@ -412,8 +417,8 @@ static ID idl_first( ID *ids, ID *cursor )
|
|||
|
||||
static ID idl_next( ID *ids, ID *cursor )
|
||||
{
|
||||
if ( BDB_IS_ALLIDS( ids ) ) {
|
||||
if( ++(*cursor) <= ids[1] ) {
|
||||
if ( BDB_IDL_IS_RANGE( ids ) ) {
|
||||
if( ids[2] <= ++(*cursor) ) {
|
||||
return *cursor;
|
||||
}
|
||||
return NOID;
|
||||
|
|
|
|||
Loading…
Reference in a new issue