Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes all the way down #58

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eb12cce
WIP: rewriting everything with inner classes
laughedelic Mar 26, 2016
bbec14a
Added source and target graphs to the edge parameters; otherwise sour…
laughedelic Mar 27, 2016
758be84
Returning VT.Vertex-like types; using .new Vertex() for that; .fromRa…
laughedelic Mar 28, 2016
e9bb8a1
Cleaned build well, now .fromRaw() works as expected; added a note ab…
laughedelic Mar 28, 2016
fbbaffd
Added arity-specific methods in/out-E/V methods with default implemen…
laughedelic Mar 28, 2016
7bb50cf
Moved all in/out methods from graph to Vertex class
laughedelic Mar 28, 2016
23ebbf0
Moved source/target, all propeties-related methods and addVertex/addE…
laughedelic Mar 28, 2016
f17a4e7
Just moved things from GraphSchema to TypedGraph (now it's one class)
laughedelic Mar 28, 2016
1a8b15a
Made top-level classes public, renamed files
laughedelic Mar 29, 2016
a41459e
Added TypedLinkGraph (not the best name, but will work for now)
laughedelic Mar 29, 2016
86b6145
Updated tests code; discovered that .fromRaw() doesn't return the exp…
laughedelic Mar 29, 2016
0f3f829
Rewrote index-related code; added two classes refining the interface …
laughedelic Mar 29, 2016
f9dc524
Made top-level entities explicitly public
laughedelic Mar 29, 2016
3226993
Added methods for all members instead of fields (except of the _label…
laughedelic Mar 30, 2016
604ddad
Added to ElementType properties set and made the properties factory m…
laughedelic Mar 30, 2016
d83494e
Added a set containing all vertex types of a graph (which are automat…
laughedelic Mar 30, 2016
0a8be61
Added a check on the set construction for distinct labels (if you try…
laughedelic Mar 30, 2016
e89f450
Added inner class Property to the ElementType
laughedelic Mar 30, 2016
6635419
Added UntypedGraphSchema interface for schema creation; separated tra…
laughedelic Mar 30, 2016
e3b59ae
Added sets for holding all graph's edge types and indexes
laughedelic Mar 30, 2016
94012e6
Merge branch 'feature/schema-creation' into refactoring/everything-is…
laughedelic Mar 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ excludeFilter in unmanagedSources :=
(excludeFilter in unmanagedSources).value ||
"*Index.java" ||
"*Query.java"

javacOptions ++= Seq(
"-Xdiags:verbose"
)
8 changes: 5 additions & 3 deletions src/main/java/com/bio4j/angulillos/TypedEdge.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ protected EdgeType(ST sourceType, TT targetType) {
this.targetType = targetType;
}

@Override public Edge fromRaw(RE raw) { return this.new Edge(raw); }
// @Override
// @SuppressWarnings("unchecked")
// public final ET.Edge fromRaw(RE raw) { return self().new Edge(raw); }


class Edge extends Element {
Expand All @@ -42,11 +44,11 @@ class Edge extends Element {

/* the source vertex of this edge */
public final
VertexType<ST, SG,RV,RE>.Vertex source() { return graph.source( this ); }
ST.Vertex source() { return graph.source( this ); }

// /* the target vertex of this edge */
public final
VertexType<TT, TG,RV,RE>.Vertex target() { return graph.target( this ); }
TT.Vertex target() { return graph.target( this ); }

@Override public
<X> X get(Property<ET,X> property) { return graph.getProperty(this, property); }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bio4j/angulillos/TypedElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ElementType <
public abstract FT self();

/* Constructs a new element of this element type */
public abstract Element fromRaw(RF raw);
// public abstract Element fromRaw(RF raw);

/* Defines a new property on this element type */
public final <X> Property<FT,X> property(String nameSuffix, Class<X> valueClass) {
Expand Down
65 changes: 27 additions & 38 deletions src/main/java/com/bio4j/angulillos/TypedGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,26 @@ interface TypedGraph <
default <
VT extends VertexType<VT, G,RV,RE>
>
VertexType<VT,G,RV,RE>.Vertex addVertex(VT vertexType) {
VT.Vertex addVertex(VT vertexType) {

return vertexType.fromRaw(
return vertexType.new Vertex(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eparejatobes take a look, please. If I use .fromRaw here, I get

com.bio4j.angulillos.VertexType.Vertex cannot be converted to 
com.bio4j.angulillos.VertexType.Vertex

😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you need VT extends G.VertexType<...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this moment there is no G.VertexType yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is something funny happening. I've tried changing that many times and sometimes I cannot get rid of these errors, but then if I clean (well) and compile, it compiles fine. I just tried to make a little snippet of code with the same pattern and I couldn't reproduce this compilation error, so I think that it's some incremental compilation artefacts..

raw().addVertex( vertexType._label )
);
}

/* adds an edge; note that this method does not set any properties. As it needs to be called by vertices in possibly different graphs, all the graph bounds are free with respect to G. */
default <
ST extends VertexType<ST, SG,RV,RE>,
SG extends TypedGraph<SG,RV,RE>,
ET extends EdgeType<ST,SG, ET,G, TT,TG, RV,RE>,
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
ST extends VertexType<ST, ?,RV,RE>,
ET extends EdgeType<ST,?, ET,G, TT,?, RV,RE>,
TT extends VertexType<TT, ?,RV,RE>
>
EdgeType<ST,SG, ET,G, TT,TG, RV,RE>.Edge addEdge(
VertexType<ST, SG,RV,RE>.Vertex source,
ET.Edge addEdge(
VertexType<ST, ?,RV,RE>.Vertex source,
ET edgeType,
VertexType<TT, TG,RV,RE>.Vertex target
VertexType<TT, ?,RV,RE>.Vertex target
) {

return edgeType.fromRaw(
return edgeType.new Edge(
raw().addEdge( source.raw, edgeType._label, target.raw )
);
}
Expand Down Expand Up @@ -100,29 +98,27 @@ G setProperty(EdgeType<?,?, ET,G, ?,?, RV,RE>.Edge edge, Property<ET,X> property
gets the source of an edge of G, which could be of a different graph.
*/
default <
ST extends VertexType<ST, SG,RV,RE>,
SG extends TypedGraph<SG,RV,RE>,
ET extends EdgeType<ST,SG, ET,G, ?,?, RV,RE>
ST extends VertexType<ST, ?,RV,RE>,
ET extends EdgeType<ST,?, ET,G, ?,?, RV,RE>
>
VertexType<ST, SG,RV,RE>.Vertex source(
EdgeType<ST,SG, ET,G, ?,?, RV,RE>.Edge edge
ST.Vertex source(
EdgeType<ST,?, ET,G, ?,?, RV,RE>.Edge edge
) {

return edge.type.sourceType.fromRaw(
return edge.type.sourceType.new Vertex(
raw().source(edge.raw)
);
}

default <
ET extends EdgeType<?,?, ET,G, TT,TG, RV,RE>,
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
ET extends EdgeType<?,?, ET,G, TT,?, RV,RE>,
TT extends VertexType<TT, ?,RV,RE>
>
VertexType<TT, TG,RV,RE>.Vertex target(
EdgeType<?,?, ET,G, TT,TG, RV,RE>.Edge edge
TT.Vertex target(
EdgeType<?,?, ET,G, TT,?, RV,RE>.Edge edge
) {

return edge.type.targetType.fromRaw(
return edge.type.targetType.new Vertex(
raw().target(edge.raw)
);
}
Expand All @@ -131,20 +127,15 @@ VertexType<TT, TG,RV,RE>.Vertex target(
/* #### Outgoing edges */
default <
ST extends VertexType<ST, G,RV,RE>,
ET extends EdgeType<ST,G, ET,EG, TT,TG, RV,RE>,
EG extends TypedGraph<EG,RV,RE>,
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
ET extends EdgeType<ST,G, ET,?, ?,?, RV,RE>
>
Stream<
EdgeType<ST,G, ET,EG, TT,TG, RV,RE>.Edge
> outE(VertexType<ST, G,RV,RE>.Vertex source, ET edgeType) {
Stream<ET.Edge> outE(VertexType<ST, G,RV,RE>.Vertex source, ET edgeType) {

return raw().outE(
source.raw,
edgeType._label
).map(
edgeType::fromRaw
).map( re ->
edgeType.new Edge(re)
);
}

Expand Down Expand Up @@ -232,20 +223,18 @@ > outE(VertexType<ST, G,RV,RE>.Vertex source, ET edgeType) {
/* #### Outgoing vertices */
default <
ST extends VertexType<ST, G,RV,RE>,
ET extends EdgeType<ST,G, ET,EG, TT,TG, RV,RE>,
EG extends TypedGraph<EG,RV,RE>,
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
ET extends EdgeType<ST,G, ET,?, TT,?, RV,RE>,
TT extends VertexType<TT, ?,RV,RE>
>
Stream<
VertexType<TT, TG,RV,RE>.Vertex
TT.Vertex
> outV(VertexType<ST, G,RV,RE>.Vertex source, ET edgeType) {

return raw().outV(
source.raw,
edgeType._label
).map( rawT ->
edgeType.targetType.fromRaw(rawT)
edgeType.targetType.new Vertex(rawT)
);
}

Expand Down
12 changes: 5 additions & 7 deletions src/main/java/com/bio4j/angulillos/TypedVertex.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ abstract class VertexType <
RV,RE
> extends ElementType<VT,G,RV> {

@Override public Vertex fromRaw(RV raw) { return this.new Vertex(raw); }
// @Override
// @SuppressWarnings("unchecked")
// public final VT.Vertex fromRaw(RV raw) { return self().new Vertex(raw); }

public final class Vertex extends Element {

Expand All @@ -40,9 +42,7 @@ <X> Vertex set(Property<VT,X> property, X value) {
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
>
Stream<
EdgeType<VT,G, ET,EG, TT,TG, RV,RE>.Edge
> outE(ET edgeType) { return graph().outE(this, edgeType); }
Stream<ET.Edge> outE(ET edgeType) { return graph().outE(this, edgeType); }


/* #### outV */
Expand All @@ -52,9 +52,7 @@ <X> Vertex set(Property<VT,X> property, X value) {
TT extends VertexType<TT, TG,RV,RE>,
TG extends TypedGraph<TG,RV,RE>
>
Stream<
VertexType<TT, TG,RV,RE>.Vertex
> outV(ET edgeType) { return graph().outV(this, edgeType); }
Stream<TT.Vertex> outV(ET edgeType) { return graph().outV(this, edgeType); }

}

Expand Down