Mercurial > hg > Applications > Grep
view regexParser/cerium/ppe/Exec.cc @ 288:f2491681914e
special state for start search
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 01 Feb 2016 01:35:12 +0900 |
parents | 87a801c14117 |
children | 868f01f1ba8e |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include "Exec.h" #include "Func.h" #include "regexParser.h" #include "threadedSearch.h" #include "FileMapReduce.h" #include "CeriumMain.h" /* これは必須 */ SchedDefineTask1(Exec,blockedGrep); TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { TSValue tsv; tsv.buff = buff; tsv.tg = tg; if (task_spawned == 0) { tsv.current = tg->stateStart->tState; } else { tsv.current = tg->anyState->tState; } tsv.result = NULL; ResultPtr result = NULL; tsv.resultEnd = &result; unsigned char *end = tsv.buff.buffend; tsv.buff.buffend = tsv.buff.buff+1; tsv = tSearch(tsv); tsv.blockBegin = tsv.current; tsv.buff.buffend = end; tsv = tSearch(tsv); tsv.blockEnd = tsv.current; if (tsv.blockEnd->state->bitState.bitContainer != 1) { if (tsv.buff.matchBegin != tsv.buff.buffptr) { // partial match case at block end. ResultPtr r = NEW(Result); r->continued = true; r->begin = tsv.buff.matchBegin; r->end = tsv.buff.buffptr; *tsv.resultEnd = r; r->next = NULL; tsv.resultEnd = &r->next; // printf("Exec %lx r->begin : %p r->end : %p\n",tsv.blockEnd->state->bitState.bitContainer, r->begin,r->end); } } tsv.result = result; return tsv; } static int blockedGrep(SchedTask *s, void *rbuf, void *wbuf) { long task_spawned = (long)s->get_param(0); long division_size = (long)s->get_param(1); long length = (long)s->get_param(2); long out_size = (long)s->get_param(3); MapReduce *w = (MapReduce*)s->get_param(4); long allocation = task_spawned + (long)s->x; unsigned char* i_data; unsigned long * o_data; if (division_size) { i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; } else { i_data = (unsigned char*)s->get_input(0); o_data = (unsigned long *)s->get_output(0); } TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; Buffer buff; buff.buff = buff.buffptr = buff.matchBegin = i_data; buff.buffend = buff.buff + length; TSValue tsv = blockSearch(tg,buff,task_spawned); // resultPrint(tsv.result,"Exec"); o_data[0] = (unsigned long)tsv.result; o_data[1] = (unsigned long)tsv.blockBegin->state; o_data[2] = (unsigned long)tsv.blockEnd->state; return 0; }