Commit 1ead3402 authored by Rich Prohaska's avatar Rich Prohaska

remove c++ api and db-benchmark-test

parent 05f8220d
# -*- Mode: Makefile -*-
# standard build: make
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
.DEFAULT_GOAL= default
TOKUROOT=../
INCLUDEDIRS=-I.
DEPEND_COMPILE += \
./*.h \
#end
HERE = cxx
include $(TOKUROOT)toku_include/Makefile.include
#
#
# OPTFLAGS = -O2
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CPPFLAGS = -I../include -I../toku_include
CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Werror -Wall -g $(OPTFLAGS) $(GCOV_FLAGS)
LDFLAGS = -lz
SRCS = $(wildcard *.cpp)
OBJS = $(patsubst %.cpp, %.o, $(SRCS))
ifeq ($(CC),icc)
CXXFLAGS += -diag-disable 981
CXX=icc
endif
LIBNAME = libtokudb_cxx
default: install build
build: $(LIBNAME).a
if ! diff $(LIBNAME).a ../lib/$(LIBNAME).a >/dev/null 2>&1; then cp $< ../lib/; fi
cd tests; $(MAKE) build
check:
cd tests; $(MAKE) check
install: $(LIBNAME).a
cp $< ../lib/
$(OBJS): ../include/db_cxx.h
test1: test1.o dbt.o db.o dbenv.o ../lib/libdb.a
$(LIBNAME).a: $(OBJS)
$(AR) cr $@ $(OBJS)
clean:
rm -f $(OBJS) $(LIBNAME).a $(LIBNAME).so *.gcno *.gcda *.gcov
cd tests && $(MAKE) clean
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <assert.h>
#include <db.h>
#include <errno.h>
#include <db_cxx.h>
#define do_maybe_error(errno)
Db::Db(DbEnv *env, u_int32_t flags)
: the_Env(env)
{
assert(env); // modern versions of TokuDB require an env.
the_db = 0;
is_private_env = (the_Env == 0);
DB *tmp_db;
int ret = db_create(&tmp_db, the_Env->get_DB_ENV(), flags & ~(DB_CXX_NO_EXCEPTIONS));
if (ret!=0) {
the_Env->maybe_throw_error(ret);
// Otherwise cannot do much
return;
}
the_db = tmp_db;
tmp_db->api_internal = this;
if (is_private_env) {
the_Env = new DbEnv(tmp_db->dbenv, flags & DB_CXX_NO_EXCEPTIONS);
}
}
Db::~Db() {
if (the_db) {
close(0); // the user should have called close, but we do it here if not done.
assert(the_db==0);
}
if (is_private_env && the_Env) {
the_Env->close(0);
delete the_Env;
}
}
int Db::set_flags(u_int32_t flags) {
int ret = the_db->set_flags(the_db, flags);
return the_Env->maybe_throw_error(ret);
}
int Db::get_flags(u_int32_t *flags) {
int ret = the_db->get_flags(the_db, flags);
return the_Env->maybe_throw_error(ret);
}
int Db::close (u_int32_t flags) {
if (!the_db) {
return the_Env->maybe_throw_error(EINVAL);
}
the_db->api_internal = 0;
int ret = the_db->close(the_db, flags);
the_db = 0;
int no_exceptions = the_Env->do_no_exceptions; // Get this out before possibly deleting the env
if (is_private_env) {
// The env was closed by the_db->close, we have to tell the DbEnv that the DB_ENV is gone, and delete it.
the_Env->the_env = 0;
delete the_Env;
the_Env=0;
}
// Do we need to clean up "private environments"?
// What about cursors? They should be cleaned up already, but who did it?
// This maybe_throw must be the static one because the env is gone.
return DbEnv::maybe_throw_error(ret, NULL, no_exceptions);
}
int Db::open(DbTxn *txn, const char *filename, const char *subname, DBTYPE typ, u_int32_t flags, int mode) {
int ret = the_db->open(the_db, txn->get_DB_TXN(), filename, subname, typ, flags, mode);
return the_Env->maybe_throw_error(ret);
}
int Db::del(DbTxn *txn, Dbt *key, u_int32_t flags) {
int ret = the_db->del(the_db, txn->get_DB_TXN(), key->get_DBT(), flags);
return the_Env->maybe_throw_error(ret);
}
int Db::get(DbTxn *txn, Dbt *key, Dbt *data, u_int32_t flags) {
int ret = the_db->get(the_db, txn->get_DB_TXN(), key->get_DBT(), data->get_DBT(), flags);
return the_Env->maybe_throw_error(ret);
}
int Db::put(DbTxn *txn, Dbt *key, Dbt *data, u_int32_t flags) {
int ret = the_db->put(the_db, txn->get_DB_TXN(), key->get_DBT(), data->get_DBT(), flags);
return the_Env->maybe_throw_error(ret);
}
int Db::cursor(DbTxn *txn, Dbc **cursorp, u_int32_t flags) {
int ret = the_db->cursor(the_db, txn->get_DB_TXN(), (DBC**)cursorp, flags);
return the_Env->maybe_throw_error(ret);
}
int Db::set_pagesize(u_int32_t size) {
int ret = the_db->set_pagesize(the_db, size);
return the_Env->maybe_throw_error(ret);
}
int Db::remove(const char *file, const char *database, u_int32_t flags) {
int ret = the_db->remove(the_db, file, database, flags);
the_db = 0;
return the_Env->maybe_throw_error(ret);
}
#if 0
extern "C" int toku_bt_compare_callback_c(DB *db_c, const DBT *a, const DBT *b) {
Db *db_cxx=Db::get_Db(db_c);
return db_cxx->do_bt_compare_callback_cxx(db_cxx, Dbt::get_const_Dbt(a), Dbt::get_const_Dbt(b));
}
int Db::do_bt_compare_callback_cxx(Db *db, const Dbt *a, const Dbt *b) {
return the_Env->bt_compare_callback_cxx(db, a, b);
}
int Db::set_bt_compare(int (*bt_compare_callback)(Db *, const Dbt *, const Dbt *)) {
bt_compare_callback_cxx = bt_compare_callback;
int ret = the_db->set_bt_compare(the_db, toku_bt_compare_callback_c);
return the_Env->maybe_throw_error(ret);
}
int Db::set_bt_compare(bt_compare_fcn_type bt_compare_fcn) {
int ret = the_db->set_bt_compare(the_db, bt_compare_fcn);
return the_Env->maybe_throw_error(ret);
}
#endif
int Db::fd(int *fdp) {
int ret = the_db->fd(the_db, fdp);
return the_Env->maybe_throw_error(ret);
}
extern "C" int toku_dup_compare_callback_c(DB *db_c, const DBT *a, const DBT *b) {
Db *db_cxx=Db::get_Db(db_c);
return db_cxx->dup_compare_callback_cxx(db_cxx, Dbt::get_const_Dbt(a), Dbt::get_const_Dbt(b));
}
void Db::set_errpfx(const char *errpfx) {
the_Env->set_errpfx(errpfx);
}
void Db::set_error_stream(std::ostream *new_error_stream) {
the_Env->set_error_stream(new_error_stream);
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
int Dbc::close (void) {
DBC *dbc = this;
DbEnv *env = (DbEnv*)dbc->dbp->api_internal; // Must grab the env before closing the cursor.
int ret = dbc->c_close(dbc);
return env->maybe_throw_error(ret);
}
int Dbc::get(Dbt* key, Dbt *data, u_int32_t flags) {
DBC *dbc = this;
int ret = dbc->c_get(dbc, key, data, flags);
DB_ENV *dbenv_c=dbc->dbp->dbenv;
DbEnv *env = (DbEnv*)dbenv_c->api1_internal;
return env->maybe_throw_error(ret);
}
#if 0
// No longer present (see #4576)
int Dbc::del(u_int32_t flags) {
DBC *dbc = this;
int ret = dbc->c_del(dbc, flags);
DB_ENV *dbenv_c=dbc->dbp->dbenv;
DbEnv *env = (DbEnv*)dbenv_c->api1_internal;
return env->maybe_throw_error(ret);
}
#endif
int Dbc::count(db_recno_t *count, u_int32_t flags) {
DBC *dbc = this;
int ret = dbc->c_count(dbc, count, flags);
DB_ENV *dbenv_c=dbc->dbp->dbenv;
DbEnv *env = (DbEnv*)dbenv_c->api1_internal;
return env->maybe_throw_error(ret);
}
// Not callable, but some compilers require it to be defined anyway.
Dbc::~Dbc()
{
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdarg.h>
#include <errno.h>
#include <toku_assert.h>
#include "../ft/fttypes.h"
#include <db_cxx.h>
DbEnv::DbEnv (u_int32_t flags)
: do_no_exceptions((flags&DB_CXX_NO_EXCEPTIONS)!=0),
errcall(NULL)
{
int ret = db_env_create(&the_env, flags & ~DB_CXX_NO_EXCEPTIONS);
assert(ret==0); // should do an error.
the_env->api1_internal = this;
}
DbEnv::DbEnv(DB_ENV *env, u_int32_t flags)
: do_no_exceptions((flags&DB_CXX_NO_EXCEPTIONS)!=0), _error_stream(0)
{
the_env = env;
if (env == 0) {
DB_ENV *new_env;
int ret = db_env_create(&new_env, flags & ~DB_CXX_NO_EXCEPTIONS);
assert(ret==0); // should do an error.
the_env = new_env;
}
the_env->api1_internal = this;
}
// If still open, close it. In most cases, the caller should call close explicitly so that they can catch the exceptions.
DbEnv::~DbEnv(void)
{
if (the_env!=NULL) {
(void)the_env->close(the_env, 0);
the_env = 0;
}
}
int DbEnv::close(u_int32_t flags) {
int ret = EINVAL;
if (the_env)
ret = the_env->close(the_env, flags);
the_env = 0; /* get rid of the env ref, so we don't touch it (even if we failed, or when the destructor is called) */
return maybe_throw_error(ret);
}
int DbEnv::open(const char *home, u_int32_t flags, int mode) {
int ret = the_env->open(the_env, home, flags, mode);
return maybe_throw_error(ret);
}
int DbEnv::set_cachesize(u_int32_t gbytes, u_int32_t bytes, int ncache) {
int ret = the_env->set_cachesize(the_env, gbytes, bytes, ncache);
return maybe_throw_error(ret);
}
int DbEnv::set_redzone(u_int32_t percent) {
int ret = the_env->set_redzone(the_env, percent);
return maybe_throw_error(ret);
}
int DbEnv::set_flags(u_int32_t flags, int onoff) {
int ret = the_env->set_flags(the_env, flags, onoff);
return maybe_throw_error(ret);
}
#if DB_VERSION_MAJOR<4 || (DB_VERSION_MAJOR==4 && DB_VERSION_MINOR<=4)
int DbEnv::set_lk_max(u_int32_t flags) {
int ret = the_env->set_lk_max(the_env, flags);
return maybe_throw_error(ret);
}
#endif
int DbEnv::txn_begin(DbTxn *parenttxn, DbTxn **txnp, u_int32_t flags) {
DB_TXN *txn;
int ret = the_env->txn_begin(the_env, parenttxn->get_DB_TXN(), &txn, flags);
if (ret==0) {
*txnp = new DbTxn(txn);
}
return maybe_throw_error(ret);
}
int DbEnv::set_default_bt_compare(bt_compare_fcn_type bt_compare_fcn) {
int ret = the_env->set_default_bt_compare(the_env, bt_compare_fcn);
return maybe_throw_error(ret);
}
int DbEnv::set_data_dir(const char *dir) {
int ret = the_env->set_data_dir(the_env, dir);
return maybe_throw_error(ret);
}
void DbEnv::set_errpfx(const char *errpfx) {
the_env->set_errpfx(the_env, errpfx);
}
int DbEnv::maybe_throw_error(int err, DbEnv *env, int no_exceptions) throw (DbException) {
if (err==0 || err==DB_NOTFOUND || err==DB_KEYEXIST) return err;
if (no_exceptions) return err;
if (err==DB_LOCK_DEADLOCK) {
DbDeadlockException e(env);
throw e;
} else {
DbException e(err);
e.set_env(env);
throw e;
}
}
int DbEnv::maybe_throw_error(int err) throw (DbException) {
return maybe_throw_error(err, this, do_no_exceptions);
}
extern "C" void toku_ydb_error_all_cases(const DB_ENV * env,
int error,
BOOL include_stderrstring,
BOOL use_stderr_if_nothing_else,
const char *fmt, va_list ap);
void DbEnv::err(int error, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
toku_ydb_error_all_cases(the_env, error, TRUE, TRUE, fmt, ap);
va_end(ap);
}
void DbEnv::set_errfile(FILE *errfile) {
the_env->set_errfile(the_env, errfile);
}
int DbEnv::get_flags(u_int32_t *flagsp) {
int ret = the_env->get_flags(the_env, flagsp);
return maybe_throw_error(ret);
}
extern "C" void toku_db_env_errcall_c(const DB_ENV *dbenv_c, const char *errpfx, const char *msg) {
DbEnv *dbenv = (DbEnv *) dbenv_c->api1_internal;
dbenv->errcall(dbenv, errpfx, msg);
}
void DbEnv::set_errcall(void (*db_errcall_fcn)(const DbEnv *, const char *, const char *)) {
errcall = db_errcall_fcn;
the_env->set_errcall(the_env, toku_db_env_errcall_c);
}
extern "C" void toku_db_env_error_stream_c(const DB_ENV *dbenv_c, const char *errpfx, const char *msg) {
DbEnv *dbenv = (DbEnv *) dbenv_c->api1_internal;
if (dbenv->_error_stream) {
if (errpfx) *(dbenv->_error_stream) << errpfx;
if (msg) *(dbenv->_error_stream) << ":" << msg << "\n";
}
}
void DbEnv::set_error_stream(std::ostream *new_error_stream) {
_error_stream = new_error_stream;
the_env->set_errcall(the_env, toku_db_env_error_stream_c);
}
int DbEnv::set_lk_max_locks(u_int32_t max_locks) {
int ret = the_env->set_lk_max_locks(the_env, max_locks);
return maybe_throw_error(ret);
}
int DbEnv::get_lk_max_locks(u_int32_t *max_locks) {
int ret = the_env->get_lk_max_locks(the_env, max_locks);
return maybe_throw_error(ret);
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
Dbt::Dbt(void) {
DBT *dbt = this;
memset(dbt, 0, sizeof(*dbt));
}
Dbt::Dbt(void *data, u_int32_t size) {
DBT *dbt = this;
memset(dbt, 0, sizeof(*dbt));
set_data(data);
set_size(size);
}
Dbt::~Dbt(void)
{
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db.h>
#include <db_cxx.h>
static char*cpp_strdup (const char *s)
{
int l=strlen(s)+1;
char *r = new char[l];
strncpy(r, s, l);
return r;
}
DbException::~DbException() throw()
{
if (the_what!=0) {
delete [] the_what;
}
}
DbException::DbException(int err)
: the_err(err),
the_env(0)
{
FillTheWhat();
}
void DbException::FillTheWhat(void)
{
if (the_err!=0) {
the_what = cpp_strdup(db_strerror(the_err));
}
}
int DbException::get_errno() const
{
return the_err;
}
const char *DbException::what() const throw()
{
return the_what;
}
DbEnv *DbException::get_env() const
{
return the_env;
}
void DbException::set_env(DbEnv *new_env)
{
the_env = new_env;
}
// Must define a copy constructor so that the delete[] of the same the_what doesn't happen
DbException::DbException (const DbException &that)
: std::exception(),
the_what(cpp_strdup(that.the_what)),
the_err(that.the_err),
the_env(that.the_env)
{
}
DbException &DbException::operator = (const DbException &that)
{
if (this != &that) {
delete [] the_what;
the_what = cpp_strdup(that.the_what);
the_err = that.the_err;
the_env = that.the_env;
}
return (*this);
}
DbDeadlockException::DbDeadlockException (DbEnv *env)
: DbException(DB_LOCK_DEADLOCK)
{
this->set_env(env);
}
# -*- Mode: Makefile -*-
# standard build: make
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
.DEFAULT_GOAL= default
TOKUROOT=../../
INCLUDEDIRS=-I.
DEPEND_COMPILE += \
../*.h \
./*.h \
#end
HERE = cxx/tests
include $(TOKUROOT)toku_include/Makefile.include
SHELL=/bin/bash #Use of &> is a bash feature
SHOULD_FAIL = check_exceptions
$(SHOULD_FAIL): MAYBEINVERTER=;test $$? -ne 0
$(SHOULD_FAIL): VGRIND=
HERE = cxx/tests
ifeq ($(SUMMARIZE),1)
SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sPASS\n" $(HERE)/$@; else printf "%-60sFAIL\n" $(HERE)/$@ ; test 0 = 1; fi
$(SHOULD_FAIL): SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sXFAIL\n" $(HERE)/$@; else printf "%-60sXPASS\n" $(HERE)/$@ ; test 0 = 1; fi
else
SUMMARIZE_CMD =
endif
SRCS = $(wildcard *.cpp)
TARGETS = $(patsubst %.cpp,%,$(SRCS))
# OPTFLAGS = -O0
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CPPFLAGS = -I../ -I../../include -I../../linux -I$(TOKUROOT)toku_include -DUSE_ENV
CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Werror -Wall $(OPTFLAGS) -g $(GCOV_FLAGS)
LDLIBS = ../../lib/libtokudb_cxx.a -ltokudb -lz -lpthread -ltokuportability
RPATH_DIRS=$(TOKUROOT)lib
ifeq ($(CC),icc)
CXXFLAGS += -diag-disable 981
CXX=icc
endif
ifneq ($(OSX),)
VGRIND=
else
VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes --suppressions=../../ft/valgrind.suppressions
endif
default: build
build all: $(TARGETS)
$(TARGETS): $(DBCXX)
$(DBCXX):
cd ..;make
clean:
rm -rf $(TARGETS) *.gcno *.gcda *.gcov *.db dir.test.db.assoc3 test_reverse_compare_fun.cpp.dir *.tdb.clean *.tdb.dirty
rm -rf *.dir
rm -rf *.out
rm -rf \
*.tokudb \
tokudb.environment \
tokudb.directory \
test_no_env \
#this line left blank
check_test1: test1
$(VGRIND) ./$< $(SUMMARIZE_CMD)
check_test_errpfx: test_errpfx
$(VGRIND) ./$< > errpfxactual.out && \
(echo "Prefix: Hello Name!";echo -n ": Success") > errpfxexpect.out && \
diff errpfxactual.out errpfxexpect.out \
$(SUMMARIZE_CMD)
check_test_db_assoc3: test_db_assoc3
$(VGRIND) ./test_db_assoc3 && \
$(VGRIND) ./test_db_assoc3 --more \
$(SUMMARIZE_CMD)
check_test_cursor_count: test_cursor_count
$(VGRIND) ./test_cursor_count $(MAYBEINVERTER) $(SUMMARIZE_CMD)
check_test_error_stream: test_error_stream
$(VGRIND) ./test_error_stream 2> $@.out $(SUMMARIZE_CMD)
check_test1e: test1e
$(VGRIND) ./test1e > test1eactual.out && \
(echo "Prefix: Hello Name!";echo -n ": Success") > test1expect.out
diff test1eactual.out test1expect.out \
$(SUMMARIZE_CMD)
check_create_dump_diff: db_create db_dump db_dump_e
rm -rf $@.dir
mkdir $@.dir
$(VGRIND) ./db_create --env_dir $@.dir cdd.tdb a b c d && \
$(VGRIND) ./db_dump --env_dir $@.dir cdd.tdb > cdd.out && \
(echo " 61";echo " 62";echo " 63";echo " 64")>cddexpect.out && \
diff cdd.out cddexpect.out && \
$(VGRIND) ./db_dump_e --env_dir $@.dir cdd.tdb > cdd.out && \
diff cdd.out cddexpect.out \
$(SUMMARIZE_CMD)
check_test_reverse_compare_fun: test_reverse_compare_fun
$(VGRIND) ./test_reverse_compare_fun $(SUMMARIZE_CMD)
check: $(TARGETS) \
check_create_dump_diff \
check_test1 \
check_test_errpfx \
check_test_cursor_count \
check_test_error_stream \
check_test_reverse_compare_fun \
check_test1e \
check_db_create \
check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4 \
check_permissions \
check_exceptions \
check_test_db_delete \
check_test_get_not_found \
# line intentionally left blank
check_test_get_not_found: test_get_not_found
$(VGRIND) ./test_get_not_found $(SUMMARIZE_CMD)
check_test_db_delete: test_db_delete
$(VGRIND) ./test_db_delete $(SUMMARIZE_CMD)
check_exceptions: exceptions
$(VGRIND) ./exceptions $(MAYBEINVERTER) $(SUMMARIZE_CMD)
check_db_create: db_create
rm -rf $@.dir
mkdir $@.dir
$(VGRIND) ./db_create --env_dir $@.dir -s main $@.tdb $(SUMMARIZE_CMD)
# These don't need to set the env dir
check_db_create_1: db_create
$(VGRIND) ./db_create &> $@.out ; test $$? -ne 0 $(SUMMARIZE_CMD)
check_db_create_2: db_create
$(VGRIND) ./db_create -h &> $@.out ; test $$? -ne 0 $(SUMMARIZE_CMD)
check_db_create_3: db_create
$(VGRIND) ./db_create --help &> $@.out; test $$? -ne 0 $(SUMMARIZE_CMD)
check_db_create_4: db_create
$(VGRIND) ./db_create -s &> $@.out ; test $$? -ne 0 $(SUMMARIZE_CMD)
check_permissions: db_create
rm -rf $@.dir && mkdir $@.dir && \
./db_create --env_dir $@.dir permissions.tdb 1 1 && \
chmod -w $@.dir/*.tokudb && \
(./db_create --env_dir $@.dir permissions.tdb 2 2 &> check_permissions.out 2>&1 ; test $$? -ne 0) \
$(SUMMARIZE_CMD)
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <assert.h>
#include <db_cxx.h>
char *data_dir, *env_dir=NULL;
static int dbcreate(char *dbfile, char *dbname, int dbflags, int argc, char *argv[]) {
int r;
DbEnv *env = new DbEnv(DB_CXX_NO_EXCEPTIONS);
if (data_dir) {
r = env->set_data_dir(data_dir); assert(r == 0);
}
r = env->set_redzone(0); assert(r==0);
r = env->open(env_dir ? env_dir : ".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
Db *db = new Db(env, DB_CXX_NO_EXCEPTIONS);
r = db->set_flags(dbflags); assert(r == 0);
r = db->open(0, dbfile, dbname, DB_BTREE, DB_CREATE, 0777);
if (r != 0) {
printf("db->open %s(%s) %d %s\n", dbfile, dbname, r, db_strerror(r));
db->close(0); delete db;
env->close(0); delete env;
return 1;
}
int i = 0;
while (i < argc) {
char *k = argv[i++];
if (i < argc) {
char *v = argv[i++];
Dbt key(k, strlen(k)); Dbt val(v, strlen(v));
r = db->put(0, &key, &val, 0); assert(r == 0);
}
}
r = db->close(0); assert(r == 0);
delete db;
r = env->close(0); assert(r == 0);
delete env;
return 0;
}
static int usage() {
fprintf(stderr, "db_create [-s DBNAME] DBFILE [KEY VAL]*\n");
fprintf(stderr, "[--set_data_dir DIRNAME]\n");
return 1;
}
int main(int argc, char *argv[]) {
char *dbname = 0;
int dbflags = 0;
int i;
for (i=1; i<argc; i++) {
char *arg = argv[i];
if (0 == strcmp(arg, "-h") || 0 == strcmp(arg, "--help"))
return usage();
if (0 == strcmp(arg, "-s")) {
if (i+1 >= argc)
return usage();
dbname = argv[++i];
continue;
}
if (0 == strcmp(arg, "--env_dir")) {
if (i+1 >= argc)
return usage();
env_dir = argv[++i];
continue;
}
if (0 == strcmp(arg, "--set_data_dir")) {
if (i+1 >= argc)
return usage();
data_dir = argv[++i];
continue;
}
if (arg[0]=='-') {
printf("I don't understand this argument: %s\n", arg);
return 1;
}
break;
}
if (i >= argc)
return usage();
char *dbfile = argv[i++];
return dbcreate(dbfile, dbname, dbflags, argc-i, &argv[i]);
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdlib.h>
#include <assert.h>
#include <db_cxx.h>
#include <memory.h>
static void hexdump(Dbt *d) {
unsigned char *cp = (unsigned char *) d->get_data();
int n = d->get_size();
printf(" ");
for (int i=0; i<n; i++)
printf("%2.2x", cp[i]);
printf("\n");
}
static int dbdump(const char *env_dir, const char *dbfile, const char *dbname) {
int r;
#if defined(USE_ENV) && USE_ENV
DbEnv env(DB_CXX_NO_EXCEPTIONS);
r = env.set_redzone(0); assert(r==0);
r = env.open(env_dir, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
Db db(&env, DB_CXX_NO_EXCEPTIONS);
#else
Db db(0, DB_CXX_NO_EXCEPTIONS);
#endif
r = db.open(0, dbfile, dbname, DB_UNKNOWN, 0, 0777);
if (r != 0) {
printf("cant open %s:%s %d:%s\n", dbfile, dbname, r, db_strerror(r));
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 1;
}
u_int32_t dbflags;
r = db.get_flags(&dbflags); assert(r == 0);
#ifndef TOKUDB
if (dbflags & DB_DUP)
printf("duplicates=1\n");
if (dbflags & DB_DUPSORT)
printf("dupsort=1\n");
#endif
#if 0
u_int32_t nodesize;
r = db.get_nodesize(&nodesize); assert(r == 0);
printf("nodesize=%d\n", nodesize);
#endif
Dbc *cursor;
r = db.cursor(0, &cursor, 0); assert(r == 0);
Dbt key; key.set_flags(DB_DBT_REALLOC);
Dbt val; val.set_flags(DB_DBT_REALLOC);
for (;;) {
r = cursor->get(&key, &val, DB_NEXT);
if (r != 0) break;
// printf("%.*s\n", key.get_size(), (char *)key.get_data());
hexdump(&key);
// printf("%.*s\n", val.get_size(), (char *)val.get_data());
hexdump(&val);
}
if (key.get_data()) toku_free(key.get_data());
if (val.get_data()) toku_free(val.get_data());
r = cursor->close(); assert(r == 0);
r = db.close(0); assert(r == 0);
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 0;
}
static int usage() {
printf("db_dump [-s DBNAME] DBFILE\n");
return 1;
}
int main(int argc, const char *argv[]) {
const char *dbname = 0;
const char *env_dir = ".";
int i;
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-h") || 0 == strcmp(arg, "--help"))
return usage();
if (0 == strcmp(arg, "-s")) {
if (i+1 >= argc)
return usage();
dbname = argv[++i];
continue;
}
if (0 == strcmp(arg, "--env_dir")) {
if (i+1 >= argc)
return usage();
env_dir = argv[++i];
continue;
}
break;
}
if (i >= argc)
return usage();
return dbdump(env_dir, argv[i], dbname);
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
/* Just like db_dump.cpp except use exceptions. */
#include <stdlib.h>
#include <assert.h>
#include <db_cxx.h>
#include <memory.h>
static void hexdump(Dbt *d) {
unsigned char *cp = (unsigned char *) d->get_data();
int n = d->get_size();
printf(" ");
for (int i=0; i<n; i++)
printf("%2.2x", cp[i]);
printf("\n");
}
static int dbdump(const char *env_dir, const char *dbfile, const char *dbname) {
int r;
#if defined(USE_ENV) && USE_ENV
DbEnv env(0);
r = env.set_redzone(0); assert(r==0);
r = env.open(env_dir, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
Db db(&env, 0);
#else
Db db(0, 0);
#endif
try {
r = db.open(0, dbfile, dbname, DB_BTREE, 0, 0777);
assert(r==0);
} catch (DbException e) {
printf("Cannot open %s:%s due to error %d\n", dbfile, dbname, e.get_errno());
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 1;
}
Dbc *cursor;
r = db.cursor(0, &cursor, 0); assert(r == 0);
Dbt key; key.set_flags(DB_DBT_REALLOC);
Dbt val; val.set_flags(DB_DBT_REALLOC);
try {
for (;;) {
r = cursor->get(&key, &val, DB_NEXT);
if (r == DB_NOTFOUND) break;
assert(r==0);
// printf("%.*s\n", key.get_size(), (char *)key.get_data());
hexdump(&key);
// printf("%.*s\n", val.get_size(), (char *)val.get_data());
hexdump(&val);
}
} catch (DbException ) {
/* Nothing, that's just how we got out of the loop. */
}
toku_free(key.get_data());
toku_free(val.get_data());
r = cursor->close(); assert(r == 0);
r = db.close(0); assert(r == 0);
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 0;
}
static int usage() {
printf("db_dump [-s DBNAME] DBFILE\n");
return 1;
}
int main(int argc, char *argv[]) {
int i;
const char *env_dir = ".";
const char *dbname = 0;
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-h") || 0 == strcmp(arg, "--help"))
return usage();
if (0 == strcmp(arg, "-s")) {
i++;
if (i >= argc)
return usage();
dbname = argv[i];
continue;
}
if (0 == strcmp(arg, "--env_dir")) {
if (i+1 >= argc)
return usage();
env_dir = argv[++i];
continue;
}
break;
}
if (i >= argc)
return usage();
return dbdump(env_dir, argv[i], dbname);
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdlib.h>
#include <assert.h>
#include <db_cxx.h>
#include <memory.h>
static inline void hexdump(Dbt *d) {
unsigned char *cp = (unsigned char *) d->get_data();
int n = d->get_size();
printf(" ");
for (int i=0; i<n; i++)
printf("%2.2x", cp[i]);
printf("\n");
}
static void hexput(Dbt *d, int c) {
unsigned char *cp = (unsigned char *) d->get_data();
int n = d->get_size();
int ulen = d->get_ulen();
if (n+1 >= ulen) {
int newulen = ulen == 0 ? 1 : ulen*2;
cp = (unsigned char *) toku_realloc(cp, newulen); assert(cp);
d->set_data(cp);
d->set_ulen(newulen);
}
cp[n++] = (unsigned char)c;
d->set_size(n);
}
static int hextrans(int c) {
if ('0' <= c && c <= '9') return c - '0';
if ('a' <= c && c <= 'f') return c - 'a' + 10;
if ('A' <= c && c <= 'F') return c - 'A' + 10;
return 0;
}
static int hexload(Dbt *d) {
d->set_size(0);
int c = getchar();
if (c == EOF || c != ' ') return 0;
for (;;) {
int c0 = getchar();
if (c0 == EOF) return 0;
if (c0 == '\n') break;
int c1 = getchar();
if (c1 == EOF) return 0;
if (c1 == '\n') break;
hexput(d, (hextrans(c0) << 4) + hextrans(c1));
}
return 1;
}
static int dbload(const char *envdir, const char *dbfile, const char *dbname) {
int r;
#if defined(USE_ENV) && USE_ENV
DbEnv env(DB_CXX_NO_EXCEPTIONS);
r = env.open(envdir, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
Db db(&env, DB_CXX_NO_EXCEPTIONS);
#else
Db db(0, DB_CXX_NO_EXCEPTIONS);
#endif
r = db.open(0, dbfile, dbname, DB_BTREE, DB_CREATE, 0777);
if (r != 0) {
printf("cant open %s:%s\n", dbfile, dbname);
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 1;
}
Dbt key, val;
for (;;) {
if (!hexload(&key)) break;
// hexdump(&key);
if (!hexload(&val)) break;
// hexdump(&val);
r = db.put(0, &key, &val, 0);
assert(r == 0);
}
if (key.get_data()) toku_free(key.get_data());
if (val.get_data()) toku_free(val.get_data());
r = db.close(0); assert(r == 0);
#if defined(USE_ENV) && USE_ENV
r = env.close(0); assert(r == 0);
#endif
return 0;
}
static int usage() {
printf("db_load [-s DBNAME] DBFILE\n");
return 1;
}
int main(int argc, const char *argv[]) {
int i;
const char *dbname = 0;
const char *env_dir = ".";
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-h") || 0 == strcmp(arg, "--help"))
return usage();
if (0 == strcmp(arg, "-s")) {
i++;
if (i >= argc)
return usage();
dbname = argv[i];
continue;
}
if (0 == strcmp(arg, "--env_dir")) {
if (i+1 >= argc)
return usage();
env_dir = argv[++i];
continue;
}
break;
}
if (i >= argc)
return usage();
return dbload(env_dir, argv[i], dbname);
}
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <iostream>
using namespace std;
void test_dbt(void) {
u_int32_t size = 3;
u_int32_t flags = 5;
u_int32_t ulen = 7;
void* data = &size;
Dbt dbt;
dbt.set_size(size);
dbt.set_flags(flags);
dbt.set_data(data);
dbt.set_ulen(ulen);
assert(dbt.get_size() == size);
assert(dbt.get_flags() == flags);
assert(dbt.get_data() == data);
assert(dbt.get_ulen() == ulen);
}
int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) {
return 0;
}
void test_db(void) {
DbEnv env(DB_CXX_NO_EXCEPTIONS);
{ int r = env.set_redzone(0); assert(r==0); }
{ int r = env.set_default_bt_compare(cmp); assert(r == 0); }
int r = env.open("test1.dir", DB_CREATE|DB_PRIVATE, 0666);
assert(r==0);
Db db(&env, 0);
r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT);
// The db is closed
r = env.close(0); assert(r== 0);
}
int main()
{
system("rm -rf test1.dir");
mkdir("test1.dir", 0777);
test_dbt();
test_db();
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <iostream>
using namespace std;
int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) {
return 0;
}
#define DIR "test1e.dir"
void test_db(void) {
system("rm -rf " DIR);
mkdir(DIR, 0777);
DbEnv env(0);
{ int r = env.set_redzone(0); assert(r==0); }
{ int r = env.set_default_bt_compare(cmp); assert(r == 0); }
env.open(DIR, DB_CREATE|DB_PRIVATE, 0666);
Db db(&env, 0);
try {
db.remove("DoesNotExist.db", NULL, 0);
abort(); // must not make it here.
} catch (DbException e) {
assert(e.get_errno() == ENOENT);
}
// The db is closed.
env.close(0);
}
void test_db_env(void) {
DbEnv dbenv(0);
int r;
r = dbenv.set_data_dir("."); assert(r == 0);
try {
r = dbenv.set_data_dir(NULL);
abort();
} catch (DbException e) {
assert(e.get_errno() == EINVAL);
}
dbenv.set_errpfx("Prefix");
dbenv.set_errfile(stdout);
dbenv.err(0, "Hello %s!\n", "Name");
dbenv.close(0);
}
int main()
{
test_db();
test_db_env();
return 0;
}
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdio.h>
#include <assert.h>
#include <db_cxx.h>
#include <stdlib.h>
#include <memory.h>
#define DIR __FILE__ ".dir"
#define FNAME "test.tdb"
void test_new_delete() {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0);
{ int r = env.set_redzone(0); assert(r==0); }
{ int r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); }
Db *db = new Db(&env, 0); assert(db != 0);
delete db;
}
void test_new_open_delete() {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0);
{ int r = env.set_redzone(0); assert(r==0); }
{ int r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); }
Db *db = new Db(&env, 0); assert(db != 0);
{ int r = db->open(NULL, FNAME, 0, DB_BTREE, DB_CREATE, 0777); assert(r == 0); }
{ int r = db->close(0); assert(r == 0); }
delete db;
}
int main() {
test_new_delete();
test_new_open_delete();
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <assert.h>
#include <db_cxx.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int r;
DbEnv env(DB_CXX_NO_EXCEPTIONS);
r = env.set_flags(0, 0); assert(r == 0);
r = env.set_flags(0, 1); assert(r == 0);
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <iostream>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <db_cxx.h>
#include <memory.h>
int verbose;
#define DIR __FILE__ ".dir"
#define FNAME "test.tdb"
int test_error_stream(void) {
int r;
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(DB_CXX_NO_EXCEPTIONS);
env.set_errpfx("my_env_error_stream");
env.set_error_stream(&std::cerr);
r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == EINVAL);
Db db(&env, 0);
db.set_errpfx("my_db_error_stream");
db.set_error_stream(&std::cerr);
r = db.open(NULL, FNAME, 0, DB_BTREE, DB_CREATE, 0777); assert(r == 0);
r = db.close(0); assert(r == 0);
r = db.close(0); assert(r == EINVAL);
r = env.close(0); assert(r == 0);
r = env.close(0); assert(r == EINVAL);
return 0;
}
int usage() {
printf("test_error_stream [-v] [--verbose]\n");
return 1;
}
int main(int argc, char *argv[]) {
for (int i=1; i<argc; i++) {
char *arg = argv[i];
if (0 == strcmp(arg, "-h") || 0 == strcmp(arg, "--help")) {
return usage();
}
if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose")) {
verbose = 1; continue;
}
}
return test_error_stream();
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
#include <errno.h>
#include <assert.h>
#include <iostream>
using namespace std;
void test_db_env(void) {
DbEnv dbenv(DB_CXX_NO_EXCEPTIONS);
int r;
r = dbenv.set_data_dir(".."); assert(r == 0);
r = dbenv.set_data_dir(NULL); assert(r == EINVAL);
dbenv.set_errpfx("Prefix");
dbenv.set_errfile(stdout);
dbenv.err(0, "Hello %s!\n", "Name");
}
int main()
{
test_db_env();
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
/* This test ensures that a db->get DB_NOTFOUND does not cause an
exception when exceptions are enabled, which is consistent with
Berkeley DB */
#include <db_cxx.h>
#include <assert.h>
#include <stdlib.h>
#include <memory.h>
#define DIR __FILE__ ".dir"
#define fname "foo.tdb"
void db_put(Db *db, int k, int v) {
Dbt key(&k, sizeof k);
Dbt val(&v, sizeof v);
int r = db->put(0, &key, &val, 0);
assert(r == 0);
}
void db_del(Db *db, int k) {
Dbt key(&k, sizeof k);
int r = db->del(0, &key, 0);
assert(r == 0);
}
void db_get(Db *db, int k, int v, int expectr) {
Dbt key(&k, sizeof k);
Dbt val; val.set_data(&v); val.set_ulen(sizeof v); val.set_flags(DB_DBT_USERMEM);
int r = db->get(0, &key, &val, 0);
assert(r == expectr);
if (r == 0) {
assert(val.get_size() == sizeof v);
int vv;
memcpy(&vv, val.get_data(), val.get_size());
assert(vv == v);
}
}
DbEnv *env = NULL;
void reset_env (void) {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
if (env) delete env;
env = new DbEnv(DB_CXX_NO_EXCEPTIONS);
{ int r = env->set_redzone(0); assert(r==0); }
int r = env->open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777);
assert(r == 0);
}
void test_not_found(void) {
int r;
reset_env();
Db *db = new Db(env, DB_CXX_NO_EXCEPTIONS); assert(db);
r = db->open(0, fname, 0, DB_BTREE, DB_CREATE, 0777); assert(r == 0);
db_put(db, 1, 2);
db_get(db, 1, 2, 0);
db_del(db, 1);
db_get(db, 1, 0, DB_NOTFOUND);
r = db->close(0); assert(r == 0);
delete db;
}
void test_exception_not_found(void) {
int r;
reset_env();
Db *db = new Db(env, 0); assert(db);
r = db->open(0, fname, 0, DB_BTREE, DB_CREATE, 0777); assert(r == 0);
db_put(db, 1, 2);
db_get(db, 1, 2, 0);
db_del(db, 1);
try {
db_get(db, 1, 0, DB_NOTFOUND);
} catch(...) {
assert(0);
}
r = db->close(0); assert(r == 0);
delete db;
}
int main(int argc, char *argv[]) {
test_not_found();
test_exception_not_found();
if (env) delete env;
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
/* try a reverse compare function to verify that the database always uses the application's
compare function */
#include <arpa/inet.h>
#include <assert.h>
#include <db_cxx.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <memory.h>
#define DIR __FILE__ ".dir"
int verbose;
int keycompare (const void *key1, unsigned int key1len, const void *key2, unsigned int key2len) {
if (key1len==key2len) {
return memcmp(key1,key2,key1len);
} else if (key1len<key2len) {
int r = memcmp(key1,key2,key1len);
if (r<=0) return -1; /* If the keys are the same up to 1's length, then return -1, since key1 is shorter than key2. */
else return 1;
} else {
return -keycompare(key2,key2len,key1,key1len);
}
}
extern "C" int reverse_compare(DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
return -keycompare(a->data, a->size, b->data, b->size);
}
void expect(Dbc *cursor, int k, int v) {
Dbt key; key.set_flags(DB_DBT_MALLOC);
Dbt val; val.set_flags(DB_DBT_MALLOC);
int r = cursor->get(&key, &val, DB_NEXT);
assert(r == 0);
assert(key.get_size() == sizeof k);
int kk;
memcpy(&kk, key.get_data(), key.get_size());
assert(val.get_size() == sizeof v);
int vv;
memcpy(&vv, val.get_data(), val.get_size());
if (kk != k || vv != v) printf("expect key %d got %d - %d %d\n", htonl(k), htonl(kk), htonl(v), htonl(vv));
assert(kk == k);
assert(vv == v);
toku_free(key.get_data());
toku_free(val.get_data());
}
void test_reverse_compare(int n) {
if (verbose) printf("test_reverse_compare:%d\n", n);
Db *db;
DbTxn * const null_txn = 0;
const char * const fname = "reverse.compare.db";
int r;
int i;
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
/* create the dup database file */
DbEnv env(DB_CXX_NO_EXCEPTIONS);
r = env.set_redzone(0); assert(r==0);
r = env.set_default_bt_compare(reverse_compare);
assert(r == 0);
r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
db = new Db(&env, DB_CXX_NO_EXCEPTIONS);
assert(db);
r = db->set_pagesize(4096);
assert(r == 0);
r = db->open(null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
assert(r == 0);
/* insert n unique keys {0, 1, n-1} */
for (i=0; i<n; i++) {
int k, v;
k = htonl(i);
Dbt key(&k, sizeof k);
v = htonl(i);
Dbt val(&v, sizeof v);
r = db->put(null_txn, &key, &val, 0);
assert(r == 0);
}
/* reopen the database to force nonleaf buffering */
r = db->close(0);
assert(r == 0);
delete db;
db = new Db(&env, 0);
assert(db);
r = db->set_pagesize(4096);
assert(r == 0);
r = db->open(null_txn, fname, "main", DB_BTREE, 0, 0666);
assert(r == 0);
/* insert n unique keys {n, n+1, 2*n-1} */
for (i=n; i<2*n; i++) {
int k, v;
k = htonl(i);
Dbt key(&k, sizeof k);
v = htonl(i);
Dbt val(&v, sizeof v);
r = db->put(null_txn, &key, &val, 0);
assert(r == 0);
}
/* verify the sort order with a cursor */
Dbc *cursor;
r = db->cursor(null_txn, &cursor, 0);
assert(r == 0);
//for (i=0; i<2*n; i++)
for (i=2*n-1; i>=0; i--)
expect(cursor, htonl(i), htonl(i));
r = cursor->close();
assert(r == 0);
r = db->close(0);
assert(r == 0);
delete db;
}
int main(int argc, const char *argv[]) {
int i;
for (i = 1; i <= (1<<16); i *= 2) {
test_reverse_compare(i);
}
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <db_cxx.h>
DbTxn::DbTxn(DB_TXN *txn)
: the_txn(txn)
{
txn->api_internal = this;
}
DbTxn::~DbTxn()
{
if (the_txn) {
the_txn->abort(0);
}
}
int DbTxn::commit (u_int32_t flags) {
DbEnv *env = (DbEnv*)the_txn->mgrp->api1_internal; // Must grab the env before committing the txn (because that releases the txn memory.)
int ret = the_txn->commit(the_txn, flags);
the_txn=0; // So we don't touch it my mistake.
return env->maybe_throw_error(ret);
}
int DbTxn::abort () {
DbEnv *env = (DbEnv*)the_txn->mgrp->api1_internal; // Must grab the env before committing the txn (because that releases the txn memory.)
int ret = the_txn->abort(the_txn);
the_txn=0; // So we don't touch it my mistake.
return env->maybe_throw_error(ret);
}
# -*- Mode: Makefile -*-
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
# standard build: make
# build with Berkeley DB 4.1: make BDBDIR=/usr/local/BerkeleyDB.4.1
# build with TokuDB: make BDBDIR=~/svn/tokudb
# build with g++: make CC=g++
.DEFAULT_GOAL= build
TOKUROOT=../
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)include -I$(TOKUROOT)toku_include -I$(TOKUROOT)ft -I../range_tree -I../lock_tree
DEPEND_COMPILE += \
./*.h \
#end
HERE = db-benchmark-test-cxx
include $(TOKUROOT)toku_include/Makefile.include
BENCHDBS = bench.bdb/ bench.tokudb
OPTFLAGS = -O2
CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS)
ifeq ($(CC),icc)
CXX=icc
endif
# CFLAGS += -pg
ifdef BDBDIR
BDB_CPPFLAGS = -I$(BDBDIR)/include -DHAVE_CXX_STDHEADERS
BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb_cxx -Wl,-rpath,$(BDBDIR)/lib -ldl
else
BDB_CPPFLAGS =
BDB_LDFLAGS = -ldb_cxx
endif
BDB_LDFLAGS += -lpthread -L../lib -Wl,-rpath,$(PWD)/../lib -ltokuportability
TARGET_BDB = db-benchmark-test-bdb
TARGET_TDB = db-benchmark-test-tokudb
TARGETS = $(TARGET_BDB) $(TARGET_TDB)
HERE = db-benchmark-test-cxx
ifeq ($(SUMMARIZE),1)
SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sPASS\n" $(HERE)/$@; else printf "%-60sFAIL\n" $(HERE)/$@ ; test 0 = 1; fi
QUIET = -q
else
SUMMARIZE_CMD =
QUIET =
endif
default: build
build: $(TARGETS)
check: check-default
check-default: $(TARGET_TDB)
$(VGRIND) ./$(TARGET_TDB) $(QUIET) $(SUMMARIZE_CMD)
check-x: $(TARGET_TDB)
$(VGRIND) ./$(TARGET_TDB) -x $(QUIET) $(SUMMARIZE_CMD)
clean:
rm -rf $(TARGETS) $(BENCHDBS) *.gcno *.gcda *.gcov
db-benchmark-test-tokudb: ../lib/libtokudb_cxx.a
db-benchmark-test-tokudb: db-benchmark-test.cpp
$(CXX) $(CXXFLAGS) -I../include -I../toku_include -L../lib -Wl,-rpath,$(PWD)/../lib $< -o $@ -ltokudb -ltokudb_cxx -DDIRSUF=tokudb -lz -lpthread -ltokuportability
db-benchmark-test-bdb: db-benchmark-test.cpp
$(CXX) $(CXXFLAGS) $(BDB_CPPFLAGS) $(BDB_LDFLAGS) $< -o $@ -DDIRSUF=bdb
This diff is collapsed.
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPRECATE_ERRNO)
set(both_bins
db-benchmark-test
scanscan
ptquery
txncommit
)
set(tokudbonly_bins
scanrace
multi-bench
db-verify
)
if(BDB_FOUND)
foreach(bdb_bin ${both_bins})
add_executable(${bdb_bin}-bdb ${bdb_bin})
set_property(TARGET ${bdb_bin}-bdb APPEND PROPERTY
COMPILE_DEFINITIONS "DIRSUF=bdb;TOKU_ALLOW_DEPRECATED;ENVDIR=\"${bdb_bin}.cc.bdb\"")
set_target_properties(${bdb_bin}-bdb PROPERTIES
INCLUDE_DIRECTORIES "${BDB_INCLUDE_DIR};${CMAKE_CURRENT_BINARY_DIR}/../toku_include;${CMAKE_CURRENT_SOURCE_DIR}/../toku_include;${CMAKE_CURRENT_SOURCE_DIR}/../portability;${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(${bdb_bin}-bdb ${LIBTOKUPORTABILITY} ${BDB_LIBRARIES})
add_space_separated_property(TARGET ${bdb_bin}-bdb COMPILE_FLAGS -fvisibility=hidden)
endforeach(bdb_bin)
endif()
foreach(tokudb_bin ${both_bins} ${tokudbonly_bins})
add_executable(${tokudb_bin}-tokudb ${tokudb_bin})
set_property(TARGET ${tokudb_bin}-tokudb APPEND PROPERTY
COMPILE_DEFINITIONS "TOKUDB;ENVDIR=\"${tokudb_bin}.cc.tdb\"")
target_link_libraries(${tokudb_bin}-tokudb ${LIBTOKUDB} ${LIBTOKUPORTABILITY})
add_space_separated_property(TARGET ${tokudb_bin}-tokudb COMPILE_FLAGS -fvisibility=hidden)
endforeach(tokudb_bin)
This diff is collapsed.
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdio.h>
#include <string.h>
#include <db.h>
#include "tokudb_common_funcs.h"
#include <assert.h>
static int verbose = 0;
static int env_open_flags_yesx = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL|DB_INIT_TXN|DB_INIT_LOG|DB_INIT_LOCK;
static int env_open_flags_nox = DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL;
int test_main(int argc, char * const argv[]) {
int r;
const char *envdir = "bench.tokudb";
const char *dbfilename = "bench.db";
bool do_txns = false;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
verbose++;
continue;
}
if (strcmp(argv[i], "-q") == 0) {
if (verbose > 0)
verbose--;
continue;
}
if (strcmp(argv[i], "-x") == 0) {
do_txns = true;
continue;
}
}
DB_ENV *env = NULL;
r = db_env_create(&env, 0);
assert(r == 0);
r = env->open(env, envdir, do_txns ? env_open_flags_yesx : env_open_flags_nox, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
assert(r == 0);
DB *db = NULL;
r = db_create(&db, env, 0);
assert(r == 0);
r = db->open(db, NULL, dbfilename, NULL, DB_BTREE, DB_AUTO_COMMIT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
assert(r == 0);
if (verbose) {
DB_BTREE_STAT64 s;
r = db->stat64(db, NULL, &s); assert(r == 0);
printf("nkeys=%" PRIu64 " dsize=%" PRIu64 "\n", s.bt_nkeys, s.bt_dsize);
}
r = db->verify_with_progress(db, NULL, NULL, verbose > 0, false);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
r = env->close(env, 0);
assert(r == 0);
return 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
#if !defined(TOKUDB_COMMON_FUNCS_H)
#define TOKUDB_COMMON_FUNCS_H
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include <db.h>
#include <memory.h>
#if defined(TOKUDB) && TOKU_WINDOWS
#include <ydb.h>
#endif
static int test_main (int argc, char *const argv[]);
int
main(int argc, char *const argv[]) {
int r;
#if defined(TOKUDB) && TOKU_WINDOWS
toku_ydb_init();
#endif
#if !defined(TOKUDB) && DB_VERSION_MINOR==4 && DB_VERSION_MINOR == 7
r = db_env_set_func_malloc(toku_malloc); assert(r==0);
r = db_env_set_func_free(toku_free); assert(r==0);
r = db_env_set_func_realloc(toku_realloc); assert(r==0);
#endif
r = test_main(argc, argv);
#if defined(TOKUDB) && TOKU_WINDOWS
toku_ydb_destroy();
#endif
return r;
}
static __attribute__((__unused__)) void
print_engine_status(DB_ENV * UU(env)) {
#if defined(TOKUDB)
int buffsize = 1024 * 128;
char buff[buffsize];
env->get_engine_status_text(env, buff, buffsize);
printf("Engine status:\n");
printf("%s", buff);
#endif
}
#endif /* #if !defined(TOKUDB_COMMON_H) */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
libtokudb.so
libtokudbtrace.so
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