/** * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#getFsIndexes() */ public FsIndexDescription[] getFsIndexes() { return mFsIndexCollection == null ? null : mFsIndexCollection.getFsIndexes(); }
/** * Creates a {@link FsIndexCollection} from all index descriptions that can be found via the * pattern specified in the system property {@code org.apache.uima.fit.fsindex.import_pattern} or * via the {@code META-INF/org.apache.uima.fit/fsindexes.txt} files in the classpath. * * @return the auto-scanned indexes. * @throws ResourceInitializationException * if the index collection could not be assembled */ public static FsIndexCollection createFsIndexCollection() throws ResourceInitializationException { List<FsIndexDescription> fsIndexList = new ArrayList<FsIndexDescription>(); for (String location : scanIndexDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location); FsIndexCollection fsIdxCol = getXMLParser().parseFsIndexCollection(xmlInput); fsIdxCol.resolveImports(); fsIndexList.addAll(asList(fsIdxCol.getFsIndexes())); LogFactory.getLog(FsIndexFactory.class).debug("Detected index at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(FsIndexFactory.class).warn( "[" + location + "] is not a index descriptor file. Ignoring.", e); } } return createFsIndexCollection(fsIndexList.toArray(new FsIndexDescription[fsIndexList.size()])); }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedFsIndexCollectionURLs, Collection<FsIndexDescription> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache FsIndexCollection desc; String urlString = aURL.toString(); Map<String, XMLizable> importCache = ((ResourceManager_impl)aResourceManager).getImportCache(); Map<String, Set<String>> importUrlsCache = ((ResourceManager_impl)aResourceManager).getImportUrlsCache(); synchronized(importCache) { XMLizable cachedObject = importCache.get(urlString); if (cachedObject instanceof FsIndexCollection) { desc = (FsIndexCollection)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedFsIndexCollectionURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseFsIndexCollection(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedFsIndexCollectionURLs); desc.resolveImports(aAlreadyImportedFsIndexCollectionURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedFsIndexCollectionURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getFsIndexes())); }
public CasDefinition(Collection<? extends ProcessingResourceMetaData> aMetaDataToMerge, ResourceManager aResourceManager) throws ResourceInitializationException { // extract TypeSystems, TypePriorities, and FsIndexes from metadata List<TypeSystemDescription> typeSystems = new ArrayList<TypeSystemDescription>(); List<TypePriorities> typePrioritiesList = new ArrayList<TypePriorities>(); List<FsIndexCollection> fsIndexes = new ArrayList<FsIndexCollection>(); Iterator<? extends ProcessingResourceMetaData> it = aMetaDataToMerge.iterator(); while (it.hasNext()) { ProcessingResourceMetaData md = it.next(); if (md.getTypeSystem() != null) typeSystems.add(md.getTypeSystem()); if (md.getTypePriorities() != null) typePrioritiesList.add(md.getTypePriorities()); if (md.getFsIndexCollection() != null) fsIndexes.add(md.getFsIndexCollection()); } // merge TypePriorities and FsIndexes TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePrioritiesList, aResourceManager); FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexes, aResourceManager); TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystems, aResourceManager); this.typeSystemDescription = aggTypeDesc; this.typePriorities = aggTypePriorities; this.fsIndexDescriptions = aggIndexColl.getFsIndexes(); this.resourceManager = aResourceManager; }
throw new ResourceInitializationException(e); FsIndexDescription[] indexes = indexColl.getFsIndexes(); for (int i = 0; i < indexes.length; i++) {
/** * Checks if is feature used in index. * * @param fullFeatureName the full feature name * @return true, if is feature used in index */ private boolean isFeatureUsedInIndex(String fullFeatureName) { if (!isLocalProcessingDescriptor()) { return false; } FsIndexCollection indexCollection = editor.getMergedFsIndexCollection(); FsIndexDescription[] fsid = (null == indexCollection) ? null : indexCollection.getFsIndexes(); if (null != fsid) { for (int i = 0; i < fsid.length; i++) { FsIndexKeyDescription[] keys = fsid[i].getKeys(); if (null != keys) { for (int j = 0; j < keys.length; j++) { if (keys[j].getFeatureName().equals(fullFeatureName)) return true; } } } } return false; }
return doCreateCas(aTypeSystem, null, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager); } else { return doCreateCas(null, aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager);
FsIndexCollection aggIndexColl = mergeFsIndexes(fsIndexes, aResourceManager); return doCreateCas(null, aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager);
/** * Creates the cas. * * @param aAeDescription the a ae description * @param aPerformanceTuningSettings the a performance tuning settings * @param aResourceManager the a resource manager * @return the cas * @throws ResourceInitializationException the resource initialization exception */ public CAS createCas(AnalysisEngineDescription aAeDescription, Properties aPerformanceTuningSettings, ResourceManager aResourceManager) throws ResourceInitializationException { getMergeInput(aAeDescription, aResourceManager); // merge TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystemsToMerge, aResourceManager); TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePrioritiesToMerge, aResourceManager); FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexesToMerge, aResourceManager); return CasCreationUtils.createCas(aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager); }
/** * Creates a new {@link JCas}. The type system is detected automatically using * {@link TypeSystemDescriptionFactory#createTypeSystemDescription()}. Type priorities are * detected automatically using {@link TypePrioritiesFactory#createTypePriorities()}. Indexes are * detected automatically using {@link FsIndexFactory#createFsIndexCollection()}. * * @return a new JCas * @throws UIMAException * if the JCas could not be initialized */ public static JCas createJCas() throws UIMAException { TypeSystemDescription tsd = createTypeSystemDescription(); TypePriorities tp = createTypePriorities(); FsIndexCollection indexes = createFsIndexCollection(); ResourceManager resMgr = ResourceManagerFactory.newResourceManager(); return CasCreationUtils.createCas(tsd, tp, indexes.getFsIndexes(), null, resMgr).getJCas(); }