@Override public String toString() { List<List<GradoopId>> idCollection = new ArrayList<>(); for (int i = 0; i < size(); i++) { idCollection.add(getIdAsList(i)); } String idString = idCollection .stream() .map(entry -> { if (entry.size() == 1) { return entry.get(0).toString(); } else { return entry.stream().map(GradoopId::toString).collect(joining(", ", "[", "]")); } }) .collect(joining(", ")); String propertyString = getProperties() .stream() .map(PropertyValue::toString) .collect(joining(", ")); return "Embedding{ " + "entries: {" + idString + "}, " + "properties: {" + propertyString + "} " + "}"; } }
@Override public GraphHeadString map(GraphHead graphHead) throws Exception { return new GraphHeadString(graphHead.getId(), graphHead.getId().toString()); } }
@Override public GraphHeadString map(GraphHead graphHead) throws Exception { return new GraphHeadString(graphHead.getId(), graphHead.getId().toString()); } }
@Override public CSVEdge map(Edge edge) throws Exception { csvEdge.setId(edge.getId().toString()); csvEdge.setGradoopIds(collectionToCsvString(edge.getGraphIds())); csvEdge.setSourceId(edge.getSourceId().toString()); csvEdge.setTargetId(edge.getTargetId().toString()); csvEdge.setLabel(StringEscaper.escape(edge.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvEdge.setProperties(getPropertyString(edge, MetaDataSource.EDGE_TYPE)); return csvEdge; } }
@Override public CSVEdge map(Edge edge) throws Exception { csvEdge.setId(edge.getId().toString()); csvEdge.setGradoopIds(collectionToCsvString(edge.getGraphIds())); csvEdge.setSourceId(edge.getSourceId().toString()); csvEdge.setTargetId(edge.getTargetId().toString()); csvEdge.setLabel(StringEscaper.escape(edge.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvEdge.setProperties(getPropertyString(edge, MetaDataSource.EDGE_TYPE)); return csvEdge; } }
@Nonnull @Override public Pair<Key, Value> toRow(@Nonnull EPGMGraphHead record) throws IOException { //write to content return new Pair<>(new Key(record.getId().toString()), new Value(KryoUtils.dumps(factory.initGraphHead( record.getId(), record.getLabel(), record.getProperties())))); }
@Nonnull @Override public Pair<Key, Value> toRow(@Nonnull EPGMVertex record) throws IOException { //write to content return new Pair<>(new Key(record.getId().toString()), new Value(KryoUtils.dumps(factory.initVertex( record.getId(), record.getLabel(), record.getProperties(), record.getGraphIds())))); }
@Override public CSVGraphHead map(GraphHead graphHead) throws Exception { csvGraphHead.setId(graphHead.getId().toString()); csvGraphHead.setLabel(StringEscaper.escape(graphHead.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvGraphHead.setProperties(getPropertyString(graphHead, MetaDataSource.GRAPH_TYPE)); return csvGraphHead; } }
@Override public CSVGraphHead map(GraphHead graphHead) throws Exception { csvGraphHead.setId(graphHead.getId().toString()); csvGraphHead.setLabel(StringEscaper.escape(graphHead.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvGraphHead.setProperties(getPropertyString(graphHead, MetaDataSource.GRAPH_TYPE)); return csvGraphHead; } }
@Nonnull @Override public Pair<Key, Value> toRow(@Nonnull EPGMEdge record) throws IOException { //write to content return new Pair<>(new Key(record.getId().toString()), new Value(KryoUtils.dumps(factory.initEdge( record.getId(), record.getLabel(), record.getSourceId(), record.getTargetId(), record.getProperties(), record.getGraphIds())))); }
@Test public void testFromString() { GradoopId originalId = GradoopId.get(); GradoopId fromStringId = GradoopId.fromString(originalId.toString()); assertEquals("reconstruction from string failed", originalId, fromStringId); }
@Override public Mutation writeRow( Mutation mutation, EPGMVertex record ) { mutation.put(AccumuloTables.KEY.LABEL, AccumuloTables.KEY.NONE, record.getLabel()); //encode properties value bytes as base64 string Iterable<String> keys = record.getPropertyKeys(); if (keys != null) { keys.forEach(key -> mutation.put( /*cf*/AccumuloTables.KEY.PROPERTY, /*cq*/key, /*value*/new Value(record.getPropertyValue(key).getRawBytes()))); } //write graph ids GradoopIdSet ids = record.getGraphIds(); if (ids != null) { ids.forEach( id -> mutation.put(AccumuloTables.KEY.GRAPH, id.toString(), AccumuloTables.KEY.NONE)); } return mutation; }
@Override public CSVVertex map(Vertex vertex) throws Exception { csvVertex.setId(vertex.getId().toString()); csvVertex.setGradoopIds(collectionToCsvString(vertex.getGraphIds())); csvVertex.setLabel(StringEscaper.escape(vertex.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvVertex.setProperties(getPropertyString(vertex, MetaDataSource.VERTEX_TYPE)); return csvVertex; } }
@Override public CSVVertex map(Vertex vertex) throws Exception { csvVertex.setId(vertex.getId().toString()); csvVertex.setGradoopIds(collectionToCsvString(vertex.getGraphIds())); csvVertex.setLabel(StringEscaper.escape(vertex.getLabel(), CSVConstants.ESCAPED_CHARACTERS)); csvVertex.setProperties(getPropertyString(vertex, MetaDataSource.VERTEX_TYPE)); return csvVertex; } }
@Override public void validateGraphProperties(LogicalGraph graph) throws Exception { List<Vertex> vertices = graph.getVertices().collect(); for (Vertex v : vertices) { assertTrue("No local value stored in vertex: " + v.getId().toString(), v.hasProperty(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL)); } } }
@Override public void validateGraphProperties(LogicalGraph graph) throws Exception { List<Vertex> vertices = graph.getVertices().collect(); for (Vertex v : vertices) { assertTrue("No local value stored in vertex: " + v.getId().toString(), v.hasProperty(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL)); } } }
@Override public void testFullyConnectedGraph() throws Exception { validateGraphProperties(fullGraph); List<Vertex> vertices = fullGraph.getVertices().collect(); for (Vertex v : vertices) { assertEquals( "Wrong local value for clique-vertex '" + v.getId().toString() + "', should be 1", 1d, v.getPropertyValue(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL).getDouble(), 0.0); } }
@Override public void testNonConnectedGraph() throws Exception { validateGraphProperties(nonConnectedGraph); List<Vertex> vertices = nonConnectedGraph.getVertices().collect(); for (Vertex v : vertices) { assertEquals( "Wrong local value for not connected vertex: " + v.getId().toString() + ", should be 0", 0d, v.getPropertyValue(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL).getDouble(), 0.0); } }
@Override public void testNonConnectedGraph() throws Exception { validateGraphProperties(nonConnectedGraph); List<Vertex> vertices = nonConnectedGraph.getVertices().collect(); for (Vertex v : vertices) { assertEquals( "Wrong local value for not connected vertex: " + v.getId().toString() + ", should be 0", 0d, v.getPropertyValue(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL).getDouble(), 0.0); } }
@Override public void testFullyConnectedGraph() throws Exception { validateGraphProperties(fullGraph); List<Vertex> vertices = fullGraph.getVertices().collect(); for (Vertex v : vertices) { assertEquals("Wrong local value for clique-vertex '" + v.getId().toString() + "', should be 1", 1d, v.getPropertyValue(ClusteringCoefficientBase.PROPERTY_KEY_LOCAL).getDouble(), 0.0); } }