当前位置: 首页>>代码示例>>C++>>正文


C++ DBC::put方法代码示例

本文整理汇总了C++中DBC::put方法的典型用法代码示例。如果您正苦于以下问题:C++ DBC::put方法的具体用法?C++ DBC::put怎么用?C++ DBC::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBC的用法示例。


在下文中一共展示了DBC::put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rberkeley_dbcursor_put

/* {{{ rberkeley_dbcursor_put */
SEXP rberkeley_dbcursor_put (SEXP _dbc, SEXP _key, SEXP _data, SEXP _flags)
{
  DBC *dbc;
  DBT key, data;
  u_int32_t flags;
  int ret;

  flags = (u_int32_t)INTEGER(_flags)[0];
  if(flags != DB_AFTER &&
     flags != DB_BEFORE &&
     flags != DB_CURRENT &&
     flags != DB_KEYFIRST &&
     flags != DB_KEYLAST &&
     flags != DB_NODUPDATA) {
    error("incorrect flags value");
  }
  dbc = R_ExternalPtrAddr(_dbc);
  if(R_ExternalPtrTag(_dbc) != install("DBC") || dbc == NULL)
    error("invalid 'dbc' handle");

  memset(&key, 0, sizeof(DBT));
  memset(&data, 0, sizeof(DBT));

  key.data = (unsigned char *)RAW(_key);
  key.size = length(_key);

  data.data = (unsigned char *)RAW(_data);
  data.size = length(_data);

  ret = dbc->put(dbc, &key, &data, flags);

  return ScalarInteger(ret);
}
开发者ID:cran,项目名称:RBerkeley,代码行数:34,代码来源:cursor.c

示例2:

static int
kvs_cursor_update(WT_CURSOR *wtcursor)
{
	CURSOR_SOURCE *cursor;
	DBC *dbc;
	DBT *key, *value;
	WT_EXTENSION_API *wt_api;
	WT_SESSION *session;
	int ret = 0;

	session = wtcursor->session;
	cursor = (CURSOR_SOURCE *)wtcursor;
	wt_api = cursor->wt_api;

	dbc = cursor->dbc;
	key = &cursor->key;
	value = &cursor->value;

	if ((ret = copyin_key(wtcursor)) != 0)
		return (ret);
	copyin_value(wtcursor);

	if ((ret = dbc->put(dbc, key, value, DB_KEYFIRST)) != 0)
		ERET(wt_api,
		    session, WT_ERROR, "DbCursor.put: %s", db_strerror(ret));

	return (0);
}
开发者ID:Machyne,项目名称:mongo,代码行数:28,代码来源:kvs_bdb.c

示例3: replace_impl

/**
 @brief replace OR insert a record
 @note
  if not thrown an exception, always success
 @return true replace the record
		 false insert the record
 @throws exception, failed
 */
bool kmapdset_base::replace_impl(const void* k1, const void* d, DB_TXN* txn, const char* func)
{
	PortableDataOutput<AutoGrownMemIO> oKey1, oData;
	try {
		save_key1(oKey1, k1);
		save_data(oData, d);
	}
	catch (const IOException& exp)
	{
		string_appender<> oss;
		oss << exp.what() << "... at: " << func;
		throw std::runtime_error(oss.str());
	}
	DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
	DBT tdd; memset(&tdd, 0, sizeof(DBT)); tdd.data = oData.begin(); tdd.size = oData.tell();
	DBC* curp = NULL;
	int ret = m_db->cursor(m_db, txn, &curp, 0);
	if (0 == ret)
	{
		ret = curp->get(curp, &tk1, &tdd, DB_GET_BOTH);
		if (0 == ret)
		{
			tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
			tdd.data = oData.begin(); tdd.size = oData.tell();
			ret = curp->put(curp, &tk1, &tdd, DB_CURRENT);
			curp->close(curp);
			if (0 == ret)
				return true;
		}
		else if (DB_NOTFOUND == ret)
		{
			ret = curp->put(curp, &tk1, &tdd, DB_NODUPDATA);
			curp->close(curp);
			if (0 == ret)
				return false;
		}
	}
	string_appender<> oss;
	oss << db_strerror(ret)
		<< "... at: " << func
		<< "\n"
		;
	throw std::runtime_error(oss.str());
}
开发者ID:rockeet,项目名称:nark-berkeley-db-util,代码行数:52,代码来源:kmapdset.cpp

示例4:

void
bdb_insert(
    const void *key_data, uint32_t key_size,
    const void *value_data, uint32_t value_size)
{
	DBC *dbc;

	key.data = (void *)key_data;
	key.size = key_size;
	value.data = (void *)value_data;
	value.size = value_size;

	dbc = g.dbc;

	assert(dbc->put(dbc, &key, &value, DB_KEYFIRST) == 0);
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:16,代码来源:bdb.c

示例5: if

static int
kvs_cursor_insert(WT_CURSOR *wtcursor)
{
	CURSOR_SOURCE *cursor;
	DB *db;
	DBC *dbc;
	DBT *key, *value;
	WT_EXTENSION_API *wt_api;
	WT_SESSION *session;
	int ret = 0;

	session = wtcursor->session;
	cursor = (CURSOR_SOURCE *)wtcursor;
	wt_api = cursor->wt_api;

	dbc = cursor->dbc;
	db = cursor->db;
	key = &cursor->key;
	value = &cursor->value;

	if ((ret = copyin_key(wtcursor)) != 0)
		return (ret);
	copyin_value(wtcursor);

	if (cursor->config_append) {
		/*
		 * Berkeley DB cursors have no operation to append/create a
		 * new record and set the cursor; use the DB handle instead
		 * then set the cursor explicitly.
		 *
		 * When appending, we're allocating and returning a new record
		 * number.
		 */
		if ((ret = db->put(db, NULL, key, value, DB_APPEND)) != 0)
			ERET(wt_api,
			    session, WT_ERROR, "Db.put: %s", db_strerror(ret));
		wtcursor->recno = *(db_recno_t *)key->data;

		if ((ret = dbc->get(dbc, key, value, DB_SET)) != 0)
			ERET(wt_api, session, WT_ERROR,
			    "DbCursor.get: %s", db_strerror(ret));
	} else if (cursor->config_overwrite) {
		if ((ret = dbc->put(dbc, key, value, DB_KEYFIRST)) != 0)
			ERET(wt_api, session, WT_ERROR,
			    "DbCursor.put: %s", db_strerror(ret));
	} else {
		/*
		 * Berkeley DB cursors don't have a no-overwrite flag; use
		 * the DB handle instead then set the cursor explicitly.
		 */
		if ((ret =
		    db->put(db, NULL, key, value, DB_NOOVERWRITE)) != 0) {
			if (ret == DB_KEYEXIST)
				return (WT_DUPLICATE_KEY);
			ERET(wt_api,
			    session, WT_ERROR, "Db.put: %s", db_strerror(ret));
		}
		if ((ret = dbc->get(dbc, key, value, DB_SET)) != 0)
			ERET(wt_api, session, WT_ERROR,
			    "DbCursor.get: %s", db_strerror(ret));
	}

	return (0);
}
开发者ID:Machyne,项目名称:mongo,代码行数:64,代码来源:kvs_bdb.c


注:本文中的DBC::put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。