示例#1
0
rc_t bt_cursor_t::next()
{
    if (!is_valid()) {
        return RCOK; // EOF
    }

    if (_first_time) {
        _first_time = false;
        W_DO(_locate_first ());
        if (_eof) {
            return RCOK;
        }
    }

    w_assert3(_pid);
    btree_page_h p;
    W_DO(_refix_current_key(p));
    w_assert3(p.is_fixed());
    w_assert3(p.pid() == _pid);

    W_DO(_check_page_update(p));

    // Move one slot to the right(left if backward scan)
    bool eof_ret = false;
    W_DO(_find_next(p, eof_ret));

    if (eof_ret) {
        close();
        return RCOK;
    }

    w_assert3(p.is_fixed());
    w_assert3(p.is_leaf());

    w_assert3(_slot >= 0);
    w_assert3(_slot < p.nrecs());

    // get the current slot's values
    W_DO( _make_rec(p) );
    return RCOK;
}
示例#2
0
State *StateCloner::_make_rec( Scp &p, const char *msg ) {
    // already created ?
    TC::iterator iter = created.find( p.bid() );
    if ( iter != created.end() ) {
        if ( p.display_steps )
            coutn << p.display_prefix << "found same bid " << p.bid();
        return iter->second;
    }

    // if not authorized
    if ( not p.state->eq_op_id() )
        return 0;

    // if dst
    if ( p.state == p.dst )
        return new State;


    // else, get updated instructions
    Vec<const Instruction *> vi;
    int an = -1;
    for( int i = 0; i < p.state->instructions.size(); ++i ) {
        P( *p.dst->instructions[ 0 ] );
        for( std::set<const Instruction *>::const_iterator v = p.dst->visited.begin(); v != p.dst->visited.end(); ++v )
            P( **v );

        if ( p.state->instructions[ i ]->can_lead_to( p.dst->instructions[ 0 ], p.dst->visited ) ) {
            if ( p.state->action_num == i )
                an = vi.size();
            vi << p.state->instructions[ i ];
        }
    }

    // do we need a set_mark ?
    if ( an >= 0 and vi.size() >= 2 and not p.set_mark ) {
        State *res = _new_State( p );
        res->instructions = vi;
        res->set_mark = true;
        res->action_num = -1;
        p.set_mark = res;
        res->add_next( _make_rec( p, "set_mark" ) );
        return res;
    }

    // do we need a use_mark ?
    if ( p.set_mark and vi.size() == 1 ) {
        State *res = _new_State( p );
        res->use_mark = p.set_mark;
        res->action_num = -1;
        res->instructions = vi;
        p.set_mark = 0;
        res->add_next( _make_rec( p, "use_mark" ) );
        use_mark_stack << res;
        return res;
    }

    // else, make a copy (with a new next and a new prev)
    State *res = _new_State( p );
    res->instructions = vi;
    res->action_num = an;

    for( int i = 0; i < p.state->next.size(); ++i ) {
        State::Next n = p.state->next[ i ];
        Scp np = p; np.state = n.s;
        n.s = _make_rec( np, "cont" );
        if ( n.s )
            res->add_next( n );
    }

    return res;
}
示例#3
0
State *StateCloner::make( State *smk, State *dst ) {
    dst->prev_mark( smk );

    Scp p( smk->next[ 0 ].s, dst );
    return _make_rec( p, "orig" );
}