本文整理汇总了C++中IndexReader::instanceOf方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexReader::instanceOf方法的具体用法?C++ IndexReader::instanceOf怎么用?C++ IndexReader::instanceOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexReader
的用法示例。
在下文中一共展示了IndexReader::instanceOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeFields
int32_t SegmentMerger::mergeFields() {
//Func - Merge the fields of all segments
//Pre - true
//Post - The field infos and field values of all segments have been merged.
if (!mergeDocStores) {
// When we are not merging by doc stores, that means
// all segments were written as part of a single
// autoCommit=false IndexWriter session, so their field
// name -> number mapping are the same. So, we start
// with the fieldInfos of the last segment in this
// case, to keep that numbering.
assert(readers[readers.size()-1]->instanceOf(SegmentReader::getClassName()));
assert(false);//check last...and remove if correct...
SegmentReader* sr = (SegmentReader*)readers[readers.size()-1];
fieldInfos = sr->fieldInfos()->clone();
} else {
//Create a new FieldInfos
fieldInfos = _CLNEW FieldInfos(); // merge field names
}
//Condition check to see if fieldInfos points to a valid instance
CND_CONDITION(fieldInfos != NULL,"Memory allocation for fieldInfos failed");
IndexReader* reader = NULL;
//Iterate through all readers
for (uint32_t i = 0; i < readers.size(); i++){
//get the i-th reader
reader = readers[i];
//Condition check to see if reader points to a valid instance
CND_CONDITION(reader != NULL,"No IndexReader found");
if (reader->instanceOf(SegmentReader::getClassName())) {
SegmentReader* segmentReader = (SegmentReader*) reader;
for (size_t j = 0; j < segmentReader->getFieldInfos()->size(); j++) {
FieldInfo* fi = segmentReader->getFieldInfos()->fieldInfo(j);
fieldInfos->add(fi->name, fi->isIndexed, fi->storeTermVector,
fi->storePositionWithTermVector, fi->storeOffsetWithTermVector,
!reader->hasNorms(fi->name), fi->storePayloads);
}
} else {
StringArrayWithDeletor tmp;
tmp.clear(); reader->getFieldNames(IndexReader::TERMVECTOR_WITH_POSITION_OFFSET, tmp);
addIndexed(reader, fieldInfos, tmp, true, true, true, false);
tmp.clear(); reader->getFieldNames(IndexReader::TERMVECTOR_WITH_POSITION, tmp);
addIndexed(reader, fieldInfos, tmp, true, true, false, false);
tmp.clear(); reader->getFieldNames(IndexReader::TERMVECTOR_WITH_OFFSET, tmp);
addIndexed(reader, fieldInfos, tmp, true, false, true, false);
tmp.clear(); reader->getFieldNames(IndexReader::TERMVECTOR, tmp);
addIndexed(reader, fieldInfos, tmp, true, false, false, false);
tmp.clear(); reader->getFieldNames(IndexReader::STORES_PAYLOADS, tmp);
addIndexed(reader, fieldInfos, tmp, false, false, false, true);
tmp.clear(); reader->getFieldNames(IndexReader::INDEXED, tmp);
addIndexed(reader, fieldInfos, tmp, false, false, false, false);
tmp.clear(); reader->getFieldNames(IndexReader::UNINDEXED, tmp);
if ( tmp.size() > 0 ){
TCHAR** arr = _CL_NEWARRAY(TCHAR*,tmp.size()+1);
tmp.toArray_nullTerminated(arr);
fieldInfos->add((const TCHAR**)arr, false);
_CLDELETE_ARRAY(arr); //no need to delete the contents, since tmp is responsible for it
}
}
}