]> git.sur5r.net Git - openldap/commitdiff
New slapindex framework (no meat)
authorKurt Zeilenga <kurt@openldap.org>
Wed, 19 Jul 2000 02:24:08 +0000 (02:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 19 Jul 2000 02:24:08 +0000 (02:24 +0000)
servers/slapd/back-ldbm/external.h
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/tools.c
servers/slapd/slap.h
servers/slapd/tools/slapcommon.c
servers/slapd/tools/slapindex.c

index 1ea9d565614a89deb58ce8549f8a74d1153e1ba0..2bdac2f06930879149431f0f117a88aa9b576d11 100644 (file)
@@ -96,11 +96,7 @@ extern ID ldbm_tool_entry_next LDAP_P(( BackendDB *be ));
 extern Entry* ldbm_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
 extern ID ldbm_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
 
-extern int ldbm_tool_index_attr LDAP_P(( BackendDB *be,
-       AttributeDescription* desc ));
-extern int ldbm_tool_index_change LDAP_P(( BackendDB *be,
-       AttributeDescription* desc,
-       struct berval **bv, ID id, int op ));
+extern int ldbm_tool_entry_reindex LDAP_P(( BackendDB *be, ID id ));
 extern int ldbm_tool_sync LDAP_P(( BackendDB *be ));
 
 extern int ldbm_back_referrals LDAP_P(( BackendDB *bd,
index d81105ae8ceb217389bc22f366a90ad7cac824e1..dc4b5b81deb5e5b531b11cea840e94d23e8c1b9a 100644 (file)
@@ -79,7 +79,7 @@ ldbm_back_initialize(
        bi->bi_tool_entry_next = ldbm_tool_entry_next;
        bi->bi_tool_entry_get = ldbm_tool_entry_get;
        bi->bi_tool_entry_put = ldbm_tool_entry_put;
-       bi->bi_tool_index_attr = ldbm_tool_index_attr;
+       bi->bi_tool_entry_reindex = ldbm_tool_entry_reindex;
        bi->bi_tool_sync = ldbm_tool_sync;
 
        bi->bi_connection_init = 0;
index 1715465e69b4bbb1c3e77c942259c0ee68f2e50b..d83d70360ae60f66b80f0c4daaafeca4c19888af 100644 (file)
@@ -192,48 +192,11 @@ ID ldbm_tool_entry_put(
        return e->e_id;
 }
 
-int ldbm_tool_index_attr(
+int ldbm_tool_entry_reindex(
        BackendDB *be,
-       AttributeDescription *desc
-)
+       ID id )
 {
-       static DBCache *db = NULL;
-       slap_index indexmask;
-       char *at_cname;
-
-       assert( slapMode & SLAP_TOOL_MODE );
-
-       at_cname = desc->ad_cname->bv_val;
-
-       assert( desc != NULL );
-       attr_mask( be->be_private, at_cname, &indexmask );
-
-       if ( (db = ldbm_cache_open( be, at_cname, LDBM_SUFFIX, LDBM_NEWDB ))
-           == NULL )
-       {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= index_attr NULL (could not open %s%s)\n", at_cname,
-                   LDBM_SUFFIX, 0 );
-               return 0;
-       }
-
-       ldbm_cache_close( be, db );
-
-       return indexmask != 0;
-}
-
-int ldbm_tool_index_change(
-       BackendDB *be,
-       AttributeDescription *desc,
-       struct berval **bv,
-       ID id,
-       int op )
-{
-       assert( slapMode & SLAP_TOOL_MODE );
-
-       index_values( be, desc, bv, id, op );
-
-       return 0;
+       return LDAP_OTHER;
 }
 
 int ldbm_tool_sync( BackendDB *be )
index f4f7b6374da61a2491f94342fc83794ea687a466..2e9fbb03755ced9e67d6bb23697e2d48bf4e3ad7 100644 (file)
@@ -787,10 +787,9 @@ struct slap_backend_db {
 #define                be_entry_close bd_info->bi_tool_entry_close
 #define                be_entry_first bd_info->bi_tool_entry_first
 #define                be_entry_next bd_info->bi_tool_entry_next
+#define                be_entry_reindex bd_info->bi_tool_entry_reindex
 #define                be_entry_get bd_info->bi_tool_entry_get
 #define                be_entry_put bd_info->bi_tool_entry_put
-#define                be_index_attr bd_info->bi_tool_index_attr
-#define                be_index_change bd_info->bi_tool_index_change
 #define                be_sync bd_info->bi_tool_sync
 #endif
 
@@ -960,11 +959,7 @@ struct slap_backend_info {
        ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be ));
        Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
        ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
-       int (*bi_tool_index_attr) LDAP_P(( BackendDB *be,
-               AttributeDescription *desc ));
-       int (*bi_tool_index_change) LDAP_P(( BackendDB *be,
-               AttributeDescription *desc,
-               struct berval **bv, ID id, int op ));
+       int (*bi_tool_entry_reindex) LDAP_P(( BackendDB *be, ID id ));
        int (*bi_tool_sync) LDAP_P(( BackendDB *be ));
 
 #define SLAP_INDEX_ADD_OP              0x0001
index 45ba63a2d88e346a4886e5f611199e89fd3d9b6a..954635a801d62f93b522fae194cd46f82dbe0686 100644 (file)
@@ -54,7 +54,7 @@ usage( int tool )
                break;
 
        case SLAPINDEX:
-               options = "\tattributetype\n";
+               options = "\n";
                break;
        }
 
@@ -161,9 +161,7 @@ slap_tool_init(
                }
        }
 
-       if ( ( argc != optind + (tool == SLAPINDEX ? 1 : 0) )
-               || (dbnum >= 0 && base != NULL ) )
-       {
+       if ( ( argc != optind ) || (dbnum >= 0 && base != NULL ) ) {
                usage( tool );
        }
 
index efee55d7e873e23d39762d655dc7f338d29a3966..87ab02d84f7a9656f8a84f80c296cf11f92f1ade 100644 (file)
@@ -31,9 +31,7 @@ main( int argc, char **argv )
                !be->be_entry_close &&
                !be->be_entry_first &&
                !be->be_entry_next &&
-               !be->be_entry_get &&
-               !be->be_index_attr &&
-               !be->be_index_change )
+               !be->be_entry_reindex )
        {
                fprintf( stderr, "%s: database doesn't support necessary operations.\n",
                        progname );
@@ -50,12 +48,6 @@ main( int argc, char **argv )
                exit( EXIT_FAILURE );
        }
 
-       if ( !be->be_index_attr( be, desc ) ) {
-               fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
-                       type );
-               exit( EXIT_FAILURE );
-       }
-
        if( be->be_entry_open( be, 0 ) != 0 ) {
                fprintf( stderr, "%s: could not open database.\n",
                        progname );
@@ -66,43 +58,19 @@ main( int argc, char **argv )
                id != NOID;
                id = be->be_entry_next( be ) )
        {
-               Entry* e = be->be_entry_get( be, id );
-
-               if ( e == NULL ) {
-                       fprintf( stderr,
-                               "entry id=%08lx: no data\n", (long) id );
-                       rc = EXIT_FAILURE;
-                       if( continuemode ) continue;
-                       break;
-               }
+               int rtn;
 
                if( verbose ) {
-                       printf("indexing id=%08lx dn=\"%s\"\n",
-                               id, e->e_dn );
+                       printf("indexing id=%08lx\n", (long) id );
                }
 
-               {
-                       Attribute *attr;
-                       
-                       for( attr = attrs_find( e->e_attrs, desc );
-                               attr != NULL;
-                               attr = attrs_find( attr->a_next, desc ) )
-                       {
-
-                               if ( be->be_index_change( be,
-                                       desc, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
-                               {
-                                       rc = EXIT_FAILURE;
-
-                                       if( !continuemode ) {
-                                               entry_free( e );
-                                               goto done;
-                                       }
-                               }
-                       }
-               }
+               rtn =  be->be_entry_reindex( be, id );
 
-               entry_free( e );
+               if( rtn != LDAP_SUCCESS ) {
+                       rc = EXIT_FAILURE;
+                       if( continuemode ) continue;
+                       break;
+               }
        }
 
 done: