Commit 54490d3c authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Simplify structures to keep track of whether data in an index is sorted. Refs #2654. [t:2654].

git-svn-id: file:///svn/toku/tokudb@20644 c7de825b-a66e-492c-adef-691d508d4ae1
parent 57fb43c9
...@@ -133,7 +133,6 @@ struct brtloader_s { ...@@ -133,7 +133,6 @@ 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. 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 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. 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. struct rowset *rows; // secondary rows that have been put, but haven't been sorted and written to a file.
......
...@@ -315,7 +315,6 @@ void toku_brtloader_internal_destroy (BRTLOADER bl, BOOL is_error) { ...@@ -315,7 +315,6 @@ void toku_brtloader_internal_destroy (BRTLOADER bl, BOOL is_error) {
destroy_merge_fileset(&bl->fs[i]); destroy_merge_fileset(&bl->fs[i]);
toku_free(bl->fs); toku_free(bl->fs);
toku_free(bl->rowset_is_sorted);
for (int i=0; i < bl->N; i++) { for (int i=0; i < bl->N; i++) {
toku_free(bl->last_key[i].data); toku_free(bl->last_key[i].data);
} }
...@@ -442,7 +441,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp, ...@@ -442,7 +441,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
MY_CALLOC_N(N, bl->rows); MY_CALLOC_N(N, bl->rows);
MY_CALLOC_N(N, bl->fs); MY_CALLOC_N(N, bl->fs);
MY_CALLOC_N(N, bl->rowset_is_sorted);
MY_CALLOC_N(N, bl->last_key); MY_CALLOC_N(N, bl->last_key);
for(int i=0;i<N;i++) { for(int i=0;i<N;i++) {
{ {
...@@ -450,7 +448,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp, ...@@ -450,7 +448,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
if (r!=0) { toku_brtloader_internal_destroy(bl, TRUE); return r; } if (r!=0) { toku_brtloader_internal_destroy(bl, TRUE); return r; }
} }
init_merge_fileset(&bl->fs[i]); 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. 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 { // note : currently brt_loader_init_error_callback always returns 0
...@@ -1380,6 +1377,8 @@ static int update_progress (int N, ...@@ -1380,6 +1377,8 @@ static int update_progress (int N,
CILK_BEGIN CILK_BEGIN
int sort_and_write_rows (struct rowset rows, struct merge_fileset *fs, BRTLOADER bl, int which_db, DB *dest_db, brt_compare_func compare) int sort_and_write_rows (struct rowset rows, struct merge_fileset *fs, BRTLOADER bl, int which_db, DB *dest_db, brt_compare_func compare)
/* Effect: Given a rowset, sort it and write it to a temporary file. /* Effect: Given a rowset, sort it and write it to a temporary file.
* Note: The loader maintains for each index the most recently written-to file, as well as the DBT for the last key written into that file.
* If this rowset is sorted and all greater than that dbt, then we append to the file (skipping the sort, and reducing the number of temporary files).
* Arguments: * Arguments:
* rows the rowset * rows the rowset
* fs the fileset into which the sorted data will be added * fs the fileset into which the sorted data will be added
......
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