Commit 89f70142 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3081 simplify dbt initialization in the indexer closes[t:3081]

git-svn-id: file:///svn/toku/tokudb@26055 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7c200b09
......@@ -4,12 +4,19 @@
#include "includes.h"
DBT*
toku_init_dbt (DBT *ybt) {
DBT *
toku_init_dbt(DBT *ybt) {
memset(ybt, 0, sizeof(*ybt));
return ybt;
}
DBT *
toku_init_dbt_flags(DBT *ybt, uint32_t flags) {
toku_init_dbt(ybt);
ybt->flags = flags;
return ybt;
}
void
toku_destroy_dbt(DBT *dbt) {
switch (dbt->flags) {
......@@ -21,7 +28,7 @@ toku_destroy_dbt(DBT *dbt) {
}
}
DBT*
DBT *
toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
toku_init_dbt(dbt);
dbt->size=len;
......
......@@ -13,15 +13,16 @@
extern "C" {
#endif
DBT* toku_init_dbt (DBT *);
void toku_destroy_dbt (DBT *);
DBT *toku_init_dbt(DBT *);
DBT *toku_init_dbt_flags(DBT *, uint32_t flags);
void toku_destroy_dbt(DBT *);
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
int toku_dbt_set (ITEMLEN len, bytevec val, DBT *d, struct simple_dbt *sdbt);
int toku_dbt_set_value (DBT *, bytevec *val, ITEMLEN vallen, void **staticptrp, BOOL ybt1_disposable);
int toku_dbt_set(ITEMLEN len, bytevec val, DBT *d, struct simple_dbt *sdbt);
int toku_dbt_set_value(DBT *, bytevec *val, ITEMLEN vallen, void **staticptrp, BOOL ybt1_disposable);
void toku_sdbt_cleanup(struct simple_dbt *sdbt);
#if defined(__cplusplus) || defined(__cilkplusplus)
};
}
#endif
#endif
......@@ -53,10 +53,8 @@ indexer_commit_keys_add(struct indexer_commit_keys *keys, size_t length, void *p
int new_max_keys = keys->max_keys == 0 ? 256 : keys->max_keys * 2;
keys->keys = (DBT *) toku_realloc(keys->keys, new_max_keys * sizeof (DBT));
resource_assert(keys->keys);
for (int i = keys->current_keys; i < new_max_keys; i++) {
toku_init_dbt(&keys->keys[i]);
keys->keys[i].flags = DB_DBT_REALLOC;
}
for (int i = keys->current_keys; i < new_max_keys; i++)
toku_init_dbt_flags(&keys->keys[i], DB_DBT_REALLOC);
keys->max_keys = new_max_keys;
}
DBT *key = &keys->keys[keys->current_keys];
......@@ -89,8 +87,8 @@ static int indexer_is_xid_live(DB_INDEXER *indexer, TXNID xid);
void
indexer_undo_do_init(DB_INDEXER *indexer) {
indexer_commit_keys_init(&indexer->i->commit_keys);
toku_init_dbt(&indexer->i->hotkey); indexer->i->hotkey.flags = DB_DBT_REALLOC;
toku_init_dbt(&indexer->i->hotval); indexer->i->hotval.flags = DB_DBT_REALLOC;
toku_init_dbt_flags(&indexer->i->hotkey, DB_DBT_REALLOC);
toku_init_dbt_flags(&indexer->i->hotval, DB_DBT_REALLOC);
}
// destroy the undo globals
......
......@@ -224,8 +224,8 @@ static int
build_index(DB_INDEXER *indexer) {
int result = 0;
DBT key; toku_init_dbt(&key); key.flags = DB_DBT_REALLOC;
DBT le; toku_init_dbt(&le); le.flags = DB_DBT_REALLOC;
DBT key; toku_init_dbt_flags(&key, DB_DBT_REALLOC);
DBT le; toku_init_dbt_flags(&le, DB_DBT_REALLOC);
BOOL done = FALSE;
for (uint64_t loop_count = 0; !done; loop_count++) {
......
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