-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
closes #17
- Loading branch information
1 parent
2749dac
commit 32412ec
Showing
7 changed files
with
213 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/gradoop/benchmarks/grouping/KeyedGroupingBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/main/java/org/gradoop/benchmarks/tpgm/PatternMatchingBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright © 2014 - 2021 Leipzig University (Database Research Group) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.gradoop.benchmarks.tpgm; | ||
|
||
import org.apache.commons.cli.CommandLine; | ||
import org.apache.flink.api.common.typeinfo.TypeHint; | ||
import org.apache.flink.api.java.DataSet; | ||
import org.apache.flink.api.java.ExecutionEnvironment; | ||
import org.apache.flink.api.java.tuple.Tuple2; | ||
import org.apache.flink.core.fs.FileSystem; | ||
import org.gradoop.temporal.model.impl.TemporalGraph; | ||
import org.gradoop.temporal.model.impl.TemporalGraphCollection; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Dedicated program to benchmark the query operator on temporal data. | ||
* The benchmark is expected to be executed on the LDBC data set. | ||
*/ | ||
public class PatternMatchingBenchmark extends BaseTpgmBenchmark { | ||
/** | ||
* Main program to run the benchmark. Arguments are the available options. | ||
* Example: {@code /path/to/flink run -c org.gradoop.benchmarks.tpgm.PatternMatchingBenchmark | ||
* path/to/gradoop-benchmarks.jar -i hdfs:///graph -f indexed -o hdfs:///output -c results.csv} | ||
* <p> | ||
* It is advisable to use the {@link org.gradoop.temporal.io.impl.csv.indexed.TemporalIndexedCSVDataSource} | ||
* for a better performance by using parameter {@code -f indexed}. | ||
* | ||
* @param args program arguments | ||
* @throws Exception in case of an error | ||
*/ | ||
public static void main(String[] args) throws Exception { | ||
CommandLine cmd = parseArguments(args, PatternMatchingBenchmark.class.getName()); | ||
|
||
if (cmd == null) { | ||
return; | ||
} | ||
|
||
readBaseCMDArguments(cmd); | ||
|
||
TemporalGraph graph = readTemporalGraph(INPUT_PATH, INPUT_FORMAT); | ||
|
||
ExecutionEnvironment env = graph.getConfig().getExecutionEnvironment(); | ||
|
||
String query = "MATCH (p:person)-[l:likes]->(c:comment), (c)-[r:replyOf]->(po:post) " + | ||
"WHERE l.val_from.after(Timestamp(2012-06-01)) AND " + | ||
" l.val_from.before(Timestamp(2012-06-02)) AND " + | ||
" c.val_from.after(Timestamp(2012-05-30)) AND " + | ||
" c.val_from.before(Timestamp(2012-06-02)) AND " + | ||
" po.val_from.after(Timestamp(2012-05-30)) AND " + | ||
" po.val_from.before(Timestamp(2012-06-02))"; | ||
|
||
TemporalGraphCollection results = graph.temporalQuery(query); | ||
|
||
// only count the results and write it to a csv file | ||
DataSet<Tuple2<String, Long>> sum = results.getGraphHeads() | ||
.map(g -> new Tuple2<>("G", 1L)).returns(new TypeHint<Tuple2<String, Long>>() {}) | ||
// group by the element type (V or E) | ||
.groupBy(0) | ||
// sum the values | ||
.sum(1); | ||
|
||
sum.writeAsCsv(appendSeparator(OUTPUT_PATH) + "count.csv", FileSystem.WriteMode.OVERWRITE); | ||
|
||
env.execute(PatternMatchingBenchmark.class.getSimpleName() + " - P: " + env.getParallelism()); | ||
writeCSV(env); | ||
} | ||
|
||
/** | ||
* Method to create and add lines to a csv-file | ||
* | ||
* @param env given ExecutionEnvironment | ||
* @throws IOException exception during file writing | ||
*/ | ||
private static void writeCSV(ExecutionEnvironment env) throws IOException { | ||
String head = String.format("%s|%s|%s|%s", "Parallelism", "dataset", "format", "Runtime(s)"); | ||
String tail = String.format("%s|%s|%s|%s", env.getParallelism(), INPUT_PATH, INPUT_FORMAT, | ||
env.getLastJobExecutionResult().getNetRuntime(TimeUnit.SECONDS)); | ||
writeToCSVFile(head, tail); | ||
} | ||
} |
Oops, something went wrong.