[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Incremental search
Hi,
On Sun, Dec 17, 2017 at 12:09:32AM +0300, Azat Khuzhin wrote:
> (and evbuffer_ptr_set()+evbuffer_search_range() is not compatible with
> evbuffer_pullup() and any other API that playing with chains)
I've tried to take the invalidation of evbuffer_ptrs into account.
> > } else {
> > // a hit
> >
> > incr_ptr.pos = -1;
>
> So here you don't remove that part of the buffer (the one from the
> beginning to the delimiter), yes?
Actually I do. Currently it looks like that:
#v+
} else {
// a hit
ctx->incr_ptr.pos = -1;
cptr = malloc (tmp_ptr.pos + 1);
evbuffer_remove (ctx->evbuff_in, cptr, tmp_ptr.pos);
evbuffer_drain (ctx->evbuff_in, 1);
cptr[tmp_ptr.pos] = '\0';
printf("data: %s\n", cptr);
free (cptr);
}
#v-
In my previous email I left only the line marking the evbuffer_ptr as
invalid to force recalculation in the next iteration:
ctx->incr_ptr.pos != -1 ? &ctx->incr_ptr : NULL
> Yeah, and we can't change evbuffer_ptr_set() since this will break
> compatibility.
> Maybe introduce some EVBUFFER_PTR_END that will set the ptr to the end
> (real one), and this should be enough for incremental search?
>
> (but I wasn't thinking about this enough time, so don't consider this
> as some final decision).
I should probably fully grasp the difference between .last_with_datap
and .last before trying to write a PoC.
> > Probably it would be perfect if an alternative evbuffer_search_range()
> > API existed with a non-const start/end evbuffer_ptr updated on every
> > call so one can continue the search from the last seen position.
>
> I guess so, but it doesn't exists for now, if you are interested in
> contribute this feature, please go ahead!
Roger. I hope there will be some time to make an experiment.
--
Marcin Szewczyk
http://wodny.org
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.