use of org.teiid.internal.core.index.Index in project teiid by teiid.
the class IndexMetadataRepository method loadAll.
// there are multiple threads trying to load this, since the initial index lading is not
// optimized for multi-thread loading this locking to sync will work
private synchronized void loadAll(Collection<Datatype> systemDatatypes, Map<String, ? extends VDBResource> resources) throws IOException {
if (this.loaded) {
return;
}
ArrayList<Index> tmp = new ArrayList<Index>();
for (VDBResource f : resources.values()) {
if (f.getName().endsWith(VDBResources.INDEX_EXT)) {
Index index = new Index(f);
index.setDoCache(true);
tmp.add(index);
}
}
for (Index index : tmp) {
try {
IEntryResult[] results = SimpleIndexUtil.queryIndex(new Index[] { index }, new char[0], true, true, false);
recordFactory.getMetadataRecord(results);
} catch (TeiidException e) {
throw new TeiidRuntimeException(RuntimeMetadataPlugin.Event.TEIID80000, e);
}
}
// force close, since we cached the index files
for (Index index : tmp) {
index.close();
}
Map<String, AbstractMetadataRecord> uuidToRecord = getByType(MetadataConstants.RECORD_TYPE.DATATYPE);
if (systemDatatypes != null) {
for (Datatype datatype : systemDatatypes) {
uuidToRecord.put(datatype.getUUID(), datatype);
}
}
this.loaded = true;
// associate the annotation/extension metadata
for (Map<String, AbstractMetadataRecord> map : allRecords.values()) {
for (AbstractMetadataRecord metadataRecord : map.values()) {
String uuid = metadataRecord.getUUID();
metadataRecord.setAnnotation(this.annotationCache.get(uuid));
metadataRecord.setProperties(this.extensionCache.get(uuid));
}
}
}
Aggregations