]> git.sur5r.net Git - openldap/commitdiff
Fix typo in previous commit as well as integrate bubble move
authorKurt Zeilenga <kurt@openldap.org>
Sun, 8 Aug 1999 00:54:27 +0000 (00:54 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 8 Aug 1999 00:54:27 +0000 (00:54 +0000)
replacement.

servers/slapd/back-bdb2/back-bdb2.h
servers/slapd/back-bdb2/idl.c
servers/slapd/back-bdb2/proto-back-bdb2.h
servers/slapd/back-bdb2/search.c

index 4a8879d4ec11f40876794363cd70a62643f3d8eb..cfcc4924254406d8b220bb0626d5fa016e0c2404 100644 (file)
@@ -119,8 +119,6 @@ struct attrinfo {
 */
 };
 
-#define MAXDBCACHE     10
-
 /* this could be made an option */
 #ifndef SLAPD_NEXTID_CHUNK
 #define SLAPD_NEXTID_CHUNK     32
index e5a2867c5b1fbf0e92ea9d1cf7f2450d8937e1d4..5b000f308e1ae49adf1d402ed69496668846ee1d 100644 (file)
@@ -646,7 +646,7 @@ bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
 
        /* make a slot for the new id */
        SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1),
-               ID_BLOCKS_NIDS(*idl) - i );
+               ID_BLOCK_NIDS(*idl) - i );
 
        ID_BLOCK_ID(*idl, i) = id;
        ID_BLOCK_NIDS(*idl)++;
@@ -993,10 +993,14 @@ bdb2i_idl_notin(
  *             NIDS > 1 return 1
  *             otherwise return NOID 
  *     otherwise return first ID
+ *
+ *  cursor is set to 1
  */         
 ID
-bdb2i_idl_firstid( ID_BLOCK *idl )
+bdb2i_idl_firstid( ID_BLOCK *idl, ID *cursor )
 {
+       *cursor = 1;
+
        if ( idl == NULL || ID_BLOCK_NIDS(idl) == 0 ) {
                return( NOID );
        }
@@ -1010,27 +1014,27 @@ bdb2i_idl_firstid( ID_BLOCK *idl )
 
 
 /*     return next ID after id
- *     if ALLIDS block, increment id. 
+ *     if ALLIDS block, cursor is id
+ *             increment id
  *             if id < NIDS return id
  *             otherwise NOID.
- *     otherwise SEARCH for next id (ugh!)
+ *     otherwise cursor is index into block
+ *             if index < nids
+ *                     return id at index then increment
  */ 
 ID
-bdb2i_idl_nextid( ID_BLOCK *idl, ID id )
+bdb2i_idl_nextid( ID_BLOCK *idl, ID *cursor )
 {
-       unsigned int    i;
-
        if ( ID_BLOCK_ALLIDS( idl ) ) {
-               return( ++id < ID_BLOCK_NIDS(idl) ? id : NOID );
-       }
-
-       for ( i = 0; i < ID_BLOCK_NIDS(idl) && ID_BLOCK_ID(idl, i) <= id; i++ ) {
-               ;       /* NULL */
+               if( ++(*cursor) < ID_BLOCK_NIDS(idl) ) {
+                       return *cursor;
+               } else {
+                       return NOID;
+               }
        }
 
-       if ( i >= ID_BLOCK_NIDS(idl) ) {
-               return( NOID );
-       } else {
-               return( ID_BLOCK_ID(idl, i) );
+       if ( *cursor < ID_BLOCK_NIDS(idl) ) {
+               return ID_BLOCK_ID(idl, (*cursor)++);
        }
+       return NOID;
 }
index e6ac08c6e620941e0a5e7bbfe11c0661cf4bc7be..f0583e1f14cfc694562a5977021fce477c95b02f 100644 (file)
@@ -130,8 +130,8 @@ int bdb2i_idl_delete_key LDAP_P(( BackendDB *be, struct dbcache *db, Datum key,
 ID_BLOCK * bdb2i_idl_intersection LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
 ID_BLOCK * bdb2i_idl_union LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
 ID_BLOCK * bdb2i_idl_notin LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
-ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl ));
-ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID id ));
+ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
+ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
 
 /*
  * index.c
index 6fa45c895ae93fa397a4ed77f378797c5567fc3c..9117aeafb9918f667c004d92dc1d24602f9e98ae 100644 (file)
@@ -40,7 +40,7 @@ bdb2i_back_search_internal(
        char *text;
        time_t          stoptime;
        ID_BLOCK                *candidates;
-       ID              id;
+       ID              id, cursor;
        Entry           *e;
        struct berval **v2refs = NULL;
        Entry   *matched = NULL;
@@ -147,8 +147,8 @@ bdb2i_back_search_internal(
                goto done;
        }
 
-       for ( id = bdb2i_idl_firstid( candidates ); id != NOID;
-           id = bdb2i_idl_nextid( candidates, id ) )
+       for ( id = bdb2i_idl_firstid( candidates, &cursor ); id != NOID;
+           id = bdb2i_idl_nextid( candidates, &cursor ) )
        {
                int             scopeok = 0;