Mercurial > hg > Applications > Grep
comparison regexParser/cerium/ppe/Print.cc @ 302:27414e6fb33c
retrying blocked search
fix for CbC support
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Feb 2016 08:59:38 +0900 |
parents | c5a7caa37f61 |
children | cc770cd8d000 |
comparison
equal
deleted
inserted
replaced
301:4cb6eea3ab12 | 302:27414e6fb33c |
---|---|
3 #include "Print.h" | 3 #include "Print.h" |
4 #include "Func.h" | 4 #include "Func.h" |
5 #include "FileMapReduce.h" | 5 #include "FileMapReduce.h" |
6 #include "regexParser.h" | 6 #include "regexParser.h" |
7 #include "CeriumMain.h" | 7 #include "CeriumMain.h" |
8 #include "threadedSearch.h" | |
8 | 9 |
9 #define STATUS_NUM 2 | 10 #define STATUS_NUM 2 |
10 /* これは必須 */ | 11 /* これは必須 */ |
11 SchedDefineTask1(Print,run_print); | 12 SchedDefineTask1(Print,run_print); |
13 | |
14 static | |
15 TSValue stateSkipOnce(TSValue tsv) { | |
16 if (tsv.matchEnd) { | |
17 addResult(tsv,false,tsv.matchBegin,tsv.matchEnd); | |
18 } | |
19 tsv.buff.buffend = tsv.buff.buffptr; // end search | |
20 return tsv; | |
21 } | |
22 | |
12 | 23 |
13 static int | 24 static int |
14 run_print(SchedTask *s, void *rbuf, void *wbuf) | 25 run_print(SchedTask *s, void *rbuf, void *wbuf) |
15 { | 26 { |
16 MapReduce *w = (MapReduce*)s->get_input(0); | 27 MapReduce *w = (MapReduce*)s->get_input(0); |
18 int out_size = w->division_out_size / sizeof(unsigned long long); | 29 int out_size = w->division_out_size / sizeof(unsigned long long); |
19 int out_task_num = w->task_num; | 30 int out_task_num = w->task_num; |
20 ResultPtr prev = NULL; | 31 ResultPtr prev = NULL; |
21 for (int i = 0; i < out_task_num ; i++) { | 32 for (int i = 0; i < out_task_num ; i++) { |
22 ResultPtr r = (ResultPtr)w->o_data[i*out_size+0]; | 33 ResultPtr r = (ResultPtr)w->o_data[i*out_size+0]; |
34 // first reply contains block begin and block end | |
35 unsigned char *begin = r->begin; | |
36 unsigned char *end = r->end; | |
37 r = r->next; | |
23 if (r == NULL) { | 38 if (r == NULL) { |
24 prev = NULL; | 39 prev = NULL; |
25 continue; | 40 continue; |
26 } | 41 } |
27 StatePtr blockBegin = (StatePtr)w->o_data[i*out_size+1]; | 42 StatePtr blockBegin = (StatePtr)w->o_data[i*out_size+1]; |
33 printf("task %d prev begin : %p r->begin : %p r->end : %p\n", i,prev->begin,r->begin,r->end); | 48 printf("task %d prev begin : %p r->begin : %p r->end : %p\n", i,prev->begin,r->begin,r->end); |
34 printf("nextblockBegin : %lx prevBlockEnd : %lx : string ",blockBegin->bitState.bitContainer,prevBlockEnd->bitState.bitContainer); | 49 printf("nextblockBegin : %lx prevBlockEnd : %lx : string ",blockBegin->bitState.bitContainer,prevBlockEnd->bitState.bitContainer); |
35 fwrite(r->begin,r->end - r->begin-1,1,stdout); | 50 fwrite(r->begin,r->end - r->begin-1,1,stdout); |
36 printf(" match %d\n", ((prevBlockEnd->bitState.bitContainer & ~blockBegin->bitState.bitContainer)==0)? 1 : 0 ); | 51 printf(" match %d\n", ((prevBlockEnd->bitState.bitContainer & ~blockBegin->bitState.bitContainer)==0)? 1 : 0 ); |
37 #endif | 52 #endif |
38 if ((prevBlockEnd->bitState.bitContainer & ~blockBegin->bitState.bitContainer)==0) { | 53 if (prevBlockEnd->bitState.bitContainer !=1) { |
39 // 前のブロックの matchBegin から最初 result の end までがマッチ | 54 // そこから最初の stateSkip までやり直し。マッチしたら表示。 |
40 fwrite(prev->begin,r->end - prev->begin,1,stdout); | 55 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; |
41 // printf("####"); | 56 tg->stateSkip = stateSkipOnce; |
42 if (!r->continued) puts(""); | 57 Buffer buff; |
58 buff.buff = buff.buffptr = begin; | |
59 buff.buffend = end; | |
60 TSValue tsv = createTSValue(tg,buff); | |
61 BlockOutput blk; | |
62 tsv.blk = &blk; | |
63 tsv.current = prevBlockEnd->tState; | |
64 tsv.blk->result = NULL; | |
65 ResultPtr result = NULL; | |
66 tsv.blk->resultEnd = &result; | |
67 tsv.matchBegin = prev->begin; | |
68 tsv.matchEnd = prev->end; | |
69 tsv = tSearch(tsv); | |
70 if (result) { | |
71 resultPrint(prev->next,"Print"); | |
72 } | |
43 } | 73 } |
44 r = r->next; | |
45 // printf("%p\n",r); | 74 // printf("%p\n",r); |
46 } else { | 75 } else { |
47 if ((blockBegin->bitState.bitContainer & 1)!=1) r = r->next; | 76 if ((blockBegin->bitState.bitContainer & 1)!=1) r = r->next; |
48 } | 77 } |
49 prev = resultPrint(r,"Print"); | 78 prev = resultPrint(r,"Print"); |