[
https://issues.apache.org/jira/browse/FLINK-3036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15009081#comment-15009081
]
ASF GitHub Bot commented on FLINK-3036:
---------------------------------------
GitHub user tillrohrmann opened a pull request:
https://github.com/apache/flink/pull/1370
[FLINK-3036] [gelly] Fix Graph.fromCsvReader method in Gelly's Scala API
The Graph.fromCsvReader in Gelly's Scala API returns a wrongly typed Graph
instance because
the implementation contains code paths with return types which are not
compatible. This
lead to a bad user experience.
This commit fixes this. However, it also introduces a slightly different
behaviour and is
thus API breaking. Before there were parameters hasEdgeValues and
readVertices which
controlled whether edge values and vertices shall be read. This is now
implicitly controlled
by the types of the vertex and edge value. If the type is NullValue for the
edge values then
the edge value won't be read from the given csv file. If the vertex value
type is NullValue,
then all vertices will have a value of a NullValue instance. If the
pathVertices is not
specified and the vertex value type is unequal to NullValue, then the
vertexValueInitializer
is used for the initialization.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/tillrohrmann/flink fixGelly
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/1370.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1370
----
commit 2edec702ceac62ff8bbcdf7b6dda8f029d5f2bea
Author: Till Rohrmann <[email protected]>
Date: 2015-11-17T17:21:47Z
[FLINK-3036] [gelly] Fix Graph.fromCsvReader method in Gelly's Scala API
The Graph.fromCsvReader in Gelly's Scala API returns a wrongly typed Graph
instance because
the implementation contains code paths with return types which are not
compatible. This
lead to a bad user experience.
This commit fixes this. However, it also introduces a slightly different
behaviour and is
thus API breaking. Before there were parameters hasEdgeValues and
readVertices which
controlled whether edge values and vertices shall be read. This is now
implicitly controlled
by the types of the vertex and edge value. If the type is NullValue for the
edge values then
the edge value won't be read from the given csv file. If the vertex value
type is NullValue,
then all vertices will have a value of a NullValue instance. If the
pathVertices is not
specified and the vertex value type is unequal to NullValue, then the
vertexValueInitializer
is used for the initialization.
----
> Gelly's Graph.fromCsvReader method returns wrongly parameterized Graph
> ----------------------------------------------------------------------
>
> Key: FLINK-3036
> URL: https://issues.apache.org/jira/browse/FLINK-3036
> Project: Flink
> Issue Type: Bug
> Components: Gelly
> Affects Versions: 0.10.0
> Reporter: Till Rohrmann
> Assignee: Till Rohrmann
>
> The Scala method {{Graph.fromCsvReader}} of Gelly returns a wrongly typed
> {{Graph}} instance. The problem is that no return type has been explicitly
> defined for the method. Additionally, the method returns fundamentally
> incompatible types depending on the given parameters. So for example, the
> method can return a {{Graph[Long, Long, Long]}} if a vertex and edge file is
> specified (in this case with value type {{Long}}). If the vertex file is not
> specified and neither a vertex value initializer, then the return type is
> {{Graph[Long, NullValue, Long]}}. Since {{NullValue}} and {{Long}} have
> nothing in common, Scala's type inference infers that the {{fromCsvReader}}
> method must have a return type {{Graph[Long, t >: Long with NullValue,
> Long]}} with {{t}} being a supertype of {{Long with NullValue}}. This type is
> not useful at all, since there is no such type. As a consequence, the user
> has to cast the resulting {{Graph}} to have either the type {{Graph[Long,
> NullValue, Long]}} or {{Graph[Long, Long, Long]}} if he wants to do something
> more elaborate than just collecting the edges for example.
> This can be especially confusing because one usually writes something like
> {code}
> val graph = Graph.fromCsvReader[Long, Double, Double](...)
> graph.run(new PageRank(...))
> {code}
> and does not see that the type of {{graph}} is {{Graph[Long, t >: Double with
> NullValue, u >: Double with NullValue}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)