Search in sources :

Example 1 with AssociationEndMetaData

use of jetbrains.exodus.query.metadata.AssociationEndMetaData in project xodus by JetBrains.

the class QueryEngine method selectManyDistinct.

public Iterable<Entity> selectManyDistinct(Iterable<Entity> it, final String linkName) {
    if (it == null) {
        return EntityIterableBase.EMPTY;
    }
    if (mmd != null) {
        if (it instanceof StaticTypedEntityIterable) {
            final StaticTypedEntityIterable tree = (StaticTypedEntityIterable) it;
            it = toEntityIterable(it);
            if (isPersistentIterable(it)) {
                final String entityType = tree.getEntityType();
                final EntityMetaData emd = mmd.getEntityMetaData(entityType);
                if (emd != null) {
                    final AssociationEndMetaData aemd = emd.getAssociationEndMetaData(linkName);
                    if (aemd != null) {
                        final String resultType = aemd.getOppositeEntityMetaData().getType();
                        return new StaticTypedIterableDecorator(resultType, selectManyDistinctImpl((EntityIterableBase) it, linkName), this);
                    }
                }
            }
        } else if (isPersistentIterable(it)) {
            return selectManyDistinctImpl((EntityIterableBase) it, linkName);
        }
    }
    return inMemorySelectManyDistinct(it, linkName);
}
Also used : AssociationEndMetaData(jetbrains.exodus.query.metadata.AssociationEndMetaData) EntityIterableBase(jetbrains.exodus.entitystore.iterate.EntityIterableBase) EntityMetaData(jetbrains.exodus.query.metadata.EntityMetaData)

Example 2 with AssociationEndMetaData

use of jetbrains.exodus.query.metadata.AssociationEndMetaData in project xodus by JetBrains.

the class QueryEngine method selectDistinct.

public Iterable<Entity> selectDistinct(Iterable<Entity> it, final String linkName) {
    if (it == null) {
        return EntityIterableBase.EMPTY;
    }
    if (mmd != null) {
        if (it instanceof StaticTypedEntityIterable) {
            final StaticTypedEntityIterable ktei = (StaticTypedEntityIterable) it;
            it = toEntityIterable(it);
            if (isPersistentIterable(it)) {
                final String entityType = ktei.getEntityType();
                final EntityMetaData emd = mmd.getEntityMetaData(entityType);
                if (emd != null) {
                    final AssociationEndMetaData aemd = emd.getAssociationEndMetaData(linkName);
                    if (aemd != null) {
                        final String resultType = aemd.getOppositeEntityMetaData().getType();
                        return new StaticTypedIterableDecorator(resultType, selectDistinctImpl((EntityIterableBase) it, linkName), this);
                    }
                }
            }
        } else if (isPersistentIterable(it)) {
            return selectDistinctImpl((EntityIterableBase) it, linkName);
        }
    }
    return inMemorySelectDistinct(it, linkName);
}
Also used : AssociationEndMetaData(jetbrains.exodus.query.metadata.AssociationEndMetaData) EntityIterableBase(jetbrains.exodus.entitystore.iterate.EntityIterableBase) EntityMetaData(jetbrains.exodus.query.metadata.EntityMetaData)

Aggregations

EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)2 AssociationEndMetaData (jetbrains.exodus.query.metadata.AssociationEndMetaData)2 EntityMetaData (jetbrains.exodus.query.metadata.EntityMetaData)2