org.apache.flink.graph.GraphCsvReader Java Examples

The following examples show how to use org.apache.flink.graph.GraphCsvReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSV.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Graph<K, NullValue, NullValue> create(ExecutionEnvironment env) throws Exception {
	GraphCsvReader reader = Graph.fromCsvReader(inputFilename.getValue(), env)
		.ignoreCommentsEdges(commentPrefix.getValue())
		.lineDelimiterEdges(lineDelimiter.getValue())
		.fieldDelimiterEdges(fieldDelimiter.getValue());

	Graph<K, NullValue, NullValue> graph;

	switch (type.getValue()) {
		case INTEGER:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(IntValue.class);
			break;

		case LONG:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(LongValue.class);
			break;

		case STRING:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(StringValue.class);
			break;

		default:
			throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
	}

	return simplify.simplify(graph, parallelism.getValue().intValue());
}
 
Example #2
Source File: CSV.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Graph<K, NullValue, NullValue> create(ExecutionEnvironment env) throws Exception {
	GraphCsvReader reader = Graph.fromCsvReader(inputFilename.getValue(), env)
		.ignoreCommentsEdges(commentPrefix.getValue())
		.lineDelimiterEdges(lineDelimiter.getValue())
		.fieldDelimiterEdges(fieldDelimiter.getValue());

	Graph<K, NullValue, NullValue> graph;

	switch (type.getValue()) {
		case INTEGER:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(IntValue.class);
			break;

		case LONG:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(LongValue.class);
			break;

		case STRING:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(StringValue.class);
			break;

		default:
			throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
	}

	return simplify.simplify(graph, parallelism.getValue().intValue());
}
 
Example #3
Source File: CSV.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Graph<K, NullValue, NullValue> create(ExecutionEnvironment env) throws Exception {
	GraphCsvReader reader = Graph.fromCsvReader(inputFilename.getValue(), env)
		.ignoreCommentsEdges(commentPrefix.getValue())
		.lineDelimiterEdges(lineDelimiter.getValue())
		.fieldDelimiterEdges(fieldDelimiter.getValue());

	Graph<K, NullValue, NullValue> graph;

	switch (type.getValue()) {
		case INTEGER:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(IntValue.class);
			break;

		case LONG:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(LongValue.class);
			break;

		case STRING:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(StringValue.class);
			break;

		default:
			throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
	}

	return simplify.simplify(graph, parallelism.getValue().intValue());
}