本文整理汇总了C++中WT_CURSOR::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_CURSOR::reset方法的具体用法?C++ WT_CURSOR::reset怎么用?C++ WT_CURSOR::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_CURSOR
的用法示例。
在下文中一共展示了WT_CURSOR::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* __wt_las_cursor_close --
* Discard a lookaside cursor.
*/
int
__wt_las_cursor_close(
WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t session_flags)
{
WT_CONNECTION_IMPL *conn;
WT_CURSOR *cursor;
WT_DECL_RET;
conn = S2C(session);
if ((cursor = *cursorp) == NULL)
return (0);
*cursorp = NULL;
/* Reset the cursor. */
ret = cursor->reset(cursor);
/*
* We turned off caching and eviction while the lookaside cursor was in
* use, restore the session's flags.
*/
F_CLR(session, WT_SESSION_NO_CACHE | WT_SESSION_NO_EVICTION);
F_SET(session, session_flags);
/*
* Some threads have their own lookaside table cursors, else unlock the
* shared lookaside cursor.
*/
if (!F_ISSET(session, WT_SESSION_LOOKASIDE_CURSOR))
__wt_spin_unlock(session, &conn->las_lock);
return (ret);
}
示例2:
/*
* __wt_bloom_open --
* Open a Bloom filter object for use by a single session. The filter must
* have been created and finalized.
*/
int
__wt_bloom_open(WT_SESSION_IMPL *session,
const char *uri, uint32_t factor, uint32_t k,
WT_CURSOR *owner, WT_BLOOM **bloomp)
{
WT_BLOOM *bloom;
WT_CURSOR *c;
WT_DECL_RET;
uint64_t size;
WT_RET(__bloom_init(session, uri, NULL, &bloom));
WT_ERR(__bloom_open_cursor(bloom, owner));
c = bloom->c;
/* Find the largest key, to get the size of the filter. */
WT_ERR(c->prev(c));
WT_ERR(c->get_key(c, &size));
WT_ERR(c->reset(c));
WT_ERR(__bloom_setup(bloom, 0, size, factor, k));
*bloomp = bloom;
return (0);
err: (void)__wt_bloom_close(bloom);
return (ret);
}
示例3: fetchStats
void WiredTigerOperationStats::fetchStats(WT_SESSION* session,
const std::string& uri,
const std::string& config) {
invariant(session);
WT_CURSOR* c = nullptr;
const char* cursorConfig = config.empty() ? nullptr : config.c_str();
int ret = session->open_cursor(session, uri.c_str(), nullptr, cursorConfig, &c);
uassert(ErrorCodes::CursorNotFound, "Unable to open statistics cursor", ret == 0);
invariant(c);
ON_BLOCK_EXIT([&] { c->close(c); });
const char* desc;
uint64_t value;
uint64_t key;
while (c->next(c) == 0 && c->get_key(c, &key) == 0) {
fassert(51035, c->get_value(c, &desc, nullptr, &value) == 0);
#if defined(__s390x__)
_stats[key >> 32] = WiredTigerUtil::castStatisticsValue<long long>(value);
#else
_stats[key] = WiredTigerUtil::castStatisticsValue<long long>(value);
#endif // __s390x__
}
// Reset the statistics so that the next fetch gives the recent values.
invariantWTOK(c->reset(c));
}
示例4:
/*
* __session_reset_cursors --
* Reset all open cursors.
*/
static int
__session_reset_cursors(WT_SESSION_IMPL *session)
{
WT_CURSOR *cursor;
WT_DECL_RET;
TAILQ_FOREACH(cursor, &session->cursors, q)
WT_TRET(cursor->reset(cursor));
return (ret);
}
示例5: main
int main(void)
{
/*! [access example connection] */
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
const char *key, *value;
int ret;
if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0 ||
(ret = conn->open_session(conn, NULL, NULL, &session)) != 0) {
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
return (ret);
}
/*! [access example connection] */
/*! [access example table create] */
ret = session->create(session,
"table:access", "key_format=S,value_format=S");
/*! [access example table create] */
/*! [access example cursor open] */
ret = session->open_cursor(session,
"table:access", NULL, NULL, &cursor);
/*! [access example cursor open] */
/*! [access example cursor insert] */
cursor->set_key(cursor, "key1"); /* Insert a record. */
cursor->set_value(cursor, "value1");
ret = cursor->insert(cursor);
/*! [access example cursor insert] */
/*! [access example cursor list] */
ret = cursor->reset(cursor); /* Restart the scan. */
while ((ret = cursor->next(cursor)) == 0) {
ret = cursor->get_key(cursor, &key);
ret = cursor->get_value(cursor, &value);
printf("Got record: %s : %s\n", key, value);
}
/*! [access example cursor list] */
/*! [access example close] */
ret = conn->close(conn, NULL);
/*! [access example close] */
return (ret);
}
示例6: if
/*
* __clsm_next --
* WT_CURSOR->next method for the LSM cursor type.
*/
static int
__clsm_next(WT_CURSOR *cursor)
{
WT_CURSOR_LSM *clsm;
WT_CURSOR *c;
WT_DECL_RET;
WT_SESSION_IMPL *session;
u_int i;
int cmp;
bool check, deleted;
clsm = (WT_CURSOR_LSM *)cursor;
CURSOR_API_CALL(cursor, session, next, NULL);
WT_CURSOR_NOVALUE(cursor);
WT_ERR(__clsm_enter(clsm, false, false));
/* If we aren't positioned for a forward scan, get started. */
if (clsm->current == NULL || !F_ISSET(clsm, WT_CLSM_ITERATE_NEXT)) {
F_CLR(clsm, WT_CLSM_MULTIPLE);
WT_FORALL_CURSORS(clsm, c, i) {
if (!F_ISSET(cursor, WT_CURSTD_KEY_SET)) {
WT_ERR(c->reset(c));
ret = c->next(c);
} else if (c != clsm->current) {
c->set_key(c, &cursor->key);
if ((ret = c->search_near(c, &cmp)) == 0) {
if (cmp < 0)
ret = c->next(c);
else if (cmp == 0) {
if (clsm->current == NULL)
clsm->current = c;
else
F_SET(clsm,
WT_CLSM_MULTIPLE);
}
} else
F_CLR(c, WT_CURSTD_KEY_SET);
}
WT_ERR_NOTFOUND_OK(ret);
}
F_SET(clsm, WT_CLSM_ITERATE_NEXT);
F_CLR(clsm, WT_CLSM_ITERATE_PREV);
/* We just positioned *at* the key, now move. */
if (clsm->current != NULL)
goto retry;
} else {
示例7:
/*
* __curds_cursor_resolve --
* Resolve cursor operation.
*/
static int
__curds_cursor_resolve(WT_CURSOR *cursor, int ret)
{
WT_CURSOR *source;
source = ((WT_CURSOR_DATA_SOURCE *)cursor)->source;
/*
* Update the cursor's key, value and flags. (We use the _INT flags in
* the same way as file objects: there's some chance the underlying data
* source is passing us a reference to data only pinned per operation,
* might as well be safe.)
*
* There's also a requirement the underlying data-source never returns
* with the cursor/source key referencing application memory: it'd be
* great to do a copy as necessary here so the data-source doesn't have
* to worry about copying the key, but we don't have enough information
* to know if a cursor is pointing at application or data-source memory.
*/
if (ret == 0) {
cursor->key.data = source->key.data;
cursor->key.size = source->key.size;
cursor->value.data = source->value.data;
cursor->value.size = source->value.size;
cursor->recno = source->recno;
F_CLR(cursor, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT);
F_SET(cursor, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT);
} else {
if (ret == WT_NOTFOUND)
F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET);
else
F_CLR(cursor, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT);
/*
* Cursor operation failure implies a lost cursor position and
* a subsequent next/prev starting at the beginning/end of the
* table. We simplify underlying data source implementations
* by resetting the cursor explicitly here.
*/
WT_TRET(source->reset(source));
}
return (ret);
}
示例8:
/*
* __wt_metadata_cursor_release --
* Release a metadata cursor.
*/
int
__wt_metadata_cursor_release(WT_SESSION_IMPL *session, WT_CURSOR **cursorp)
{
WT_CURSOR *cursor;
WT_UNUSED(session);
if ((cursor = *cursorp) == NULL)
return (0);
*cursorp = NULL;
/*
* If using the session's cached metadata cursor, clear the in-use flag
* and reset it, otherwise, discard the cursor.
*/
if (F_ISSET(cursor, WT_CURSTD_META_INUSE)) {
WT_ASSERT(session, cursor == session->meta_cursor);
F_CLR(cursor, WT_CURSTD_META_INUSE);
return (cursor->reset(cursor));
}
return (cursor->close(cursor));
}
示例9: indexSearch
void indexSearch(size_t indexId, fstring key, valvec<llong>* recIdvec) override {
assert(started == m_status);
assert(indexId < m_indices.size());
WT_ITEM item;
WT_SESSION* ses = m_session.ses;
const Schema& schema = m_sconf.getIndexSchema(indexId);
WT_CURSOR* cur = m_indices[indexId].insert;
WtWritableIndex::setKeyVal(schema, cur, key, 0, &item, &m_wrtBuf);
recIdvec->erase_all();
if (schema.m_isUnique) {
int err = cur->search(cur);
BOOST_SCOPE_EXIT(cur) { cur->reset(cur); } BOOST_SCOPE_EXIT_END;
if (WT_NOTFOUND == err) {
return;
}
if (err) {
THROW_STD(invalid_argument
, "ERROR: wiredtiger search: %s", ses->strerror(ses, err));
}
llong recId = 0;
cur->get_value(cur, &recId);
recIdvec->push_back(recId);
}
示例10: storeInto
void WiredTigerSizeStorer::storeInto( WiredTigerSession* session,
const std::string& uri ) {
Map myMap;
{
boost::mutex::scoped_lock lk( _entriesMutex );
for ( Map::iterator it = _entries.begin(); it != _entries.end(); ++it ) {
std::string uriKey = it->first;
Entry& entry = it->second;
if ( entry.rs ) {
if ( entry.dataSize != entry.rs->dataSize( NULL ) ) {
entry.dataSize = entry.rs->dataSize( NULL );
entry.dirty = true;
}
if ( entry.numRecords != entry.rs->numRecords( NULL ) ) {
entry.numRecords = entry.rs->numRecords( NULL );
entry.dirty = true;
}
}
if ( !entry.dirty )
continue;
myMap[uriKey] = entry;
}
}
WT_SESSION* s = session->getSession();
WT_CURSOR* c = NULL;
int ret = s->open_cursor( s, uri.c_str(), NULL, NULL, &c );
if ( ret == ENOENT ) {
invariantWTOK( s->create( s, uri.c_str(), "" ) );
ret = s->open_cursor( s, uri.c_str(), NULL, NULL, &c );
}
invariantWTOK( ret );
for ( Map::iterator it = myMap.begin(); it != myMap.end(); ++it ) {
string uriKey = it->first;
Entry& entry = it->second;
BSONObj data;
{
BSONObjBuilder b;
b.append( "numRecords", entry.numRecords );
b.append( "dataSize", entry.dataSize );
data = b.obj();
}
LOG(2) << "WiredTigerSizeStorer::storeInto " << uriKey << " -> " << data;
WiredTigerItem key( uriKey.c_str(), uriKey.size() );
WiredTigerItem value( data.objdata(), data.objsize() );
c->set_key( c, key.Get() );
c->set_value( c, value.Get() );
invariantWTOK( c->insert(c) );
entry.dirty = false;
c->reset(c);
}
invariantWTOK( c->close(c) );
}
示例11: if
/*
* __curjoin_entry_member --
* Do a membership check for a particular index that was joined,
* if not a member, returns WT_NOTFOUND.
*/
static int
__curjoin_entry_member(WT_SESSION_IMPL *session, WT_CURSOR_JOIN_ENTRY *entry,
WT_ITEM *key, WT_CURSOR_JOIN_ITER *iter)
{
WT_CURJOIN_EXTRACTOR extract_cursor;
WT_CURSOR *c;
WT_CURSOR_STATIC_INIT(iface,
__wt_cursor_get_key, /* get-key */
__wt_cursor_get_value, /* get-value */
__wt_cursor_set_key, /* set-key */
__wt_cursor_set_value, /* set-value */
__wt_cursor_compare_notsup, /* compare */
__wt_cursor_equals_notsup, /* equals */
__wt_cursor_notsup, /* next */
__wt_cursor_notsup, /* prev */
__wt_cursor_notsup, /* reset */
__wt_cursor_notsup, /* search */
__wt_cursor_search_near_notsup, /* search-near */
__curjoin_extract_insert, /* insert */
__wt_cursor_modify_notsup, /* modify */
__wt_cursor_notsup, /* update */
__wt_cursor_notsup, /* remove */
__wt_cursor_notsup, /* reserve */
__wt_cursor_reconfigure_notsup, /* reconfigure */
__wt_cursor_notsup, /* cache */
__wt_cursor_reopen_notsup, /* reopen */
__wt_cursor_notsup); /* close */
WT_DECL_RET;
WT_INDEX *idx;
WT_ITEM v;
bool bloom_found;
if (entry->subjoin == NULL && iter != NULL &&
(iter->end_pos + iter->end_skip >= entry->ends_next ||
(iter->end_skip > 0 &&
F_ISSET(entry, WT_CURJOIN_ENTRY_DISJUNCTION))))
return (0); /* no checks to make */
entry->stats.membership_check++;
bloom_found = false;
if (entry->bloom != NULL) {
/*
* If the item is not in the Bloom filter, we return
* immediately, otherwise, we still may need to check the
* long way, since it may be a false positive.
*
* If we don't own the Bloom filter, we must be sharing one
* in a previous entry. So the shared filter has already
* been checked and passed, we don't need to check it again.
* We'll still need to check the long way.
*/
if (F_ISSET(entry, WT_CURJOIN_ENTRY_OWN_BLOOM))
WT_ERR(__wt_bloom_inmem_get(entry->bloom, key));
if (F_ISSET(entry, WT_CURJOIN_ENTRY_FALSE_POSITIVES))
return (0);
bloom_found = true;
}
if (entry->subjoin != NULL) {
WT_ASSERT(session,
iter == NULL || entry->subjoin == iter->child->cjoin);
ret = __curjoin_entries_in_range(session, entry->subjoin,
key, iter == NULL ? NULL : iter->child);
if (iter != NULL &&
WT_CURJOIN_ITER_CONSUMED(iter->child)) {
WT_ERR(__curjoin_iter_bump(iter));
ret = WT_NOTFOUND;
}
return (ret);
}
if (entry->index != NULL) {
/*
* If this entry is used by the iterator, then we already
* have the index key, and we won't have to do any
* extraction either.
*/
if (iter != NULL && entry == iter->entry)
WT_ITEM_SET(v, iter->idxkey);
else {
memset(&v, 0, sizeof(v)); /* Keep lint quiet. */
c = entry->main;
c->set_key(c, key);
entry->stats.main_access++;
if ((ret = c->search(c)) == 0)
ret = c->get_value(c, &v);
else if (ret == WT_NOTFOUND) {
__wt_err(session, ret,
"main table for join is missing entry");
ret = WT_ERROR;
}
WT_TRET(c->reset(c));
WT_ERR(ret);
}
} else
WT_ITEM_SET(v, *key);
//.........这里部分代码省略.........
示例12: strlen
//.........这里部分代码省略.........
/*! [Set the cursor's string value] */
}
{
/*! [Get the cursor's string value] */
const char *value; /* Get the cursor's string value. */
error_check(cursor->get_value(cursor, &value));
/*! [Get the cursor's string value] */
}
{
/*! [Get the cursor's raw value] */
WT_ITEM value; /* Get the cursor's raw value. */
error_check(cursor->get_value(cursor, &value));
/*! [Get the cursor's raw value] */
}
{
/*! [Set the cursor's raw value] */
WT_ITEM value; /* Set the cursor's raw value. */
value.data = "another value";
value.size = strlen("another value");
cursor->set_value(cursor, &value);
/*! [Set the cursor's raw value] */
error_check(cursor->insert(cursor));
}
/*! [Return the next record] */
error_check(cursor->next(cursor));
/*! [Return the next record] */
/*! [Reset the cursor] */
error_check(cursor->reset(cursor));
/*! [Reset the cursor] */
/*! [Return the previous record] */
error_check(cursor->prev(cursor));
/*! [Return the previous record] */
{
WT_CURSOR *other = NULL;
error_check(
session->open_cursor(session, NULL, cursor, NULL, &other));
{
/*! [Cursor comparison] */
int compare;
error_check(cursor->compare(cursor, other, &compare));
if (compare == 0) {
/* Cursors reference the same key */
} else if (compare < 0) {
/* Cursor key less than other key */
} else if (compare > 0) {
/* Cursor key greater than other key */
}
/*! [Cursor comparison] */
}
{
/*! [Cursor equality] */
int equal;
error_check(cursor->equals(cursor, other, &equal));
if (equal) {
/* Cursors reference the same key */
}
示例13: strlen
//.........这里部分代码省略.........
{
/*! [Set the cursor's record number key] */
uint64_t recno = 37; /* Set the cursor's record number key. */
cursor->set_key(cursor, recno);
/*! [Set the cursor's record number key] */
}
{
/*! [Set the cursor's string value] */
/* Set the cursor's string value. */
const char *value = "another value";
cursor->set_value(cursor, value);
/*! [Set the cursor's string value] */
}
{
/*! [Set the cursor's raw value] */
WT_ITEM value; /* Set the cursor's raw value. */
value.data = "another value";
value.size = strlen("another value");
cursor->set_value(cursor, &value);
/*! [Set the cursor's raw value] */
}
/*! [Return the next record] */
ret = cursor->next(cursor);
/*! [Return the next record] */
/*! [Return the previous record] */
ret = cursor->prev(cursor);
/*! [Return the previous record] */
/*! [Reset the cursor] */
ret = cursor->reset(cursor);
/*! [Reset the cursor] */
{
WT_CURSOR *other = NULL;
/*! [Cursor comparison] */
int compare;
ret = cursor->compare(cursor, other, &compare);
if (compare == 0) {
/* Cursors reference the same key */
} else if (compare < 0) {
/* Cursor key less than other key */
} else if (compare > 0) {
/* Cursor key greater than other key */
}
/*! [Cursor comparison] */
}
{
/*! [Search for an exact match] */
const char *key = "some key";
cursor->set_key(cursor, key);
ret = cursor->search(cursor);
/*! [Search for an exact match] */
}
cursor_search_near(cursor);
{
/*! [Insert a new record] */
/* Insert a new record. */
const char *key = "some key", *value = "some value";
cursor->set_key(cursor, key);
示例14: if
/*
* __curjoin_entry_member --
* Do a membership check for a particular index that was joined,
* if not a member, returns WT_NOTFOUND.
*/
static int
__curjoin_entry_member(WT_SESSION_IMPL *session, WT_CURSOR_JOIN *cjoin,
WT_CURSOR_JOIN_ENTRY *entry, bool skip_left)
{
WT_CURJOIN_EXTRACTOR extract_cursor;
WT_CURSOR *c;
WT_CURSOR_STATIC_INIT(iface,
__wt_cursor_get_key, /* get-key */
__wt_cursor_get_value, /* get-value */
__wt_cursor_set_key, /* set-key */
__wt_cursor_set_value, /* set-value */
__wt_cursor_notsup, /* compare */
__wt_cursor_notsup, /* equals */
__wt_cursor_notsup, /* next */
__wt_cursor_notsup, /* prev */
__wt_cursor_notsup, /* reset */
__wt_cursor_notsup, /* search */
__wt_cursor_notsup, /* search-near */
__curjoin_extract_insert, /* insert */
__wt_cursor_notsup, /* update */
__wt_cursor_notsup, /* reconfigure */
__wt_cursor_notsup, /* remove */
__wt_cursor_notsup); /* close */
WT_DECL_RET;
WT_INDEX *idx;
WT_ITEM *key, v;
bool bloom_found;
key = cjoin->iter->curkey;
entry->stats.accesses++;
bloom_found = false;
if (entry->bloom != NULL) {
/*
* If we don't own the Bloom filter, we must be sharing one
* in a previous entry. So the shared filter has already
* been checked and passed.
*/
if (!F_ISSET(entry, WT_CURJOIN_ENTRY_OWN_BLOOM))
return (0);
/*
* If the item is not in the Bloom filter, we return
* immediately, otherwise, we still need to check the
* long way.
*/
WT_ERR(__wt_bloom_inmem_get(entry->bloom, key));
bloom_found = true;
}
if (entry->index != NULL) {
memset(&v, 0, sizeof(v)); /* Keep lint quiet. */
c = entry->main;
c->set_key(c, key);
if ((ret = c->search(c)) == 0)
ret = c->get_value(c, &v);
else if (ret == WT_NOTFOUND)
WT_ERR_MSG(session, WT_ERROR,
"main table for join is missing entry.");
WT_TRET(c->reset(c));
WT_ERR(ret);
} else
v = *key;
if ((idx = entry->index) != NULL && idx->extractor != NULL) {
extract_cursor.iface = iface;
extract_cursor.iface.session = &session->iface;
extract_cursor.iface.key_format = idx->exkey_format;
extract_cursor.ismember = 0;
extract_cursor.entry = entry;
WT_ERR(idx->extractor->extract(idx->extractor,
&session->iface, key, &v, &extract_cursor.iface));
if (!extract_cursor.ismember)
WT_ERR(WT_NOTFOUND);
} else
WT_ERR(__curjoin_entry_in_range(session, entry, &v, skip_left));
if (0) {
err: if (ret == WT_NOTFOUND && bloom_found)
entry->stats.bloom_false_positive++;
}
return (ret);
}
示例15: strlen
//.........这里部分代码省略.........
{
/*! [Set the cursor's string value] */
/* Set the cursor's string value. */
const char *value = "another value";
cursor->set_value(cursor, value);
/*! [Set the cursor's string value] */
}
{
/*! [Get the cursor's raw value] */
WT_ITEM value; /* Get the cursor's raw value. */
ret = cursor->get_value(cursor, &value);
/*! [Get the cursor's raw value] */
}
{
/*! [Set the cursor's raw value] */
WT_ITEM value; /* Set the cursor's raw value. */
value.data = "another value";
value.size = strlen("another value");
cursor->set_value(cursor, &value);
/*! [Set the cursor's raw value] */
}
/*! [Return the next record] */
ret = cursor->next(cursor);
/*! [Return the next record] */
/*! [Return the previous record] */
ret = cursor->prev(cursor);
/*! [Return the previous record] */
/*! [Reset the cursor] */
ret = cursor->reset(cursor);
/*! [Reset the cursor] */
{
WT_CURSOR *other = NULL;
/*! [Cursor comparison] */
int compare;
ret = cursor->compare(cursor, other, &compare);
if (compare == 0) {
/* Cursors reference the same key */
} else if (compare < 0) {
/* Cursor key less than other key */
} else if (compare > 0) {
/* Cursor key greater than other key */
}
/*! [Cursor comparison] */
}
{
/*! [Search for an exact match] */
const char *key = "some key";
cursor->set_key(cursor, key);
ret = cursor->search(cursor);
/*! [Search for an exact match] */
}
cursor_search_near(cursor);
{
/*! [Insert a new record or overwrite an existing record] */
/* Insert a new record or overwrite an existing record. */
const char *key = "some key", *value = "some value";
ret = session->open_cursor(