diff --git a/c/containers/join_bucket_keeper.c b/c/containers/join_bucket_keeper.c index 007274a50..96daa6ee1 100644 --- a/c/containers/join_bucket_keeper.c +++ b/c/containers/join_bucket_keeper.c @@ -7,6 +7,20 @@ #include "containers/join_bucket_keeper.h" #include "input/lrec_readers.h" +// xxx overview here ... + +// +-----------+-----------+-----------+-----------+-----------+-----------+ +// | L R | L R | L R | L R | L R | L R | +// + --- --- + --- --- + --- --- + --- --- + --- --- + --- --- + +// | a | a | e | a | e e | e e | +// | b | e | e | e e | e | e e | +// | e | e | e | e | e | e | +// | e | e | f | e | f | g g | +// | e | f | g | g | g | g | +// | g | g | g | g | g | | +// | g | g | h | | | | +// +-----------+-----------+-----------+-----------+-----------+-----------+ + #define LEFT_STATE_0_PREFILL 0 #define LEFT_STATE_1_FULL 1 #define LEFT_STATE_2_LAST_BUCKET 2 @@ -191,8 +205,6 @@ static void join_bucket_keeper_fill(join_bucket_keeper_t* pkeeper) { // else ... parallel initial_fill. :) // Post-conditions: // * xxx -// * xxx -// * xxx static void join_bucket_keeper_advance_to(join_bucket_keeper_t* pkeeper, slls_t* pright_field_values, sllv_t** ppbucket_paired, sllv_t** ppbucket_left_unpaired) @@ -298,7 +310,8 @@ void join_bucket_keeper_print(join_bucket_keeper_t* pkeeper) { printf(" pvhandle = %p\n", pkeeper->pvhandle); context_print(pkeeper->pctx, " "); printf(" pleft_field_names = "); - slls_debug_print(pkeeper->pleft_field_names, stdout); // xxx remove stdout from api; xxx remove embedded "\n" + slls_print(pkeeper->pleft_field_names); + printf("\n"); join_bucket_print(pkeeper->pbucket, " "); printf(" prec_peek = "); if (pkeeper->prec_peek == NULL) { @@ -313,7 +326,8 @@ void join_bucket_keeper_print(join_bucket_keeper_t* pkeeper) { void join_bucket_print(join_bucket_t* pbucket, char* indent) { printf("%spbucket at %p:\n", indent, pbucket); printf("%s pleft_field_values = ", indent); - slls_debug_print(pbucket->pleft_field_values, stdout); + slls_print(pbucket->pleft_field_values); + printf("\n"); if (pbucket->precords == NULL) { printf("%s precords:\n", indent); printf("%s (null)\n", indent); @@ -324,30 +338,3 @@ void join_bucket_print(join_bucket_t* pbucket, char* indent) { } printf("%s was_paired = %d\n", indent, pbucket->was_paired); } - -// +-----------+-----------+-----------+-----------+-----------+-----------+ -// | L R | L R | L R | L R | L R | L R | -// + --- --- + --- --- + --- --- + --- --- + --- --- + --- --- + -// | a | a | e | a | e e | e e | -// | b | e | e | e e | e | e e | -// | e | e | e | e | e | e | -// | e | e | f | e | f | g g | -// | e | f | g | g | g | g | -// | g | g | g | g | g | | -// | g | g | h | | | | -// +-----------+-----------+-----------+-----------+-----------+-----------+ - -// Cases: -// * 1st emit, right row < 1st left row -// * 1st emit, right row == 1st left row -// * 1st emit, right row > 1st left row -// * subsequent emit, right row < 1st left row -// * subsequent emit, right row == 1st left row -// * subsequent emit, right row > 1st left row -// * new left EOF, right row < 1st left row -// * new left EOF, right row == 1st left row -// * new left EOF, right row > 1st left row -// * old left EOF, right row < 1st left row -// * old left EOF, right row == 1st left row -// * old left EOF, right row > 1st left row - diff --git a/c/containers/slls.c b/c/containers/slls.c index 361a0691e..11918ce7d 100644 --- a/c/containers/slls.c +++ b/c/containers/slls.c @@ -132,14 +132,16 @@ char* slls_join(slls_t* plist, char fs) { return output; } -void slls_debug_print(slls_t* plist, FILE* output_stream) { +void slls_print(slls_t* plist) { if (plist == NULL) { - fprintf(output_stream, "NULL\n"); + printf("NULL"); } else { - // xxx redo this without join ... just for-loop and print it - char* string = slls_join(plist, ','); - fprintf(output_stream, "[%s]\n", string); - free(string); + int i = 0; + for (sllse_t* pe = plist->phead; pe != NULL; pe = pe->pnext, i++) { + if (i > 0) + printf(","); + printf("%s", pe->value); + } } } diff --git a/c/containers/slls.h b/c/containers/slls.h index 7a1ef09d4..c220343af 100644 --- a/c/containers/slls.h +++ b/c/containers/slls.h @@ -27,11 +27,13 @@ void slls_add_with_free(slls_t* plist, char* value); void slls_add_no_free(slls_t* plist, char* value); int slls_equals(slls_t* pa, slls_t* pb); slls_t* slls_from_line(char* line, char ifs, int allow_repeat_ifs); -// xxx cmt for debug: inefficient. (wideband usage is direct-to-ostream.) -char* slls_join(slls_t* plist, char fs); -void slls_debug_print(slls_t* plist, FILE* output_stream); + void slls_reverse(slls_t* plist); int slls_hash_func(slls_t *plist); int slls_compare_lexically(slls_t* pa, slls_t* pb); +// Debug routines: +char* slls_join(slls_t* plist, char fs); +void slls_print(slls_t* plist); + #endif // SLLS_H