#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 */
*/
} AttrInfo;
-#define MAXDBCACHE 10
+#define MAXDBCACHE 16
/* this could be made an option */
#ifndef SLAPD_NEXTID_CHUNK
* 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 );
}
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 );
}
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
char *text;
time_t stoptime;
ID_BLOCK *candidates;
- ID id;
+ ID id, cursor;
Entry *e;
struct berval **v2refs = NULL;
Entry *matched = NULL;
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;
char buf[256];
Datum savekey, key, data, last;
char *fname;
- ID id;
+ ID id, cursor;
ID_BLOCK *idl;
Backend *tbe;
int i;
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,