Logo Search packages:      
Sourcecode: db version File versions

int com::sleepycat::collections::DataCursor::repositionRange ( byte[]  keyBytes,
byte[]  priKeyBytes,
byte[]  valueBytes,
boolean  lockForWrite 
) throws DatabaseException [inline, package]

Repositions to a given raw key/data pair, or just past it if that record has been deleted.

Returns:
REPOS_EXACT, REPOS_NEXT or REPOS_EOF.

Definition at line 235 of file DataCursor.java.

References com::sleepycat::collections::DataView::dupsAllowed, getLockMode(), com::sleepycat::util::keyrange::RangeCursor::getSearchBothRange(), com::sleepycat::util::keyrange::RangeCursor::getSearchKeyRange(), com::sleepycat::collections::DataView::isSecondary(), REPOS_EOF, REPOS_EXACT, REPOS_NEXT, and setThangs().

                                 {

        LockMode lockMode = getLockMode(lockForWrite);
        OperationStatus status = null;

        /* Use the given key/data byte arrays. */
        setThangs(keyBytes, priKeyBytes, valueBytes);

        /* Position on or after the given key/data pair. */
        if (view.dupsAllowed) {
            status = cursor.getSearchBothRange(keyThang, primaryKeyThang,
                                               valueThang, lockMode);
        }
        if (status != OperationStatus.SUCCESS) {
            status = cursor.getSearchKeyRange(keyThang, primaryKeyThang,
                                              valueThang, lockMode);
        }

        /* Return the result of the operation. */
        if (status == OperationStatus.SUCCESS) {
            if (!KeyRange.equalBytes(keyBytes, 0, keyBytes.length,
                                     keyThang.getData(),
                                     keyThang.getOffset(),
                                     keyThang.getSize())) {
                return REPOS_NEXT;
            }
            if (view.dupsAllowed) {
                DatabaseEntry thang = view.isSecondary() ? primaryKeyThang
                                                         : valueThang;
                byte[] bytes = view.isSecondary() ? priKeyBytes
                                                  : valueBytes;
                if (!KeyRange.equalBytes(bytes, 0, bytes.length,
                                         thang.getData(),
                                         thang.getOffset(),
                                         thang.getSize())) {
                    return REPOS_NEXT;
                }
            }
            return REPOS_EXACT;
        } else {
            return REPOS_EOF;
        }
    }


Generated by  Doxygen 1.6.0   Back to index