public MetadataStore getMetadataStore(Collection<Datatype> systemDatatypes) throws IOException {
if (this.store == null) {
this.store = new MetadataStore();
ArrayList<Index> tmp = new ArrayList<Index>();
for (VirtualFile f : indexFiles) {
Index index = new Index(f, true);
index.setDoCache(true);
tmp.add(index);
}
this.indexes = tmp.toArray(new Index[tmp.size()]);
getAnnotationCache();
getExtensionCache();
Map<String, Datatype> datatypes = getDatatypeCache();
if (systemDatatypes != null) {
for (Datatype datatype : systemDatatypes) {
datatypes.put(datatype.getUUID(), datatype);
}
}
List<KeyRecord> keys = findMetadataRecords(MetadataConstants.RECORD_TYPE.PRIMARY_KEY, null, false);
for (KeyRecord keyRecord : keys) {
this.primaryKeyCache.put(keyRecord.getUUID(), keyRecord);
}
getModels();
getTables();
getProcedures();
//force close, since we cached the index files
for (Index index : tmp) {
index.close();
}
}
return store;
}