/*
* This file is part of Gradoop.
*
* Gradoop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Gradoop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gradoop. If not, see <http://www.gnu.org/licenses/>.
*/
package org.gradoop.utils.statistics;
import org.apache.flink.api.common.ProgramDescription;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.java.tuple.Tuple3;
import org.gradoop.examples.AbstractRunner;
import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatisticsReader;
import org.gradoop.flink.model.impl.operators.statistics.SourceLabelAndEdgeLabelDistribution;
/**
* Computes {@link SourceLabelAndEdgeLabelDistribution} for a given logical graph.
*/
public class SourceAndEdgeLabelDistributionRunner extends AbstractRunner implements ProgramDescription {
/**
* args[0] - path to input directory
* args[1] - input format (json, csv)
* args[2] - path to output directory
*
* @param args arguments
* @throws Exception if something goes wrong
*/
public static void main(String[] args) throws Exception {
new SourceLabelAndEdgeLabelDistribution()
.execute(readLogicalGraph(args[0], args[1]))
.map(value -> Tuple3.of(value.f0.f0, value.f0.f1, value.f1))
.returns(new TypeHint<Tuple3<String, String, Long>>() { })
.writeAsCsv(
appendSeparator(args[2]) +
GraphStatisticsReader.FILE_EDGE_COUNT_BY_SOURCE_VERTEX_AND_EDGE_LABEL,
System.lineSeparator(), GraphStatisticsReader.TOKEN_SEPARATOR)
.setParallelism(1);
getExecutionEnvironment().execute("Statistics: Source and edge label distribution");
}
@Override
public String getDescription() {
return SourceAndEdgeLabelDistributionRunner.class.getName();
}
}