本文整理汇总了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);
}
示例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
}
}
}
}