Example #1
0
static int
_gmodule_pprint(char* buf)
{
    PSTART(buf);
    _gmodule->pprint();
    return PEND(buf);
}
Example #2
0
void alloc(Inverter_t * v, uint32_t i, const char *term)
{
    char *p = v->ppool + 2 * sizeof(uint32_t *);
    char *pterm = p;

    while (*pterm++ = *term++);

    v->ppool = pterm + INITIAL_SIZE;

    PLIST(p) = (uint32_t *) pterm;
    PEND(p) = (uint32_t *) v->ppool;

    v->record[i] = p;
}
Example #3
0
void inverter_realloc(Inverter_t * v, uint32_t i)
{
    uint32_t p1 = 1 + (100 * (v->ppool - v->pool)) / v->maxpool;
    uint32_t p2 = 1 + (100 * v->count) / MAX_COUNT;

    uint32_t oldsize = (char *) PLIST(v->record[i]) - v->record[i];
    uint32_t newsize = (150 * oldsize) / MAX(p1, p2);

    char *p = v->ppool + 2 * sizeof(uint32_t *);
    v->ppool = p + newsize;

    memcpy(p, v->record[i], oldsize);

    PLIST(p) = (uint32_t *) (p + oldsize);
    PEND(p) = (uint32_t *) (p + newsize);

    v->record[i] = p;
}
Example #4
0
/* insert term/docid pair into inverter */
void inverter_insert(Inverter_t * v, const char *term, uint32_t docid)
{
    uint32_t i;

    if (v->record == NULL)
        inverter_alloc(v);

    i = inverter_lookup(v, term);

    if (v->record[i] == NULL) {
        alloc(v, i, term);
        *PLIST(v->record[i])++ = docid;
        v->count++;
        return;
    }

    if (docid > PLIST(v->record[i])[-1]) {
        if (PLIST(v->record[i]) >= PEND(v->record[i]) - 1)
            inverter_realloc(v, i);

        *PLIST(v->record[i])++ = docid;
    }
}