Mercurial > hg > Applications > Grep
comparison regexParser/cerium/ppe/Print.cc @ 266:e51cac73e42a
CeriumGrep start
author | masa |
---|---|
date | Thu, 28 Jan 2016 21:14:34 +0900 |
parents | |
children | 5aa9d01926f1 |
comparison
equal
deleted
inserted
replaced
265:1e2c12ec25b7 | 266:e51cac73e42a |
---|---|
1 #include <stdio.h> | |
2 #include <string.h> | |
3 #include "Print.h" | |
4 #include "Func.h" | |
5 #include "FileMapReduce.h" | |
6 | |
7 #define STATUS_NUM 2 | |
8 /* これは必須 */ | |
9 SchedDefineTask1(Print,run_print); | |
10 | |
11 static int | |
12 run_print(SchedTask *s, void *rbuf, void *wbuf) | |
13 { | |
14 MapReduce *w = (MapReduce*)s->get_input(0); | |
15 | |
16 unsigned char* buff = (unsigned char*)w->i_data; | |
17 int out_size = w->division_out_size / sizeof(unsigned long long); | |
18 ResultPtr prev = NULL; | |
19 for (int i = 0; i < out_task_num ; i++) { | |
20 ResultPtr *idata = (ResultPtr*)w->o_data[i*3+0]; | |
21 StatePtr *blockEnd = (StatePtr)w->o_data[i*3+2]; | |
22 StatePtr *blockBegin = (StatePtr)w->o_data[i*3+4]; // next Block's blockBegin. | |
23 ResultPtr r = idata[i*out_size]; | |
24 if (prev && i != out_task_num-1) { | |
25 // 最後のブロックでなく、前の blockEnd が state 1 でない場合) | |
26 if (blockBegin->bi.bitContainer & blockEnd->bi.bitContainer) { | |
27 // 前のブロックの matchBegin から最初 result の end までがマッチ | |
28 fwrite(prev->result,r->end - prev->begin,1,stdout); | |
29 } | |
30 r = r->next; | |
31 } | |
32 for (;r;r = r->next) { | |
33 if (r->end == NULL) { | |
34 prev = r; | |
35 break; | |
36 } | |
37 fwrite(r->begin,r->end - r->begin,1,stdout); | |
38 puts("\n"); | |
39 } | |
40 } | |
41 return 0; | |
42 } |