You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by st...@apache.org on 2017/07/01 15:28:07 UTC
[16/46] incubator-s2graph git commit: [GraphTest]: passed.
[GraphTest]: passed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/1328546d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/1328546d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/1328546d
Branch: refs/heads/master
Commit: 1328546d7569b6162de8bacdb5cbf46517ecad81
Parents: 450171d
Author: DO YUNG YOON <st...@apache.org>
Authored: Sun Apr 16 09:35:52 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sun Apr 16 09:35:52 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 41 ++++++++++++++++----
.../scala/org/apache/s2graph/core/S2Graph.scala | 16 +++++---
.../core/tinkerpop/S2GraphProvider.scala | 26 ++++++++++---
3 files changed, 65 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1328546d/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
index 27d0b42..6b389f7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -20,17 +20,19 @@
package org.apache.s2graph.core
import java.util
-import java.util.function.{Consumer, BiConsumer}
+import java.util.function.{BiConsumer, Consumer}
-import org.apache.s2graph.core.S2Edge.{State, Props}
+import org.apache.s2graph.core.GraphExceptions.LabelNotExistException
+import org.apache.s2graph.core.S2Edge.{Props, State}
import org.apache.s2graph.core.JSONParser._
import org.apache.s2graph.core.mysqls.{Label, LabelIndex, LabelMeta, ServiceColumn}
import org.apache.s2graph.core.types._
import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.structure
import org.apache.tinkerpop.gremlin.structure.util.StringFactory
-import org.apache.tinkerpop.gremlin.structure.{Graph, Vertex, Edge, Property, Direction}
-import play.api.libs.json.{Json, JsNumber, JsObject}
+import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Graph, Property, Vertex}
+import play.api.libs.json.{JsNumber, JsObject, Json}
+
import scala.collection.JavaConverters._
import scala.collection.mutable.{Map => MutableMap}
import scala.concurrent.Await
@@ -682,16 +684,41 @@ case class S2Edge(innerGraph: S2Graph,
override def graph(): Graph = innerGraph
- override def id(): AnyRef = {
+ lazy val edgeId: AnyRef = {
// NOTE: xxxForVertex makes direction to be "out"
val timestamp = if (this.innerLabel.consistencyLevel == "strong") 0l else ts
- EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), direction, timestamp)
+// EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
+ if (direction == "out")
+ EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
+ else
+ EdgeId(tgtVertex.innerId, srcVertex.innerId, label(), "out", timestamp)
}
+ override def id(): AnyRef = edgeId
+
override def label(): String = innerLabel.label
}
+object EdgeId {
+ val EdgeIdDelimiter = ","
+ def fromString(s: String): EdgeId = {
+ val Array(src, tgt, labelName, dir, ts) = s.split(EdgeIdDelimiter)
+ val label = Label.findByName(labelName).getOrElse(throw LabelNotExistException(labelName))
+ val srcColumn = label.srcColumnWithDir(GraphUtil.toDirection(dir))
+ val tgtColumn = label.tgtColumnWithDir(GraphUtil.toDirection(dir))
+ EdgeId(
+ JSONParser.toInnerVal(src, srcColumn.columnType, label.schemaVersion),
+ JSONParser.toInnerVal(tgt, tgtColumn.columnType, label.schemaVersion),
+ labelName,
+ dir,
+ ts.toLong
+ )
+ }
+}
+case class EdgeId(srcVertexId: InnerValLike, tgtVertexId: InnerValLike, labelName: String, direction: String, ts: Long) {
+ override def toString: String =
+ Seq(srcVertexId.toIdString(), tgtVertexId.toIdString(), labelName, direction, ts.toString).mkString(EdgeId.EdgeIdDelimiter)
-case class EdgeId(srcVertexId: InnerValLike, tgtVertexId: InnerValLike, labelName: String, direction: String, ts: Long)
+}
object EdgeMutate {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1328546d/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
index 8856a8c..20e19e4 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -566,13 +566,13 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"),
// passed: all, failed: none
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="shouldRemoveVertices", reason="random label creation is not supported. all label need to be pre-configured."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnVertex", reason="Assigning the same ID to an Element update instead of throwing exception."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="shouldRemoveEdges", reason="random label creation is not supported. all label need to be pre-configured."),
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"),
// passed: , failed:
- // shouldIterateEdgesWithCustomIdSupportUsingStringRepresentations, shouldTraverseInOutFromVertexWithMultipleEdgeLabelFilter,
- // shouldRemoveVertices, shouldHaveExceptionConsistencyWhenAssigningSameIdOnVertex, shouldRemoveEdges, shouldEvaluateConnectivityPatterns,
- // shouldIterateEdgesWithCustomIdSupportUsingEdge, shouldTraverseInOutFromVertexWithSingleEdgeLabelFilter, shouldIterateEdgesWithCustomIdSupportUsingEdges,
- // shouldRemoveEdgesWithoutConcurrentModificationException, shouldIterateEdgesWithCustomIdSupportUsingStringRepresentation
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="shouldNotEvaluateToEqualDifferentId", reason="Assigning the same ID to an Element update instead of throwing exception."),
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="*", reason="no"),
// passed: , failed: shouldNotEvaluateToEqualDifferentId, shouldConstructReferenceEdge
@@ -1570,7 +1570,11 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
def edgesAsync(edgeIds: AnyRef*): Future[util.Iterator[structure.Edge]] = {
- val s2EdgeIds = edgeIds.filter(_.isInstanceOf[EdgeId]).map(_.asInstanceOf[EdgeId])
+ val s2EdgeIds = edgeIds.collect {
+ case s2Edge: S2Edge => s2Edge.id().asInstanceOf[EdgeId]
+ case id: EdgeId => id
+ case s: String => EdgeId.fromString(s)
+ }
val edgesToFetch = for {
id <- s2EdgeIds
} yield {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1328546d/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
index 0ab3dc7..e838447 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
@@ -71,7 +71,7 @@ class S2GraphProvider extends AbstractGraphProvider {
val defaultServiceColumn = s2Graph.DefaultColumn
val columnNames = Set(defaultServiceColumn.columnName, "person", "software", "product", "dog")
- val labelNames = Set("knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks")
+ val labelNames = Set("knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks", "hates", "link")
Management.deleteService(defaultService.serviceName)
columnNames.foreach { columnName =>
@@ -173,9 +173,15 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Seq(Prop("xxx", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
- val self = mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Nil, "weak", None, None,
- options = Option("""{"skipReverse": true}"""))
+ val self = if (testClass.getSimpleName.contains("GraphTest")) {
+ mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil, "strong", None, None,
+ options = Option("""{"skipReverse": true}"""))
+ } else {
+ mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": true}"""))
+ }
val friends = mnt.createLabel("friends", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil, Nil,
@@ -194,7 +200,7 @@ class S2GraphProvider extends AbstractGraphProvider {
)
val hate = mnt.createLabel("hate", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Nil, "weak", None, None,
+ true, defaultService.serviceName, Nil, Nil, "strong", None, None,
options = Option("""{"skipReverse": false}""")
)
@@ -235,6 +241,16 @@ class S2GraphProvider extends AbstractGraphProvider {
options = Option("""{"skipReverse": false}""")
)
+ val hates = mnt.createLabel("hates", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val link = mnt.createLabel("link", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil, "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
super.loadGraphData(graph, loadGraphWith, testClass, testName)
}