src/siri/db/points.c
/*
 * This merge method works best for only a few series with possible a lot
 * of points.
 */
This merge method works best for only a few series with possible a lot
of points.
This merge method works best for only a few series with possible a lot of points .
static void POINTS_sort_while_merge(slist_t * plist, siridb_points_t * points)
{
    siridb_points_t ** m;
    size_t i, n;
    siridb_points_t ** tpts;
    n = points->len;
    while (plist->len)
    {
        m = (siridb_points_t **) plist->data;
        for (i = 1, tpts = m + 1; i < plist->len; i++, tpts++)
        {
            if (((*tpts)->data + (*tpts)->len)->ts >
                ((*m)->data + (*m)->len)->ts)
            {
                m = tpts;
            }
        }
        points->data[--n] = (*m)->data[(*m)->len];
        if (!(*m)->len--)
        {
            siridb_points_free(*m);
            if (--plist->len)
            {
                *m = (siridb_points_t *) plist->data[plist->len];
            }
        }
        if (!(n % MAX_ITERATE_MERGE_COUNT))
        {
            usleep(3000);
        }
    }
#ifdef DEBUG
    assert (n == 0);
#endif
}
static void POINTS_sort_while_merge ( slist_t * plist , siridb_points_t * points ) { siridb_points_t * * m ; size_t i , n ; siridb_points_t * * tpts ; n = points -> len ; while ( plist -> len ) { m = ( siridb_points_t * * ) plist -> data ; for ( i = 1 , tpts = m + 1 ; i < plist -> len ; i ++ , tpts ++ ) { if ( ( ( * tpts ) -> data + ( * tpts ) -> len ) -> ts > ( ( * m ) -> data + ( * m ) -> len ) -> ts ) { m = tpts ; } } points -> data [ -- n ] = ( * m ) -> data [ ( * m ) -> len ] ; if ( ! ( * m ) -> len -- ) { siridb_points_free ( * m ) ; if ( -- plist -> len ) { * m = ( siridb_points_t * ) plist -> data [ plist -> len ] ; } } if ( ! ( n % MAX_ITERATE_MERGE_COUNT ) ) { usleep ( 3000 ) ; } } #ifdef DEBUG assert ( n == 0 ) ; #endif }
This merge method works best for only a few series with possible a lot
 of points.
This merge method works best for only a few series with possible a lot of points .
/* size should be exactly zero */