2007-07-13 19:37:47 +00:00
# ifndef BRTTYPES_H
# define BRTTYPES_H
2007-11-29 14:18:54 +00:00
2013-04-16 23:57:48 -04:00
# ident "$Id$"
2013-04-16 23:59:09 -04:00
# ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved."
2013-04-16 23:57:48 -04:00
# 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."
2007-11-29 14:18:54 +00:00
2007-11-14 17:58:38 +00:00
# include <sys/types.h>
2008-01-15 13:04:10 +00:00
# ifndef _XOPEN_SOURCE
2007-07-13 19:37:47 +00:00
# define _XOPEN_SOURCE 500
2008-01-15 13:04:10 +00:00
# endif
2007-07-13 19:37:47 +00:00
# define _FILE_OFFSET_BITS 64
2007-11-21 13:07:49 +00:00
2013-04-16 23:57:48 -04:00
# include <db.h>
2013-04-16 23:57:18 -04:00
# include <inttypes.h>
2008-02-29 20:47:11 +00:00
2013-04-16 23:59:09 -04:00
# if defined(__cplusplus) || defined(__cilkplusplus)
extern " C " {
# endif
2007-11-21 13:07:49 +00:00
typedef struct brt * BRT ;
2013-04-16 23:59:25 -04:00
typedef struct brtnode * BRTNODE ;
2013-04-16 23:59:40 -04:00
typedef struct brtnode_leaf_basement_node * BASEMENTNODE ;
2013-04-16 23:59:41 -04:00
typedef struct brtnode_nonleaf_childinfo * NONLEAF_CHILDINFO ;
2013-04-16 23:59:40 -04:00
typedef struct subtree_estimates * SUBTREE_EST ;
2007-11-21 13:07:49 +00:00
struct brt_header ;
struct wbuf ;
2013-04-16 23:59:22 -04:00
struct dbuf ;
2007-11-21 13:07:49 +00:00
2007-07-13 19:37:47 +00:00
typedef unsigned int ITEMLEN ;
typedef const void * bytevec ;
//typedef const void *bytevec;
2007-09-28 17:11:22 +00:00
2013-04-16 23:57:18 -04:00
typedef int64_t DISKOFF ; /* Offset in a disk. -1 is the NULL pointer. */
2007-11-22 20:30:38 +00:00
typedef u_int64_t TXNID ;
2013-04-16 23:57:56 -04:00
# define TXNID_NONE_LIVING ((TXNID)0)
2013-04-16 23:59:01 -04:00
# define TXNID_NONE ((TXNID)0)
2013-04-16 23:57:56 -04:00
2013-04-16 23:57:18 -04:00
typedef struct s_blocknum { int64_t b ; } BLOCKNUM ; // make a struct so that we will notice type problems.
2013-04-16 23:59:05 -04:00
# define ROLLBACK_NONE ((BLOCKNUM){0})
2013-04-16 23:57:18 -04:00
static inline BLOCKNUM make_blocknum ( int64_t b ) { BLOCKNUM result = { b } ; return result ; }
2007-09-28 17:11:22 +00:00
2007-11-22 07:13:08 +00:00
typedef struct {
2008-04-02 23:40:36 +00:00
u_int32_t len ;
2007-11-22 07:13:08 +00:00
char * data ;
2007-11-22 20:30:38 +00:00
} BYTESTRING ;
2007-11-22 07:13:08 +00:00
2013-04-16 23:59:40 -04:00
/* Log Sequence Number (LSN)
* Make the LSN be a struct instead of an integer so that we get better type checking . */
2007-11-14 17:58:38 +00:00
typedef struct __toku_lsn { u_int64_t lsn ; } LSN ;
# define ZERO_LSN ((LSN){0})
2013-04-16 23:57:56 -04:00
# define MAX_LSN ((LSN){UINT64_MAX})
2007-11-14 17:58:38 +00:00
2013-04-16 23:59:40 -04:00
/* Message Sequence Number (MSN)
* Make the MSN be a struct instead of an integer so that we get better type checking . */
typedef struct __toku_msn { u_int64_t msn ; } MSN ;
# define ZERO_MSN ((MSN){0}) // dummy used for message construction, to be filled in when msg is applied to tree
# define MIN_MSN ((MSN){(u_int64_t)1<<32}) // first 2**32 values reserved for messages created before Dr. No (for upgrade)
# define MAX_MSN ((MSN){UINT64_MAX})
2013-04-16 23:59:01 -04:00
/* At the brt layer, a FILENUM uniquely identifies an open file.
* At the ydb layer , a DICTIONARY_ID uniquely identifies an open dictionary .
* With the introduction of the loader ( ticket 2216 ) , it is possible for the file that holds
* an open dictionary to change , so these are now separate and independent unique identifiers .
*/
typedef struct { u_int32_t fileid ; } FILENUM ;
2013-04-16 23:58:59 -04:00
# define FILENUM_NONE ((FILENUM){UINT32_MAX})
2007-11-14 17:58:38 +00:00
2013-04-16 23:59:13 -04:00
typedef struct { u_int64_t dictid ; } DICTIONARY_ID ;
2013-04-16 23:59:01 -04:00
# define DICTIONARY_ID_NONE ((DICTIONARY_ID){0})
2013-04-16 23:58:58 -04:00
typedef struct {
u_int32_t num ;
FILENUM * filenums ;
} FILENUMS ;
2013-04-16 23:57:45 -04:00
# if !TOKU_WINDOWS && !defined(BOOL_DEFINED)
# define BOOL_DEFINED
2013-04-16 23:59:39 -04:00
# include <stdbool.h>
// typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
# define TRUE true
# define FALSE false
typedef bool BOOL ;
2013-04-16 23:57:27 -04:00
# endif
2007-11-14 17:58:38 +00:00
typedef struct tokulogger * TOKULOGGER ;
# define NULL_LOGGER ((TOKULOGGER)0)
typedef struct tokutxn * TOKUTXN ;
2013-04-16 23:59:05 -04:00
typedef struct txninfo * TXNINFO ;
2007-11-18 12:48:36 +00:00
# define NULL_TXN ((TOKUTXN)0)
2007-11-14 17:58:38 +00:00
2013-04-16 23:57:44 -04:00
struct logged_btt_pair {
DISKOFF off ;
int32_t size ;
} ;
2008-01-11 22:24:43 +00:00
typedef struct cachetable * CACHETABLE ;
typedef struct cachefile * CACHEFILE ;
2008-02-29 20:47:11 +00:00
/* tree command types */
2013-04-16 23:58:00 -04:00
enum brt_msg_type {
2008-02-29 20:47:11 +00:00
BRT_NONE = 0 ,
BRT_INSERT = 1 ,
2008-04-07 01:30:25 +00:00
BRT_DELETE_ANY = 2 , // Delete any matching key. This used to be called BRT_DELETE.
2013-04-16 23:59:21 -04:00
//BRT_DELETE_BOTH = 3,
2008-04-07 01:30:25 +00:00
BRT_ABORT_ANY = 4 , // Abort any commands on any matching key.
2013-04-16 23:59:21 -04:00
//BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value
2008-04-07 01:30:25 +00:00
BRT_COMMIT_ANY = 6 ,
2013-04-16 23:59:21 -04:00
//BRT_COMMIT_BOTH = 7,
2013-04-16 23:58:02 -04:00
BRT_COMMIT_BROADCAST_ALL = 8 , // Broadcast to all leafentries, (commit all transactions).
BRT_COMMIT_BROADCAST_TXN = 9 , // Broadcast to all leafentries, (commit specific transaction).
BRT_ABORT_BROADCAST_TXN = 10 , // Broadcast to all leafentries, (commit specific transaction).
2013-04-16 23:59:00 -04:00
BRT_INSERT_NO_OVERWRITE = 11 ,
2013-04-16 23:59:25 -04:00
BRT_OPTIMIZE = 12 , // Broadcast
BRT_OPTIMIZE_FOR_UPGRADE = 13 , // same as BRT_OPTIMIZE, but record version number in leafnode
2013-04-16 23:59:37 -04:00
BRT_UPDATE = 14 ,
BRT_UPDATE_BROADCAST_ALL = 15
2008-02-29 20:47:11 +00:00
} ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
typedef struct xids_t * XIDS ;
typedef struct fifo_msg_t * FIFO_MSG ;
2008-02-29 20:47:11 +00:00
/* tree commands */
2013-04-16 23:58:00 -04:00
struct brt_msg {
enum brt_msg_type type ;
2013-04-16 23:59:40 -04:00
MSN msn ; // message sequence number
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
XIDS xids ;
2008-02-29 20:47:11 +00:00
union {
/* insert or delete */
struct brt_cmd_insert_delete {
2013-04-16 23:59:37 -04:00
const DBT * key ; // for insert, delete, upsertdel
const DBT * val ; // for insert, delete, (and it is the "extra" for upsertdel, upsertdel_broadcast_all)
2008-02-29 20:47:11 +00:00
} id ;
} u ;
} ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
// Message sent into brt to implement command (insert, delete, etc.)
2013-04-16 23:58:00 -04:00
// This structure supports nested transactions, and obsoletes brt_msg.
2013-04-16 23:59:37 -04:00
typedef struct brt_msg BRT_MSG_S ;
typedef const struct brt_msg * BRT_MSG ;
2013-04-16 23:57:21 -04:00
2013-04-16 23:57:59 -04:00
typedef int ( * brt_compare_func ) ( DB * , const DBT * , const DBT * ) ;
2013-04-16 23:59:37 -04:00
typedef void ( * setval_func ) ( const DBT * , void * ) ;
typedef int ( * brt_update_func ) ( DB * , const DBT * , const DBT * , const DBT * , setval_func , void * ) ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
# define UU(x) x __attribute__((__unused__))
2008-04-22 20:39:50 +00:00
2013-04-16 23:59:05 -04:00
typedef struct memarena * MEMARENA ;
typedef struct rollback_log_node * ROLLBACK_LOG_NODE ;
2013-04-16 23:59:23 -04:00
//
// Types of snapshots that can be taken by a tokutxn
// - TXN_SNAPSHOT_NONE: means that there is no snapshot. Reads do not use snapshot reads.
// used for SERIALIZABLE and READ UNCOMMITTED
// - TXN_SNAPSHOT_ROOT: means that all tokutxns use their root transaction's snapshot
// used for REPEATABLE READ
// - TXN_SNAPSHOT_CHILD: means that each child tokutxn creates its own snapshot
// used for READ COMMITTED
//
2013-04-16 23:59:22 -04:00
typedef enum __TXN_SNAPSHOT_TYPE {
TXN_SNAPSHOT_NONE = 0 ,
TXN_SNAPSHOT_ROOT = 1 ,
TXN_SNAPSHOT_CHILD = 2
} TXN_SNAPSHOT_TYPE ;
2013-04-16 23:59:09 -04:00
# if defined(__cplusplus) || defined(__cilkplusplus)
} ;
# endif
2007-07-13 19:37:47 +00:00
# endif
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00