/** * Appends the given ASCII GDL String to the database. * * Variables previously used can be reused as their refer to the same objects. * * @param asciiGraph GDL string (must not be {@code null}) */ public void appendToDatabaseFromString(String asciiGraph) { if (asciiGraph == null) { throw new IllegalArgumentException("AsciiGraph must not be null"); } if (loader != null) { loader.appendFromString(asciiGraph); } else { initDatabaseFromString(asciiGraph); } }
/** * Appends the given ASCII GDL String to the database. * * Variables previously used can be reused as their refer to the same objects. * * @param asciiGraph GDL string (must not be {@code null}) */ public void appendToDatabaseFromString(String asciiGraph) { if (asciiGraph == null) { throw new IllegalArgumentException("AsciiGraph must not be null"); } if (loader != null) { loader.appendFromString(asciiGraph); } else { initDatabaseFromString(asciiGraph); } }
/** * 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"); }
protected FlinkAsciiGraphLoader getLoaderFromString(String asciiString) { FlinkAsciiGraphLoader loader = getNewLoader(); loader.initDatabaseFromString(asciiString); return loader; }
/** * Runs the benchmark with demo data. * * @param gradoopConf gradoop config * @throws Exception */ private static void executeWithDemoData(GradoopFlinkConfig gradoopConf) throws Exception { ExampleOutput out = new ExampleOutput(); FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader(gradoopConf); String graphDefinition = IOUtils.toString(SNABenchmark2.class .getResourceAsStream("/data/gdl/sna.gdl")); loader.initDatabaseFromString(graphDefinition); LogicalGraph inputGraph = loader.getLogicalGraphByVariable("db"); out.add("Input Graph", inputGraph); LogicalGraph outputGraph = execute(inputGraph, 2); out.add("Output Graph", outputGraph); out.print(); }
/** * Executes a rollUp on edges using a single grouping key and checks if the result * is correct. * * @throws Exception If the execution fails. */ @Test public void testEdgeRollUpWithSingleGroupingKey() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); LogicalGraph input = loader.getGraphCollectionByVariables("g0", "g1", "g2", "g3") .reduce(new ReduceCombination()); //expected loader.initDatabaseFromString("g0 {edgeRollUpGroupingKeys:\":label\"}[" + "(v0)" + "(v0)-[e_0:knows{count:10L}]->(v0)" + "(v0)-[e_1:hasModerator{count:1L}]->(v0)" + "(v0)-[e_2:hasMember{count:2L}]->(v0)" + "]"); GraphCollection expected = loader.getGraphCollection(); List<String> vertexGK = Collections.emptyList(); List<AggregateFunction> vertexAGG = Collections.emptyList(); List<String> edgeGK = Collections.singletonList(Grouping.LABEL_SYMBOL); List<AggregateFunction> edgeAGG = Collections.singletonList(new Count("count")); GraphCollection output = input.groupEdgesByRollUp(vertexGK, vertexAGG, edgeGK, edgeAGG); collectAndAssertTrue(output.equalsByGraphData(expected)); }
loader.initDatabaseFromString("g0 {vertexRollUpGroupingKeys:\"age\"}[" + "(v0 {count:1L,age:20})" + "(v1 {count:2L,age:30})" +
loader.initDatabaseFromString("g0 {edgeRollUpGroupingKeys:\":label,since,vertexCount\"}[" + "(v0)" + "(v0)-[e_0:hasModerator{count:1L,vertexCount:NULL,since:2013}]->(v0)" +
loader.initDatabaseFromString("g0 {vertexRollUpGroupingKeys:\"age,gender,city\"}[" + "(v2 {gender:\"f\",city:\"Dresden\",count:1L,age:30})" + "(v3 {gender:\"m\",city:\"Leipzig\",count:1L,age:30})" +
loader.initDatabaseFromString(graph);
loader.initDatabaseFromString(graphString); LogicalGraph graph = loader.getLogicalGraphByVariable("g");