From 57940a6cca54cef89e12e0608a6a695f57673f41 Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Tue, 16 Apr 2013 23:57:56 -0400 Subject: [PATCH] db-insert compiles (from db-benchmark-test). [t:1904] git-svn-id: file:///svn/toku/tokudb@13637 c7de825b-a66e-492c-adef-691d508d4ae1 --- release/examples/db-insert/Makefile | 2 ++ release/examples/db-insert/db-insert.c | 11 +++++++-- release/examples/include/{db.h => tokudb.h} | 25 ++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) rename release/examples/include/{db.h => tokudb.h} (95%) diff --git a/release/examples/db-insert/Makefile b/release/examples/db-insert/Makefile index 35ae8a10dda..29bf40d7a27 100644 --- a/release/examples/db-insert/Makefile +++ b/release/examples/db-insert/Makefile @@ -1 +1,3 @@ +CPPFLAGS = -I../include +LDFLAGS = -L../.. -lfractaltreeindex -Wl,-rpath,../.. default: db-insert diff --git a/release/examples/db-insert/db-insert.c b/release/examples/db-insert/db-insert.c index e191806c877..c86378471f8 100644 --- a/release/examples/db-insert/db-insert.c +++ b/release/examples/db-insert/db-insert.c @@ -2,7 +2,8 @@ #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." /* Insert a bunch of stuff */ -#include +#include +#include #include #include #include @@ -11,6 +12,10 @@ #include #include +static inline float toku_tdiff (struct timeval *a, struct timeval *b) { + return (a->tv_sec - b->tv_sec) +1e-6*(a->tv_usec - b->tv_usec); +} + #if !defined(DB_YESOVERWRITE) #define DB_YESOVERWRITE 0 #endif @@ -206,7 +211,7 @@ static void benchmark_shutdown (void) { if (singlex_child) fprintf(stderr, "SKIPPED 'small rolltmp' test for child txn\n"); else assert(s->rolltmp_raw_count < 100); // gross test, not worth investigating details - os_free(s); + free(s); //system("ls -l bench.tokudb"); #endif } @@ -380,6 +385,8 @@ static int print_usage (const char *argv0) { return 1; } +#define UU(x) x __attribute__((__unused__)) + #if defined(TOKUDB) static int nothing(DBT const* UU(key), DBT const* UU(val), void* UU(extra)) { diff --git a/release/examples/include/db.h b/release/examples/include/tokudb.h similarity index 95% rename from release/examples/include/db.h rename to release/examples/include/tokudb.h index 6d7c9ec2ae8..8d286276662 100644 --- a/release/examples/include/db.h +++ b/release/examples/include/tokudb.h @@ -35,7 +35,30 @@ typedef u_int32_t db_recno_t; typedef int(*YDB_CALLBACK_FUNCTION)(DBT const*, DBT const*, void*); typedef int(*YDB_HEAVISIDE_CALLBACK_FUNCTION)(DBT const *key, DBT const *value, void *extra_f, int r_h); typedef int(*YDB_HEAVISIDE_FUNCTION)(const DBT *key, const DBT *value, void *extra_h); -#include + +// Included by db.h, defines some internal structures. These structures are inlined in some versions of db.h +// the types DB_TXN and so forth have been defined. + +struct simple_dbt { + u_int32_t len; + void *data; +}; + +struct __toku_db_txn_internal { + //TXNID txnid64; /* A sixty-four bit txn id. */ + struct tokutxn *tokutxn; + struct __toku_lth *lth; //Hash table holding list of dictionaries this txn has touched + u_int32_t flags; + DB_TXN *child; +}; + +struct __toku_dbc_internal { + struct brt_cursor *c; + DB_TXN *txn; + struct simple_dbt skey_s,sval_s; + struct simple_dbt *skey,*sval; +}; + typedef struct __toku_db_btree_stat64 { u_int64_t bt_nkeys; /* how many unique keys (guaranteed only to be an estimate, even when flattened) */ u_int64_t bt_ndata; /* how many key-value pairs (an estimate, but exact when flattened) */