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));
}
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());
}
Aggregations