266
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include "Print.h"
|
|
4 #include "Func.h"
|
|
5 #include "FileMapReduce.h"
|
272
|
6 #include "regexParser.h"
|
266
|
7
|
|
8 #define STATUS_NUM 2
|
|
9 /* これは必須 */
|
|
10 SchedDefineTask1(Print,run_print);
|
|
11
|
|
12 static int
|
|
13 run_print(SchedTask *s, void *rbuf, void *wbuf)
|
|
14 {
|
|
15 MapReduce *w = (MapReduce*)s->get_input(0);
|
|
16
|
|
17 int out_size = w->division_out_size / sizeof(unsigned long long);
|
272
|
18 int out_task_num = w->task_num;
|
266
|
19 ResultPtr prev = NULL;
|
|
20 for (int i = 0; i < out_task_num ; i++) {
|
|
21 ResultPtr *idata = (ResultPtr*)w->o_data[i*3+0];
|
272
|
22 StatePtr blockEnd = (StatePtr)w->o_data[i*3+2];
|
|
23 StatePtr blockBegin = (StatePtr)w->o_data[i*3+4]; // next Block's blockBegin.
|
266
|
24 ResultPtr r = idata[i*out_size];
|
|
25 if (prev && i != out_task_num-1) {
|
|
26 // 最後のブロックでなく、前の blockEnd が state 1 でない場合)
|
272
|
27 if ((blockBegin->bitState.bitContainer & ~blockEnd->bitState.bitContainer)==0) {
|
266
|
28 // 前のブロックの matchBegin から最初 result の end までがマッチ
|
272
|
29 fwrite(prev->begin,r->end - prev->begin,1,stdout);
|
266
|
30 }
|
|
31 r = r->next;
|
|
32 }
|
|
33 for (;r;r = r->next) {
|
|
34 if (r->end == NULL) {
|
|
35 prev = r;
|
|
36 break;
|
|
37 }
|
|
38 fwrite(r->begin,r->end - r->begin,1,stdout);
|
|
39 puts("\n");
|
|
40 }
|
|
41 }
|
|
42 return 0;
|
|
43 }
|