Search in sources :

Example 16 with JanusGraphElement

use of org.janusgraph.core.JanusGraphElement in project janusgraph by JanusGraph.

the class IndexSerializerTest method testReindexElementNotAppliesTo.

@Test
public void testReindexElementNotAppliesTo() {
    Configuration config = mock(Configuration.class);
    Serializer serializer = mock(Serializer.class);
    Map<String, ? extends IndexInformation> indexes = new HashMap<>();
    IndexSerializer mockSerializer = new IndexSerializer(config, serializer, indexes, true);
    JanusGraphElement nonIndexableElement = mock(JanusGraphElement.class);
    MixedIndexType mit = mock(MixedIndexType.class);
    doReturn(ElementCategory.VERTEX).when(mit).getElement();
    Map<String, Map<String, List<IndexEntry>>> docStore = new HashMap<>();
    assertFalse("re-index", mockSerializer.reindexElement(nonIndexableElement, mit, docStore));
}
Also used : Configuration(org.janusgraph.diskstorage.configuration.Configuration) HashMap(java.util.HashMap) JanusGraphElement(org.janusgraph.core.JanusGraphElement) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) IndexEntry(org.janusgraph.diskstorage.indexing.IndexEntry) HashMap(java.util.HashMap) Map(java.util.Map) Serializer(org.janusgraph.graphdb.database.serialize.Serializer) Test(org.junit.jupiter.api.Test)

Example 17 with JanusGraphElement

use of org.janusgraph.core.JanusGraphElement in project janusgraph by JanusGraph.

the class AbstractIndexSelectionStrategy method coversAll.

private boolean coversAll(final MixedIndexType index, Condition<JanusGraphElement> condition, IndexSerializer indexInfo) {
    if (condition.getType() != Condition.Type.LITERAL) {
        return StreamSupport.stream(condition.getChildren().spliterator(), false).allMatch(child -> coversAll(index, child, indexInfo));
    }
    if (!(condition instanceof PredicateCondition)) {
        return false;
    }
    final PredicateCondition<RelationType, JanusGraphElement> atom = (PredicateCondition) condition;
    if (atom.getValue() == null && atom.getPredicate() != Cmp.NOT_EQUAL) {
        return false;
    }
    Preconditions.checkArgument(atom.getKey().isPropertyKey());
    final PropertyKey key = (PropertyKey) atom.getKey();
    final ParameterIndexField[] fields = index.getFieldKeys();
    final ParameterIndexField match = Arrays.stream(fields).filter(field -> field.getStatus() == SchemaStatus.ENABLED).filter(field -> field.getFieldKey().equals(key)).findAny().orElse(null);
    if (match == null) {
        return false;
    }
    boolean existsQuery = atom.getValue() == null && atom.getPredicate() == Cmp.NOT_EQUAL && indexInfo.supportsExistsQuery(index, match);
    return existsQuery || indexInfo.supports(index, match, atom.getPredicate());
}
Also used : PredicateCondition(org.janusgraph.graphdb.query.condition.PredicateCondition) MultiCondition(org.janusgraph.graphdb.query.condition.MultiCondition) Arrays(java.util.Arrays) JointIndexQuery(org.janusgraph.graphdb.query.graph.JointIndexQuery) Condition(org.janusgraph.graphdb.query.condition.Condition) IndexSerializer(org.janusgraph.graphdb.database.IndexSerializer) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OrderList(org.janusgraph.graphdb.internal.OrderList) Cardinality(org.janusgraph.core.Cardinality) Cmp(org.janusgraph.core.attribute.Cmp) SchemaStatus(org.janusgraph.core.schema.SchemaStatus) IndexField(org.janusgraph.graphdb.types.IndexField) Map(java.util.Map) Or(org.janusgraph.graphdb.query.condition.Or) ParameterIndexField(org.janusgraph.graphdb.types.ParameterIndexField) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) IndexType(org.janusgraph.graphdb.types.IndexType) StreamSupport(java.util.stream.StreamSupport) Nullable(javax.annotation.Nullable) JanusGraphElement(org.janusgraph.core.JanusGraphElement) JanusGraphSchemaType(org.janusgraph.core.schema.JanusGraphSchemaType) QueryUtil(org.janusgraph.graphdb.query.QueryUtil) RelationType(org.janusgraph.core.RelationType) And(org.janusgraph.graphdb.query.condition.And) CompositeIndexType(org.janusgraph.graphdb.types.CompositeIndexType) PropertyKey(org.janusgraph.core.PropertyKey) Configuration(org.janusgraph.diskstorage.configuration.Configuration) Collection(java.util.Collection) Set(java.util.Set) ElementCategory(org.janusgraph.graphdb.internal.ElementCategory) AbstractMap(java.util.AbstractMap) List(java.util.List) ImplicitKey(org.janusgraph.graphdb.types.system.ImplicitKey) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) JanusGraphRelation(org.janusgraph.core.JanusGraphRelation) PredicateCondition(org.janusgraph.graphdb.query.condition.PredicateCondition) JanusGraphElement(org.janusgraph.core.JanusGraphElement) RelationType(org.janusgraph.core.RelationType) ParameterIndexField(org.janusgraph.graphdb.types.ParameterIndexField) PropertyKey(org.janusgraph.core.PropertyKey)

Aggregations

JanusGraphElement (org.janusgraph.core.JanusGraphElement)17 Map (java.util.Map)8 PropertyKey (org.janusgraph.core.PropertyKey)8 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 List (java.util.List)6 MixedIndexType (org.janusgraph.graphdb.types.MixedIndexType)6 Preconditions (com.google.common.base.Preconditions)5 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 Set (java.util.Set)5 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)5 RelationType (org.janusgraph.core.RelationType)5 IndexEntry (org.janusgraph.diskstorage.indexing.IndexEntry)5 ElementCategory (org.janusgraph.graphdb.internal.ElementCategory)5 OrderList (org.janusgraph.graphdb.internal.OrderList)5 PredicateCondition (org.janusgraph.graphdb.query.condition.PredicateCondition)5 Test (org.junit.jupiter.api.Test)5 Iterator (java.util.Iterator)4 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)4