Beispiel #1
0
static int
so_snapshotdestroy(srobj *o, va_list args ssunused)
{
	sosnapshot *s = (sosnapshot*)o;
	so *e = so_of(o);
	uint32_t id = s->t.id;
	sr_objlist_del(&e->snapshot, &s->o);
	so_dbunbind(e, id);
	so_snapshotfree(s);
	return 0;
}
Beispiel #2
0
static int
so_snapshotfree(sosnapshot *s)
{
	so *e = so_of(&s->o);
	sx_rollback(&s->t);
	if (sslikely(s->name)) {
		ss_free(&e->a, s->name);
		s->name = NULL;
	}
	ss_free(&e->a_snapshot, s);
	return 0;
}
Beispiel #3
0
static void*
so_snapshotget(srobj *o, va_list args)
{
	sosnapshot *s = (sosnapshot*)o;
	so *e = so_of(o);
	va_list va;
	va_copy(va, args);
	sov *v = va_arg(va, sov*);
	va_end(va);
	if (ssunlikely(v->o.id != SOV)) {
		sr_error(&e->error, "%s", "bad arguments");
		return NULL;
	}
	sodb *db = (sodb*)v->parent;
	return so_txdbget(db, 0, s->vlsn, 0, args);
}
Beispiel #4
0
static void*
so_snapshotcursor(srobj *o, va_list args)
{
	sosnapshot *s = (sosnapshot*)o;
	so *e = so_of(o);
	va_list va;
	va_copy(va, args);
	sov *v = va_arg(va, sov*);
	va_end(va);
	if (ssunlikely(v->o.id != SOV))
		goto error;
	if (ssunlikely(v->parent == NULL || v->parent->id != SODB))
		goto error;
	sodb *db = (sodb*)v->parent;
	return so_cursornew(db, s->vlsn, 0, args);
error:
	sr_error(&e->error, "%s", "bad arguments");
	return NULL;
}
Beispiel #5
0
int so_scheduler_branch(void *arg)
{
    sodb *db = arg;
    so *e = so_of(&db->o);
    sizone *z = so_zoneof(e);
    soworker stub;
    so_workerstub_init(&stub);
    int rc;
    while (1) {
        uint64_t vlsn = sx_vlsn(&e->xm);
        siplan plan = {
            .explain   = SI_ENONE,
            .plan      = SI_BRANCH,
            .a         = z->branch_wm,
            .b         = 0,
            .c         = 0,
            .node      = NULL
        };
        rc = si_plan(&db->index, &plan);
        if (rc == 0)
            break;
        rc = si_execute(&db->index, &db->r, &stub.dc, &plan, vlsn);
        if (srunlikely(rc == -1))
            break;
    }
    so_workerstub_free(&stub, &db->r);
    return rc;
}

int so_scheduler_compact(void *arg)
{
    sodb *db = arg;
    so *e = so_of(&db->o);
    sizone *z = so_zoneof(e);
    soworker stub;
    so_workerstub_init(&stub);
    int rc;
    while (1) {
        uint64_t vlsn = sx_vlsn(&e->xm);
        siplan plan = {
            .explain   = SI_ENONE,
            .plan      = SI_COMPACT,
            .a         = z->compact_wm,
            .b         = 0,
            .c         = 0,
            .node      = NULL
        };
        rc = si_plan(&db->index, &plan);
        if (rc == 0)
            break;
        rc = si_execute(&db->index, &db->r, &stub.dc, &plan, vlsn);
        if (srunlikely(rc == -1))
            break;
    }
    so_workerstub_free(&stub, &db->r);
    return rc;
}

int so_scheduler_checkpoint(void *arg)
{
    so *o = arg;
    soscheduler *s = &o->sched;
    uint64_t lsn = sr_seq(&o->seq, SR_LSN);
    sr_mutexlock(&s->lock);
    s->checkpoint_lsn = lsn;
    s->checkpoint = 1;
    sr_mutexunlock(&s->lock);
    return 0;
}