@Test public void testEvaluation() { String queryString = "MATCH (a), (b), (c)" + "WHERE a=b OR a.name = \"Alice\" OR a.age > c.age"; QueryHandler query = new QueryHandler(queryString); CNFElement cnfElement = query.getPredicates().getPredicates().get(0); EmbeddingMetaData metaData = new EmbeddingMetaData(); metaData.setEntryColumn("a", EntryType.VERTEX, 0); metaData.setEntryColumn("b", EntryType.VERTEX, 1); metaData.setEntryColumn("c", EntryType.VERTEX, 2); metaData.setPropertyColumn("a", "name", 0); metaData.setPropertyColumn("a", "age", 1); metaData.setPropertyColumn("c", "age", 2); GradoopId a = GradoopId.get(); GradoopId c = GradoopId.get(); Embedding embedding = new Embedding(); embedding.add( a, PropertyValue.create("Alfred"), PropertyValue.create(42) ); embedding.add(a); embedding.add( c, PropertyValue.create(42) ); assertTrue(cnfElement.evaluate(embedding, metaData)); embedding = new Embedding(); embedding.add( a, PropertyValue.create("Alice"), PropertyValue.create(42) ); embedding.add(GradoopId.get()); embedding.add( c, PropertyValue.create(42) ); assertTrue(cnfElement.evaluate(embedding, metaData)); embedding = new Embedding(); embedding.add( a, PropertyValue.create("Alfred"), PropertyValue.create(42) ); embedding.add(GradoopId.get()); embedding.add( c, PropertyValue.create(23) ); assertTrue(cnfElement.evaluate(embedding, metaData)); embedding = new Embedding(); embedding.add( a, PropertyValue.create("Alfred"), PropertyValue.create(42) ); embedding.add(GradoopId.get()); embedding.add( c, PropertyValue.create(42) ); assertFalse(cnfElement.evaluate(embedding, metaData)); }
@Override public boolean evaluate(Embedding embedding, EmbeddingMetaData metaData) { for (ComparisonExpression comparisonExpression : predicates) { if (comparisonExpression.evaluate(embedding, metaData)) { return true; } } return false; }
CNFElement extends PredicateCollection<ComparisonExpression> { @Override public boolean evaluate(Embedding embedding, EmbeddingMetaData metaData) { for (ComparisonExpression comparisonExpression : predicates) { if (comparisonExpression.evaluate(embedding, metaData)) { return true; } } return false; } }
CNFElement extends PredicateCollection<ComparisonExpression> { @Override public boolean evaluate(Embedding embedding, EmbeddingMetaData metaData) { for (ComparisonExpression comparisonExpression : predicates) { if (comparisonExpression.evaluate(embedding, metaData)) { return true; } } return false; } CNFElement();  CNFElement(List<ComparisonExpression> predicates); }
CNFElement extends PredicateCollection<ComparisonExpression> { @Override public boolean evaluate(Embedding embedding, EmbeddingMetaData metaData) { for (ComparisonExpression comparisonExpression : predicates) { if (comparisonExpression.evaluate(embedding, metaData)) { return true; } } return false; } CNFElement();  CNFElement(List<ComparisonExpression> predicates); @Override boolean evaluate(Embedding embedding, EmbeddingMetaData metaData); @Override boolean evaluate(GraphElement element); @Override Set<String> getVariables(); @Override Set<String> getPropertyKeys(String variable); @Override String operatorName(); }
CNFElement extends PredicateCollection<ComparisonExpression> { @Override public boolean evaluate(Embedding embedding, EmbeddingMetaData metaData) { for (ComparisonExpression comparisonExpression : predicates) { if (comparisonExpression.evaluate(embedding, metaData)) { return true; } } return false; } CNFElement();  CNFElement(List<ComparisonExpression> predicates); @Override boolean evaluate(Embedding embedding, EmbeddingMetaData metaData); @Override boolean evaluate(GraphElement element); @Override Set<String> getVariables(); @Override Set<String> getPropertyKeys(String variable); @Override String operatorName();  }