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:27:57 UTC
[06/46] incubator-s2graph git commit: [EdgeTest]: passed all.
[EdgeTest]: passed all.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/cac223dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/cac223dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/cac223dd
Branch: refs/heads/master
Commit: cac223ddc20c402bfb63c48418acc834294986de
Parents: 9ce2847
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu Apr 6 23:44:01 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu Apr 6 23:44:01 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 23 +++-
.../scala/org/apache/s2graph/core/S2Graph.scala | 108 ++++++++-----------
.../org/apache/s2graph/core/S2Property.scala | 2 +-
.../org/apache/s2graph/core/S2Vertex.scala | 22 ++--
.../core/tinkerpop/S2GraphProvider.scala | 30 +++---
.../core/tinkerpop/structure/S2GraphTest.scala | 79 +++++++++++---
6 files changed, 161 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/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 e953718..162ada5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -614,7 +614,16 @@ case class S2Edge(innerGraph: S2Graph,
override def properties[V](keys: String*): util.Iterator[Property[V]] = {
val ls = new util.ArrayList[Property[V]]()
- keys.foreach { key => ls.add(property(key)) }
+ if (keys.isEmpty) {
+ propsWithTs.forEach(new BiConsumer[String, S2Property[_]] {
+ override def accept(key: String, property: S2Property[_]): Unit = {
+ if (!LabelMeta.reservedMetaNamesSet(key) && property.isPresent)
+ ls.add(property.asInstanceOf[S2Property[V]])
+ }
+ })
+ } else {
+ keys.foreach { key => ls.add(property(key)) }
+ }
ls.iterator()
}
@@ -649,7 +658,13 @@ case class S2Edge(innerGraph: S2Graph,
override def remove(): Unit = {
if (graph.features().edge().supportsRemoveEdges()) {
- // remove edge
+ val requestTs = System.currentTimeMillis()
+ val edgeToDelete = this.copyEdge(op = GraphUtil.operations("delete"),
+ version = version + S2Edge.incrementVersion, propsWithTs = S2Edge.propsToState(updatePropsWithTs()), ts = requestTs)
+ // should we delete related edges also?
+ val future = innerGraph.mutateEdges(Seq(edgeToDelete), withWait = true)
+ val mutateSuccess = Await.result(future, innerGraph.WaitTimeout)
+ if (!mutateSuccess.forall(identity)) throw new RuntimeException("edge remove failed.")
} else {
throw Edge.Exceptions.edgeRemovalNotSupported()
}
@@ -660,9 +675,9 @@ case class S2Edge(innerGraph: S2Graph,
override def id(): AnyRef = {
// NOTE: xxxForVertex makes direction to be "out"
if (this.innerLabel.consistencyLevel == "strong") {
- EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), "out", 0)
+ EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), direction, 0)
} else {
- EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), "out", ts)
+ EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), direction, ts)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/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 1d1150e..df8fa8a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -535,8 +535,8 @@ object S2Graph {
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"), // pass
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest", method="*", reason="no"), // pss
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest", method="*", reason="no"), // pss
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"), // pass
@@ -597,7 +597,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
val MaxSize = config.getInt("future.cache.max.size")
val ExpireAfterWrite = config.getInt("future.cache.expire.after.write")
val ExpireAfterAccess = config.getInt("future.cache.expire.after.access")
- val WaitTimeout = Duration(300, TimeUnit.SECONDS)
+ val WaitTimeout = Duration(60, TimeUnit.SECONDS)
val scheduledEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())
val management = new Management(this)
@@ -914,20 +914,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
}
-// def deleteAllAdjacentEdges(vertex: S2Vertex,
-// labels: Seq[Label],
-// ts: Long = System.currentTimeMillis()): Future[Boolean] = {
-// val indexEdges = labels.flatMap { label =>
-// val propsPlusTs = Map(LabelMeta.timestamp.name -> ts)
-// val propsWithTs = label.propsToInnerValsWithTs(propsPlusTs, ts)
-// val edge = newEdge(vertex, vertex, label,
-// GraphUtil.directions("out"),
-// GraphUtil.operations("delete"), propsWithTs = propsWithTs)
-// edge.relatedEdges.flatMap(e => e.edgesWithIndexValid)
-// }
-// val kvs = indexEdges.flatMap(ie => defaultStorage.indexEdgeSerializer(ie).toKeyValues)
-// defaultStorage.writeToStorage(vertex.hbaseZkAddr, kvs, withWait = true)
-// }
/** mutate */
def deleteAllAdjacentEdges(srcVertices: Seq[S2Vertex],
labels: Seq[Label],
@@ -966,7 +952,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
stepInnerResultLs <- Future.sequence(queries.map(getEdgesStepInner(_, true)))
(allDeleted, ret) <- deleteAllFetchedEdgesLs(stepInnerResultLs, requestTs)
} yield {
- logger.debug(s"fetchAndDeleteAll: ${allDeleted}, ${ret}")
+ // logger.debug(s"fetchAndDeleteAll: ${allDeleted}, ${ret}")
(allDeleted, ret)
}
@@ -1012,7 +998,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
ret
}
- logger.error(s"[FutureSize]: ${futures.size}")
+
if (futures.isEmpty) {
// all deleted.
Future.successful(true -> true)
@@ -1027,8 +1013,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
if (filtered.isEmpty) StepResult.Empty
else {
- logger.error(s"[buildEdgesToDelete]: ${filtered.size}")
-
val head = filtered.head
val label = head.edge.innerLabel
val edgeWithScoreLs = filtered.map { edgeWithScore =>
@@ -1056,8 +1040,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
// edgeWithScore.edge.copy(op = newOp, version = newVersion, propsWithTs = newPropsWithTs)
val edgeToDelete = edgeWithScore.copy(edge = copiedEdge)
- logger.error(s"delete edge from deleteAll: ${edgeToDelete.edge.toLogString}")
- logger.error(s"delete edge from deleteAll edge: ${edge.toLogString}")
+ // logger.debug(s"delete edge from deleteAll: ${edgeToDelete.edge.toLogString}")
edgeToDelete
}
//Degree edge?
@@ -1404,41 +1387,41 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
* @param operation
* @return
*/
- private[core] def addEdgeInner(srcVertex: S2Vertex,
- tgtVertex: S2Vertex,
- labelName: String,
- direction: String = "out",
- props: Map[String, AnyRef] = Map.empty,
- ts: Long = System.currentTimeMillis(),
- operation: String = "insert"): S2Edge = {
- Await.result(addEdgeInnerAsync(srcVertex, tgtVertex, labelName, direction, props, ts, operation), WaitTimeout)
- }
-
- private[core] def addEdgeInnerAsync(srcVertex: S2Vertex,
- tgtVertex: S2Vertex,
- labelName: String,
- direction: String = "out",
- props: Map[String, AnyRef] = Map.empty,
- ts: Long = System.currentTimeMillis(),
- operation: String = "insert"): Future[S2Edge] = {
- // Validations on input parameter
- val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName))
- val dir = GraphUtil.toDir(direction).getOrElse(throw new RuntimeException(s"$direction is not supported."))
-// if (srcVertex.id.column != label.srcColumnWithDir(dir)) throw new RuntimeException(s"srcVertex's column[${srcVertex.id.column}] is not matched to label's srcColumn[${label.srcColumnWithDir(dir)}")
-// if (tgtVertex.id.column != label.tgtColumnWithDir(dir)) throw new RuntimeException(s"tgtVertex's column[${tgtVertex.id.column}] is not matched to label's tgtColumn[${label.tgtColumnWithDir(dir)}")
-
- // Convert given Map[String, AnyRef] property into internal class.
- val propsPlusTs = props ++ Map(LabelMeta.timestamp.name -> ts)
- val propsWithTs = label.propsToInnerValsWithTs(propsPlusTs, ts)
- val op = GraphUtil.toOp(operation).getOrElse(throw new RuntimeException(s"$operation is not supported."))
-
- val edge = newEdge(srcVertex, tgtVertex, label, dir, op = op, version = ts, propsWithTs = propsWithTs)
- // store edge into storage withWait option.
- mutateEdges(Seq(edge), withWait = true).map { rets =>
- if (!rets.headOption.getOrElse(false)) throw new RuntimeException("add edge failed.")
- else edge
- }
- }
+// private[core] def addEdgeInner(srcVertex: S2Vertex,
+// tgtVertex: S2Vertex,
+// labelName: String,
+// direction: String = "out",
+// props: Map[String, AnyRef] = Map.empty,
+// ts: Long = System.currentTimeMillis(),
+// operation: String = "insert"): S2Edge = {
+// Await.result(addEdgeInnerAsync(srcVertex, tgtVertex, labelName, direction, props, ts, operation), WaitTimeout)
+// }
+//
+// private[core] def addEdgeInnerAsync(srcVertex: S2Vertex,
+// tgtVertex: S2Vertex,
+// labelName: String,
+// direction: String = "out",
+// props: Map[String, AnyRef] = Map.empty,
+// ts: Long = System.currentTimeMillis(),
+// operation: String = "insert"): Future[S2Edge] = {
+// // Validations on input parameter
+// val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName))
+// val dir = GraphUtil.toDir(direction).getOrElse(throw new RuntimeException(s"$direction is not supported."))
+//// if (srcVertex.id.column != label.srcColumnWithDir(dir)) throw new RuntimeException(s"srcVertex's column[${srcVertex.id.column}] is not matched to label's srcColumn[${label.srcColumnWithDir(dir)}")
+//// if (tgtVertex.id.column != label.tgtColumnWithDir(dir)) throw new RuntimeException(s"tgtVertex's column[${tgtVertex.id.column}] is not matched to label's tgtColumn[${label.tgtColumnWithDir(dir)}")
+//
+// // Convert given Map[String, AnyRef] property into internal class.
+// val propsPlusTs = props ++ Map(LabelMeta.timestamp.name -> ts)
+// val propsWithTs = label.propsToInnerValsWithTs(propsPlusTs, ts)
+// val op = GraphUtil.toOp(operation).getOrElse(throw new RuntimeException(s"$operation is not supported."))
+//
+// val edge = newEdge(srcVertex, tgtVertex, label, dir, op = op, version = ts, propsWithTs = propsWithTs)
+// // store edge into storage withWait option.
+// mutateEdges(Seq(edge), withWait = true).map { rets =>
+// if (!rets.headOption.getOrElse(false)) throw new RuntimeException("add edge failed.")
+// else edge
+// }
+// }
def newVertexId(serviceName: String)(columnName: String)(id: Any): VertexId = {
@@ -1476,15 +1459,16 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
Await.result(getVertices(Seq(v)).map { vertices => vertices.headOption }, WaitTimeout)
}
- def fetchEdges(vertex: S2Vertex, labelNames: Seq[String], direction: String = "out"): util.Iterator[Edge] = {
- Await.result(fetchEdgesAsync(vertex, labelNames, direction), WaitTimeout)
+ def fetchEdges(vertex: S2Vertex, labelNameWithDirs: Seq[(String, String)]): util.Iterator[Edge] = {
+ Await.result(fetchEdgesAsync(vertex, labelNameWithDirs), WaitTimeout)
}
- def fetchEdgesAsync(vertex: S2Vertex, labelNames: Seq[String], direction: String = "out"): Future[util.Iterator[Edge]] = {
- val queryParams = labelNames.map { l =>
+ def fetchEdgesAsync(vertex: S2Vertex, labelNameWithDirs: Seq[(String, String)]): Future[util.Iterator[Edge]] = {
+ val queryParams = labelNameWithDirs.map { case (l, direction) =>
QueryParam(labelName = l, direction = direction)
}
val query = Query.toQuery(Seq(vertex), queryParams)
+
getEdges(query).map { stepResult =>
val ls = new util.ArrayList[Edge]()
stepResult.edgeWithScores.foreach(es => ls.add(es.edge))
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
index b5fc110..defa476 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
@@ -94,7 +94,7 @@ case class S2Property[V](element: S2Edge,
override def remove(): Unit = isRemoved = true
override def hashCode(): Int = {
- MurmurHash3.stringHash(labelMeta.labelId + "," + labelMeta.id.get + "," + key + "," + value + "," + ts)
+ MurmurHash3.stringHash(labelMeta.labelId + "," + labelMeta.id + "," + key + "," + value + "," + ts)
}
override def equals(other: Any): Boolean = other match {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
index 797ed98..e13f581 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -138,18 +138,22 @@ case class S2Vertex(graph: S2Graph,
}
override def edges(direction: Direction, labelNames: String*): util.Iterator[Edge] = {
- val labelNameList = {
+ val labelNameWithDirs =
if (labelNames.isEmpty) {
- val labelList =
- // TODO: Let's clarify direction
- if (direction == Direction.IN) Label.findBySrcColumnId(id.colId)
- else Label.findBySrcColumnId(id.colId)
- labelList.map(_.label)
+ // TODO: Let's clarify direction
+ if (direction == Direction.BOTH) {
+ Label.findBySrcColumnId(id.colId).map(l => l.label -> Direction.OUT.name) ++
+ Label.findByTgtColumnId(id.colId).map(l => l.label -> Direction.IN.name)
+ } else if (direction == Direction.IN) {
+ Label.findByTgtColumnId(id.colId).map(l => l.label -> direction.name)
+ } else {
+ Label.findBySrcColumnId(id.colId).map(l => l.label -> direction.name)
+ }
} else {
- labelNames
+ labelNames.map(_ -> direction.name())
}
- }
- graph.fetchEdges(this, labelNameList, direction.name())
+
+ graph.fetchEdges(this, labelNameWithDirs)
}
// do no save to storage
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/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 e0fc765..18bf998 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
@@ -64,6 +64,8 @@ class S2GraphProvider extends AbstractGraphProvider {
}
private def cleanupSchema(graph: Graph): Unit = {
+// new File("./var/metastore").delete()
+
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
val defaultService = s2Graph.DefaultService
@@ -141,13 +143,15 @@ class S2GraphProvider extends AbstractGraphProvider {
// mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
// true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- if (testClass.getSimpleName.contains("VertexTest") || (testClass.getSimpleName == "EdgeTest" && testName == "shouldAutotypeDoubleProperties")) {
- mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- } else {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- }
+ mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+// if (testClass.getSimpleName.contains("VertexTest") || (testClass.getSimpleName == "EdgeTest" && testName == "shouldAutotypeDoubleProperties")) {
+// mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
+// true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+// } else {
+// mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+// }
val personColumn = Management.createServiceColumn(defaultService.serviceName, "person", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
val softwareColumn = Management.createServiceColumn(defaultService.serviceName, "software", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("lang", "-", "string")))
@@ -172,8 +176,8 @@ class S2GraphProvider extends AbstractGraphProvider {
val friends = mnt.createLabel("friends", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil, Nil,
- "weak", None, None,
- options = Option("""{"skipReverse": true}"""))
+ "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
val friend = mnt.createLabel("friend", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil,
@@ -182,7 +186,7 @@ class S2GraphProvider extends AbstractGraphProvider {
Prop("location", "-", "string"),
Prop("status", "-", "string")
),
- "weak", None, None,
+ "strong", None, None,
options = Option("""{"skipReverse": false}""")
)
@@ -213,18 +217,18 @@ class S2GraphProvider extends AbstractGraphProvider {
options = Option("""{"skipReverse": false}""")
)
val pets = mnt.createLabel("pets", 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}""")
)
val walks = mnt.createLabel("walks", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil,
Seq(
Prop("location", "-", "string")
- ), "weak", None, None,
+ ), "strong", None, None,
options = Option("""{"skipReverse": false}""")
)
val livesWith = mnt.createLabel("livesWith", 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}""")
)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cac223dd/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala
index 28a16d3..46f58a8 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala
@@ -19,12 +19,15 @@
package org.apache.s2graph.core.tinkerpop.structure
+import java.io.File
+
import org.apache.s2graph.core.Management.JsonModel.Prop
import org.apache.s2graph.core.mysqls.Label
import org.apache.s2graph.core.utils.logger
import org.apache.s2graph.core.{Management, S2Graph, S2Vertex, TestCommonWithModels}
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, T, Vertex}
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils
import org.scalatest.{FunSuite, Matchers}
@@ -189,7 +192,7 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
val defaultService = graph.DefaultService
val defaultServiceColumn = graph.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", "knows")
+ val labelNames = Set("knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks")
Management.deleteService(defaultService.serviceName)
columnNames.foreach { columnName =>
@@ -202,38 +205,86 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
val knows = mnt.createLabel("knows",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer")), "strong", None, None,
+ true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer")), consistencyLevel = "strong", None, None,
options = Option("""{"skipReverse": false}"""))
val pets = mnt.createLabel("pets",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Nil, "strong", None, None,
+ true, defaultService.serviceName, Nil, Nil, consistencyLevel = "strong", None, None,
options = Option("""{"skipReverse": false}"""))
val walks = mnt.createLabel("walks",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("location", "-", "string")), "strong", None, None,
+ true, defaultService.serviceName, Nil, Seq(Prop("location", "-", "string")), consistencyLevel = "strong", None, None,
options = Option("""{"skipReverse": false}"""))
val livesWith = mnt.createLabel("livesWith",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Nil, "strong", None, None,
+ true, defaultService.serviceName, Nil, Nil, consistencyLevel = "strong", None, None,
options = Option("""{"skipReverse": false}"""))
- (0 until 2).foreach(i => graph.addVertex("myId", Int.box(i)))
-
- graph.vertices().foreach(v =>
- graph.vertices().foreach(u => v.addEdge("knows", u, "myEdgeId", Int.box(12)))
+ val friend = mnt.createLabel("friend", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("name", "-", "string"),
+ Prop("location", "-", "string"),
+ Prop("status", "-", "string")
+ ),
+ "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
)
+// (0 until 2).foreach(i => graph.addVertex("myId", Int.box(i)))
+//
+// graph.vertices().foreach(v =>
+// graph.vertices().foreach(u => v.addEdge("knows", u, "myEdgeId", Int.box(12)))
+// )
+//
+// val v = graph.vertices().toSeq.head
+// v.remove()
+//
+// graph.edges().foreach(e =>
+// logger.error(s"[Edge]: $e")
+// )
- val v = graph.vertices().toSeq.head
- v.remove()
- graph.edges().foreach(e =>
- logger.error(s"[Edge]: $e")
- )
+// val v1 = graph.addVertex(T.id, "v1", "name", "marko")
+// val v2 = graph.addVertex(T.id, "101", "name", "puppy")
+// v1.addEdge("knows", v2, "since", Int.box(2010))
+// v1.addEdge("pets", v2)
+// v1.addEdge("walks", v2, "location", "arroyo")
+// v2.addEdge("knows", v1, "since", Int.box(2010))
+//
+// v1.edges(Direction.BOTH).foreach(edge => {
+// v1.addEdge("livesWith", v2)
+// v1.addEdge("walks", v2, "location", "river")
+// edge.remove()
+// })
+//
+// val edges = v1.edges(Direction.BOTH)
+// edges.foreach { e =>
+// logger.error(s"[Before]: $e")
+// e.remove()
+// }
+//
+// v1.edges(Direction.OUT).foreach { e =>
+// logger.error(s"[V1.Edge]: $e")
+// }
+// v2.edges(Direction.BOTH).foreach { e =>
+// logger.error(s"[V2.Edge]: $e")
+// }
+ (0 until 25).foreach { i =>
+ val v = graph.addVertex()
+ v.addEdge("friend", v)
+ }
+ graph.vertices().foreach(v => logger.error(s"[Vertex]: $v"))
+ graph.edges().foreach(e => logger.error(s"[Edge]: $e"))
+
+ graph.edges().foreach(e => e.remove)
+
+ graph.edges().foreach(e => logger.error(s"[Edge]: $e"))
}
+
}
\ No newline at end of file