Ejemplo n.º 1
0
rc_t ShoreYCSBEnv::xct_populate_db(const int /* xct_id */, populate_db_input_t& pin)
{
    assert (_pssm);
    assert (_initialized);

    tuple_guard<ycsbtable_man_impl> tuple(ycsbtable_man);
    rep_row_t areprow(ycsbtable_man->ts());
    rep_row_t areprowkey(ycsbtable_man->ts());
    areprow.set(ycsbtable_man->table()->maxsize());
    areprowkey.set(ycsbtable_man->table()->maxsize());
    tuple->_rep = &areprow;
    tuple->_rep_key = &areprowkey;

    W_DO(db()->begin_xct());

    uint64_t key = pin.firstKey;
    char field[FieldSize];
    for (unsigned i = 0; i < pin.count; i++) {
        tuple->set_value(0, key);
        for (int j = 1; j <= FieldCount; j++) {
            fill_value(field);
            tuple->set_value(j, field);
        }
        W_DO(ycsbtable_man->add_tuple(_pssm, tuple));
        key++;
    }

    W_DO(db()->commit_xct());
    return RCOK;
}
Ejemplo n.º 2
0
rc_t ShoreYCSBEnv::xct_read(const int /* xct_id */, read_input_t& pin)
{
    assert (_pssm);
    assert (_initialized);
    assert (_loaded);

    tuple_guard<ycsbtable_man_impl> tuple(ycsbtable_man);
    rep_row_t areprow(ycsbtable_man->ts());
    rep_row_t areprowkey(ycsbtable_man->ts());
    areprow.set(ycsbtable_man->table()->maxsize());
    areprowkey.set(ycsbtable_man->table()->maxsize());
    tuple->_rep = &areprow;
    tuple->_rep_key = &areprowkey;

    // Probe index for given key
    W_DO(ycsbtable_man->index_probe(_pssm, tuple, pin.key));
    // Copy fields into local variables, just to "do something" with the tuple
    uint64_t key;
    char values[10][FieldSize];
    tuple->get_value(0, key);
    for (int i = 0; i < 10; i++) {
        tuple->get_value(i+1, values[i], FieldSize);
    }

    return RCOK;
}
Ejemplo n.º 3
0
w_rc_t table_man_t<T>::fetch_table(ss_m* db, lock_mode_t /* alm */)
{
    assert (db);
    assert (_ptable);

    bool eof = false;
    int counter = -1;

    table_row_t* tuple = get_tuple();
    rep_row_t areprow(ts());
    rep_row_t areprow_key(ts());
    areprow.set(_ptable->maxsize());
    areprow_key.set(_ptable->maxsize());
    tuple->_rep = &areprow;
    tuple->_rep_key = &areprow_key;

    W_DO(db->begin_xct());

    // 1. scan the table
    table_scan_iter_impl<T> t_scan(this);
    while(!eof) {
	W_DO(t_scan.next(eof, *tuple));
	counter++;
    }
    TRACE( TRACE_ALWAYS, "%s:%d pages\n", _ptable->name(), counter);

    // 2. scan the indexes
    for (auto index : _ptable->get_indexes()) {
        index_scan_iter_impl<T> i_scan(index, this);
        eof = false;
        counter = -1;
        while(!eof) {
            W_DO(i_scan.next(eof, *tuple));
            counter++;
        }
        TRACE( TRACE_ALWAYS, "\t%s:%d pages\n", index->name().c_str(), counter);
    }

    W_DO(db->commit_xct());
    give_tuple(tuple);

    return RCOK;
}
Ejemplo n.º 4
0
rc_t ShoreYCSBEnv::xct_update(const int /* xct_id */, update_input_t& pin)
{
    assert (_pssm);
    assert (_initialized);
    assert (_loaded);

    tuple_guard<ycsbtable_man_impl> tuple(ycsbtable_man);
    rep_row_t areprow(ycsbtable_man->ts());
    rep_row_t areprowkey(ycsbtable_man->ts());
    areprow.set(ycsbtable_man->table()->maxsize());
    areprowkey.set(ycsbtable_man->table()->maxsize());
    tuple->_rep = &areprow;
    tuple->_rep_key = &areprowkey;

    // Probe index for given key
    W_DO(ycsbtable_man->index_probe_forupdate(_pssm, tuple, pin.key));
    // Update value of given field
    w_assert1(pin.field_number <= FieldCount);
    w_assert1(pin.field_number > 0);
    tuple->set_value(pin.field_number, pin.value);
    W_DO(ycsbtable_man->update_tuple(_pssm, tuple));

    return RCOK;
}