Mercurial > hg > Applications > Grep
diff regexParser/cerium/ppe/Print.cc @ 266:e51cac73e42a
CeriumGrep start
author | masa |
---|---|
date | Thu, 28 Jan 2016 21:14:34 +0900 |
parents | |
children | 5aa9d01926f1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/cerium/ppe/Print.cc Thu Jan 28 21:14:34 2016 +0900 @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <string.h> +#include "Print.h" +#include "Func.h" +#include "FileMapReduce.h" + +#define STATUS_NUM 2 +/* これは必須 */ +SchedDefineTask1(Print,run_print); + +static int +run_print(SchedTask *s, void *rbuf, void *wbuf) +{ + MapReduce *w = (MapReduce*)s->get_input(0); + + unsigned char* buff = (unsigned char*)w->i_data; + int out_size = w->division_out_size / sizeof(unsigned long long); + ResultPtr prev = NULL; + for (int i = 0; i < out_task_num ; i++) { + ResultPtr *idata = (ResultPtr*)w->o_data[i*3+0]; + StatePtr *blockEnd = (StatePtr)w->o_data[i*3+2]; + StatePtr *blockBegin = (StatePtr)w->o_data[i*3+4]; // next Block's blockBegin. + ResultPtr r = idata[i*out_size]; + if (prev && i != out_task_num-1) { + // 最後のブロックでなく、前の blockEnd が state 1 でない場合) + if (blockBegin->bi.bitContainer & blockEnd->bi.bitContainer) { + // 前のブロックの matchBegin から最初 result の end までがマッチ + fwrite(prev->result,r->end - prev->begin,1,stdout); + } + r = r->next; + } + for (;r;r = r->next) { + if (r->end == NULL) { + prev = r; + break; + } + fwrite(r->begin,r->end - r->begin,1,stdout); + puts("\n"); + } + } + return 0; +}