Search in sources :

Example 1 with EntityMetaData

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

the class LinksEqualDecorator method instantiateDecorated.

protected Iterable<Entity> instantiateDecorated(String entityType, QueryEngine queryEngine, ModelMetaData metaData) {
    Iterable<Entity> result = decorated.instantiate(entityType, queryEngine, metaData);
    final EntityMetaData emd = metaData == null ? null : metaData.getEntityMetaData(entityType);
    if (emd != null) {
        for (String subType : emd.getSubTypes()) {
            result = queryEngine.unionAdjusted(result, instantiateDecorated(subType, queryEngine, metaData));
        }
    }
    return result;
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityMetaData(jetbrains.exodus.query.metadata.EntityMetaData)

Example 2 with EntityMetaData

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

the class PropertyNotNull method instantiate.

@Override
public Iterable<Entity> instantiate(String entityType, QueryEngine queryEngine, ModelMetaData metaData) {
    final EntityMetaData emd = metaData == null ? null : metaData.getEntityMetaData(entityType);
    final PropertyMetaData pmd = emd == null ? null : emd.getPropertyMetaData(name);
    queryEngine.assertOperational();
    final PersistentStoreTransaction txn = queryEngine.getPersistentStore().getAndCheckCurrentTransaction();
    return pmd == null || pmd.getType() == PropertyType.PRIMITIVE ? txn.findWithProp(entityType, name) : txn.findWithBlob(entityType, name);
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) PropertyMetaData(jetbrains.exodus.query.metadata.PropertyMetaData) EntityMetaData(jetbrains.exodus.query.metadata.EntityMetaData)

Example 3 with EntityMetaData

use of jetbrains.exodus.query.metadata.EntityMetaData 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 4 with EntityMetaData

use of jetbrains.exodus.query.metadata.EntityMetaData 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)

Example 5 with EntityMetaData

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

the class TreeKeepingEntityIterable method instantiateForWholeHierarchy.

private Iterable<Entity> instantiateForWholeHierarchy(final String entityType, final NodeBase ast) {
    final ModelMetaData mmd = queryEngine.getModelMetaData();
    final EntityMetaData emd = mmd == null ? null : mmd.getEntityMetaData(entityType);
    Iterable<Entity> result = ast.getClone().instantiate(entityType, queryEngine, mmd);
    if (!(emd == null || ast.polymorphic())) {
        for (String subType : emd.getSubTypes()) {
            if (Utils.getUnionSubtypes()) {
                // union returns sorted by id results provided its operands are sorted by id
                result = queryEngine.unionAdjusted(result, instantiateForWholeHierarchy(subType, ast));
            } else {
                result = queryEngine.concatAdjusted(result, instantiateForWholeHierarchy(subType, ast));
            }
        }
    }
    return queryEngine.adjustEntityIterable(result);
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityMetaData(jetbrains.exodus.query.metadata.EntityMetaData) ModelMetaData(jetbrains.exodus.query.metadata.ModelMetaData)

Aggregations

EntityMetaData (jetbrains.exodus.query.metadata.EntityMetaData)5 Entity (jetbrains.exodus.entitystore.Entity)2 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)2 AssociationEndMetaData (jetbrains.exodus.query.metadata.AssociationEndMetaData)2 PersistentStoreTransaction (jetbrains.exodus.entitystore.PersistentStoreTransaction)1 ModelMetaData (jetbrains.exodus.query.metadata.ModelMetaData)1 PropertyMetaData (jetbrains.exodus.query.metadata.PropertyMetaData)1