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


C++ KeySet::diff方法代码示例

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


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

示例1: update

MojErr MojDbIndex::update(const MojObject* newObj, const MojObject* oldObj, MojDbStorageTxn* txn, bool forcedel)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(isOpen());
	MojAssert(newObj || oldObj);

	// figure out which versions we include
	bool includeOld = includeObj(oldObj);
	bool includeNew = includeObj(newObj);

	if (includeNew && !includeOld) {
		// we include the new but not the old, so just put all the new keys
		MojAssert(newObj);
		KeySet newKeys;
		MojErr err = getKeys(*newObj, newKeys);
		MojErrCheck(err);
		err = insertKeys(newKeys, txn);
		MojErrCheck(err);
		err = notifyWatches(newKeys, txn);
		MojErrCheck(err);
        LOG_DEBUG("[db_mojodb] IndexAdd: %s; Keys= %zu \n", this->m_name.data(), newKeys.size());
	} else if (includeOld && !includeNew) {
		// we include the old but not the new objects, so del all the old keys
		MojAssert(oldObj);
		KeySet oldKeys;
		MojErr err = getKeys(*oldObj, oldKeys);
		MojErrCheck(err);
		err = delKeys(oldKeys, txn, forcedel);
		MojErrCheck(err);
		err = notifyWatches(oldKeys, txn);
		MojErrCheck(err);
        LOG_DEBUG("[db_mojodb] IndexDel: %s; Keys= %zu \n", this->name().data(), oldKeys.size());
	} else if (includeNew && includeOld) {
		// we include old and new objects
		MojAssert(newObj && oldObj);
		KeySet newKeys;
		MojErr err = getKeys(*newObj, newKeys);
		MojErrCheck(err);
		KeySet oldKeys;
		err = getKeys(*oldObj, oldKeys);
		MojErrCheck(err);
		// we need to put the keys that are in the new set, but not in the old
		KeySet keysToPut;
		err = newKeys.diff(oldKeys, keysToPut);
		MojErrCheck(err);
		// we need to del the keys that are in the old set, but not in the new
		KeySet keysToDel;
		err = oldKeys.diff(newKeys, keysToDel);
		MojErrCheck(err);
		err = insertKeys(keysToPut, txn);
		MojErrCheck(err);
		err = delKeys(keysToDel, txn, forcedel);
		
        LOG_DEBUG("[db_mojodb] IndexMerge: %s; OldKeys= %zu; NewKeys= %zu; Dropped= %zu; Added= %zu ; err = %d\n",
			this->name().data(), oldKeys.size(), newKeys.size(), keysToDel.size(), keysToPut.size(), (int)err);

		MojErrCheck(err);
		// notify on union of old and new keys
		err = newKeys.put(oldKeys);
		MojErrCheck(err);
		err = notifyWatches(newKeys, txn);
		MojErrCheck(err);
	
	}
	return MojErrNone;
}
开发者ID:sailesharya,项目名称:db8,代码行数:66,代码来源:MojDbIndex.cpp


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