/* * __wt_schema_range_truncate -- * WT_SESSION::truncate with a range. */ int __wt_schema_range_truncate( WT_SESSION_IMPL *session, WT_CURSOR *start, WT_CURSOR *stop) { WT_DATA_SOURCE *dsrc; WT_DECL_RET; const char *uri; uri = start->internal_uri; if (WT_PREFIX_MATCH(uri, "file:")) { WT_ERR(__cursor_needkey(start)); if (stop != NULL) WT_ERR(__cursor_needkey(stop)); WT_WITH_BTREE(session, ((WT_CURSOR_BTREE *)start)->btree, ret = __wt_btcur_range_truncate( (WT_CURSOR_BTREE *)start, (WT_CURSOR_BTREE *)stop)); } else if (WT_PREFIX_MATCH(uri, "table:")) ret = __wt_table_range_truncate( (WT_CURSOR_TABLE *)start, (WT_CURSOR_TABLE *)stop); else if ((dsrc = __wt_schema_get_source(session, uri)) != NULL && dsrc->range_truncate != NULL) ret = dsrc->range_truncate(dsrc, &session->iface, start, stop); else ret = __wt_range_truncate(start, stop); err: return (ret); }
/* * __curstat_get_key -- * WT_CURSOR->get_key for statistics cursors. */ static int __curstat_get_key(WT_CURSOR *cursor, ...) { WT_CURSOR_STAT *cst; WT_DECL_RET; WT_ITEM *item; WT_SESSION_IMPL *session; size_t size; va_list ap; cst = (WT_CURSOR_STAT *)cursor; va_start(ap, cursor); CURSOR_API_CALL(cursor, session, get_key, NULL); WT_ERR(__cursor_needkey(cursor)); if (F_ISSET(cursor, WT_CURSTD_RAW)) { WT_ERR(__wt_struct_size( session, &size, cursor->key_format, cst->key)); WT_ERR(__wt_buf_initsize(session, &cursor->key, size)); WT_ERR(__wt_struct_pack(session, cursor->key.mem, size, cursor->key_format, cst->key)); item = va_arg(ap, WT_ITEM *); item->data = cursor->key.data; item->size = cursor->key.size; } else
/* * __curds_compare -- * WT_CURSOR.compare method for the data-source cursor type. */ static int __curds_compare(WT_CURSOR *a, WT_CURSOR *b, int *cmpp) { WT_COLLATOR *collator; WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(a, session, compare, NULL); /* * Confirm both cursors refer to the same source and have keys, then * compare them. */ if (strcmp(a->internal_uri, b->internal_uri) != 0) WT_ERR_MSG(session, EINVAL, "Cursors must reference the same object"); WT_ERR(__cursor_needkey(a)); WT_ERR(__cursor_needkey(b)); if (WT_CURSOR_RECNO(a)) { if (a->recno < b->recno) *cmpp = -1; else if (a->recno == b->recno) *cmpp = 0; else *cmpp = 1; } else { /* * The assumption is data-sources don't provide WiredTiger with * WT_CURSOR.compare methods, instead, we'll copy the key/value * out of the underlying data-source cursor and any comparison * to be done can be done at this level. */ collator = ((WT_CURSOR_DATA_SOURCE *)a)->collator; WT_ERR(__wt_compare( session, collator, &a->key, &b->key, cmpp)); } err: API_END_RET(session, ret); }
/* * __curds_key_set -- * Set the key for the data-source. */ static int __curds_key_set(WT_CURSOR *cursor) { WT_CURSOR *source; source = ((WT_CURSOR_DATA_SOURCE *)cursor)->source; WT_RET(__cursor_needkey(cursor)); source->recno = cursor->recno; source->key.data = cursor->key.data; source->key.size = cursor->key.size; return (0); }