Commit 8a91f6fe authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Fix up type conflicts with ydb.c

git-svn-id: file:///svn/tokudb@37 c7de825b-a66e-492c-adef-691d508d4ae1
parent 90972738
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
long long parsell (char *s) {
char *end;
errno=0;
long long r = strtoll(s, &end, 10);
assert(*end==0 && end!=s && errno==0);
return r;
}
int main (int argc, char *argv[]) {
long long i;
assert(argc==3);
long long lo=parsell(argv[1]);
long long hi=parsell(argv[2]);
for (i=lo; i<hi; i++) {
printf("%lld\t%d\n", i, random());
}
return 0;
}
......@@ -64,7 +64,7 @@ struct brt {
BRT_CURSOR cursors_head, cursors_tail;
int (*compare_fun)(DB*,DBT*,DBT*);
int (*compare_fun)(DB*,const DBT*,const DBT*);
void *skey,*sval; /* Used for DBT return values. */
};
......
......@@ -692,7 +692,7 @@ DBT *fill_b(DBT *x, unsigned char *key, unsigned int keylen) {
return x;
}
int wrong_compare_fun(DB *db, DBT *a, DBT *b) {
int wrong_compare_fun(DB *db, const DBT *a, const DBT *b) {
unsigned int i;
unsigned char *ad=a->data;
unsigned char *bd=b->data;
......
......@@ -957,7 +957,7 @@ static int setup_brt_root_node (BRT t, diskoff offset) {
#endif
int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable,
int (*compare_fun)(DB*,DBT*,DBT*)) {
int (*compare_fun)(DB*,const DBT*,const DBT*)) {
/* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */
int r;
BRT t;
......
......@@ -9,7 +9,7 @@
#include "../include/ydb-constants.h"
#include "cachetable.h"
typedef struct brt *BRT;
int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, int(*)(DB*,DBT*,DBT*));
int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, int(*)(DB*,const DBT*,const DBT*));
//int brt_create (BRT **, int nodesize, int n_nodes_in_cache); /* the nodesize and n_nodes in cache really should be separately configured. */
//int brt_open (BRT *, char *fname, char *dbname);
int brt_insert (BRT brt, DBT *k, DBT *v, DB*db);
......
......@@ -26,6 +26,6 @@ void test_keycompare (void) {
assert(keycompare("aaaaa",3, "aaaba",3)==0);
}
int default_compare_fun (DB *db __attribute__((__unused__)), DBT *a, DBT*b) {
int default_compare_fun (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
return keycompare(a->data, a->size, b->data, b->size);
}
......@@ -4,4 +4,4 @@
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
void test_keycompare (void) ;
int default_compare_fun (DB *, DBT *, DBT*);
int default_compare_fun (DB *, const DBT *, const DBT*);
......@@ -27,7 +27,7 @@ struct pma {
* Regions of size 128 are 60% full. Regions of size 256 are 50% full.
* The densitystep is 0.10. */
PMA_CURSOR cursors_head, cursors_tail;
int (*compare_fun)(DB*,DBT*,DBT*);
int (*compare_fun)(DB*,const DBT*,const DBT*);
void *skey, *sval; /* used in dbts */
};
......
......@@ -479,7 +479,7 @@ void test_pma_cursor (void) {
}
int wrong_endian_compare_fun (DB *ignore __attribute__((__unused__)),
DBT *a, DBT *b) {
const DBT *a, const DBT *b) {
unsigned int i;
unsigned char *ad=a->data;
unsigned char *bd=b->data;
......
......@@ -263,7 +263,7 @@ int pmainternal_count_region (struct pair *pairs, int lo, int hi) {
return n;
}
int pma_create (PMA *pma, int (*compare_fun)(DB*,DBT*,DBT*)) {
int pma_create (PMA *pma, int (*compare_fun)(DB*,const DBT*,const DBT*)) {
TAGMALLOC(PMA, result);
int i;
if (result==0) return -1;
......
......@@ -12,7 +12,7 @@ typedef struct pma *PMA;
typedef struct pma_cursor *PMA_CURSOR;
/* All functions return 0 on success. */
int pma_create (PMA *, int (*compare_fun)(DB*,DBT*,DBT*));
int pma_create (PMA *, int (*compare_fun)(DB*,const DBT*,const DBT*));
/* returns 0 if OK.
* You must have freed all the cursors, otherwise returns nonzero and does nothing. */
......
CFLAGS = -W -Wall -Wno-unused -g -fPIC
CPPFLAGS = -I../include -I../newbrt
install: libdb.so
cp libdb.so ../src-bdbwrap/
cp libdb.so ../lib/
ydb.o: ../include/db.h ../newbrt/cachetable.h
DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/cachetable.o ../newbrt/hashtable.o ../newbrt/header-io.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/pma.o ../newbrt/ybt.o
libdb.so: $(DBBINS)
......
......@@ -364,12 +364,13 @@ int yobi_db_open (DB *db, DB_TXN *txn, const char *fname, const char *dbname, D
// Each tree has its own cache, instead of a big shared cache.
// It doesn't do error checking on insert.
// It's tough to do cursors.
r=open_brt(db->i->full_fname, dbname, (flags&DB_CREATE), &db->i->brt, 1<<20, db->i->env->i->cachetable);
r=open_brt(db->i->full_fname, dbname, (flags&DB_CREATE), &db->i->brt, 1<<20, db->i->env->i->cachetable,
db->i->bt_compare);
assert(r==0);
return 0;
}
int yobi_db_put (DB *db, DB_TXN *txn, DBT *dbta, DBT *dbtb, u_int32_t flags) {
int r = brt_insert(db->i->brt, dbta->data, dbta->size, dbtb->data, dbtb->size);
int r = brt_insert(db->i->brt, dbta, dbtb, db);
//printf("%s:%d %d=yobi_db_put(...)\n", __FILE__, __LINE__, r);
return r;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment