Only dump the first unsorted region
This commit is contained in:
parent
d6c558118d
commit
ba18ada0ae
34
sort.c
34
sort.c
@ -135,8 +135,6 @@ hexdump(uint8_t *buf, size_t size)
|
|||||||
UNUSED(buf);
|
UNUSED(buf);
|
||||||
UNUSED(size);
|
UNUSED(size);
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG
|
|
||||||
|
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
//printf("writing %ld bytes in cpu=%d\n", size, rthread.cpu);
|
//printf("writing %ld bytes in cpu=%d\n", size, rthread.cpu);
|
||||||
@ -162,24 +160,19 @@ hexdump(uint8_t *buf, size_t size)
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize,
|
sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize,
|
||||||
uint8_t *srcbad, uint8_t *srcnext)
|
uint8_t *srcbad, uint8_t *srcnext)
|
||||||
{
|
{
|
||||||
uint8_t *p, *q, *obuf=buf;
|
uint8_t *p, *q;
|
||||||
int64_t evsize, injected = 0, obufsize=bufsize;
|
int64_t evsize, injected = 0;
|
||||||
struct ovni_ev *ep, *eq, *ev;
|
struct ovni_ev *ep, *eq, *ev;
|
||||||
|
|
||||||
p = src;
|
p = src;
|
||||||
q = srcbad;
|
q = srcbad;
|
||||||
|
|
||||||
dbg("src before:\n");
|
|
||||||
hexdump(src, obufsize);
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
ep = (struct ovni_ev *) p;
|
ep = (struct ovni_ev *) p;
|
||||||
@ -213,14 +206,11 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize,
|
|||||||
injected++;
|
injected++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg("buf after:\n");
|
|
||||||
hexdump(obuf, obufsize);
|
|
||||||
|
|
||||||
dbg("injected %ld events in the past\n", injected);
|
dbg("injected %ld events in the past\n", injected);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
execute_sort_plan(struct sortplan *sp)
|
execute_sort_plan(struct sortplan *sp, size_t region)
|
||||||
{
|
{
|
||||||
int64_t i0, bufsize;
|
int64_t i0, bufsize;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
@ -250,6 +240,12 @@ execute_sort_plan(struct sortplan *sp)
|
|||||||
if(!buf)
|
if(!buf)
|
||||||
die("malloc failed: %s\n", strerror(errno));
|
die("malloc failed: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
if(region == 0)
|
||||||
|
{
|
||||||
|
err("stream window region %ld BEFORE sort:\n", region);
|
||||||
|
hexdump((uint8_t *) first, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
sort_buf((uint8_t *) first, buf, bufsize,
|
sort_buf((uint8_t *) first, buf, bufsize,
|
||||||
(uint8_t *) sp->bad0, (uint8_t *) sp->next);
|
(uint8_t *) sp->bad0, (uint8_t *) sp->next);
|
||||||
|
|
||||||
@ -257,6 +253,12 @@ execute_sort_plan(struct sortplan *sp)
|
|||||||
memcpy(first, buf, bufsize);
|
memcpy(first, buf, bufsize);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
if(region == 0)
|
||||||
|
{
|
||||||
|
err("stream window region %ld AFTER sort:\n", region);
|
||||||
|
hexdump((uint8_t *) first, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +275,8 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
|
|||||||
ring_reset(r);
|
ring_reset(r);
|
||||||
sp.r = r;
|
sp.r = r;
|
||||||
|
|
||||||
|
size_t region = 0;
|
||||||
|
|
||||||
for(i=0; stream->active; i++)
|
for(i=0; stream->active; i++)
|
||||||
{
|
{
|
||||||
ovni_load_next_event(stream);
|
ovni_load_next_event(stream);
|
||||||
@ -303,7 +307,7 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
|
|||||||
{
|
{
|
||||||
sp.next = ev;
|
sp.next = ev;
|
||||||
dbg("executing sort plan for stream tid=%d\n", stream->tid);
|
dbg("executing sort plan for stream tid=%d\n", stream->tid);
|
||||||
if(execute_sort_plan(&sp) < 0)
|
if(execute_sort_plan(&sp, region) < 0)
|
||||||
{
|
{
|
||||||
err("sort failed for stream tid=%d\n",
|
err("sort failed for stream tid=%d\n",
|
||||||
stream->tid);
|
stream->tid);
|
||||||
@ -314,6 +318,8 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
|
|||||||
sp.next = NULL;
|
sp.next = NULL;
|
||||||
sp.bad0 = NULL;
|
sp.bad0 = NULL;
|
||||||
|
|
||||||
|
region++;
|
||||||
|
|
||||||
st = 'S';
|
st = 'S';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user