Commit 60812ccb authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1603 Row descriptor changed from DB->DBT to DB->DBT*

Will aid in having multiple DB handles to a single brt, which is needed to kill root fifo

git-svn-id: file:///svn/toku/tokudb@11157 c7de825b-a66e-492c-adef-691d508d4ae1
parent 23f171e4
......@@ -202,7 +202,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[22];
char __toku_dummy1[96];
......
......@@ -212,7 +212,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[25];
char __toku_dummy1[96];
......
......@@ -215,7 +215,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[27];
char __toku_dummy1[96];
......
......@@ -215,7 +215,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[30];
char __toku_dummy1[96];
......
......@@ -219,7 +219,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy1[34];
char __toku_dummy2[80];
......
......@@ -352,7 +352,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
"const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/",
"int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */",
"int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */",
"DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
"const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
"int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */",
NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
......
......@@ -219,7 +219,7 @@ struct __toku_db {
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*delboth) (DB*, DB_TXN*, DBT*, DBT*, u_int32_t) /* Delete the key/value pair. */;
int (*row_size_supported) (DB*, u_int32_t) /* Test whether a row size is supported. */;
DBT descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
const DBT *descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy1[34];
char __toku_dummy2[80];
......
......@@ -168,7 +168,7 @@ struct brt_header {
BLOCKNUM root; // roots of the dictionary
struct remembered_hash root_hash; // hash of the root offset.
unsigned int flags;
struct simple_dbt descriptor;
DBT descriptor;
FIFO fifo; // all the abort and commit commands. If the header gets flushed to disk, we write the fifo contents beyond the unused_memory.
......
......@@ -1091,7 +1091,7 @@ toku_serialize_descriptor_contents_to_fd(int fd, DBT *desc, DISKOFF offset) {
}
static void
deserialize_descriptor_from(int fd, struct brt_header *h, struct simple_dbt *desc) {
deserialize_descriptor_from(int fd, struct brt_header *h, DBT *desc) {
DISKOFF offset;
DISKOFF size;
toku_get_descriptor_offset_size(h->blocktable, &offset, &size);
......@@ -1113,7 +1113,7 @@ deserialize_descriptor_from(int fd, struct brt_header *h, struct simple_dbt *des
u_int32_t stored_x1764 = toku_dtoh32(*(int*)(dbuf + size-4));
assert(x1764 == stored_x1764);
}
desc->len = size-4;
desc->size = size-4;
desc->data = dbuf; //Uses 4 extra bytes, but fast.
}
}
......
......@@ -3031,8 +3031,9 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre
}
}
}
assert(t->h);
if (t->did_set_descriptor) {
if (t->h->descriptor.len!=t->temp_descriptor.size ||
if (t->h->descriptor.size!=t->temp_descriptor.size ||
memcmp(t->h->descriptor.data, t->temp_descriptor.data, t->temp_descriptor.size)) {
DISKOFF offset;
//4 for checksum
......@@ -3040,16 +3041,13 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre
r = toku_serialize_descriptor_contents_to_fd(toku_cachefile_fd(t->cf), &t->temp_descriptor, offset);
if (r!=0) goto died_after_read_and_pin;
if (t->h->descriptor.data) toku_free(t->h->descriptor.data);
t->h->descriptor.data = t->temp_descriptor.data;
t->h->descriptor.len = t->temp_descriptor.size;
t->temp_descriptor.data = NULL;
toku_fill_dbt(&t->h->descriptor, t->temp_descriptor.data, t->temp_descriptor.size);
}
else toku_free(t->temp_descriptor.data);
t->temp_descriptor.data = NULL;
t->did_set_descriptor = 0;
}
if (t->db) {
toku_fill_dbt(&t->db->descriptor, t->h->descriptor.data, t->h->descriptor.len);
}
assert(t->h);
if (t->db) t->db->descriptor = &t->h->descriptor;
//Opening a brt may restore to previous checkpoint. Truncate if necessary.
toku_maybe_truncate_cachefile_on_open(t->h->blocktable, t->h);
......
......@@ -1134,7 +1134,7 @@ int toku_txn_note_brt (TOKUTXN txn, BRT brt) {
return 0;
}
static int remove_brt (OMTVALUE txnv, u_int32_t UU(idx), void *brtv) {
static int remove_brt (OMTVALUE txnv, u_int32_t idx, void *brtv) {
TOKUTXN txn = txnv;
BRT brt = brtv;
OMTVALUE brtv_again=NULL;
......@@ -1142,6 +1142,7 @@ static int remove_brt (OMTVALUE txnv, u_int32_t UU(idx), void *brtv) {
int r = toku_omt_find_zero(txn->open_brts, find_filenum, brt, &brtv_again, &index, NULL);
assert(r==0);
assert((void*)brtv_again==brtv);
assert(index==idx);
r = toku_omt_delete_at(txn->open_brts, index);
assert(r==0);
return 0;
......@@ -1153,7 +1154,7 @@ int toku_txn_note_close_brt (BRT brt) {
return 0;
}
static int remove_txn (OMTVALUE brtv, u_int32_t UU(idx), void *txnv) {
static int remove_txn (OMTVALUE brtv, u_int32_t idx, void *txnv) {
BRT brt = brtv;
TOKUTXN txn = txnv;
OMTVALUE txnv_again=NULL;
......@@ -1161,6 +1162,7 @@ static int remove_txn (OMTVALUE brtv, u_int32_t UU(idx), void *txnv) {
int r = toku_omt_find_zero(brt->txns, find_xid, txn, &txnv_again, &index, NULL);
assert(r==0);
assert((void*)txnv_again==txnv);
assert(index==idx);
r = toku_omt_delete_at(brt->txns, index);
assert(r==0);
return 0;
......
......@@ -37,7 +37,7 @@ int manual_truncate = 0;
static void
verify_db_matches(void) {
DBT * dbt = &db->descriptor;
const DBT * dbt = db->descriptor;
if (last_open_descriptor<0) {
assert(dbt->size == 0 && dbt->data == NULL);
......
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