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


C++ TrieNode::isTerminalNode方法代码示例

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


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

示例1: _deleteRecordGetInternalId

// delete a record with a specific id //TODO Give the correct return message for delete pass/fail
// get the deleted internal recordID
INDEXWRITE_RETVAL IndexData::_deleteRecordGetInternalId(
		const std::string &externalRecordId, unsigned &internalRecordId) {
	bool hasRecord =
			this->forwardIndex->getInternalRecordIdFromExternalRecordId(
					externalRecordId, internalRecordId);
	if (hasRecord) {
		ForwardList* forwardList =
				this->forwardIndex->getForwardList_ForCommit(
						internalRecordId);
		this->permissionMap->deleteResourceFromRoles(externalRecordId, forwardList->getAccessList()->getRoles());

		if (this->schemaInternal->getIndexType()
				== srch2::instantsearch::LocationIndex) {

				StoredRecordBuffer buffer = forwardList->getInMemoryData();

				Schema * storedSchema = Schema::create();
				srch2::util::RecordSerializerUtil::populateStoredSchema(
						storedSchema, this->getSchema());
				srch2::util::RecordSerializer compactRecDeserializer =
						srch2::util::RecordSerializer(*storedSchema);

				// get the name of the attributes
				const string* nameOfLatitudeAttribute =
						this->getSchema()->getNameOfLatituteAttribute();
				const string* nameOfLongitudeAttribute =
						this->getSchema()->getNameOfLongitudeAttribute();

				unsigned idLat = storedSchema->getRefiningAttributeId(
						*nameOfLatitudeAttribute);
				unsigned latOffset = compactRecDeserializer.getRefiningOffset(
						idLat);

				unsigned idLong = storedSchema->getRefiningAttributeId(
						*nameOfLongitudeAttribute);
				unsigned longOffset = compactRecDeserializer.getRefiningOffset(
						idLong);
				Point point;
				point.x = *((float *) (buffer.start.get() + latOffset));
				point.y = *((float *) (buffer.start.get() + longOffset));
				this->quadTree->remove_ThreadSafe(point, internalRecordId);
		}
	}

	INDEXWRITE_RETVAL success =
			this->forwardIndex->deleteRecord(externalRecordId) ?
					OP_SUCCESS : OP_FAIL;


	if (success == OP_SUCCESS) {
		ForwardList * fwdList = this->forwardIndex->getForwardList_ForCommit(internalRecordId);
		if (fwdList) {
			unsigned keywordsCount = fwdList->getNumberOfKeywords();
			const unsigned * listofKeywordIds = fwdList->getKeywordIds();
			// Loop over the keyword-ids for the current forward list and get
			// the inverted-list-ids from the trie.
			TrieNodePath trieNodePath;
			trieNodePath.path = new vector<TrieNode *>();
			// first id: invertedListId; second id: keywordId
			vector<pair<unsigned, unsigned> > invertedListIdsToMerge;
			for (unsigned i = 0; i < keywordsCount; ++i) {
				unsigned keywordId = *(listofKeywordIds + i);
				// get the TrieNode path of the current keyword in write view based on its id.
				this->trie->getKeywordCorrespondingPathToTrieNode_WriteView(keywordId, &trieNodePath);
				if (trieNodePath.path->size() == 0) {
					// should not happen.
					ASSERT(false);
					continue;
				}
				TrieNode * leafNode = trieNodePath.path->back();
				if(leafNode && leafNode->isTerminalNode()) {
					invertedListIdsToMerge.push_back(make_pair(leafNode->invertedListOffset, leafNode->id));
				} else {
					// should not happen.
					ASSERT(false);
				}
				trieNodePath.path->clear();
			}
			delete trieNodePath.path;
			this->invertedIndex->appendInvertedListKeywordIdsForMerge(invertedListIdsToMerge);
		}

		this->mergeRequired = true; // need to tell the merge thread to merge
		this->writeCounter->decDocsCounter();
		this->writeCounter->incWritesCounter();
	}

	return success;
}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:91,代码来源:IndexData.cpp


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