in src/framework/casdefinition.cpp [489:589]
void CASDefinition::createIndexesFromSpecifier(AnalysisEngineMetaData::TyVecpFSIndexDescriptions const & crIndexDescVec) {
uima::lowlevel::TypeSystem const & crTypeSystem = *iv_typeSystem;
vector<uima::lowlevel::TyFSFeature> keyFeatures;
vector<uima::lowlevel::IndexComparator::EnKeyFeatureComp> comparators;
AnalysisEngineMetaData::TyVecpFSIndexDescriptions::const_iterator citIndex;
// for all index descriptions
for (citIndex = crIndexDescVec.begin(); citIndex != crIndexDescVec.end(); ++citIndex) {
FSIndexDescription const * cpIndexDesc = *citIndex;
// determine index kind
FSIndexDescription::EnIndexKind indexDescKind = cpIndexDesc->getIndexKind();
uima::lowlevel::IndexDefinition::EnIndexKind kind = uima::lowlevel::IndexDefinition::enOrdered;
switch (indexDescKind) {
case FSIndexDescription::SORTED:
kind = uima::lowlevel::IndexDefinition::enOrdered;
break;
case FSIndexDescription::SET:
kind = uima::lowlevel::IndexDefinition::enSet;
break;
case FSIndexDescription::BAG:
kind = uima::lowlevel::IndexDefinition::enFIFO;
break;
default:
assert(false);
}
icu::UnicodeString const & crTypeName = cpIndexDesc->getTypeName();
// type is the type the index is defined on
uima::lowlevel::TyFSType type = crTypeSystem.getTypeByName(crTypeName);
if (! crTypeSystem.isValidType(type) ) {
UIMA_EXC_THROW_NEW(UnknownTypeException,
UIMA_ERR_UNKNOWN_TYPE,
ErrorMessage(UIMA_MSG_ID_EXC_UNKNOWN_TYPE_NAME, crTypeName),
ErrorMessage(UIMA_MSG_ID_EXCON_CREATING_INDEXES_FROM_CONFIG),
ErrorInfo::recoverable);
}
icu::UnicodeString const & crIndexLabel = cpIndexDesc->getLabel();
// determine key features and comparison scheme for each feature
keyFeatures.clear();
comparators.clear();
uima::FSIndexDescription::TyVecpFSIndexKeys const & crIndexKeys = cpIndexDesc->getFSIndexKeys();
uima::FSIndexDescription::TyVecpFSIndexKeys::const_iterator citKeys;
// for each key feature
for (citKeys = crIndexKeys.begin(); citKeys != crIndexKeys.end(); ++citKeys) {
FSIndexKeyDescription const * cpIndexKeyDesc = *citKeys;
uima::lowlevel::TyFSFeature feat;
bool bIsTypePriority = cpIndexKeyDesc->isTypePriority();
if ( ! bIsTypePriority) {
icu::UnicodeString const & crFeatureName = cpIndexKeyDesc->getFeatureName();
feat = crTypeSystem.getFeatureByBaseName( type, crFeatureName);
if (! crTypeSystem.isValidFeature(feat) ) {
UIMA_EXC_THROW_NEW(UnknownFeatureException,
UIMA_ERR_UNKNOWN_FEATURE,
ErrorMessage(UIMA_MSG_ID_EXC_UNKNOWN_FEATURE_NAME, crFeatureName),
ErrorMessage(UIMA_MSG_ID_EXCON_CREATING_INDEXES_FROM_CONFIG),
ErrorInfo::recoverable);
}
assert( crTypeSystem.isValidFeature(feat) );
} else {
// use INVALID_FEATURE as a marker for type priority
feat = uima::lowlevel::TypeSystem::INVALID_FEATURE;
}
keyFeatures.push_back(feat);
FSIndexKeyDescription::EnComparatorType enComp = FSIndexKeyDescription::STANDARD;
// this if statement is not necessary when type priorities can have different kind of comparators!!
if (! bIsTypePriority) {
enComp = cpIndexKeyDesc->getComparator();
}
switch (enComp) {
case FSIndexKeyDescription::STANDARD:
comparators.push_back( uima::lowlevel::IndexComparator::STANDARD_COMPARE );
break;
case FSIndexKeyDescription::REVERSE:
comparators.push_back( uima::lowlevel::IndexComparator::REVERSE_STANDARD_COMPARE );
break;
default:
assert(false);
}
}
iv_indexDefinition->defineIndex( kind,
type,
keyFeatures,
comparators,
crIndexLabel );
}
}