Esempio n. 1
0
int fs_ptable_remove_chain(fs_ptable *pt, fs_row_id b)
{
    if (!pt->ptr) {
        fs_error(LOG_CRIT, "attempted to remove row from unmapped ptable");

        return 1;
    }
    if (b > pt->header->size) {
        fs_error(LOG_CRIT, "tried to remove row %08x, past end of ptable\n", b);

        return 1;
    }
    if (b == 0) {
        fs_error(LOG_CRIT, "attempted to remove row 0");

        return 1;
    }
    do {
        fs_row_id next = pt->data[b].cont;
        fs_ptable_free_row(pt, b);
        b = next;
        if (b > pt->header->size) {
            fs_error(LOG_CRIT, "tried to remove bucket %08x, past end of ptable\n", b);

            return 1;
        }
    } while (b != 0);

    return 0;
}
Esempio n. 2
0
/* we add models to the models set, if the matching RID is set to a wildcard */
fs_row_id fs_ptable_remove_pair(fs_ptable *pt, fs_row_id b, fs_rid pair[2], int *removed, fs_rid_set *models)
{
    fs_row_id ret = b;

    if (b == 0) {
        fs_error(LOG_CRIT, "tried to read row 0");

        return ret;
    }
    if (b > pt->header->length) {
        fs_error(LOG_CRIT, "tried to read off end of ptable %s (%d > %d)", pt->filename, b, pt->header->length);

        return ret;
    }

    /* NULL, NULL means remove everything */
    if (pair[0] == FS_RID_NULL && pair[1] == FS_RID_NULL) {
        /* loop over the chain, count length, remove entries, and set all
         * models to be marked as sparse */
        while (b != 0) {
            (*removed)++;
            row *r = &(pt->data[b]);
            if (models) {
                fs_rid_set_add(models, r->data[0]);
            }
            fs_row_id nextb = r->cont;
            fs_ptable_free_row(pt, b);
            b = nextb;
        }

        return 0;
    }

    row *prevr = NULL;
    while (b != 0) {
        row *r = &(pt->data[b]);
        fs_row_id nextb = r->cont;
        if (pair[0] != FS_RID_NULL && pair[1] == FS_RID_NULL) {
            if (r->data[0] == pair[0]) {
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else if (pair[0] == FS_RID_NULL && pair[1] != FS_RID_NULL) {
            if (r->data[1] == pair[1]) {
                if (models) {
                    fs_rid_set_add(models, r->data[0]);
                }
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else if (pair[0] != FS_RID_NULL && pair[1] != FS_RID_NULL) {
            if (r->data[0] == pair[0] && r->data[1] == pair[1]) {
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else {
            fs_error(LOG_CRIT, "trying to remove with unsupported pattern");
        }
        b = nextb;
    }

    return ret;
}
Esempio n. 3
0
fs_row_id fs_ptable_remove_pair(fs_ptable *pt, fs_row_id b, fs_rid pair[2], int *removed)
{
    fs_row_id ret = b;

    if (b == 0) {
        fs_error(LOG_CRIT, "tried to read row 0");

        return ret;
    }
    if (b > pt->header->length) {
        fs_error(LOG_CRIT, "tried to read off end of ptable (%d > %d)", b, pt->header->length);

        return ret;
    }

    /* NULL, NULL means remove everything */
    if (pair[0] == FS_RID_NULL && pair[1] == FS_RID_NULL) {
        *removed += fs_ptable_chain_length(pt, b, 0);
        fs_ptable_remove_chain(pt, b);

        return 0;
    }

    row *prevr = NULL;
    while (b != 0) {
        row *r = &(pt->data[b]);
        fs_row_id nextb = r->cont;
        if (pair[0] != FS_RID_NULL && pair[1] == FS_RID_NULL) {
            if (r->data[0] == pair[0]) {
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else if (pair[0] == FS_RID_NULL && pair[1] != FS_RID_NULL) {
            if (r->data[1] == pair[1]) {
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else if (pair[0] != FS_RID_NULL && pair[1] != FS_RID_NULL) {
            if (r->data[0] == pair[0] && r->data[1] == pair[1]) {
                if (prevr) {
                    prevr->cont = nextb;
                } else {
                    ret = nextb;
                }
                fs_ptable_free_row(pt, b);
                (*removed)++;
            } else {
                prevr = r;
            }
        } else {
            fs_error(LOG_CRIT, "trying to remove with unsupported pattern");
        }
        b = nextb;
    }

    return ret;
}