]> git.sur5r.net Git - openldap/commitdiff
Add some initial BDB_INDEX code... needs much work.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 4 Oct 2001 22:29:34 +0000 (22:29 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 4 Oct 2001 22:29:34 +0000 (22:29 +0000)
servers/slapd/back-bdb/Makefile.in
servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/dbcache.c [new file with mode: 0644]
servers/slapd/back-bdb/filterindex.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/key.c [new file with mode: 0644]
servers/slapd/back-bdb/proto-bdb.h

index c284240f5a823a07ae822c4b3e5481a3392ef8c9..c68ca75cc23794daedeef6478247e03d804436ca 100644 (file)
@@ -3,12 +3,12 @@
 SRCS = init.c tools.c config.c \
        add.c bind.c compare.c delete.c modify.c modrdn.c search.c \
        extended.c passwd.c referral.c \
-       attr.c index.c \
+       attr.c index.c key.c dbcache.c \
        dn2entry.c dn2id.c error.c id2entry.c idl.c nextid.c
 OBJS = init.lo tools.lo config.lo \
        add.lo bind.lo compare.lo delete.lo modify.lo modrdn.lo search.lo \
        extended.lo passwd.lo referral.lo \
-       attr.lo index.lo \
+       attr.lo index.lo key.lo dbcache.lo \
        dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo
 
 LDAP_INCDIR= ../../../include       
index fb69dddb2e233903c611895398831d2b3bbaaee7..6ce4fbb00be63274f9cb4cfabb73f4227a1e859f 100644 (file)
@@ -57,7 +57,6 @@ ainfo_cmp(
 #endif
 }
 
-#if 0
 void
 bdb_attr_mask(
     struct bdb_info    *bdb,
@@ -75,7 +74,6 @@ bdb_attr_mask(
        
        *indexmask = a != NULL ? a->ai_indexmask : 0;
 }
-#endif
 
 int
 bdb_attr_index_config(
index ed45513c1fbc2cb332b5e09dab847da4dd9c397c..b3fd31f38375f6644220ceda62ef98b5b354c15c 100644 (file)
@@ -1,7 +1,7 @@
-/* back-bdb.h - ldap ldbm back-end header file */
+/* back-bdb.h - bdb back-end header file */
 /* $OpenLDAP$ */
 /*
- * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2001 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -15,7 +15,7 @@
 
 LDAP_BEGIN_DECL
 
-/* #define BDB_INDEX 1 */
+#define BDB_INDEX 1
 /* #define BDB_REINDEX 1 */
 /* #define BDB_FILTER_INDICES 1 */
 #define BDB_CONFIG_INDICES 1
diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c
new file mode 100644 (file)
index 0000000..1837ed4
--- /dev/null
@@ -0,0 +1,28 @@
+/* dbcache.c - manage cache of open databases */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <sys/stat.h>
+
+#include "slap.h"
+#include "back-bdb.h"
+
+int
+bdb_db_cache(
+    Backend    *be,
+    const char *name,
+       DB *db )
+{
+       return -1;
+}
index dc76338b19bc77afa8b411b52a15490a969f4e48..3e7427834b7af5775bae57c7d8e3e8f7daae5a74 100644 (file)
@@ -440,7 +440,7 @@ approx_candidates(
                ID_BLOCK *save;
                ID_BLOCK *tmp;
 
-               rc = key_read( be, db, keys[i], &tmp );
+               rc = bdb_key_read( be, db, keys[i], tmp );
 
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
@@ -562,7 +562,7 @@ substring_candidates(
                ID_BLOCK *save;
                ID_BLOCK *tmp;
 
-               rc = key_read( be, db, keys[i], &tmp );
+               rc = bdb_key_read( be, db, keys[i], &tmp );
 
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
@@ -595,4 +595,4 @@ substring_candidates(
        return( idl );
 }
 
-#endif
\ No newline at end of file
+#endif
index b19c4be499b27f08556810a1da0ec652ea46f8cc..3ce26c7e28c706453348f7ebc7e397077a616d97 100644 (file)
@@ -29,7 +29,7 @@ static slap_mask_t index_mask(
        /* we do not support indexing of binary attributes */
        if( slap_ad_is_binary( desc ) ) return 0;
 
-       attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
+       bdb_attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
 
        if( mask ) {
                *atname = desc->ad_cname->bv_val;
@@ -39,7 +39,7 @@ static slap_mask_t index_mask(
 
        if( slap_ad_is_lang( desc ) ) {
                /* has language tag */
-               attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
+               bdb_attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
 
                if( mask & SLAP_INDEX_AUTO_LANG ) {
                        *atname = desc->ad_cname->bv_val;
@@ -55,7 +55,7 @@ static slap_mask_t index_mask(
 
        /* see if supertype defined mask for its subtypes */
        for( at = desc->ad_type; at != NULL ; at = at->sat_sup ) {
-               attr_mask( be->be_private, at->sat_cname, &mask );
+               bdb_attr_mask( be->be_private, at->sat_cname, &mask );
 
                if( mask & SLAP_INDEX_AUTO_SUBTYPES ) {
                        *atname = desc->ad_type->sat_cname;
@@ -252,7 +252,7 @@ static int index_at_values(
                        dbnamep, &tmpmask );
        }
 
-       attr_mask( be->be_private, type->sat_cname, &mask );
+       bdb_attr_mask( be->be_private, type->sat_cname, &mask );
 
        if( mask ) {
                *dbnamep = type->sat_cname;
@@ -275,7 +275,7 @@ static int index_at_values(
 
                sprintf( lname, "%s;%s", type->sat_cname, lang );
 
-               attr_mask( be->be_private, lname, &tmpmask );
+               bdb_attr_mask( be->be_private, lname, &tmpmask );
 
                if( tmpmask ) {
                        dbname = lname;
diff --git a/servers/slapd/back-bdb/key.c b/servers/slapd/back-bdb/key.c
new file mode 100644 (file)
index 0000000..95109da
--- /dev/null
@@ -0,0 +1,105 @@
+/* index.c - routines for dealing with attribute indexes */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb.h"
+
+#ifdef BDB_FILTER_INDICES
+/* read a key */
+int
+bdb_key_read(
+    Backend    *be,
+       DB *db,
+       DB_TXN *txn,
+    struct berval *k,
+       ID **idout
+)
+{
+       Datum           key;
+       ID_BLOCK                *idl;
+
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
+                  "key_read: enter\n" ));
+#else
+       Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
+#endif
+
+       ldbm_datum_init( key );
+       key.dptr = k->bv_val;
+       key.dsize = k->bv_len;
+
+       rc = bdb_idl_fetch_key( be, db, key, idl );
+
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
+                  "key_read: %ld candidates\n",
+                  idl ? ID_BLOCK_NIDS(idl) : 0 ));
+#else
+       Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
+              idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
+#endif
+
+       *idout = idl;
+       return LDAP_SUCCESS;
+}
+#endif
+
+#ifdef BDB_INDEX
+/* Add or remove stuff from index files */
+int
+bdb_key_change(
+    Backend *be,
+    DB *db,
+       DB_TXN *txn,
+    struct berval *k,
+    ID id,
+    int op
+)
+{
+       int     rc;
+       DBT     key;
+
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
+               "key_change: %s ID %lx\n",
+               op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id ));
+#else
+       Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
+               op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
+#endif
+
+       DBTzero( &key );
+       key.data = k->bv_val;
+       key.size = k->bv_len;
+
+       if (op == SLAP_INDEX_ADD_OP) {
+           /* Add values */
+           rc = bdb_idl_insert_key( be, db, txn, &key, id );
+
+       } else {
+           /* Delete values */
+           rc = bdb_idl_delete_key( be, db, txn, &key, id );
+       }
+
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
+               "key_change: return %d\n", rc ));
+#else
+       Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
+#endif
+
+       return rc;
+}
+#endif
index 036129594942244e19e958044df23eb5aaad04ae..06c19225330554d36ca0437e0db8c3ff60cc1020 100644 (file)
@@ -39,6 +39,15 @@ int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
 
 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
 
+/*
+ * dbcache.c
+ */
+int
+bdb_db_cache(
+    Backend    *be,
+    const char *name,
+       DB *db );
+
 /*
  * dn2entry.c
  */
@@ -205,8 +214,18 @@ extern int
 bdb_key_read(
     Backend    *be,
        DB *db,
+       DB_TXN *txn,
     struct berval *k,
        ID *ids );
+
+extern int
+bdb_key_change(
+    Backend     *be,
+    DB *db,
+       DB_TXN *txn,
+    struct berval *k,
+    ID id,
+    int        op );
        
 /*
  * nextid.c