Commit 304631b9 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 bbcbd056
...@@ -202,7 +202,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[22]; void* __toku_dummy0[22];
char __toku_dummy1[96]; char __toku_dummy1[96];
......
...@@ -212,7 +212,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[25]; void* __toku_dummy0[25];
char __toku_dummy1[96]; char __toku_dummy1[96];
......
...@@ -215,7 +215,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[27]; void* __toku_dummy0[27];
char __toku_dummy1[96]; char __toku_dummy1[96];
......
...@@ -215,7 +215,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy0[30]; void* __toku_dummy0[30];
char __toku_dummy1[96]; char __toku_dummy1[96];
......
...@@ -219,7 +219,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy1[34]; void* __toku_dummy1[34];
char __toku_dummy2[80]; char __toku_dummy2[80];
......
...@@ -352,7 +352,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un ...@@ -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.*/", "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 (*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. */", "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 */", "int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */",
NULL}; NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra); print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
......
...@@ -219,7 +219,7 @@ struct __toku_db { ...@@ -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.*/; 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 (*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. */; 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 */; int (*set_descriptor) (DB*, const DBT*) /* set row/dictionary descriptor for a db. Available only while db is open */;
void* __toku_dummy1[34]; void* __toku_dummy1[34];
char __toku_dummy2[80]; char __toku_dummy2[80];
......
...@@ -168,7 +168,7 @@ struct brt_header { ...@@ -168,7 +168,7 @@ struct brt_header {
BLOCKNUM root; // roots of the dictionary BLOCKNUM root; // roots of the dictionary
struct remembered_hash root_hash; // hash of the root offset. struct remembered_hash root_hash; // hash of the root offset.
unsigned int flags; 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. 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) { ...@@ -1091,7 +1091,7 @@ toku_serialize_descriptor_contents_to_fd(int fd, DBT *desc, DISKOFF offset) {
} }
static void 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 offset;
DISKOFF size; DISKOFF size;
toku_get_descriptor_offset_size(h->blocktable, &offset, &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 ...@@ -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)); u_int32_t stored_x1764 = toku_dtoh32(*(int*)(dbuf + size-4));
assert(x1764 == stored_x1764); assert(x1764 == stored_x1764);
} }
desc->len = size-4; desc->size = size-4;
desc->data = dbuf; //Uses 4 extra bytes, but fast. 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 ...@@ -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->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)) { memcmp(t->h->descriptor.data, t->temp_descriptor.data, t->temp_descriptor.size)) {
DISKOFF offset; DISKOFF offset;
//4 for checksum //4 for checksum
...@@ -3040,16 +3041,13 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre ...@@ -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); 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 (r!=0) goto died_after_read_and_pin;
if (t->h->descriptor.data) toku_free(t->h->descriptor.data); if (t->h->descriptor.data) toku_free(t->h->descriptor.data);
t->h->descriptor.data = t->temp_descriptor.data; toku_fill_dbt(&t->h->descriptor, t->temp_descriptor.data, t->temp_descriptor.size);
t->h->descriptor.len = t->temp_descriptor.size;
t->temp_descriptor.data = NULL;
} }
else toku_free(t->temp_descriptor.data);
t->temp_descriptor.data = NULL;
t->did_set_descriptor = 0; t->did_set_descriptor = 0;
} }
if (t->db) { if (t->db) t->db->descriptor = &t->h->descriptor;
toku_fill_dbt(&t->db->descriptor, t->h->descriptor.data, t->h->descriptor.len);
}
assert(t->h);
//Opening a brt may restore to previous checkpoint. Truncate if necessary. //Opening a brt may restore to previous checkpoint. Truncate if necessary.
toku_maybe_truncate_cachefile_on_open(t->h->blocktable, t->h); toku_maybe_truncate_cachefile_on_open(t->h->blocktable, t->h);
......
...@@ -1134,7 +1134,7 @@ int toku_txn_note_brt (TOKUTXN txn, BRT brt) { ...@@ -1134,7 +1134,7 @@ int toku_txn_note_brt (TOKUTXN txn, BRT brt) {
return 0; 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; TOKUTXN txn = txnv;
BRT brt = brtv; BRT brt = brtv;
OMTVALUE brtv_again=NULL; OMTVALUE brtv_again=NULL;
...@@ -1142,6 +1142,7 @@ static int remove_brt (OMTVALUE txnv, u_int32_t UU(idx), void *brtv) { ...@@ -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); int r = toku_omt_find_zero(txn->open_brts, find_filenum, brt, &brtv_again, &index, NULL);
assert(r==0); assert(r==0);
assert((void*)brtv_again==brtv); assert((void*)brtv_again==brtv);
assert(index==idx);
r = toku_omt_delete_at(txn->open_brts, index); r = toku_omt_delete_at(txn->open_brts, index);
assert(r==0); assert(r==0);
return 0; return 0;
...@@ -1153,7 +1154,7 @@ int toku_txn_note_close_brt (BRT brt) { ...@@ -1153,7 +1154,7 @@ int toku_txn_note_close_brt (BRT brt) {
return 0; 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; BRT brt = brtv;
TOKUTXN txn = txnv; TOKUTXN txn = txnv;
OMTVALUE txnv_again=NULL; OMTVALUE txnv_again=NULL;
...@@ -1161,6 +1162,7 @@ static int remove_txn (OMTVALUE brtv, u_int32_t UU(idx), void *txnv) { ...@@ -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); int r = toku_omt_find_zero(brt->txns, find_xid, txn, &txnv_again, &index, NULL);
assert(r==0); assert(r==0);
assert((void*)txnv_again==txnv); assert((void*)txnv_again==txnv);
assert(index==idx);
r = toku_omt_delete_at(brt->txns, index); r = toku_omt_delete_at(brt->txns, index);
assert(r==0); assert(r==0);
return 0; return 0;
......
...@@ -37,7 +37,7 @@ int manual_truncate = 0; ...@@ -37,7 +37,7 @@ int manual_truncate = 0;
static void static void
verify_db_matches(void) { verify_db_matches(void) {
DBT * dbt = &db->descriptor; const DBT * dbt = db->descriptor;
if (last_open_descriptor<0) { if (last_open_descriptor<0) {
assert(dbt->size == 0 && dbt->data == NULL); 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