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


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

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


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

示例1: reassignKeywordIds

void IndexData::reassignKeywordIds() {
	map<TrieNode *, unsigned> trieNodeIdMapper; //
	this->trie->reassignKeywordIds(trieNodeIdMapper);

	// Generating an ID mapper by iterating through the set of trie nodes whose
	// ids need to be reassigned
	// a map from temperory id to new ids, this map is used for changing forwardIndex and quadTree
	map<unsigned, unsigned> keywordIdMapper;
	for (map<TrieNode *, unsigned>::iterator iter = trieNodeIdMapper.begin();
			iter != trieNodeIdMapper.end(); ++iter) {
		TrieNode *node = iter->first;
		unsigned newKeywordId = iter->second;

		keywordIdMapper[node->getId()] = newKeywordId;

		node->setId(newKeywordId); // set the new keyword Id
	}

	map<unsigned, unsigned> processedRecordIds; // keep track of records that have been converted

	// Now we have the ID mapper.  We want to go through the trie nodes one by one.
	// For each of them, access its inverted list.  For each record,
	// use the id mapper to change the integers on the forward list.
	changeKeywordIdsOnForwardLists(trieNodeIdMapper, keywordIdMapper,
			processedRecordIds);

	// apply the ID mapper on the keyword ids of empty leaf nodes
	this->trie->applyKeywordIdMapperOnEmptyLeafNodes(keywordIdMapper);
}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:29,代码来源:IndexData.cpp

示例2: changeKeywordIdsOnForwardLists

/*
 * Uses the id mapped to replace old ids to new ids in forward list.
 * since we use inverted index to go through all records of a keyword it is possible to visit a record more than once
 * so we use processedRecordIds to remember what records have been reassigned.
 */
void IndexData::changeKeywordIdsOnForwardLists(
		const map<TrieNode *, unsigned> &trieNodeIdMapper,
		const map<unsigned, unsigned> &keywordIdMapper,
		map<unsigned, unsigned> &processedRecordIds) {
	vectorview<unsigned>* &keywordIDsWriteView =
			this->invertedIndex->getKeywordIds()->getWriteView();

	shared_ptr<vectorview<ForwardListPtr> > forwardListDirectoryReadView;
	this->forwardIndex->getForwardListDirectory_ReadView(
			forwardListDirectoryReadView);

	for (map<TrieNode *, unsigned>::const_iterator iter =
			trieNodeIdMapper.begin(); iter != trieNodeIdMapper.end(); ++iter) {
		TrieNode *node = iter->first;

		// the following code is based on TermVirtualList.cpp
		unsigned invertedListId = node->getInvertedListOffset();
		// change the keywordId for a given invertedListId. "node" (leafnode) has a new keywordId
		keywordIDsWriteView->at(invertedListId) = node->getId();
		// Since it happens after the commit of other index structures it uses read view
		shared_ptr<vectorview<unsigned> > readview;
		shared_ptr<vectorview<InvertedListContainerPtr> > invertedListDirectoryReadView;
		this->invertedIndex->getInvertedIndexDirectory_ReadView(
				invertedListDirectoryReadView);
		this->invertedIndex->getInvertedListReadView(
				invertedListDirectoryReadView, invertedListId, readview);
		unsigned invertedListSize = readview->size();
		// go through each record id on the inverted list
		InvertedListElement invertedListElement;
		for (unsigned i = 0; i < invertedListSize; i++) {
			/*if (invertedListElement == NULL)
			 continue;*/
			unsigned recordId = readview->getElement(i);

			// re-map it only it is not done before
			if (processedRecordIds.find(recordId) == processedRecordIds.end()) {

				this->forwardIndex->reassignKeywordIds(
						forwardListDirectoryReadView, recordId,
						keywordIdMapper);
				processedRecordIds[recordId] = 0; // add it to the set
			}
		}
	}

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


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