2007-07-13 19:37:47 +00:00
|
|
|
#ifndef BRTTYPES_H
|
|
|
|
#define BRTTYPES_H
|
2007-11-29 14:18:54 +00:00
|
|
|
|
2008-01-24 15:10:32 +00:00
|
|
|
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
|
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
|
|
|
|
2007-11-21 13:07:49 +00:00
|
|
|
typedef struct brt *BRT;
|
|
|
|
struct brt_header;
|
|
|
|
struct wbuf;
|
|
|
|
|
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:18 -04:00
|
|
|
typedef struct s_blocknum { int64_t b; } BLOCKNUM; // make a struct so that we will notice type problems.
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-11-14 17:58:38 +00:00
|
|
|
/* Make the LSN be a struct instead of an integer so that we get better type checking. */
|
|
|
|
typedef struct __toku_lsn { u_int64_t lsn; } LSN;
|
|
|
|
#define ZERO_LSN ((LSN){0})
|
|
|
|
|
|
|
|
/* Make the FILEID a struct for the same reason. */
|
|
|
|
typedef struct __toku_fileid { u_int32_t fileid; } FILENUM;
|
|
|
|
|
2013-04-16 23:57:45 -04:00
|
|
|
#if !TOKU_WINDOWS && !defined(BOOL_DEFINED)
|
|
|
|
#define BOOL_DEFINED
|
2007-11-14 17:58:38 +00:00
|
|
|
typedef enum __toku_bool { FALSE=0, TRUE=1} 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;
|
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;
|
|
|
|
};
|
|
|
|
|
2007-11-22 21:11:21 +00:00
|
|
|
// The data that appears in the log to encode a brtheader. */
|
|
|
|
typedef struct loggedbrtheader {
|
|
|
|
u_int32_t size;
|
|
|
|
u_int32_t flags;
|
|
|
|
u_int32_t nodesize;
|
2013-04-16 23:57:18 -04:00
|
|
|
BLOCKNUM free_blocks;
|
|
|
|
BLOCKNUM unused_blocks;
|
2013-04-16 23:57:47 -04:00
|
|
|
BLOCKNUM root;
|
2013-04-16 23:57:44 -04:00
|
|
|
BLOCKNUM btt_size; // block translation table size
|
|
|
|
DISKOFF btt_diskoff;
|
|
|
|
struct logged_btt_pair *btt_pairs;
|
2013-04-16 23:57:41 -04:00
|
|
|
} LOGGEDBRTHEADER;
|
2007-11-22 21:11:21 +00:00
|
|
|
|
2007-12-04 10:02:59 +00:00
|
|
|
typedef struct intpairarray {
|
|
|
|
u_int32_t size;
|
|
|
|
struct intpair {
|
|
|
|
u_int32_t a,b;
|
|
|
|
} *array;
|
|
|
|
} INTPAIRARRAY;
|
|
|
|
|
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 */
|
|
|
|
enum brt_cmd_type {
|
|
|
|
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.
|
2008-02-29 20:47:11 +00:00
|
|
|
BRT_DELETE_BOTH = 3,
|
2008-04-07 01:30:25 +00:00
|
|
|
BRT_ABORT_ANY = 4, // Abort any commands on any matching key.
|
|
|
|
BRT_ABORT_BOTH = 5, // Abort commands that match both the key and the value
|
|
|
|
BRT_COMMIT_ANY = 6,
|
|
|
|
BRT_COMMIT_BOTH = 7
|
2008-02-29 20:47:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* tree commands */
|
|
|
|
struct brt_cmd {
|
|
|
|
enum brt_cmd_type type;
|
|
|
|
TXNID xid;
|
|
|
|
union {
|
|
|
|
/* insert or delete */
|
|
|
|
struct brt_cmd_insert_delete {
|
|
|
|
DBT *key;
|
|
|
|
DBT *val;
|
|
|
|
} id;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
typedef struct brt_cmd BRT_CMD_S, *BRT_CMD;
|
|
|
|
|
2013-04-16 23:57:22 -04:00
|
|
|
#if !defined(__cplusplus)
|
2013-04-16 23:57:21 -04:00
|
|
|
static inline
|
|
|
|
BRT_CMD_S
|
|
|
|
build_brt_cmd (enum brt_cmd_type type, TXNID xid, DBT *key, DBT *val) {
|
|
|
|
BRT_CMD_S result = {type, xid, .u.id={key,val}};
|
|
|
|
return result;
|
|
|
|
}
|
2013-04-16 23:57:22 -04:00
|
|
|
#endif
|
2013-04-16 23:57:21 -04:00
|
|
|
|
2008-03-14 19:14:31 +00:00
|
|
|
#define UU(x) x __attribute__((__unused__))
|
|
|
|
|
2008-04-22 20:39:50 +00:00
|
|
|
typedef struct leafentry *LEAFENTRY;
|
|
|
|
|
2007-07-13 19:37:47 +00:00
|
|
|
#endif
|