/* * __curfile_compare -- * WT_CURSOR->compare method for the btree cursor type. */ static int __curfile_compare(WT_CURSOR *a, WT_CURSOR *b, int *cmpp) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)a; CURSOR_API_CALL(a, session, compare, cbt->btree); /* * Check both cursors are a "file:" type then call the underlying * function, it can handle cursors pointing to different objects. */ if (!WT_PREFIX_MATCH(a->internal_uri, "file:") || !WT_PREFIX_MATCH(b->internal_uri, "file:")) WT_ERR_MSG(session, EINVAL, "Cursors must reference the same object"); WT_CURSOR_CHECKKEY(a); WT_CURSOR_CHECKKEY(b); ret = __wt_btcur_compare( (WT_CURSOR_BTREE *)a, (WT_CURSOR_BTREE *)b, cmpp); err: API_END_RET(session, ret); }
/* * __wt_btcur_equals -- * Return an equality comparison between two cursors. */ int __wt_btcur_equals(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *equalp) { WT_CURSOR *a, *b; WT_SESSION_IMPL *session; int cmp; a = (WT_CURSOR *)a_arg; b = (WT_CURSOR *)b_arg; cmp = 0; session = (WT_SESSION_IMPL *)a->session; /* Confirm both cursors reference the same object. */ if (a_arg->btree != b_arg->btree) WT_RET_MSG( session, EINVAL, "Cursors must reference the same object"); /* * The reason for an equals method is because we can avoid doing * a full key comparison in some cases. If both cursors point into the * tree, take the fast path, otherwise fall back to the slower compare * method; in both cases, return 1 if the cursors are equal, 0 if they * are not. */ if (F_ISSET(a, WT_CURSTD_KEY_INT) && F_ISSET(b, WT_CURSTD_KEY_INT)) *equalp = __cursor_equals(a_arg, b_arg); else { WT_RET(__wt_btcur_compare(a_arg, b_arg, &cmp)); *equalp = (cmp == 0) ? 1 : 0; } return (0); }
/* * __curfile_compare -- * WT_CURSOR->compare method for the btree cursor type. */ static int __curfile_compare(WT_CURSOR *a, WT_CURSOR *b, int *cmpp) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)a; CURSOR_API_CALL(a, session, compare, cbt->btree); /* * Confirm both cursors refer to the same source and have keys, then * call the underlying object to compare them. */ if (strcmp(a->uri, b->uri) != 0) WT_ERR_MSG(session, EINVAL, "comparison method cursors must reference the same object"); WT_CURSOR_NEEDKEY(a); WT_CURSOR_NEEDKEY(b); ret = __wt_btcur_compare( (WT_CURSOR_BTREE *)a, (WT_CURSOR_BTREE *)b, cmpp); err: API_END(session); return (ret); }