/** * {@inheritDoc} */ @Override public Tuple3<Edge, Boolean, Boolean> join(Tuple3<Edge, GradoopId, Boolean> interim, Vertex vertex) { reuse.f0 = interim.f0; reuse.f1 = interim.f2; reuse.f2 = vertex.getPropertyValue(propertyKey).getBoolean(); return reuse; } }
@Override public Tuple3<Edge, Boolean, Boolean> join(Tuple3<Edge, GradoopId, Boolean> interim, Vertex vertex) { reuse.f0 = interim.f0; reuse.f1 = interim.f2; reuse.f2 = vertex.getPropertyValue(propertyKey).getBoolean(); return reuse; } }
/** * Logical or of two boolean properties. * * @param a first value * @param b second value * @return a OR b */ public static PropertyValue or(PropertyValue a, PropertyValue b) { checkNotNull(a, b); checkBoolean(a); checkBoolean(b); a.setBoolean(a.getBoolean() || b.getBoolean()); return a; }
@Override public boolean filter(GraphHead graphHead) throws Exception { return graphHead.getPropertyValue(getAggregatePropertyKey()).getBoolean(); } }
/** * {@inheritDoc} */ @Override public Tuple3<Edge, GradoopId, Boolean> join(Edge edge, Vertex vertex) throws Exception { reuse.f0 = edge; reuse.f1 = edge.getTargetId(); reuse.f2 = vertex.getPropertyValue(propertyKey).getBoolean(); return reuse; } }
@Override public boolean filter(GraphHead graphHead) throws Exception { return graphHead.getPropertyValue(getAggregatePropertyKey()).getBoolean(); } }
@Override public Tuple3<Edge, GradoopId, Boolean> join(Edge edge, Vertex vertex) throws Exception { reuse.f0 = edge; reuse.f1 = edge.getTargetId(); reuse.f2 = vertex.getPropertyValue(propertyKey).getBoolean(); return reuse; } }
@Test public void testGetBoolean() throws Exception { PropertyValue p = PropertyValue.create(BOOL_VAL_1); assertEquals(BOOL_VAL_1, p.getBoolean()); }
@Test public void testSetBoolean() throws Exception { PropertyValue p = new PropertyValue(); p.setBoolean(BOOL_VAL_1); assertEquals(BOOL_VAL_1, p.getBoolean()); }
@Test public void testDerivedNonOverlappingGraphs() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString("g[(a {x: true}),(b {x: false})]"); LogicalGraph baseGraph = loader.getLogicalGraphByVariable("g"); LogicalGraph derivedGraph1 = baseGraph.vertexInducedSubgraph(v -> v.getPropertyValue("x").getBoolean()); LogicalGraph derivedGraph2 = baseGraph.vertexInducedSubgraph(v -> !v.getPropertyValue("x").getBoolean()); loader.appendToDatabaseFromString("expected[(a)]"); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); collectAndAssertTrue(derivedGraph1.exclude(derivedGraph2).equalsByElementIds(expected)); }
@Test public void testDerivedNonOverlappingGraphs() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString("g[(a {x: true}),(b {x: false})]"); LogicalGraph baseGraph = loader.getLogicalGraphByVariable("g"); LogicalGraph derivedGraph1 = baseGraph.vertexInducedSubgraph(v -> v.getPropertyValue("x").getBoolean()); LogicalGraph derivedGraph2 = baseGraph.vertexInducedSubgraph(v -> !v.getPropertyValue("x").getBoolean()); loader.appendToDatabaseFromString("expected[]"); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); collectAndAssertTrue(derivedGraph1.overlap(derivedGraph2).equalsByElementIds(expected)); }
@Test public void testDerivedNonOverlappingGraphs() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString("g[(a {x: true}), (b {x: false})]"); LogicalGraph baseGraph = loader.getLogicalGraphByVariable("g"); LogicalGraph derivedGraph1 = baseGraph.vertexInducedSubgraph(v -> v.getPropertyValue("x").getBoolean()); LogicalGraph derivedGraph2 = baseGraph.vertexInducedSubgraph(v -> !v.getPropertyValue("x").getBoolean()); loader.appendToDatabaseFromString("expected[(a),(b)]"); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); collectAndAssertTrue(derivedGraph1.combine(derivedGraph2).equalsByElementIds(expected)); }
@Test public void testDerivedOverlappingGraphs() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString("g[(a {x: true, y: true}), (b {x: true, y: false})]"); LogicalGraph baseGraph = loader.getLogicalGraphByVariable("g"); LogicalGraph derivedGraph1 = baseGraph.vertexInducedSubgraph(v -> v.getPropertyValue("x").getBoolean()); LogicalGraph derivedGraph2 = baseGraph.vertexInducedSubgraph(v -> !v.getPropertyValue("y").getBoolean()); loader.appendToDatabaseFromString("expected[(a),(b)]"); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); collectAndAssertTrue(derivedGraph1.combine(derivedGraph2).equalsByElementIds(expected)); }
@Test public void testDerivedOverlappingGraphs() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString("g[(a {x: true, y: true}),(b {x:true, y: false})]"); LogicalGraph baseGraph = loader.getLogicalGraphByVariable("g"); LogicalGraph derivedGraph1 = baseGraph.vertexInducedSubgraph(v -> v.getPropertyValue("x").getBoolean()); LogicalGraph derivedGraph2 = baseGraph.vertexInducedSubgraph(v -> !v.getPropertyValue("y").getBoolean()); loader.appendToDatabaseFromString("expected[(a)]"); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); collectAndAssertTrue(derivedGraph1.exclude(derivedGraph2).equalsByElementIds(expected)); }
@Test public void testGet() throws Exception { Properties properties = Properties.createFromMap(SUPPORTED_PROPERTIES); assertNotNull("property was null", properties.get(KEY_1)); assertEquals("wrong property", BOOL_VAL_1, properties.get(KEY_1).getBoolean()); assertNull("unexpected property", properties.get("1234")); }
/** * Test HasLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasElementLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasLabel hasNotExistent = new HasLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasVertexLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasVertexLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasVertexLabel hasNotExistent = new HasVertexLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasVertexLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasVertexLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasEdgeLabel with a single graph and result false. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasEdgeLabelFalse() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasEdgeLabel hasNotExistent = new HasEdgeLabel("LabelDoesNotExist"); graph = graph.aggregate(hasNotExistent); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasEdgeLabel_LabelDoesNotExist not set", graphHead.hasProperty(hasNotExistent.getAggregatePropertyKey())); assertFalse("Property hasEdgeLabel_LabelDoesNotExist is true, should be false", graphHead.getPropertyValue(hasNotExistent.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasEdgeLabel with a single graph and result true. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasEdgeLabelTrue() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasEdgeLabel hasKnows = new HasEdgeLabel("knows"); graph = graph.aggregate(hasKnows); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasEdgeLabel_knows not set", graphHead.hasProperty(hasKnows.getAggregatePropertyKey())); assertTrue("Property hasEdgeLabel_knows is false, should be true", graphHead.getPropertyValue(hasKnows.getAggregatePropertyKey()).getBoolean()); }
/** * Test HasLabel with a single graph and result true. * * @throws Exception if the execution or IO fails. */ @Test public void testSingleGraphHasElementLabelTrue() throws Exception { LogicalGraph graph = getSocialNetworkLoader().getLogicalGraphByVariable("g2"); HasLabel hasPerson = new HasLabel("Person"); graph = graph.aggregate(hasPerson); EPGMGraphHead graphHead = graph.getGraphHead().collect().get(0); assertTrue("Property hasLabel_Person not set", graphHead.hasProperty(hasPerson.getAggregatePropertyKey())); assertTrue("Property hasLabel_Person is false, should be true", graphHead.getPropertyValue(hasPerson.getAggregatePropertyKey()).getBoolean()); }