/** * Returns example integrated instance graph from GDL input. * @return integrated instance graph * @throws IOException */ public static LogicalGraph getIntegratedInstanceGraph() throws IOException { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); GradoopFlinkConfig gradoopConf = GradoopFlinkConfig.createConfig(env); FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader(gradoopConf); String gdl = IOUtils.toString(CategoryCharacteristicPatterns.class .getResourceAsStream("/data/gdl/itbda.gdl")); gdl = gdl .replaceAll("SOURCEID_KEY", SOURCEID_KEY) .replaceAll("SUPERTYPE_KEY", SUPERTYPE_KEY) .replaceAll("SUPERCLASS_VALUE_MASTER", SUPERCLASS_VALUE_MASTER) .replaceAll("SUPERCLASS_VALUE_TRANSACTIONAL", SUPERCLASS_VALUE_TRANSACTIONAL); loader.initDatabaseFromString(gdl); return loader.getLogicalGraphByVariable("iig"); }
/** * Example method to read a csv file and print the vertices of the generated graph. * * @param args program arguments * @throws Exception io exception if file not found */ public static void main(String[] args) throws Exception { ExecutionEnvironment env = getExecutionEnvironment(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env); String exampleFile = MinimalCSVImportExample.class. getResource("/data/csv/minimalcsv/person.csv").getPath(); DataSource source = new MinimalCSVImporter(exampleFile, "\\|", config, true); LogicalGraph graph = source.getLogicalGraph(); graph.getVertices().print(); }
/** * Example method to read a json file and print the vertices of the generated graph. * * @param args program arguments * @throws Exception io exception if file not found */ public static void main(String[] args) throws Exception { ExecutionEnvironment env = getExecutionEnvironment(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env); String exampleFile = MinimalJSONImportExample.class. getResource("/data/json/minimaljson/person.json").getPath(); DataSource source = new MinimalJSONImporter(exampleFile, config); LogicalGraph graph = source.getLogicalGraph(); graph.getVertices().print(); }
/** * Returns the configuration for the test * * @return Gradoop Flink configuration */ protected GradoopFlinkConfig getConfig() { if (config == null) { setConfig(GradoopFlinkConfig.createConfig(getExecutionEnvironment(), graphLayoutFactory, collectionLayoutFactory)); } return config; }
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env);
/** * Returns an EPGM DataSource for a given directory and format. * * @param directory input path * @param format format in which the data is stored (csv, indexed, json) * @return DataSource for EPGM Data * @throws IOException on failure */ private static DataSource getDataSource(String directory, String format) throws IOException { directory = appendSeparator(directory); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); format = format.toLowerCase(); switch (format) { case "json": return new JSONDataSource(directory, config); case "csv": return new CSVDataSource(directory, config); case "indexed": return new IndexedCSVDataSource(directory, config); case "lgcsv": return new LogicalGraphCSVDataSource(directory, config); case "lgindexed": return new LogicalGraphIndexedCSVDataSource(directory, config); default: throw new IllegalArgumentException("Unsupported format: " + format); } }
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env);
@Override protected GraphCollectionLayoutFactory<GraphHead, Vertex, Edge> getFactory() { // create the factory to test IndexedGVECollectionLayoutFactory factory = new IndexedGVECollectionLayoutFactory(); // create a default gradoop flink config and set it to the layout GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); factory.setGradoopFlinkConfig(config); return factory; }
@Override protected LogicalGraphLayoutFactory<GraphHead, Vertex, Edge> getFactory() { IndexedGVEGraphLayoutFactory logicalGraphLayoutFactory = new IndexedGVEGraphLayoutFactory(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); config.setLogicalGraphLayoutFactory(logicalGraphLayoutFactory); return logicalGraphLayoutFactory; } }
@Override protected LogicalGraphLayoutFactory<GraphHead, Vertex, Edge> getFactory() { // create the factory to test GVEGraphLayoutFactory factory = new GVEGraphLayoutFactory(); // create a default gradoop flink config and set it to the layout GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); factory.setGradoopFlinkConfig(config); return factory; } }
@Override protected GraphCollectionLayoutFactory<GraphHead, Vertex, Edge> getFactory() { // create the factory to test GVECollectionLayoutFactory factory = new GVECollectionLayoutFactory(); // create a default gradoop flink config and set it to the layout GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); factory.setGradoopFlinkConfig(config); return factory; } }
@Override protected GraphCollectionLayoutFactory<GraphHead, Vertex, Edge> getFactory() { TxCollectionLayoutFactory txCollectionLayoutFactory = new TxCollectionLayoutFactory(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); config.setGraphCollectionLayoutFactory(txCollectionLayoutFactory); return txCollectionLayoutFactory; } }
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(getExecutionEnvironment());
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(executionEnvironment);
@Test public void queryEdgeByProperty() throws Throwable { doTest(TEST01, (loader, store, config) -> { List<Edge> storeEdges = loader.getEdges().stream() .filter(it -> { assert it.getProperties() != null; return it.getProperties().get("since") != null && Objects.equals(it.getProperties() .get("since") .getInt(), 2013); }) .collect(Collectors.toList()); AccumuloDataSource source = new AccumuloDataSource( store, GradoopFlinkConfig.createConfig(getExecutionEnvironment())); List<Edge> query = source.applyEdgePredicate( Query.elements() .fromAll() .where(AccumuloFilters.propEquals("since", 2013))) .getGraphCollection() .getEdges() .collect(); GradoopTestUtils.validateEPGMElementCollections(storeEdges, query); }); }
/** * Tries to add an unsupported property type {@link Queue} as property value. */ @Test(expected = UnsupportedTypeException.class) public void wrongPropertyTypeTest() throws AccumuloSecurityException, AccumuloException { GradoopAccumuloConfig config = AccumuloTestSuite.getAcConfig(TEST04); AccumuloEPGMStore graphStore = new AccumuloEPGMStore(config); // Queue is not supported by final Queue<String> value = Queues.newPriorityQueue(); GradoopId vertexID = GradoopId.get(); final String label = "A"; Properties props = Properties.create(); props.set("k1", value); final GradoopIdSet graphs = new GradoopIdSet(); GradoopFlinkConfig flinkConfig = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); graphStore.writeVertex(flinkConfig .getVertexFactory() .initVertex(vertexID, label, props, graphs)); }
@BeforeClass public static void setup() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env); GraphHead g0 = config.getGraphHeadFactory().createGraphHead("A"); GraphHead g1 = config.getGraphHeadFactory().createGraphHead("B"); Vertex v0 = config.getVertexFactory().createVertex("A"); Vertex v1 = config.getVertexFactory().createVertex("B"); Vertex v2 = config.getVertexFactory().createVertex("C"); Edge e0 = config.getEdgeFactory().createEdge("a", v0.getId(), v1.getId()); Edge e1 = config.getEdgeFactory().createEdge("b", v1.getId(), v2.getId()); v0.addGraphId(g0.getId()); v1.addGraphId(g0.getId()); v1.addGraphId(g1.getId()); v2.addGraphId(g1.getId()); e0.addGraphId(g0.getId()); e1.addGraphId(g1.getId()); tx0 = new GraphTransaction(g0, Sets.newHashSet(v0, v1), Sets.newHashSet(e0)); tx1 = new GraphTransaction(g1, Sets.newHashSet(v1, v2), Sets.newHashSet(e1)); }
/** * Load social network graph and write it into accumulo graph * * @param namespace store namespace * @param context loader context * @throws Throwable if error */ protected void doTest( String namespace, SocialTestContext context ) throws Throwable { GradoopAccumuloConfig config = AccumuloTestSuite.getAcConfig(namespace); AccumuloEPGMStore graphStore = new AccumuloEPGMStore(config); //read vertices by label AsciiGraphLoader<GraphHead, Vertex, Edge> loader = GradoopTestUtils.getSocialNetworkLoader(); // write social graph to Accumulo for (GraphHead g : loader.getGraphHeads()) { graphStore.writeGraphHead(g); } for (Vertex v : loader.getVertices()) { graphStore.writeVertex(v); } for (Edge e : loader.getEdges()) { graphStore.writeEdge(e); } graphStore.flush(); GradoopFlinkConfig flinkConfig = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); context.test(loader, graphStore, flinkConfig); }
@Test public void write() throws Exception { AccumuloEPGMStore accumuloStore = new AccumuloEPGMStore(AccumuloTestSuite.getAcConfig(TEST_02)); FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader( GradoopFlinkConfig.createConfig(getExecutionEnvironment())); InputStream inputStream = getClass().getResourceAsStream( GradoopTestUtils.SOCIAL_NETWORK_GDL_FILE); loader.initDatabaseFromStream(inputStream); GradoopFlinkConfig flinkConfig = GradoopFlinkConfig.createConfig(getExecutionEnvironment()); new AccumuloDataSink(accumuloStore, flinkConfig) .write(flinkConfig.getGraphCollectionFactory() .fromCollections( loader.getGraphHeads(), loader.getVertices(), loader.getEdges())); getExecutionEnvironment().execute(); accumuloStore.flush(); validateEPGMElementCollections(loader.getGraphHeads(), accumuloStore.getGraphSpace().readRemainsAndClose()); validateEPGMElementCollections(loader.getVertices(), accumuloStore.getVertexSpace().readRemainsAndClose()); validateEPGMGraphElementCollections(loader.getVertices(), accumuloStore.getVertexSpace().readRemainsAndClose()); validateEPGMElementCollections(loader.getEdges(), accumuloStore.getEdgeSpace().readRemainsAndClose()); validateEPGMGraphElementCollections(loader.getEdges(), accumuloStore.getEdgeSpace().readRemainsAndClose()); accumuloStore.close(); }
@BeforeClass public static void setup() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env); g0 = config.getGraphHeadFactory().createGraphHead("A"); g1 = config.getGraphHeadFactory().createGraphHead("B"); v0 = config.getVertexFactory().createVertex("A"); v1 = config.getVertexFactory().createVertex("B"); v2 = config.getVertexFactory().createVertex("C"); e0 = config.getEdgeFactory().createEdge("a", v0.getId(), v1.getId()); e1 = config.getEdgeFactory().createEdge("b", v1.getId(), v2.getId()); v0.addGraphId(g0.getId()); v1.addGraphId(g0.getId()); v1.addGraphId(g1.getId()); v2.addGraphId(g1.getId()); e0.addGraphId(g0.getId()); e1.addGraphId(g1.getId()); }