use of jetbrains.exodus.entitystore.PersistentEntityStoreImpl in project xodus by JetBrains.
the class TreeKeepingEntityIterable method instantiate.
@SuppressWarnings("UnusedDeclaration")
@Override
public Iterable<Entity> instantiate() {
optimize();
Iterable<Entity> result;
if (instance == null) {
result = instantiateForWholeHierarchy();
} else if (optimizedTree instanceof GetAll) {
result = instance;
} else {
// clone
TreeKeepingEntityIterable tkei = new TreeKeepingEntityIterable(null, entityType, optimizedTree.getClone(), queryEngine);
tkei.optimizedTree = optimizedTree;
result = queryEngine.toEntityIterable(queryEngine.intersect(instance, tkei));
}
if (sorts != null) {
result = sorts.apply(entityType, result, queryEngine);
}
if (result == null) {
result = instantiateForWholeHierarchy();
}
if (isExplainOn) {
Iterable<Entity> explained = result;
while (explained instanceof SortEngine.InMemorySortIterable) {
explained = ((SortEngine.InMemorySortIterable) explained).source;
}
if (explained instanceof EntityIterableBase) {
EntityIterable entityIterable = ((EntityIterableBase) explained).getSource();
if (entityIterable instanceof EntityIterableBase && entityIterable != EntityIterableBase.EMPTY) {
EntityIterableBase entityIterableBase = ((EntityIterableBase) entityIterable);
final PersistentEntityStoreImpl store = queryEngine.getPersistentStore();
Explainer explainer = store.getExplainer();
if (!Explainer.isExplainForcedForThread()) {
explainer.start(origin);
}
entityIterableBase.setOrigin(origin);
explainer.explain(origin, Explainer.INITIAL_TREE, annotatedTree);
explainer.explain(origin, Explainer.OPTIMIZED_TREE, optimizedTree);
if (!Explainer.isExplainForcedForThread()) {
for (Entity entity : result) {
explainer.explain(origin, Explainer.ITERABLE_ADVANCES);
}
explainer.log(origin);
}
}
}
}
return result;
}
Aggregations