@Override protected G initFrom(G graphHead) { return graphHeadFactory.initGraphHead(graphHead.getId(), GradoopConstants.DEFAULT_GRAPH_LABEL); } }
@Override protected G initFrom(G graphHead) { return graphHeadFactory.initGraphHead(graphHead.getId(), GradoopConstants.DEFAULT_GRAPH_LABEL); } }
/** * Creates a new EPGMGraph from the GDL Loader. * * @param g graph from GDL Loader * @return EPGM graph head */ private G initGraphHead(Graph g) { G graphHead = (G) config.getGraphHeadFactory().createGraphHead( g.getLabel(), Properties.createFromMap(g.getProperties())); graphHeadIds.put(g.getId(), graphHead.getId()); graphHeads.put(graphHead.getId(), graphHead); return graphHead; }
@Override public GraphHead readRow(EPGMGraphHead origin) { return factory.initGraphHead( /*edge id*/origin.getId(), /*label*/origin.getLabel(), /*properties*/origin.getProperties()); }
@Override public void writeGraphHead(@Nonnull final EPGMGraphHead graphHead) throws IOException { GraphHeadHandler graphHeadHandler = config.getGraphHeadHandler(); // graph id Put put = new Put(graphHeadHandler.getRowKey(graphHead.getId())); // write graph to Put put = graphHeadHandler.writeGraphHead(put, graphHead); // write to table graphHeadTable.put(put); if (autoFlush) { admin.flush(graphHeadTable.getName()); } }
/** * Returns all edges that belong to the given graph variables. * * @param variables graph variables used in the GDL script * @return edges */ public Collection<E> getEdgesByGraphVariables(String... variables) { GradoopIdSet graphIds = new GradoopIdSet(); for (G graphHead : getGraphHeadsByVariables(variables)) { graphIds.add(graphHead.getId()); } return getEdgesByGraphIds(graphIds); }
/** * Returns all vertices that belong to the given graph variables. * * @param graphVariables graph variables used in the GDL script * @return vertices that are contained in the graphs */ public Collection<V> getVerticesByGraphVariables(String... graphVariables) { GradoopIdSet graphIds = new GradoopIdSet(); for (G graphHead : getGraphHeadsByVariables(graphVariables)) { graphIds.add(graphHead.getId()); } return getVerticesByGraphIds(graphIds); }
@Test public void createWithIDTest() { GradoopId graphID = GradoopId.get(); EPGMGraphHead g = new GraphHeadFactory().initGraphHead(graphID); assertThat(g.getId(), is(graphID)); assertThat(g.getPropertyCount(), is(0)); }
@Test public void createDefaultGraphTest() { GradoopId graphID = GradoopId.get(); String label = "A"; Properties props = Properties.create(); props.set("k1", "v1"); props.set("k2", "v2"); EPGMGraphHead graphHead = new GraphHeadFactory().initGraphHead(graphID, label, props); assertThat(graphHead.getId(), is(graphID)); assertEquals(label, graphHead.getLabel()); assertThat(graphHead.getPropertyCount(), is(2)); assertThat(graphHead.getPropertyValue("k1").getString(), Is.<Object>is("v1")); assertThat(graphHead.getPropertyValue("k2").getString(), Is.<Object>is("v2")); }
count.getAggregatePropertyKey())); if (graphHead.getId().equals(g0Id)) { assertCounts(graphHead, 3, 2); } else if (graphHead.getId().equals(g1Id)) { assertCounts(graphHead, 4, 3); } else if (graphHead.getId().equals(g2Id)) { assertCounts(graphHead, 2, 1); } else if (graphHead .getId().equals(g3Id)) { assertCounts(graphHead, 0, 0); } else {
graphHead.getPropertyValue(sumProperty.getAggregatePropertyKey()); if (graphHead.getId().equals(g0Id)) { assertEquals(1.5f, vertexAggregate.getFloat(), 0.00001); assertEquals( elementAggregate.getBigDecimal() .round(new MathContext(2, RoundingMode.HALF_UP))); } else if (graphHead.getId().equals(g1Id)) { assertEquals(0.5f, vertexAggregate.getFloat(), 0.00001); assertEquals(2L, edgeAggregate.getLong()); assertEquals(2.5f, elementAggregate.getFloat(), 0.00001); } else if (graphHead.getId().equals(g2Id)) { assertEquals(PropertyValue.NULL_VALUE, vertexAggregate); assertEquals(PropertyValue.NULL_VALUE, edgeAggregate);
graphHead.getPropertyValue(sumProperty.getAggregatePropertyKey()); if (graphHead.getId().equals(g0Id)) { assertEquals(2, edgeAggregate.getLong()); assertEquals(0.9f, vertexAggregate.getFloat(), 0.00001); assertEquals(2.9f, elementAggregate.getFloat(), 0.00001); } else if (graphHead.getId().equals(g1Id)) { assertEquals(2, edgeAggregate.getLong()); assertEquals(0.8f, vertexAggregate.getFloat(), 0.00001); assertEquals(2.8f, elementAggregate.getFloat(), 0.00001); } else if (graphHead.getId().equals(g2Id)) { assertEquals(PropertyValue.NULL_VALUE, edgeAggregate); assertEquals(PropertyValue.NULL_VALUE, vertexAggregate);
graphHead.getPropertyValue(minProperty.getAggregatePropertyKey()); if (graphHead.getId().equals(g0Id)) { assertEquals(2, edgeAggregate.getLong()); assertEquals(0.1f, vertexAggregate.getFloat(), 0.00001); assertEquals(0.1f, elementAggregate.getFloat(), 0.00001); } else if (graphHead.getId().equals(g1Id)) { assertEquals(2, edgeAggregate.getLong()); assertEquals(0.3f, vertexAggregate.getFloat(), 0.00001); assertEquals(0.3f, elementAggregate.getFloat(), 0.00001); } else if (graphHead.getId().equals(g2Id)) { assertEquals(PropertyValue.NULL_VALUE, edgeAggregate); assertEquals(PropertyValue.NULL_VALUE, vertexAggregate);
graphHead.getPropertyValue(maxProperty.getAggregatePropertyKey()); if (graphHead.getId().equals(g0Id)) { assertEquals(2L, edgeAggregate.getLong()); assertEquals(0.5f, vertexAggregate.getFloat(), 0.00001); assertEquals(2L, elementAggregate.getLong()); } else if (graphHead.getId().equals(g1Id)) { assertEquals(2L, edgeAggregate.getLong()); assertEquals(0.5f, vertexAggregate.getFloat(), 0.00001); assertEquals(2L, elementAggregate.getLong()); } else if (graphHead.getId().equals(g2Id)) { assertEquals(PropertyValue.NULL_VALUE, edgeAggregate); assertEquals(PropertyValue.NULL_VALUE, vertexAggregate);