This commit is contained in:
John Kerl 2015-07-20 08:02:02 -04:00
parent 674a1de63d
commit 9b13609bf7
3 changed files with 31 additions and 40 deletions

View file

@ -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

View file

@ -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);
}
}
}

View file

@ -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