Commit 57fb43c9 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Add structures to keep track of whether data in an index is sorted. We aren't...

Add structures to keep track of whether data in an index is sorted.  We aren't maintaining it properly yet, but everything should work since we aren't using it.  Refs #2654. [t:2654].

git-svn-id: file:///svn/toku/tokudb@20640 c7de825b-a66e-492c-adef-691d508d4ae1
parent 03031696
......@@ -133,6 +133,9 @@ struct brtloader_s {
toku_pthread_t extractor_thread; // the thread that takes primary rowset and does extraction and the first level sort and write to file.
BOOL extractor_live;
BOOL *rowset_is_sorted; // for each rowset, is the rowset sorted?
DBT *last_key; // for each rowset, remember the most recently output key. The system may choose not to keep this up-to-date when a rowset is unsorted. These keys are malloced and ulen maintains the size of the malloced block.
struct rowset *rows; // secondary rows that have been put, but haven't been sorted and written to a file.
u_int64_t n_rows; // how many rows have been put?
struct merge_fileset *fs;
......
......@@ -315,6 +315,12 @@ void toku_brtloader_internal_destroy (BRTLOADER bl, BOOL is_error) {
destroy_merge_fileset(&bl->fs[i]);
toku_free(bl->fs);
toku_free(bl->rowset_is_sorted);
for (int i=0; i < bl->N; i++) {
toku_free(bl->last_key[i].data);
}
toku_free(bl->last_key);
destroy_rowset(&bl->primary_rowset);
for (int i=0; i<bl->N; i++) {
......@@ -436,12 +442,16 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
MY_CALLOC_N(N, bl->rows);
MY_CALLOC_N(N, bl->fs);
MY_CALLOC_N(N, bl->rowset_is_sorted);
MY_CALLOC_N(N, bl->last_key);
for(int i=0;i<N;i++) {
{
int r = init_rowset(&bl->rows[i], memory_per_rowset(bl));
if (r!=0) { toku_brtloader_internal_destroy(bl, TRUE); return r; }
}
init_merge_fileset(&bl->fs[i]);
bl->rowset_is_sorted[i] = TRUE; // empty rowsets are sorted.
bl->last_key[i].flags = DB_DBT_REALLOC; // don't really need this, but it's nice to maintain it. We use ulen to keep track of the realloced space.
}
{ // note : currently brt_loader_init_error_callback always returns 0
int r = brt_loader_init_error_callback(&bl->error_callback);
......@@ -469,7 +479,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
return 0;
}
// LAZY cleanup on error paths, ticket #2591
int toku_brt_loader_open (/* out */ BRTLOADER *blp,
CACHETABLE cachetable,
generate_row_for_put_func g,
......
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