Browse files

Remove EXISTS method when ADD

  • Loading branch information...
1 parent 16a9bbb commit ff3092b9a0f7569be9b36b0dca98744329caf711 @BohuTANG BohuTANG committed Nov 6, 2011
Showing with 7 additions and 13 deletions.
  1. +1 −1 src/Makefile
  2. +5 −11 src/db.c
  3. +1 −1 src/nessdb-bench.c
View
2 src/Makefile
@@ -2,7 +2,7 @@ UNAME := $(shell uname)
CC = gcc
CFLAGS =-Wall -std=c99
-LDLIBS = -lpthread
+LDLIBS = -pthread
ifeq ($(UNAME), Linux)
DEBUG = -g -rdynamic -ggdb
else
View
16 src/db.c
@@ -92,7 +92,7 @@ static void bgsync_init()
*/
static void db_loadbloom(int idx)
{
- int r,i,super_size,table_size;
+ int i,super_size,table_size;
uint32_t total;
struct btree *btree=&_btrees[idx];
struct info *info=&_infos[idx];
@@ -104,7 +104,7 @@ static void db_loadbloom(int idx)
while(total>0){
struct btree_table *table=malloc(table_size);
- r=read(btree->fd,table, table_size) ;
+ read(btree->fd,table, table_size) ;
if(table->size>0){
for(i=0;i<table->size;i++){
uint32_t offset=from_be32(table->offsets[i]);
@@ -138,23 +138,17 @@ void db_init(int bufferpool_size,int isbgsync)
bgsync_init();
}
-int db_exists(const char *key);
int db_add(const char *key,const char *value)
{
- int isin;
uint32_t off;
unsigned int slot=djb_hash(key)%DB_SLOT;
- isin=db_exists(key);
off=btree_insert(&_btrees[slot],key,(const void*)value,strlen(value));
if(off==0)
return (0);
- if(isin){
- llru_remove(key);
- }else{
- _infos[slot].used++;
- bloom_add(&_bloom,key);
- }
+ llru_remove(key);
+ _infos[slot].used++;
+ bloom_add(&_bloom,key);
return (1);
}
View
2 src/nessdb-bench.c
@@ -54,7 +54,7 @@
#define R_NUM 20000
#define REMOVE_NUM 20000
#define BUFFERPOOL (1024*1024*1024)
-#define BGSYNC (1)
+#define BGSYNC (0)
#define V "1.7"
#define LINE "+-----------------------+---------------------------+----------------------------------+---------------------+\n"
#define LINE1 "--------------------------------------------------------------------------------------------------------------\n"

0 comments on commit ff3092b

Please sign in to comment.