]> git.sur5r.net Git - openldap/commitdiff
Use a cursor to step through ID_BLOCKS.
authorKurt Zeilenga <kurt@openldap.org>
Sat, 7 Aug 1999 21:14:24 +0000 (21:14 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 7 Aug 1999 21:14:24 +0000 (21:14 +0000)
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/search.c
servers/slapd/tools/ldbmtest.c

index 688f055b05008540f8b969480961b4a95957b741..1cdad6be934f8715949a490033347af10b06a218 100644 (file)
@@ -25,7 +25,7 @@ LDAP_BEGIN_DECL
 #define SUBLEN                 3
 
 /*
- * there is a single index for each attribute.  these prefixes insure
+ * there is a single index for each attribute.  these prefixes ensure
  * that there is no collision among keys.
  */
 #define EQ_PREFIX      '='     /* prefix for equality keys     */
@@ -116,7 +116,7 @@ typedef struct ldbm_attrinfo {
 */
 } AttrInfo;
 
-#define MAXDBCACHE     10
+#define MAXDBCACHE     16
 
 /* this could be made an option */
 #ifndef SLAPD_NEXTID_CHUNK
index 0afef2333351f3ab7b2472591a22d97dbbd90ebb..670c608a54879574ade1603f0bbf1f80f6438b16 100644 (file)
@@ -1004,10 +1004,14 @@ idl_notin(
  *             NIDS > 1 return 1
  *             otherwise return NOID 
  *     otherwise return first ID
+ *
+ *     cursor is set to 1
  */         
 ID
-idl_firstid( ID_BLOCK *idl )
+idl_firstid( ID_BLOCK *idl, ID *cursor )
 {
+       *cursor = 1;
+
        if ( idl == NULL || ID_BLOCK_NIDS(idl) == 0 ) {
                return( NOID );
        }
@@ -1019,28 +1023,29 @@ idl_firstid( ID_BLOCK *idl )
        return( ID_BLOCK_ID(idl, 0) );
 }
 
-/*     return next ID after id
- *     if ALLIDS block, increment id. 
+/*     return next 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
-idl_nextid( ID_BLOCK *idl, ID id )
+idl_nextid( ID_BLOCK *idl, ID *cursor )
 {
-       unsigned int    i;
-
        if ( ID_BLOCK_ALLIDS( idl ) ) {
-               return( ++id < ID_BLOCK_NIDS(idl) ? id : NOID );
+               if( ++(*cursor) < ID_BLOCK_NIDS(idl) ) {
+                       return *cursor;
+               } else {
+                       return NOID;
+               }
        }
 
-       for ( i = 0; i < ID_BLOCK_NIDS(idl) && ID_BLOCK_ID(idl, i) <= id; i++ ) {
-               ;       /* NULL */
+       if ( *cursor < ID_BLOCK_NIDS(idl) ) {
+               return( ID_BLOCK_ID(idl, (*cursor)++) );
        }
 
-       if ( i >= ID_BLOCK_NIDS(idl) ) {
-               return( NOID );
-       } else {
-               return( ID_BLOCK_ID(idl, i) );
-       }
+       return( NOID );
 }
index e8732bb0fc36a9111de3df8c614ebf97c870fc4a..8275b03752179334384194d93551f129a18935d4 100644 (file)
@@ -126,8 +126,8 @@ int idl_delete_key LDAP_P(( Backend *be, DBCache *db, Datum key, ID id ));
 ID_BLOCK * idl_intersection LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
 ID_BLOCK * idl_union LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
 ID_BLOCK * idl_notin LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
-ID idl_firstid LDAP_P(( ID_BLOCK *idl ));
-ID idl_nextid LDAP_P(( ID_BLOCK *idl, ID id ));
+ID idl_firstid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
+ID idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
 
 /*
  * index.c
index aaefcd3f125dd8cd09c8a5be105492128abdfe95..9589c2fd9cc8d3e28d3dcb10d4c498e113ca5f36 100644 (file)
@@ -44,7 +44,7 @@ ldbm_back_search(
        char *text;
        time_t          stoptime;
        ID_BLOCK                *candidates;
-       ID              id;
+       ID              id, cursor;
        Entry           *e;
        struct berval **v2refs = NULL;
        Entry   *matched = NULL;
@@ -151,8 +151,8 @@ ldbm_back_search(
                goto done;
        }
 
-       for ( id = idl_firstid( candidates ); id != NOID;
-           id = idl_nextid( candidates, id ) )
+       for ( id = idl_firstid( candidates, &cursor ); id != NOID;
+           id = idl_nextid( candidates, &cursor ) )
        {
                int             scopeok = 0;
 
index a1c0282290a1c3e01e4aa26a289b53e049aac726..fb058df05bdcf2be67e8707604b0e74cbbab4d9b 100644 (file)
@@ -51,7 +51,7 @@ main( int argc, char **argv )
        char            buf[256];
        Datum           savekey, key, data, last;
        char            *fname;
-       ID              id;
+       ID              id, cursor;
        ID_BLOCK                *idl;
        Backend         *tbe;
        int             i;
@@ -279,8 +279,8 @@ main( int argc, char **argv )
                        get_keydata( stdin, buf[1], &key, &data );
 
                        idl = (ID_BLOCK *) data.dptr;
-                       for ( id = idl_firstid( idl ); id != NOID;
-                           id = idl_nextid( idl, id ) ) {
+                       for ( id = idl_firstid( idl, &cursor ); id != NOID;
+                           id = idl_nextid( idl, &cursor ) ) {
                                if ( idl_insert_key( be, dbc, key, id )
                                    != 0 ) {
                                        fprintf( stderr,