use of jetbrains.exodus.entitystore.EntityIterator in project xodus by JetBrains.
the class UpdatableEntityIdSortedSetCachedInstanceIterable method toSet.
@NotNull
@Override
public EntityIdSet toSet(@NotNull final PersistentStoreTransaction txn) {
if (idSet == null) {
final boolean isImmutable = mutableLocalIds == null;
if (isImmutable) {
final EntityIdCollection idCollection = getOrCreateIdCollection();
if (idCollection instanceof EntityIdSet) {
final EntityIdSet result = (EntityIdSet) idCollection;
idSet = result;
return result;
}
}
final EntityIterator it = getIteratorImpl(txn);
EntityIdSet result = EntityIdSetFactory.newSet();
while (it.hasNext()) {
result = result.add(it.nextId());
}
if (!isImmutable) {
return result;
}
idSet = result;
return result;
}
return idSet;
}
use of jetbrains.exodus.entitystore.EntityIterator in project xodus by JetBrains.
the class And method instantiateCustom.
private static Iterable<Entity> instantiateCustom(@NotNull final String entityType, @NotNull final QueryEngine queryEngine, @NotNull final ModelMetaData metaData, @NotNull final NodeBase self, @NotNull final LinksEqualDecorator decorator, @NotNull final Instantiatable directClosure) {
final Iterable<Entity> selfInstance = self.instantiate(entityType, queryEngine, metaData);
if (selfInstance instanceof EntityIterableBase) {
final EntityIterable result = ((EntityIterableBase) selfInstance).findLinks(((EntityIterableBase) decorator.instantiateDecorated(decorator.getLinkEntityType(), queryEngine, metaData)).getSource(), decorator.getLinkName());
if (traceFindLinks) {
final Iterator<Entity> directIt = directClosure.instantiate().iterator();
final EntityIterator it = result.iterator();
while (true) {
final boolean directHasNext = directIt.hasNext();
final boolean hasNext = it.hasNext();
if (directHasNext != hasNext) {
throw new EntityStoreException("Invalid custom findLinks() result: different sizes");
}
if (!hasNext) {
break;
}
if (!directIt.next().getId().equals(it.nextId())) {
throw new EntityStoreException("Invalid custom findLinks() result");
}
}
}
return result;
}
return directClosure.instantiate();
}
Aggregations