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:52 UTC
[01/46] incubator-s2graph git commit: - define initial version of
features. - setup gremlin-test environment.
Repository: incubator-s2graph
Updated Branches:
refs/heads/master b91b8399b -> 26e4d43cf
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
index 09d7f4c..6818c1d 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
@@ -65,8 +65,8 @@ class IndexEdgeDeserializable(graph: S2Graph,
val degreeVal = bytesToLongFunc(kv.value, 0)
val tgtVertexId = VertexId(ServiceColumn.Default, InnerVal.withStr("0", schemaVer))
- edge.property(LabelMeta.timestamp.name, version, version)
- edge.property(LabelMeta.degree.name, degreeVal, version)
+ edge.propertyInner(LabelMeta.timestamp.name, version, version)
+ edge.propertyInner(LabelMeta.degree.name, degreeVal, version)
edge.tgtVertex = graph.newVertex(tgtVertexId, version)
edge.op = GraphUtil.defaultOpByte
edge.tsInnerValOpt = Option(InnerVal.withLong(tsVal, schemaVer))
@@ -95,9 +95,9 @@ class IndexEdgeDeserializable(graph: S2Graph,
if (k == LabelMeta.timestamp) tsVal = v.value.asInstanceOf[BigDecimal].longValue()
if (k == LabelMeta.degree) {
- edge.property(LabelMeta.degree.name, v.value, version)
+ edge.propertyInner(LabelMeta.degree.name, v.value, version)
} else {
- edge.property(meta.name, v.value, version)
+ edge.propertyInner(meta.name, v.value, version)
}
}
@@ -105,13 +105,13 @@ class IndexEdgeDeserializable(graph: S2Graph,
if (op == GraphUtil.operations("incrementCount")) {
// val countVal = Bytes.toLong(kv.value)
val countVal = bytesToLongFunc(kv.value, 0)
- edge.property(LabelMeta.count.name, countVal, version)
+ edge.propertyInner(LabelMeta.count.name, countVal, version)
} else {
val (props, endAt) = bytesToKeyValues(kv.value, 0, kv.value.length, schemaVer, label)
props.foreach { case (k, v) =>
if (k == LabelMeta.timestamp) tsVal = v.value.asInstanceOf[BigDecimal].longValue()
- edge.property(k.name, v.value, version)
+ edge.propertyInner(k.name, v.value, version)
}
}
/** process tgtVertexId */
@@ -121,7 +121,7 @@ class IndexEdgeDeserializable(graph: S2Graph,
TargetVertexId(ServiceColumn.Default, vId.innerVal)
} else tgtVertexIdRaw
- edge.property(LabelMeta.timestamp.name, tsVal, version)
+ edge.propertyInner(LabelMeta.timestamp.name, tsVal, version)
edge.tgtVertex = graph.newVertex(tgtVertexId, version)
edge.op = op
edge.tsInnerValOpt = Option(InnerVal.withLong(tsVal, schemaVer))
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
index eb2d42a..9d3ea72 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
@@ -20,7 +20,7 @@
package org.apache.s2graph.core.types
import org.apache.hadoop.hbase.util.Bytes
-import org.apache.s2graph.core.GraphUtil
+import org.apache.s2graph.core.{GraphUtil, S2Vertex}
import org.apache.s2graph.core.mysqls.ServiceColumn
import org.apache.s2graph.core.types.HBaseType._
@@ -67,8 +67,9 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
def bytes: Array[Byte] = Bytes.add(hashBytes, innerId.bytes, colIdBytes)
override def toString(): String = {
- column.id.get.toString() + "," + innerId.toString()
-// s"VertexId($colId, $innerId)"
+ // column.id.get.toString() + "," + innerId.toString()
+ val del = S2Vertex.VertexLabelDelimiter
+ s"${column.service.serviceName}${del}${column.columnName}${del}${innerId}"
}
override def hashCode(): Int = {
@@ -96,6 +97,7 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
def <=(other: VertexId): Boolean = compareTo(other) <= 0
def >(other: VertexId): Boolean = compareTo(other) > 0
def >=(other: VertexId): Boolean = compareTo(other) >= 0
+
}
object SourceVertexId extends HBaseDeserializable {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala b/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
index 13eb1a3..c54dcde 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
@@ -77,6 +77,8 @@ class SafeUpdateCache[T](prefix: String, maxSize: Int, ttl: Int)(implicit execut
}
}
+ def invalidateAll() = cache.invalidateAll()
+
def getAllData() : List[(String, T)] = {
cache.asMap().map { case (key, value) =>
(key.key.substring(prefix.size + 1), value._1)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/test/scala/org/apache/s2graph/core/Integrate/tinkerpop/S2GraphTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/Integrate/tinkerpop/S2GraphTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/Integrate/tinkerpop/S2GraphTest.scala
deleted file mode 100644
index 3eb04ff..0000000
--- a/s2core/src/test/scala/org/apache/s2graph/core/Integrate/tinkerpop/S2GraphTest.scala
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.s2graph.core.Integrate.tinkerpop
-
-import org.apache.s2graph.core.mysqls.Label
-import org.apache.s2graph.core.utils.logger
-import org.apache.s2graph.core.{S2Graph, TestCommonWithModels, S2Vertex}
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
-import org.apache.tinkerpop.gremlin.structure.{Edge, Vertex, T}
-import org.scalatest.{FunSuite, Matchers}
-
-
-class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
-
- import scala.collection.JavaConversions._
- import scala.concurrent.ExecutionContext.Implicits.global
-
- initTests()
-
- val g = new S2Graph(config)
-
- def printEdges(edges: Seq[Edge]): Unit = {
- edges.foreach { edge =>
- logger.debug(s"[FetchedEdge]: $edge")
- }
- }
-
- import scala.language.implicitConversions
-
- def newVertexId(id: Any, label: Label = labelV2) = g.newVertexId(label.srcService, label.srcColumn, id)
-
- def addVertex(id: AnyRef, label: Label = labelV2) =
- g.addVertex(T.label, label.srcService.serviceName + S2Vertex.VertexLabelDelimiter + label.srcColumnName,
- T.id, id).asInstanceOf[S2Vertex]
-
- val srcId = Long.box(20)
- val range = (100 until 110)
- testData(srcId, range)
-
- // val testProps = Seq(
- // Prop("affinity_score", "0.0", DOUBLE),
- // Prop("is_blocked", "false", BOOLEAN),
- // Prop("time", "0", INT),
- // Prop("weight", "0", INT),
- // Prop("is_hidden", "true", BOOLEAN),
- // Prop("phone_number", "xxx-xxx-xxxx", STRING),
- // Prop("score", "0.1", FLOAT),
- // Prop("age", "10", INT)
- // )
- def testData(srcId: AnyRef, range: Range, label: Label = labelV2) = {
- val src = addVertex(srcId)
-
- for {
- i <- range
- } {
- val tgt = addVertex(Int.box(i))
-
- src.addEdge(labelV2.label, tgt,
- "age", Int.box(10),
- "affinity_score", Double.box(0.1),
- "is_blocked", Boolean.box(true),
- "ts", Long.box(i))
- }
- }
-
- test("test traversal.") {
- val vertices = g.traversal().V(newVertexId(srcId)).out(labelV2.label).toSeq
-
- vertices.size should be(range.size)
- range.reverse.zip(vertices).foreach { case (tgtId, vertex) =>
- val vertexId = g.newVertexId(labelV2.tgtService, labelV2.tgtColumn, tgtId)
- val expectedId = g.newVertex(vertexId)
- vertex.asInstanceOf[S2Vertex].innerId should be(expectedId.innerId)
- }
- }
-
- test("test traversal. limit 1") {
- val vertexIdParams = Seq(newVertexId(srcId))
- val t: GraphTraversal[Vertex, Double] = g.traversal().V(vertexIdParams: _*).outE(labelV2.label).limit(1).values("affinity_score")
- for {
- affinityScore <- t
- } {
- logger.debug(s"$affinityScore")
- affinityScore should be (0.1)
- }
- }
- test("test traversal. 3") {
-
- val l = label
-
- val srcA = addVertex(Long.box(1), l)
- val srcB = addVertex(Long.box(2), l)
- val srcC = addVertex(Long.box(3), l)
-
- val tgtA = addVertex(Long.box(101), l)
- val tgtC = addVertex(Long.box(103), l)
-
- srcA.addEdge(l.label, tgtA)
- srcA.addEdge(l.label, tgtC)
- tgtC.addEdge(l.label, srcB)
- tgtA.addEdge(l.label, srcC)
-
- val vertexIdParams = Seq(srcA.id)
- val vertices = g.traversal().V(vertexIdParams: _*).out(l.label).out(l.label).toSeq
- vertices.size should be(2)
- vertices.foreach { v =>
- val vertex = v.asInstanceOf[S2Vertex]
- // TODO: we have too many id. this is ugly and confusing so fix me.
- vertex.id.innerId == srcB.id.innerId || vertex.id.innerId == srcC.id.innerId should be(true)
- logger.debug(s"[Vertex]: $v")
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
new file mode 100644
index 0000000..b9af825
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
@@ -0,0 +1,12 @@
+package org.apache.s2graph.core.tinkerpop
+
+import java.lang.annotation.Annotation
+
+import org.apache.tinkerpop.gremlin.LoadGraphWith
+import org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData
+
+class S2GraphData extends LoadGraphWith {
+ override def value(): GraphData = ???
+
+ override def annotationType(): Class[_ <: Annotation] = classOf[LoadGraphWith]
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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
new file mode 100644
index 0000000..5a997e8
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
@@ -0,0 +1,220 @@
+package org.apache.s2graph.core.tinkerpop
+
+import java.io.File
+import java.util
+import java.util.concurrent.atomic.AtomicLong
+
+import org.apache.commons.configuration.Configuration
+import org.apache.s2graph.core.Management.JsonModel.Prop
+import org.apache.s2graph.core._
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Label, ServiceColumn}
+import org.apache.s2graph.core.types.{HBaseType, InnerVal, VertexId}
+import org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData
+import org.apache.tinkerpop.gremlin.structure.{Element, Graph, T}
+import org.apache.tinkerpop.gremlin.{AbstractGraphProvider, LoadGraphWith}
+
+import scala.collection.JavaConverters._
+import scala.util.{Failure, Success, Try}
+import com.typesafe.config.ConfigFactory
+import org.apache.commons.io.FileUtils
+import org.apache.s2graph.core.utils.logger
+
+object S2GraphProvider {
+ val Implementation: Set[Class[_]] = Set(
+ classOf[S2Edge],
+ classOf[S2Vertex],
+ classOf[S2Property[_]],
+ classOf[S2VertexProperty[_]],
+ classOf[S2Graph]
+ )
+}
+class S2GraphProvider extends AbstractGraphProvider {
+
+ override def getBaseConfiguration(s: String, aClass: Class[_], s1: String, graphData: GraphData): util.Map[String, AnyRef] = {
+ val config = ConfigFactory.load()
+// val dbUrl =
+// if (config.hasPath("db.default.url")) config.getString("db.default.url")
+// else "jdbc:mysql://localhost:3306/graph_dev"
+
+ val dbUrl = "jdbc:mysql://localhost:3306/graph_dev"
+ val m = new java.util.HashMap[String, AnyRef]()
+ m.put(Graph.GRAPH, classOf[S2Graph].getName)
+ m.put("db.default.url", dbUrl)
+ m.put("db.default.driver", "com.mysql.jdbc.Driver")
+ m
+ }
+
+ private val H2Prefix = "jdbc:h2:file:"
+
+ override def clear(graph: Graph, configuration: Configuration): Unit =
+ if (graph != null) {
+ val s2Graph = graph.asInstanceOf[S2Graph]
+ if (s2Graph.isRunning) {
+ val labels = Label.findAll()
+ labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
+ labelsWithSameTable.headOption.foreach { label =>
+ s2Graph.management.truncateStorage(label.label)
+ }
+ }
+ s2Graph.shutdown(modelDataDelete = true)
+ logger.info("S2Graph Shutdown")
+ }
+ }
+
+ override def getImplementations: util.Set[Class[_]] = S2GraphProvider.Implementation.asJava
+
+ def initTestSchema(testClass: Class[_], testName: String) = {
+ val testClassName = testClass.getSimpleName
+ testClass.getSimpleName match {
+ case _ =>
+ }
+ }
+
+ override def loadGraphData(graph: Graph, loadGraphWith: LoadGraphWith, testClass: Class[_], testName: String): Unit = {
+ val s2Graph = graph.asInstanceOf[S2Graph]
+ val mnt = s2Graph.getManagement()
+ val defaultService = s2Graph.DefaultService
+ val defaultServiceColumn = s2Graph.DefaultColumn
+
+ initTestSchema(testClass, testName)
+
+ Management.deleteLabel("knows")
+
+ var knowsProp = Vector(
+ Prop("weight", "0.0", "double"),
+ Prop("data", "-", "string"),
+ Prop("year", "-1", "integer"),
+ Prop("boolean", "false", "boolean"),
+ Prop("float", "0.0", "float"),
+ Prop("double", "0.0", "double"),
+ Prop("long", "0.0", "long"),
+ Prop("string", "-", "string"),
+ Prop("integer", "-", "integer"),
+ Prop("aKey", "-", "string")
+ )
+
+ // Change dataType for ColumnMeta('aKey') for PropertyFeatureSupportTest
+ if (testClass.getSimpleName == "PropertyFeatureSupportTest") {
+ knowsProp = knowsProp.filterNot(_.name == "aKey")
+
+ val dataType = if (testName.toLowerCase.contains("boolean")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "false", "boolean")
+ "boolean"
+ } else if (testName.toLowerCase.contains("integer")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "0", "integer")
+ "integer"
+ } else if (testName.toLowerCase.contains("long")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "0", "long")
+ "long"
+ } else if (testName.toLowerCase.contains("double")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "0.0", "double")
+ "double"
+ } else if (testName.toLowerCase.contains("float")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "0.0", "float")
+ "float"
+ } else if (testName.toLowerCase.contains("string")) {
+ knowsProp = knowsProp.filterNot(_.name == "aKey") :+ Prop("aKey", "-", "string")
+ "string"
+ } else {
+ "string"
+ }
+
+ ColumnMeta.findByName(defaultServiceColumn.id.get, "aKey", useCache = false).foreach(cm => ColumnMeta.delete(cm.id.get))
+ ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
+ }
+
+ // knows props
+ if (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": true}"""))
+ } else {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": true}"""))
+ }
+
+ 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")))
+ val productColumn = Management.createServiceColumn(defaultService.serviceName, "product", "integer", Nil)
+ val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
+// val vertexColumn = Management.createServiceColumn(service.serviceName, "vertex", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "-1", "integer"), Prop("lang", "scala", "string")))
+
+ val created = mnt.createLabel("created", defaultService.serviceName, "person", "integer", defaultService.serviceName, "software", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+
+ val bought = mnt.createLabel("bought", defaultService.serviceName, "person", "integer", defaultService.serviceName, "product", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("x", "-", "string"), Prop("y", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": true}"""))
+
+ val test = mnt.createLabel("test", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ 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 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}"""))
+
+ 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")
+ ),
+ "weak", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ 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,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val collaborator = mnt.createLabel("collaborator", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("location", "-", "string")
+ ),
+ "strong", None, None,
+ options = Option("""{"skipReverse": true}""")
+ )
+
+ val test1 = mnt.createLabel("test1", 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 test2 = mnt.createLabel("test2", 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 test3 = mnt.createLabel("test3", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ super.loadGraphData(graph, loadGraphWith, testClass, testName)
+ }
+
+ override def convertId(id: scala.Any, c: Class[_ <: Element]): AnyRef = {
+ val isVertex = c.toString.contains("Vertex")
+ if (isVertex) {
+ VertexId(ServiceColumn.findAll().head, InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION))
+ } else {
+ EdgeId(
+ InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION),
+ InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION),
+ "_s2graph",
+ "out",
+ System.currentTimeMillis()
+ )
+ }
+ }
+
+ override def convertLabel(label: String): String = {
+ label
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
new file mode 100644
index 0000000..a909878
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
@@ -0,0 +1,13 @@
+package org.apache.s2graph.core.tinkerpop.structure
+
+import org.apache.s2graph.core.S2Graph
+import org.apache.s2graph.core.tinkerpop.S2GraphProvider
+import org.apache.tinkerpop.gremlin.GraphProviderClass
+import org.apache.tinkerpop.gremlin.structure.{StructureIntegrateSuite, StructureStandardSuite}
+import org.junit.runner.RunWith
+
+@RunWith(classOf[StructureIntegrateSuite])
+@GraphProviderClass(provider = classOf[S2GraphProvider], graph = classOf[S2Graph])
+class S2GraphStructureIntegrateTest {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
new file mode 100644
index 0000000..ed5a532
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
@@ -0,0 +1,16 @@
+package org.apache.s2graph.core.tinkerpop.structure
+
+import org.apache.s2graph.core.S2Graph
+import org.apache.s2graph.core.tinkerpop.S2GraphProvider
+import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite
+import org.apache.tinkerpop.gremlin.{GraphProviderClass, LoadGraphWith}
+import org.junit.FixMethodOrder
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(classOf[StructureStandardSuite])
+@GraphProviderClass(provider = classOf[S2GraphProvider], graph = classOf[S2Graph])
+class S2GraphStructureStandardTest {
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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
new file mode 100644
index 0000000..e69004c
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphTest.scala
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.s2graph.core.tinkerpop.structure
+
+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.{Edge, T, Vertex}
+import org.scalatest.{FunSuite, Matchers}
+
+
+class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
+
+ import scala.collection.JavaConversions._
+ import scala.concurrent.ExecutionContext.Implicits.global
+
+ initTests()
+
+ val g = new S2Graph(config)
+
+ def printEdges(edges: Seq[Edge]): Unit = {
+ edges.foreach { edge =>
+ logger.debug(s"[FetchedEdge]: $edge")
+ }
+ }
+
+ import scala.language.implicitConversions
+
+// def newVertexId(id: Any, label: Label = labelV2) = g.newVertexId(label.srcService, label.srcColumn, id)
+//
+// def addVertex(id: AnyRef, label: Label = labelV2) =
+// g.addVertex(T.label, label.srcService.serviceName + S2Vertex.VertexLabelDelimiter + label.srcColumnName,
+// T.id, id).asInstanceOf[S2Vertex]
+//
+// val srcId = Long.box(20)
+// val range = (100 until 110)
+// testData(srcId, range)
+
+ // val testProps = Seq(
+ // Prop("affinity_score", "0.0", DOUBLE),
+ // Prop("is_blocked", "false", BOOLEAN),
+ // Prop("time", "0", INT),
+ // Prop("weight", "0", INT),
+ // Prop("is_hidden", "true", BOOLEAN),
+ // Prop("phone_number", "xxx-xxx-xxxx", STRING),
+ // Prop("score", "0.1", FLOAT),
+ // Prop("age", "10", INT)
+ // )
+// def testData(srcId: AnyRef, range: Range, label: Label = labelV2) = {
+// val src = addVertex(srcId)
+//
+// for {
+// i <- range
+// } {
+// val tgt = addVertex(Int.box(i))
+//
+// src.addEdge(labelV2.label, tgt,
+// "age", Int.box(10),
+// "affinity_score", Double.box(0.1),
+// "is_blocked", Boolean.box(true),
+// "ts", Long.box(i))
+// }
+// }
+
+// test("test traversal.") {
+// val vertices = g.traversal().V(newVertexId(srcId)).out(labelV2.label).toSeq
+//
+// vertices.size should be(range.size)
+// range.reverse.zip(vertices).foreach { case (tgtId, vertex) =>
+// val vertexId = g.newVertexId(labelV2.tgtService, labelV2.tgtColumn, tgtId)
+// val expectedId = g.newVertex(vertexId)
+// vertex.asInstanceOf[S2Vertex].innerId should be(expectedId.innerId)
+// }
+// }
+//
+// test("test traversal. limit 1") {
+// val vertexIdParams = Seq(newVertexId(srcId))
+// val t: GraphTraversal[Vertex, Double] = g.traversal().V(vertexIdParams: _*).outE(labelV2.label).limit(1).values("affinity_score")
+// for {
+// affinityScore <- t
+// } {
+// logger.debug(s"$affinityScore")
+// affinityScore should be (0.1)
+// }
+// }
+// test("test traversal. 3") {
+//
+// val l = label
+//
+// val srcA = addVertex(Long.box(1), l)
+// val srcB = addVertex(Long.box(2), l)
+// val srcC = addVertex(Long.box(3), l)
+//
+// val tgtA = addVertex(Long.box(101), l)
+// val tgtC = addVertex(Long.box(103), l)
+//
+// srcA.addEdge(l.label, tgtA)
+// srcA.addEdge(l.label, tgtC)
+// tgtC.addEdge(l.label, srcB)
+// tgtA.addEdge(l.label, srcC)
+//
+// val vertexIdParams = Seq(srcA.id)
+// val vertices = g.traversal().V(vertexIdParams: _*).out(l.label).out(l.label).toSeq
+// vertices.size should be(2)
+// vertices.foreach { v =>
+// val vertex = v.asInstanceOf[S2Vertex]
+// // TODO: we have too many id. this is ugly and confusing so fix me.
+// vertex.id.innerId == srcB.id.innerId || vertex.id.innerId == srcC.id.innerId should be(true)
+// logger.debug(s"[Vertex]: $v")
+// }
+// }
+// test("add vertex without params.") {
+// val vertex = g.addVertex().asInstanceOf[S2Vertex]
+// vertex.id.column.service.serviceName should be(g.DefaultService.serviceName)
+// vertex.id.column.columnName should be(g.DefaultColumn.columnName)
+// }
+// val s2Graph = graph.asInstanceOf[S2Graph]
+// val mnt = s2Graph.getManagement()
+// override val service = s2Graph.DefaultService
+//
+// val personColumn = Management.createServiceColumn(service.serviceName, "person", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "0", "integer")))
+// val softwareColumn = Management.createServiceColumn(service.serviceName, "software", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("lang", "-", "string")))
+// // val vertexColumn = Management.createServiceColumn(service.serviceName, "vertex", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "-1", "integer"), Prop("lang", "scala", "string")))
+//
+// val created = mnt.createLabel("created", service.serviceName, "person", "integer", service.serviceName, "software", "integer",
+// true, service.serviceName, Nil, Seq(Prop("weight", "0.0", "float")), "strong", None, None)
+//
+// val knows = mnt.createLabel("knows", service.serviceName, "person", "integer", service.serviceName, "person", "integer",
+// true, service.serviceName, Nil, Seq(Prop("weight", "0.0", "float")), "strong", None, None)
+//
+
+ test("tinkerpop class graph test.") {
+// val marko = graph.addVertex(T.label, "person", T.id, Int.box(1))
+// marko.property("name", "marko")
+// marko.property("age", Int.box(29))
+// val vadas = graph.addVertex(T.label, "person", T.id, Int.box(2))
+// vadas.property("name", "vadas", "age", Int.box(27))
+// val lop = graph.addVertex(T.label, "software", T.id, Int.box(3), "name", "lop", "lang", "java")
+// val josh = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "josh", "age", Int.box(32))
+// val ripple = graph.addVertex(T.label, "software", T.id, Int.box(5), "name", "ripple", "lang", "java")
+// val peter = graph.addVertex(T.label, "person", T.id, Int.box(6), "name", "peter", "age", Int.box(35))
+//
+// marko.addEdge("knows", vadas, T.id, Int.box(7), "weight", Float.box(0.5f))
+// marko.addEdge("knows", josh, T.id, Int.box(8), "weight", Float.box(1.0f))
+// marko.addEdge("created", lop, T.id, Int.box(9), "weight", Float.box(0.4f))
+// josh.addEdge("created", ripple, T.id, Int.box(10), "weight", Float.box(1.0f))
+// josh.addEdge("created", lop, T.id, Int.box(11), "weight", Float.box(0.4f))
+// peter.addEdge("created", lop, T.id, Int.box(12), "weight", Float.box(0.2f))
+// graph.tx().commit()
+//
+// graph.traversal().V().inV()
+// val verticees = s2Graph.traversal().V().asAdmin().toSeq
+//
+//
+// val vs = verticees.toList
+// val edgeId = graph.traversal().V().has("name", "marko").outE("knows").as("e").inV().has("name", "vadas").select[Edge]("e").toList.head.id()
+// val edges = graph.traversal().E(edgeId).toList()
+//// .as("e").inV().has("name", "vadas").select[Edge]("e").asAdmin().toSeq
+//// graph.traversal.V.has("name", outVertexName).outE(edgeLabel).as("e").inV.has("name", inVertexName).select[Edge]("e").next.id
+// logger.error(edgeId.toString)
+// val x = edges.mkString("\n")
+// logger.error(x)
+ }
+
+ test("addVertex with empty parameter") {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2counter_core/src/test/scala/org/apache/s2graph/counter/core/RankingCounterSpec.scala
----------------------------------------------------------------------
diff --git a/s2counter_core/src/test/scala/org/apache/s2graph/counter/core/RankingCounterSpec.scala b/s2counter_core/src/test/scala/org/apache/s2graph/counter/core/RankingCounterSpec.scala
index 62174ad..2ab4823 100644
--- a/s2counter_core/src/test/scala/org/apache/s2graph/counter/core/RankingCounterSpec.scala
+++ b/s2counter_core/src/test/scala/org/apache/s2graph/counter/core/RankingCounterSpec.scala
@@ -21,7 +21,7 @@ package org.apache.s2graph.counter.core
import com.typesafe.config.ConfigFactory
import org.apache.s2graph.core.mysqls.Label
-import org.apache.s2graph.core.{S2Graph$, Management}
+import org.apache.s2graph.core.{Management, S2Graph, S2Graph$}
import org.apache.s2graph.counter.config.S2CounterConfig
import org.apache.s2graph.counter.core.TimedQualifier.IntervalUnit
import org.apache.s2graph.counter.core.v2.{GraphOperation, RankingStorageGraph}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/scalastyle-config.xml
----------------------------------------------------------------------
diff --git a/scalastyle-config.xml b/scalastyle-config.xml
deleted file mode 100644
index 7e3596f..0000000
--- a/scalastyle-config.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<scalastyle>
- <name>Scalastyle standard configuration</name>
- <check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
- <parameters>
- <parameter name="maxFileLength"><![CDATA[800]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
- <parameters>
- <parameter name="header"><![CDATA[// Copyright (C) 2011-2012 the original author or authors.
-// See the LICENCE.txt file distributed with this work for additional
-// information regarding copyright ownership.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
- <parameters>
- <parameter name="maxLineLength"><![CDATA[160]]></parameter>
- <parameter name="tabSize"><![CDATA[4]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
- <parameters>
- <parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
- <parameters>
- <parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
- <parameters>
- <parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
- <parameters>
- <parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
- <parameters>
- <parameter name="maxParameters"><![CDATA[8]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="true">
- <parameters>
- <parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
- <parameters>
- <parameter name="regex"><![CDATA[println]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
- <parameters>
- <parameter name="maxTypes"><![CDATA[30]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
- <parameters>
- <parameter name="maximum"><![CDATA[10]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
- <parameters>
- <parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
- <parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
- <parameters>
- <parameter name="maxLength"><![CDATA[50]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
- <parameters>
- <parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
- <parameters>
- <parameter name="maxMethods"><![CDATA[30]]></parameter>
- </parameters>
- </check>
- <check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
-</scalastyle>
\ No newline at end of file
[42/46] incubator-s2graph git commit:
[SUITE_PROCESS_STANDARD.compliance] passed all except fews. list up failed
cases as Graph.Output.
Posted by st...@apache.org.
[SUITE_PROCESS_STANDARD.compliance] passed all except fews. list up failed cases as Graph.Output.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/e77862bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/e77862bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/e77862bf
Branch: refs/heads/master
Commit: e77862bf665fffb7ff0b9a56815c84dfba88608d
Parents: f4554e1
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 17:28:22 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 21:31:29 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 43 ++++++++++++--------
1 file changed, 25 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e77862bf/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 42bf2a8..95186e8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -534,8 +534,6 @@ object S2Graph {
}
-//@Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD)
-//@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptIns(value = Array(
new Graph.OptIn(value = Graph.OptIn.SUITE_PROCESS_STANDARD),
new Graph.OptIn(value = Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@@ -670,9 +668,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_out_out_profile_grateful", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_repeat_both_modern_profile", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_out_out_profile_grateful", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profileXmetricsX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_repeat_both_profileXmetricsX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profile", reason = "fix this."),
new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_repeat_both_profile", reason = "fix this."),
// failed: grateful_V_out_out_profileXmetricsX, g_V_repeat_both_profileXmetricsX, grateful_V_out_out_profile, g_V_repeat_both_profile
@@ -700,13 +698,16 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", reason = "fix this."),
// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "*", reason = "no"),
-// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX,
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", reason = "fix this."),
+// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX", reason = "double count. fix this. "),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name", reason = "double count. fix this. "),
// failed: g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX, g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest$Traversals", method = "*", reason = "no"),
@@ -724,7 +725,8 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX", reason = "double count. fix this."),
// failed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeTest$Traversals", method = "*", reason = "no"),
@@ -735,27 +737,32 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest", method = "*", reason = "not supported yet."),
// failed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategyProcessTest", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnAddVWithSpecifiedId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnAddVWithGeneratedCustomId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnGraphAddVWithGeneratedDefaultId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnAddVWithGeneratedDefaultId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnGraphAddVWithGeneratedCustomId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "shouldGenerateDefaultIdOnGraphAddVWithSpecifiedId", reason = "GraphStep.processNextStart throw FastNoSuchElementException when GraphStep.start = true and GraphStep.end = true."),
// failed: shouldGenerateDefaultIdOnAddVWithSpecifiedId, shouldGenerateDefaultIdOnAddVWithGeneratedCustomId, shouldGenerateDefaultIdOnGraphAddVWithGeneratedDefaultId,
// shouldGenerateDefaultIdOnAddVWithGeneratedDefaultId, shouldGenerateDefaultIdOnGraphAddVWithGeneratedCustomId, shouldGenerateDefaultIdOnGraphAddVWithSpecifiedId
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest", method = "*", reason = "not supported yet."),
// failed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ReadOnlyStrategyProcessTest", method = "*", reason = "no"),
-// failed: all
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategyProcessTest", method = "*", reason = "no"),
+// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest", method = "*", reason = "not supported yet."),
// failed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategyProcessTest", method = "*", reason = "no"),
-// failed: all
+// passed: all
/** Structure */
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
@@ -879,7 +886,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(60, TimeUnit.SECONDS)
+ val WaitTimeout = Duration(600, TimeUnit.SECONDS)
val scheduledEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())
val management = new Management(this)
[45/46] incubator-s2graph git commit: remove dataType,
schemaVersion in InnerValLike.
Posted by st...@apache.org.
remove dataType, schemaVersion in InnerValLike.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/e9186211
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/e9186211
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/e9186211
Branch: refs/heads/master
Commit: e918621175f59b2187f3318be2fc1d6baee6be28
Parents: 94c9142
Author: DO YUNG YOON <st...@apache.org>
Authored: Sat May 6 22:36:21 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sat May 6 22:36:21 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/JSONParser.scala | 15 +--
.../scala/org/apache/s2graph/core/S2Graph.scala | 1 +
.../org/apache/s2graph/core/S2Vertex.scala | 2 +-
.../apache/s2graph/core/io/Conversions.scala | 107 ++++++++++------
.../s2graph/core/types/InnerValLike.scala | 26 ++--
.../apache/s2graph/core/types/v1/InnerVal.scala | 3 -
.../apache/s2graph/core/types/v2/InnerVal.scala | 25 ++--
.../core/tinkerpop/S2GraphProvider.scala | 4 +-
.../core/tinkerpop/structure/S2GraphTest.scala | 124 +++++++++----------
9 files changed, 162 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
index a0767ae..ea50b17 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
@@ -115,7 +115,7 @@ object JSONParser {
// }
// }
def isNumericType(dType: String): Boolean = {
- dType == InnerVal.BIGDECIMAL || dType == InnerVal.LONG || dType == InnerVal.INT ||
+ dType == InnerVal.LONG || dType == InnerVal.INT ||
dType == InnerVal.SHORT || dType == InnerVal.BYTE ||
dType == InnerVal.FLOAT || dType == InnerVal.DOUBLE
}
@@ -124,15 +124,6 @@ object JSONParser {
def innerValToAny(innerValLike: InnerValLike, dataType: String): Any = {
val dType = InnerVal.toInnerDataType(dataType)
dType match {
- case InnerVal.BIGDECIMAL =>
- innerValLike.value match {
- case b: BigDecimal => b
- case l: Long => BigDecimal(l)
- case i: Int => BigDecimal(i)
- case f: Float => BigDecimal(f)
- case d: Double => BigDecimal(d)
- case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
- }
case InnerVal.LONG =>
innerValLike.value match {
case b: BigDecimal => b.toLong
@@ -254,7 +245,7 @@ object JSONParser {
dType match {
case InnerVal.STRING => Some(InnerVal.withStr(jsValue.toString, version))
// case t if InnerVal.NUMERICS.contains(t) =>
- case InnerVal.BIGDECIMAL | InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
+ case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
Some(InnerVal.withNumber(n.value, version))
case _ => None
}
@@ -264,7 +255,7 @@ object JSONParser {
case InnerVal.STRING => Some(InnerVal.withStr(s, version))
case InnerVal.BOOLEAN => Some(InnerVal.withBoolean(s.toBoolean, version))
// case t if InnerVal.NUMERICS.contains(t) =>
- case InnerVal.BIGDECIMAL | InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
+ case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
Some(InnerVal.withNumber(BigDecimal(s), version))
case _ => None
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/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 176aa47..342b841 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -828,6 +828,7 @@ object S2Graph {
// all failed.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest$GryoTest", method="shouldSerializeTree", reason="order of children is reversed. not sure why."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest$GraphSONTest", method="shouldSerializeTraversalMetrics", reason="expected 2, actual 3."),
// passed: all, failed: $GryoTest.shouldSerializeTree
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/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 269cf84..d1e2eda 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -237,7 +237,7 @@ case class S2Vertex(graph: S2Graph,
Await.ready(future, graph.WaitTimeout)
edge
} catch {
- case e: LabelNotExistException => throw new java.lang.IllegalArgumentException
+ case e: LabelNotExistException => throw new java.lang.IllegalArgumentException(e)
}
case null => throw new java.lang.IllegalArgumentException
case _ => throw new RuntimeException("only S2Graph vertex can be used.")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
index 077bb84..2033e49 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
@@ -2,7 +2,7 @@ package org.apache.s2graph.core.io
import org.apache.s2graph.core.{EdgeId, JSONParser, S2VertexPropertyId}
import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
-import org.apache.s2graph.core.types.{InnerValLike, VertexId}
+import org.apache.s2graph.core.types.{HBaseType, InnerValLike, VertexId}
import play.api.libs.json._
import play.api.libs.json.Reads._
import play.api.libs.json.Writes._
@@ -10,22 +10,22 @@ import play.api.libs.functional.syntax._
object Conversions {
/* Serializer for inner value class */
- implicit object InnerValLikeReads extends Reads[InnerValLike] {
- def reads(json: JsValue) = {
- val value = (json \ "value").as[JsValue]
- val dataType = (json \ "dataType").as[String]
- val schemaVersion = (json \ "schemaVersion").as[String]
- val innerVal = JSONParser.jsValueToInnerVal(value, dataType, schemaVersion).get
- JsSuccess(innerVal)
- }
- }
- implicit object InnerValLikeWrites extends Writes[InnerValLike] {
- override def writes(o: InnerValLike): JsValue = {
- Json.obj("value" -> JSONParser.anyValToJsValue(o.value),
- "dataType" -> o.dataType,
- "schemaVersion" -> o.schemaVersion)
- }
- }
+// implicit object InnerValLikeReads extends Reads[InnerValLike] {
+// def reads(json: JsValue) = {
+// val value = (json \ "value").as[JsValue]
+// val dataType = (json \ "dataType").as[String]
+// val schemaVersion = (json \ "schemaVersion").as[String]
+// val innerVal = JSONParser.jsValueToInnerVal(value, dataType, schemaVersion).get
+// JsSuccess(innerVal)
+// }
+// }
+// implicit object InnerValLikeWrites extends Writes[InnerValLike] {
+// override def writes(o: InnerValLike): JsValue = {
+// Json.obj("value" -> JSONParser.anyValToJsValue(o.value),
+// "dataType" -> o.dataType,
+// "schemaVersion" -> o.schemaVersion)
+// }
+// }
/* Serializer for Models */
@@ -84,25 +84,60 @@ object Conversions {
)(unlift(ColumnMeta.unapply))
/* Graph Class */
- implicit val s2VertexPropertyIdReads: Reads[S2VertexPropertyId] = (
- (JsPath \ "column").read[ColumnMeta] and
- (JsPath \ "value").read[InnerValLike]
- )(S2VertexPropertyId.apply _)
-
- implicit val s2VertexPropertyIdWrites: Writes[S2VertexPropertyId] = (
- (JsPath \ "column").write[ColumnMeta] and
- (JsPath \ "value").write[InnerValLike]
- )(unlift(S2VertexPropertyId.unapply))
-
- implicit val s2VertexIdReads: Reads[VertexId] = (
- (JsPath \ "column").read[ServiceColumn] and
- (JsPath \ "value").read[InnerValLike]
- )(VertexId.apply _)
-
- implicit val s2VertexIdWrites: Writes[VertexId] = (
- (JsPath \ "column").write[ServiceColumn] and
- (JsPath \ "value").write[InnerValLike]
- )(unlift(VertexId.unapply))
+ implicit object S2VertexPropertyIdReads extends Reads[S2VertexPropertyId] {
+ override def reads(json: JsValue): JsResult[S2VertexPropertyId] = {
+ val columnMeta = columnMetaReads.reads((json \ "columnMeta").get).get
+ val innerVal = JSONParser.jsValueToInnerVal((json \ "value").get,
+ columnMeta.dataType, HBaseType.DEFAULT_VERSION).get
+ JsSuccess(S2VertexPropertyId(columnMeta, innerVal))
+ }
+ }
+ implicit object S2VertexPropertyIdWrites extends Writes[S2VertexPropertyId] {
+ override def writes(o: S2VertexPropertyId): JsValue = {
+ Json.obj("columnMeta" -> columnMetaWrites.writes(o.columnMeta),
+ "value" -> JSONParser.anyValToJsValue(o.value.value).get)
+ }
+ }
+ implicit val s2VertexPropertyIdReads: Reads[S2VertexPropertyId] = S2VertexPropertyIdReads
+// (
+// (JsPath \ "column").read[ColumnMeta] and
+// (JsPath \ "value").read[InnerValLike]
+// )(S2VertexPropertyId.apply _)
+
+ implicit val s2VertexPropertyIdWrites: Writes[S2VertexPropertyId] = S2VertexPropertyIdWrites
+// (
+// (JsPath \ "column").write[ColumnMeta] and
+// (JsPath \ "value").write[InnerValLike]
+// )(unlift(S2VertexPropertyId.unapply))
+
+ implicit object S2VertexIdReads extends Reads[VertexId] {
+ override def reads(json: JsValue): JsResult[VertexId] = {
+ val column = serviceColumnReads.reads((json \ "column").get).get
+ val valueJson = (json \ "value").get
+ val innerVal = JSONParser.jsValueToInnerVal(valueJson, column.columnType, column.schemaVersion).get
+
+ JsSuccess(VertexId(column, innerVal))
+ }
+ }
+ implicit object S2VertexIdWrites extends Writes[VertexId] {
+ override def writes(o: VertexId): JsValue = {
+ Json.obj(
+ "column" -> serviceColumnWrites.writes(o.column),
+ "value" -> JSONParser.anyValToJsValue(o.innerId.value)
+ )
+ }
+ }
+ implicit val s2VertexIdReads: Reads[VertexId] = S2VertexIdReads
+// (
+// (JsPath \ "column").read[ServiceColumn] and
+// (JsPath \ "value").read[InnerValLike]
+// )(VertexId.apply _)
+
+ implicit val s2VertexIdWrites: Writes[VertexId] = S2VertexIdWrites
+// (
+// (JsPath \ "column").write[ServiceColumn] and
+// (JsPath \ "value").write[InnerValLike]
+// )(unlift(VertexId.unapply))
implicit val s2EdgeIdReads: Reads[EdgeId] = (
(JsPath \ "srcVertexId").read[VertexId] and
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
index 3f9e7b5..4a6a154 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
@@ -39,13 +39,12 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
val INT = "integer"
val SHORT = "short"
val BYTE = "byte"
- val BIGDECIMAL = "bigDecimal"
- val NUMERICS = Set(DOUBLE, FLOAT, LONG, INT, SHORT, BYTE, BIGDECIMAL)
+ val NUMERICS = Set(DOUBLE, FLOAT, LONG, INT, SHORT, BYTE)
val BOOLEAN = "boolean"
def isNumericType(dataType: String): Boolean = {
dataType match {
- case BYTE | SHORT | INT | LONG | FLOAT | DOUBLE | BIGDECIMAL=> true
+ case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE => true
case _ => false
}
}
@@ -60,7 +59,6 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
case "short" | "int16" | "integer16" => SHORT
case "byte" | "b" | "tinyint" | "int8" | "integer8" => BYTE
case "boolean" | "bool" => BOOLEAN
- case "bigdecimal" => BIGDECIMAL
case _ => throw new RuntimeException(s"can`t convert $dataType into InnerDataType")
}
}
@@ -92,7 +90,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withLong(l: Long, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(l), LONG, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(l))
// case VERSION1 => v1.InnerVal(Some(l), None, None)
case _ => throw notSupportedEx(version)
}
@@ -100,7 +98,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withInt(i: Int, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(i), INT, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(i))
// case VERSION1 => v1.InnerVal(Some(i.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -108,7 +106,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withFloat(f: Float, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(f.toDouble), FLOAT, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(f.toDouble))
// case VERSION1 => v1.InnerVal(Some(f.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -116,7 +114,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withDouble(d: Double, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(d), DOUBLE, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(d))
// case VERSION1 => v1.InnerVal(Some(d.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -124,7 +122,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withNumber(num: BigDecimal, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(num, BIGDECIMAL, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(num)
// case VERSION1 => v1.InnerVal(Some(num.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -132,7 +130,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withBoolean(b: Boolean, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(b, BOOLEAN, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(b)
// case VERSION1 => v1.InnerVal(None, None, Some(b))
case _ => throw notSupportedEx(version)
}
@@ -140,14 +138,14 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withBlob(blob: Array[Byte], version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(blob, BLOB, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(blob)
case _ => throw notSupportedEx(version)
}
}
def withStr(s: String, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(s, STRING, version)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(s)
// case VERSION1 => v1.InnerVal(None, Some(s), None)
case _ => throw notSupportedEx(version)
}
@@ -158,10 +156,6 @@ trait InnerValLike extends HBaseSerializable {
val value: Any
- val dataType: String
-
- val schemaVersion: String
-
def compare(other: InnerValLike): Int
def +(other: InnerValLike): InnerValLike
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
index 60cb1cc..361b9cf 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
@@ -176,9 +176,6 @@ case class InnerVal(longV: Option[Long], strV: Option[String], boolV: Option[Boo
case (None, None, Some(b)) => b
case _ => throw new Exception(s"InnerVal should be [long/integeer/short/byte/string/boolean]")
}
- val dataType = valueType
-
- val schemaVersion = "v1"
def valueType = (longV, strV, boolV) match {
case (Some(l), None, None) => "long"
case (None, Some(s), None) => "string"
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
index 95888d7..9d9bdf2 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
@@ -26,7 +26,7 @@ import org.apache.s2graph.core.types.{HBaseDeserializableWithIsVertexId, HBaseSe
object InnerVal extends HBaseDeserializableWithIsVertexId {
import HBaseType._
- import types.InnerVal._
+
val order = Order.DESCENDING
def fromBytes(bytes: Array[Byte],
@@ -43,21 +43,21 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
case Order.DESCENDING => bytes(offset) == 0
case _ => bytes(offset) == -1
}
- (InnerVal(boolean, BOOLEAN, version), 1)
+ (InnerVal(boolean), 1)
}
else {
if (OrderedBytes.isNumeric(pbr)) {
val numeric = OrderedBytes.decodeNumericAsBigDecimal(pbr)
- if (isVertexId) (InnerVal(numeric.longValue(), LONG, version), pbr.getPosition - startPos)
- else (InnerVal(BigDecimal(numeric), BIGDECIMAL, version), pbr.getPosition - startPos)
+ if (isVertexId) (InnerVal(numeric.longValue()), pbr.getPosition - startPos)
+ else (InnerVal(BigDecimal(numeric)), pbr.getPosition - startPos)
// (InnerVal(numeric.doubleValue()), pbr.getPosition - startPos)
// (InnerVal(BigDecimal(numeric)), pbr.getPosition - startPos)
} else if (OrderedBytes.isText(pbr)) {
val str = OrderedBytes.decodeString(pbr)
- (InnerVal(str, STRING, version), pbr.getPosition - startPos)
+ (InnerVal(str), pbr.getPosition - startPos)
} else if (OrderedBytes.isBlobVar(pbr)) {
val blobVar = OrderedBytes.decodeBlobVar(pbr)
- (InnerVal(blobVar, BLOB, version), pbr.getPosition - startPos)
+ (InnerVal(blobVar), pbr.getPosition - startPos)
} else {
throw new RuntimeException("!!")
}
@@ -65,9 +65,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
}
}
-case class InnerVal(value: Any,
- dataType: String,
- schemaVersion: String) extends HBaseSerializable with InnerValLike {
+case class InnerVal(value: Any) extends HBaseSerializable with InnerValLike {
import types.InnerVal._
@@ -78,10 +76,9 @@ case class InnerVal(value: Any,
/* since OrderedBytes header start from 0x05, it is safe to use -1, 0
* for decreasing order (true, false) */
// Bytes.toBytes(b)
- //TODO: 0, 1 is also safe?
order match {
- case Order.DESCENDING => if (b) Array(0.toByte) else Array(1.toByte)
- case _ => if (!b) Array(0.toByte) else Array((1.toByte))
+ case Order.DESCENDING => if (b) Array(0.toByte) else Array(-1.toByte)
+ case _ => if (!b) Array(0.toByte) else Array(-1.toByte)
}
case d: Double =>
val num = BigDecimal(d)
@@ -108,6 +105,8 @@ case class InnerVal(value: Any,
val pbr = numByteRange(num)
val len = OrderedBytes.encodeNumeric(pbr, num.bigDecimal, order)
pbr.getBytes().take(len)
+
+
case b: BigDecimal =>
val pbr = numByteRange(b)
val len = OrderedBytes.encodeNumeric(pbr, b.bigDecimal, order)
@@ -156,7 +155,7 @@ case class InnerVal(value: Any,
throw new RuntimeException(s"+ $this, $other")
(value, other.value) match {
- case (v1: BigDecimal, v2: BigDecimal) => new InnerVal(BigDecimal(v1.bigDecimal.add(v2.bigDecimal)), dataType, schemaVersion)
+ case (v1: BigDecimal, v2: BigDecimal) => new InnerVal(BigDecimal(v1.bigDecimal.add(v2.bigDecimal)))
case _ => throw new RuntimeException("+ operation on inner val is for big decimal pair")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/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 bb30b75..5d68656 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
@@ -32,7 +32,7 @@ object S2GraphProvider {
val DefaultService = management.createService(DefaultServiceName, "localhost", "s2graph", 0, None).get
// Management.deleteColumn(DefaultServiceName, DefaultColumnName)
- val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, DefaultColumnName, Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
+ val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, DefaultColumnName, Some("integer"), HBaseType.DEFAULT_VERSION, useCache = false)
val DefaultColumnMetas = {
ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
@@ -185,7 +185,7 @@ class S2GraphProvider extends AbstractGraphProvider {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else {
- mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
+ mnt.createLabel("knows", defaultService.serviceName, "vertex", "integer", defaultService.serviceName, "vertex", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9186211/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 2a04df3..92c63b9 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
@@ -421,67 +421,67 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
//// }
//// }
// }
- test("Modern") {
- val mnt = graph.management
- S2GraphProvider.cleanupSchema
- S2GraphProvider.initDefaultSchema(graph)
-
- val softwareColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "software", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("lang", "-", "string")))
- val personColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "person", "integer",
- Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
-
- val knows = mnt.createLabel("knows",
- S2Graph.DefaultServiceName, "person", "integer",
- S2Graph.DefaultServiceName, "person", "integer",
- true, S2Graph.DefaultServiceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
-
- val created = mnt.createLabel("created",
- S2Graph.DefaultServiceName, "person", "integer",
- S2Graph.DefaultServiceName, "person", "integer",
- true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
-
- val g = graph.traversal()
- val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "marko", "age", Int.box(29))
- val v2 = graph.addVertex(T.label, "person", T.id, Int.box(2), "name", "vadas", "age", Int.box(27))
- val v3 = graph.addVertex(T.label, "software", T.id, Int.box(3), "name", "lop", "lang", "java")
- val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "josh", "josh", Int.box(32))
- val v5 = graph.addVertex(T.label, "software", T.id, Int.box(5), "name", "ripple", "lang", "java")
- val v6 = graph.addVertex(T.label, "person", T.id, Int.box(6), "name", "peter", "age", Int.box(35))
-
- val e1 = v1.addEdge("created", v3, "weight", Double.box(0.4))
-
- val e2 = v1.addEdge("knows", v2, "weight", Double.box(0.5))
- val e3 = v1.addEdge("knows", v4, "weight", Double.box(1.0))
-
-
- val e4 = v2.addEdge("knows", v1, "weight", Double.box(0.5))
-
- val e5 = v3.addEdge("created", v1, "weight", Double.box(0.4))
- val e6 = v3.addEdge("created", v4, "weight", Double.box(0.4))
- val e7 = v3.addEdge("created", v6, "weight", Double.box(0.2))
-
- val e8 = v4.addEdge("knows", v1, "weight", Double.box(1.0))
- val e9 = v4.addEdge("created", v5, "weight", Double.box(1.0))
- val e10 = v4.addEdge("created", v3, "weight", Double.box(0.4))
-
- val e11 = v5.addEdge("created", v4, "weight", Double.box(1.0))
-
- val e12 = v6.addEdge("created", v3, "weight", Double.box(0.2))
-
- val ls = graph.traversal().V().choose(new Predicate[Vertex] {
- override def test(t: Vertex): Boolean =
- t.label().equals("person")
- }, out("knows"), in("created")).values("name").asAdmin()
-
- val l = ls.toList
- logger.error(s"[Size]: ${l.size}")
- logger.error(l.toArray.toSeq.mkString("\n"))
- println(ls.toList)
- ls
-// val traversal = g.V().out().as("x").in().as("y").select("x", "y").by("name").fold()
-// .dedup(Scope.local, "x", "y").unfold();
-
-// val ls = traversal.toList
+// test("Modern") {
+// val mnt = graph.management
+// S2GraphProvider.cleanupSchema
+// S2GraphProvider.initDefaultSchema(graph)
+//
+// val softwareColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "software", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("lang", "-", "string")))
+// val personColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "person", "integer",
+// Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
+//
+// val knows = mnt.createLabel("knows",
+// S2Graph.DefaultServiceName, "person", "integer",
+// S2Graph.DefaultServiceName, "person", "integer",
+// true, S2Graph.DefaultServiceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+//
+// val created = mnt.createLabel("created",
+// S2Graph.DefaultServiceName, "person", "integer",
+// S2Graph.DefaultServiceName, "person", "integer",
+// true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+//
+// val g = graph.traversal()
+// val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "marko", "age", Int.box(29))
+// val v2 = graph.addVertex(T.label, "person", T.id, Int.box(2), "name", "vadas", "age", Int.box(27))
+// val v3 = graph.addVertex(T.label, "software", T.id, Int.box(3), "name", "lop", "lang", "java")
+// val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "josh", "josh", Int.box(32))
+// val v5 = graph.addVertex(T.label, "software", T.id, Int.box(5), "name", "ripple", "lang", "java")
+// val v6 = graph.addVertex(T.label, "person", T.id, Int.box(6), "name", "peter", "age", Int.box(35))
+//
+// val e1 = v1.addEdge("created", v3, "weight", Double.box(0.4))
+//
+// val e2 = v1.addEdge("knows", v2, "weight", Double.box(0.5))
+// val e3 = v1.addEdge("knows", v4, "weight", Double.box(1.0))
+//
+//
+// val e4 = v2.addEdge("knows", v1, "weight", Double.box(0.5))
+//
+// val e5 = v3.addEdge("created", v1, "weight", Double.box(0.4))
+// val e6 = v3.addEdge("created", v4, "weight", Double.box(0.4))
+// val e7 = v3.addEdge("created", v6, "weight", Double.box(0.2))
+//
+// val e8 = v4.addEdge("knows", v1, "weight", Double.box(1.0))
+// val e9 = v4.addEdge("created", v5, "weight", Double.box(1.0))
+// val e10 = v4.addEdge("created", v3, "weight", Double.box(0.4))
+//
+// val e11 = v5.addEdge("created", v4, "weight", Double.box(1.0))
+//
+// val e12 = v6.addEdge("created", v3, "weight", Double.box(0.2))
+//
+// val ls = graph.traversal().V().choose(new Predicate[Vertex] {
+// override def test(t: Vertex): Boolean =
+// t.label().equals("person")
+// }, out("knows"), in("created")).values("name").asAdmin()
+//
+// val l = ls.toList
+// logger.error(s"[Size]: ${l.size}")
+// logger.error(l.toArray.toSeq.mkString("\n"))
+// println(ls.toList)
// ls
- }
+//// val traversal = g.V().out().as("x").in().as("y").select("x", "y").by("name").fold()
+//// .dedup(Scope.local, "x", "y").unfold();
+//
+//// val ls = traversal.toList
+//// ls
+// }
}
\ No newline at end of file
[15/46] incubator-s2graph git commit: passed all before GraphTest.
Posted by st...@apache.org.
passed all before GraphTest.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/450171de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/450171de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/450171de
Branch: refs/heads/master
Commit: 450171dee04b8872704fb201d5f19d806d247c22
Parents: bfc05ba
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 14 23:57:26 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 14 23:57:26 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/JSONParser.scala | 1 +
.../scala/org/apache/s2graph/core/S2Edge.scala | 2 +
.../scala/org/apache/s2graph/core/S2Graph.scala | 62 ++++++++++----------
.../org/apache/s2graph/core/S2Property.scala | 34 ++++++++++-
.../org/apache/s2graph/core/S2Vertex.scala | 2 +
.../core/features/S2DataTypeFeatures.scala | 2 +-
.../features/S2VertexPropertyFeatures.scala | 18 +++---
7 files changed, 77 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
index 9d10dc7..90574f2 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
@@ -235,6 +235,7 @@ object JSONParser {
}
}
}
+
def jsValueToInnerVal(jsValue: JsValue, dataType: String, version: String): Option[InnerValLike] = {
val ret = try {
val dType = InnerVal.toInnerDataType(dataType.toLowerCase())
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/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 3b000f6..27d0b42 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -116,6 +116,8 @@ case class SnapshotEdge(graph: S2Graph,
}
def property[V](key: String, value: V, ts: Long): S2Property[V] = {
+ S2Property.assertValidProp(key, value)
+
val labelMeta = label.metaPropsInvMap.getOrElse(key, throw new RuntimeException(s"$key is not configured on IndexEdge."))
val newProps = new S2Property(edge, labelMeta, key, value, ts)
propsWithTs.put(key, newProps)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/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 8b48064..8856a8c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -35,7 +35,8 @@ import org.apache.s2graph.core.utils.{DeferCache, Extensions, logger}
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer
import org.apache.tinkerpop.gremlin.structure
import org.apache.tinkerpop.gremlin.structure.Graph.{Features, Variables}
-import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, T, Transaction, Vertex}
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
+import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, Property, T, Transaction, Vertex}
import play.api.libs.json.{JsObject, Json}
import scala.annotation.tailrec
@@ -533,37 +534,37 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest$BasicVertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
-// // passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
-//
+ // passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="shouldNotEvaluateToEqualDifferentId", reason="reference equals is not supported."),
-// // passed: all, failed: shouldNotEvaluateToEqualDifferentId
-//
+ // passed: all, failed: shouldNotEvaluateToEqualDifferentId
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
+ // passed: all, failed: none
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"),
-// // passed: all, failed: none, all ignored
-//
+ // passed: all, failed: none, all ignored
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="shouldNotBeEqualPropertiesAsThereIsDifferentKey", reason="reference equals is not supported."),
// // passed: , failed: shouldNotBeEqualPropertiesAsThereIsDifferentKey
-//
+
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"),
-// // passed: all, failed: none
+ // passed: all, failed: none
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"),
// passed: , failed:
@@ -1614,22 +1615,19 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
}
- def validType(t: Any): Boolean = t match {
- case _: VertexId => true
- case _: String => true
- case _: java.lang.Integer => true
- case _: java.lang.Long => true
- case _: scala.Long => true
- case _: scala.Int => true
- case _ => false
- }
-
override def addVertex(kvs: AnyRef*): structure.Vertex = {
if (!features().vertex().supportsUserSuppliedIds() && kvs.contains(T.id)) {
throw Vertex.Exceptions.userSuppliedIdsNotSupported
}
val kvsMap = S2Property.kvsToProps(kvs)
+ kvsMap.get(T.id.name()) match {
+ case Some(idValue) if !S2Property.validType(idValue) =>
+ throw Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported()
+ case _ =>
+ }
+
+ kvsMap.foreach { case (k, v) => S2Property.assertValidProp(k, v) }
if (kvsMap.contains(T.label.name()) && kvsMap(T.label.name).toString.isEmpty)
throw Element.Exceptions.labelCanNotBeEmpty
@@ -1638,7 +1636,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
case None => // do nothing
val id = Random.nextLong
makeVertex(Long.box(id), kvsMap)
- case Some(idValue) if validType(idValue) =>
+ case Some(idValue) if S2Property.validType(idValue) =>
makeVertex(idValue, kvsMap)
case _ =>
throw Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/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 bca1303..aca9826 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
@@ -21,7 +21,7 @@ package org.apache.s2graph.core
import org.apache.s2graph.core.mysqls.LabelMeta
-import org.apache.s2graph.core.types.{CanInnerValLike, InnerValLikeWithTs}
+import org.apache.s2graph.core.types.{CanInnerValLike, InnerValLikeWithTs, VertexId}
import org.apache.tinkerpop.gremlin.structure.Graph.Features
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
import org.apache.tinkerpop.gremlin.structure._
@@ -29,6 +29,29 @@ import org.apache.tinkerpop.gremlin.structure._
import scala.util.hashing.MurmurHash3
object S2Property {
+
+ def validType(t: Any): Boolean = t match {
+ case _: VertexId => true
+ case _: java.lang.Integer => true
+ case _: java.lang.Long => true
+ case _: java.lang.Float => true
+ case _: java.lang.Double => true
+ case _: java.lang.Boolean => true
+ case _: java.lang.Short => true
+ case _: java.lang.Byte => true
+ case _: java.lang.String => true
+ case _: Int => true
+ case _: Long => true
+ case _: Float => true
+ case _: Double => true
+ case _: Boolean => true
+ case _: Short => true
+ case _: Byte => true
+ case _: String => true
+ case _: BigDecimal => true
+ case _ => false
+ }
+
def kvsToProps(kvs: Seq[AnyRef]): Map[String, AnyRef] = {
import scala.collection.JavaConverters._
@@ -42,7 +65,7 @@ object S2Property {
ElementHelper.validateProperty(key, value)
// if (keySet.contains(key)) throw VertexProperty.Exceptions.multiPropertiesNotSupported
- assertValidProp(key, value)
+// assertValidProp(key, value)
keySet.add(key)
result = result + (key -> value)
@@ -56,6 +79,13 @@ object S2Property {
if (!key.isInstanceOf[String]) throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()
if (value == null) throw Property.Exceptions.propertyValueCanNotBeNull()
+ if (!validType(value)) {
+ value match {
+ case _: java.io.Serializable => throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value)
+ case _ =>
+ }
+ }
+
if (value.isInstanceOf[Iterable[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
if (value.isInstanceOf[Array[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
if (value.isInstanceOf[java.util.List[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/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 7d6433d..529ece4 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -196,6 +196,8 @@ case class S2Vertex(graph: S2Graph,
val props = S2Property.kvsToProps(kvs)
+ props.foreach { case (k, v) => S2Property.assertValidProp(k, v) }
+
//TODO: direction, operation, _timestamp need to be reserved property key.
try {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
index 3db4930..a3ff088 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
@@ -36,7 +36,7 @@ case class S2DataTypeFeatures() extends Features.DataTypeFeatures {
override def supportsLongArrayValues(): Boolean = false
- override def supportsSerializableValues(): Boolean = true
+ override def supportsSerializableValues(): Boolean = false
override def supportsStringValues(): Boolean = true
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/450171de/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
index fe74c85..b354561 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
@@ -4,21 +4,21 @@ import org.apache.tinkerpop.gremlin.structure.Graph.Features
class S2VertexPropertyFeatures extends S2PropertyFeatures with Features.VertexPropertyFeatures {
- override def supportsStringIds(): Boolean = true
+ override def supportsStringIds(): Boolean = false
- override def supportsUserSuppliedIds(): Boolean = true
-
- override def supportsAddProperty(): Boolean = true
+ override def supportsCustomIds(): Boolean = true
- override def willAllowId(id: scala.Any): Boolean = true
+ override def supportsUuidIds(): Boolean = false
- override def supportsNumericIds(): Boolean = false
+ override def supportsAddProperty(): Boolean = true
override def supportsRemoveProperty(): Boolean = true
- override def supportsUuidIds(): Boolean = false
-
- override def supportsCustomIds(): Boolean = true
+ override def supportsUserSuppliedIds(): Boolean = true
override def supportsAnyIds(): Boolean = false
+
+ override def supportsNumericIds(): Boolean = false
+
+ override def willAllowId(id: scala.Any): Boolean = true
}
[16/46] incubator-s2graph git commit: [GraphTest]: passed.
Posted by st...@apache.org.
[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)
}
[07/46] incubator-s2graph git commit: [GraphConstructionTest]: passed
all.
Posted by st...@apache.org.
[GraphConstructionTest]: 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/44258593
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/44258593
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/44258593
Branch: refs/heads/master
Commit: 442585939689cb3b09c3dacb9ad614927f9bfc7a
Parents: cac223d
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu Apr 6 23:48:59 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu Apr 6 23:48:59 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/44258593/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 df8fa8a..2771415 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -530,14 +530,13 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
-// passed
+ // 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.FeatureSupportTest", method="*", reason="no"), // pass
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.GraphConstructionTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"), // pass one error
[09/46] incubator-s2graph git commit: [PropertyTest]: passed all.
Posted by st...@apache.org.
[PropertyTest]: 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/302fc961
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/302fc961
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/302fc961
Branch: refs/heads/master
Commit: 302fc961d6e484500a4b51daa560e7c672fd4b89
Parents: 350e2e6
Author: DO YUNG YOON <st...@apache.org>
Authored: Mon Apr 10 23:34:39 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Mon Apr 10 23:35:00 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/302fc961/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 7e037b8..0b16b23 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -532,10 +532,9 @@ object S2Graph {
@Graph.OptOuts(value = Array(
// 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.PropertyTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
- 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
[30/46] incubator-s2graph git commit: Change EdgeId.
Posted by st...@apache.org.
Change EdgeId.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/ed035a32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/ed035a32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/ed035a32
Branch: refs/heads/master
Commit: ed035a3231e1dcc97f2de4f44f58ed12fc1a0d40
Parents: 0e47e11
Author: DO YUNG YOON <st...@apache.org>
Authored: Tue May 2 20:11:11 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Tue May 2 20:11:11 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/JSONParser.scala | 3 +-
.../scala/org/apache/s2graph/core/S2Edge.scala | 9 +--
.../apache/s2graph/core/io/Conversions.scala | 8 +--
.../core/tinkerpop/S2GraphProvider.scala | 62 +++++++++++---------
4 files changed, 45 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ed035a32/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
index 2324e8e..a0767ae 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
@@ -22,7 +22,7 @@ package org.apache.s2graph.core
import org.apache.s2graph.core.GraphExceptions.IllegalDataTypeException
import org.apache.s2graph.core.mysqls.LabelMeta
import org.apache.s2graph.core.rest.TemplateHelper
-import org.apache.s2graph.core.types.{InnerValLikeWithTs, InnerVal, InnerValLike}
+import org.apache.s2graph.core.types.{InnerVal, InnerValLike, InnerValLikeWithTs, VertexId}
import org.apache.s2graph.core.utils.logger
import play.api.libs.json._
@@ -189,6 +189,7 @@ object JSONParser {
val dType = InnerVal.toInnerDataType(dataType)
val isNumeric = isNumericType(dType)
any match {
+ case v: VertexId => v.innerId
case a: InnerValLike => a
case n: BigDecimal =>
if (isNumeric) InnerVal.withNumber(n, version)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ed035a32/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 eca8f18..5712754 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -692,10 +692,11 @@ case class S2Edge(innerGraph: S2Graph,
// NOTE: xxxForVertex makes direction to be "out"
val timestamp = if (this.innerLabel.consistencyLevel == "strong") 0l else ts
// EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
+ val (srcColumn, tgtColumn) = innerLabel.srcTgtColumn(dir)
if (direction == "out")
- EdgeId(srcVertex.id.innerId, tgtVertex.id.innerId, label(), "out", timestamp)
+ EdgeId(VertexId(srcColumn, srcVertex.id.innerId), VertexId(tgtColumn, tgtVertex.id.innerId), label(), "out", timestamp)
else
- EdgeId(tgtVertex.id.innerId, srcVertex.id.innerId, label(), "out", timestamp)
+ EdgeId(VertexId(tgtColumn, tgtVertex.id.innerId), VertexId(srcColumn, srcVertex.id.innerId), label(), "out", timestamp)
}
override def id(): AnyRef = edgeId
@@ -721,8 +722,8 @@ object EdgeId {
}
}
-case class EdgeId(srcVertexId: InnerValLike,
- tgtVertexId: InnerValLike,
+case class EdgeId(srcVertexId: VertexId,
+ tgtVertexId: VertexId,
labelName: String,
direction: String,
ts: Long) {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ed035a32/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
index f9cc861..077bb84 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
@@ -105,16 +105,16 @@ object Conversions {
)(unlift(VertexId.unapply))
implicit val s2EdgeIdReads: Reads[EdgeId] = (
- (JsPath \ "srcVertexId").read[InnerValLike] and
- (JsPath \ "tgtVertexId").read[InnerValLike] and
+ (JsPath \ "srcVertexId").read[VertexId] and
+ (JsPath \ "tgtVertexId").read[VertexId] and
(JsPath \ "labelName").read[String] and
(JsPath \ "direction").read[String] and
(JsPath \ "ts").read[Long]
)(EdgeId.apply _)
implicit val s2EdgeIdWrites: Writes[EdgeId] = (
- (JsPath \ "srcVertexId").write[InnerValLike] and
- (JsPath \ "tgtVertexId").write[InnerValLike] and
+ (JsPath \ "srcVertexId").write[VertexId] and
+ (JsPath \ "tgtVertexId").write[VertexId] and
(JsPath \ "labelName").write[String] and
(JsPath \ "direction").write[String] and
(JsPath \ "ts").write[Long]
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ed035a32/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 d0761e1..74edd6d 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
@@ -4,10 +4,11 @@ import java.util
import com.typesafe.config.ConfigFactory
import org.apache.commons.configuration.Configuration
+import org.apache.s2graph.core.GraphExceptions.LabelNotExistException
import org.apache.s2graph.core.Management.JsonModel.Prop
import org.apache.s2graph.core.S2Graph.{DefaultColumnName, DefaultServiceName}
import org.apache.s2graph.core._
-import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Label, Service, ServiceColumn}
import org.apache.s2graph.core.types.{HBaseType, InnerVal, VertexId}
import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData
@@ -239,31 +240,35 @@ class S2GraphProvider extends AbstractGraphProvider {
options = Option("""{"skipReverse": false}"""))
}
- val friend = if (testClass.getSimpleName.contains("IoEdgeTest")) {
- mnt.createLabel("friend", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil,
- Seq(
- Prop("name", "-", "string"),
- Prop("location", "-", "string"),
- Prop("status", "-", "string"),
- Prop("weight", "0.0", "double"),
- Prop("acl", "-", "string")
- ), "strong", None, None,
- options = Option("""{"skipReverse": false}"""))
- } else {
- 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"),
- Prop("weight", "0.0", "double"),
- Prop("acl", "-", "string")
- ),
- "strong", None, None,
- options = Option("""{"skipReverse": false}""")
- )
- }
+ val friend =
+ if (testClass.getSimpleName == "IoEdgeTest") {
+ mnt.createLabel("friend",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("name", "-", "string"),
+ Prop("location", "-", "string"),
+ Prop("status", "-", "string"),
+ Prop("weight", "0.0", "double"),
+ Prop("acl", "-", "string")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ } else {
+ 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"),
+ Prop("weight", "0.0", "double"),
+ Prop("acl", "-", "string")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+ }
val hate = mnt.createLabel("hate", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil, Nil, "strong", None, None,
@@ -325,9 +330,10 @@ class S2GraphProvider extends AbstractGraphProvider {
if (isVertex) {
VertexId(ServiceColumn.findAll().head, InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION))
} else {
+ val label = Label.findByName("_s2graph").getOrElse(throw new LabelNotExistException("_s2graph"))
EdgeId(
- InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION),
- InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION),
+ VertexId(label.srcColumn, InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION)),
+ VertexId(label.tgtColumn, InnerVal.withStr(id.toString, HBaseType.DEFAULT_VERSION)),
"_s2graph",
"out",
System.currentTimeMillis()
[41/46] incubator-s2graph git commit: [SUITE_PROCESS_STANDARD.map]
passed with few failures.
Posted by st...@apache.org.
[SUITE_PROCESS_STANDARD.map] passed with few failures.
- change default config for Graph.
- list failed test cases as Graph.OptOut.
- comment out storage.truncate on S2GraphProvider.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/f4554e1c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/f4554e1c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/f4554e1c
Branch: refs/heads/master
Commit: f4554e1c182d405b5789b7c034b23177d177e7b7
Parents: fd1bdc4
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 16:33:42 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 16:34:42 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/QueryParam.scala | 4 +--
.../scala/org/apache/s2graph/core/S2Graph.scala | 32 ++++++++++++--------
.../org/apache/s2graph/core/S2Vertex.scala | 2 +-
.../core/tinkerpop/S2GraphProvider.scala | 12 ++++----
4 files changed, 29 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/f4554e1c/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
index 1e0d3b2..5b8543a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
@@ -267,9 +267,9 @@ object QueryParam {
case class QueryParam(labelName: String,
direction: String = "out",
offset: Int = 0,
- limit: Int = 100,
+ limit: Int = S2Graph.DefaultFetchLimit,
sample: Int = -1,
- maxAttempt: Int = 2,
+ maxAttempt: Int = 20,
rpcTimeout: Int = 600000,
cacheTTLInMillis: Long = -1L,
indexName: String = LabelIndex.DefaultName,
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/f4554e1c/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 483c8c4..42bf2a8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -56,6 +56,7 @@ object S2Graph {
val DefaultScore = 1.0
val FetchAllLimit = 10000000
+ val DefaultFetchLimit = 1000
private val DefaultConfigs: Map[String, AnyRef] = Map(
"hbase.zookeeper.quorum" -> "localhost",
@@ -617,7 +618,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", reason = "somehow count becomes double. fix this. "),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX3X_count", reason = "count differ very little. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX8X_count", reason = "count differ very litter. fix this."),
// passed: all, failed: g_V_both_both_count, g_V_repeatXoutX_timesX3X_count, g_V_repeatXoutX_timesX8X_count
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapTest$Traversals", method = "*", reason = "no"),
@@ -641,33 +644,36 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MapValuesTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "*", reason = "no"),
-// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX,
- //g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX
- //g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX", reason = "fix this."),
+// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX", reason = "fix this."),
// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX, g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxTest$Traversals", method = "*", reason = "no"),
-// passed: all, failed: g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_maxX
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanTest$Traversals", method = "*", reason = "no"),
// failed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MinTest$Traversals", method = "*", reason = "no"),
-// passed: all, failed: g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_minX
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest$Traversals", method = "*", reason = "no"),
// failed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest$Traversals", method = "g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name", reason = "no"),
// passed: all, failed: g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name
-//
+
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_out_out_profile_grateful", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_repeat_both_modern_profile", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "validate_g_V_out_out_profile_grateful", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_repeat_both_profile", reason = "fix this."),
// failed: grateful_V_out_out_profileXmetricsX, g_V_repeat_both_profileXmetricsX, grateful_V_out_out_profile, g_V_repeat_both_profile
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest$Traversals", method = "*", reason = "no"),
@@ -679,7 +685,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_VX4X_bothE_otherV", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_V_out_outE_inV_inE_inV_both_name", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_VX4X_both", reason = "fix this."),
// failed: g_VX4X_bothE_otherV, g_VX1_2_3_4X_name, g_V_out_outE_inV_inE_inV_both_name, g_VX4X_bothEXcreatedX, g_VX4X_both
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest$Traversals", method = "*", reason = "no"),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/f4554e1c/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 5277851..bb60522 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -157,7 +157,7 @@ case class S2Vertex(graph: S2Graph,
}
}
- graph.fetchEdges(this, labelNameWithDirs)
+ graph.fetchEdges(this, labelNameWithDirs.distinct)
}
// do no save to storage
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/f4554e1c/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 db55c03..c66a546 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
@@ -99,12 +99,12 @@ class S2GraphProvider extends AbstractGraphProvider {
if (graph != null) {
val s2Graph = graph.asInstanceOf[S2Graph]
if (s2Graph.isRunning) {
- val labels = Label.findAll()
- labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
- labelsWithSameTable.headOption.foreach { label =>
- s2Graph.management.truncateStorage(label.label)
- }
- }
+// val labels = Label.findAll()
+// labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
+// labelsWithSameTable.headOption.foreach { label =>
+// s2Graph.management.truncateStorage(label.label)
+// }
+// }
// s2Graph.shutdown(modelDataDelete = true)
S2GraphProvider.cleanupSchema
s2Graph.shutdown(modelDataDelete = true)
[13/46] incubator-s2graph git commit: Changed DataTypeFeatures.
Posted by st...@apache.org.
Changed DataTypeFeatures.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/b8033e76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/b8033e76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/b8033e76
Branch: refs/heads/master
Commit: b8033e768b8b61b9ac0d88cd168447ca5f9c8206
Parents: 507cfcf
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 14 14:47:52 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 14 14:47:52 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 72 +++++++++++++-------
.../core/features/S2DataTypeFeatures.scala | 32 +++++----
2 files changed, 65 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/b8033e76/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 5669b2e..ec02dd5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -20,8 +20,8 @@
package org.apache.s2graph.core
import java.util
-import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
-import java.util.concurrent.{ExecutorService, Executors, TimeUnit}
+import java.util.concurrent.atomic.AtomicBoolean
+import java.util.concurrent.{Executors, TimeUnit}
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.commons.configuration.{BaseConfiguration, Configuration}
@@ -34,15 +34,12 @@ import org.apache.s2graph.core.types._
import org.apache.s2graph.core.utils.{DeferCache, Extensions, logger}
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer
import org.apache.tinkerpop.gremlin.structure
-import org.apache.tinkerpop.gremlin.structure.Graph.Features.EdgeFeatures
import org.apache.tinkerpop.gremlin.structure.Graph.{Features, Variables}
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
-import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, Property, T, Transaction, Vertex}
+import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, T, Transaction, Vertex}
import play.api.libs.json.{JsObject, Json}
import scala.annotation.tailrec
import scala.collection.JavaConversions._
-import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.concurrent._
@@ -548,22 +545,22 @@ object S2Graph {
// passed: all, failed: none
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
- // passed: , failed: shouldEnableFeatureOnEdgeIfNotEnabled, shouldEnableFeatureOnVertexIfNotEnabled, shouldSupportUserSuppliedIdsOfTypeAny
+ // passed: all, failed: none
+ // shouldEnableFeatureOnEdgeIfNotEnabled, shouldEnableFeatureOnVertexIfNotEnabled, shouldSupportUserSuppliedIdsOfTypeAny
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest$BasicVertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
// passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="shouldNotEvaluateToEqualDifferentId", reason="reference equals is not supported."),
// passed: all, failed: shouldNotEvaluateToEqualDifferentId
-
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
// passed: all, failed: none
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="shouldNotBeEqualPropertiesAsThereIsDifferentKey", reason="reference equals is not supported."),
// passed: , failed: shouldNotBeEqualPropertiesAsThereIsDifferentKey
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"),
@@ -1608,25 +1605,52 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
}
val kvsMap = S2Property.kvsToProps(kvs)
+
if (kvsMap.contains(T.label.name()) && kvsMap(T.label.name).toString.isEmpty)
throw Element.Exceptions.labelCanNotBeEmpty
- val id = kvsMap.getOrElse(T.id.toString, Random.nextLong)
-
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
-
- val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
- val (serviceName, columnName) =
- if (names.length == 1) (DefaultService.serviceName, names(0))
- else throw new RuntimeException("malformed data on vertex label.")
-
- val vertex = toVertex(serviceName, columnName, id, kvsMap)
+ def validType(t: Any): Boolean = t match {
+ case t: String => true
+ case t: java.lang.Integer => true
+ case t: java.lang.Long => true
+ case t: scala.Long => true
+ case t: scala.Int => true
+ case _ => false
+ }
- val future = mutateVertices(Seq(vertex), withWait = true).map { vs =>
- if (vs.forall(identity)) vertex
- else throw new RuntimeException("addVertex failed.")
+ val vertex = kvsMap.get(T.id.name()) match {
+ case None => // do nothing
+ val id = Random.nextLong
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+
+ val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
+ val (serviceName, columnName) =
+ if (names.length == 1) (DefaultService.serviceName, names(0))
+ else throw new RuntimeException("malformed data on vertex label.")
+
+ toVertex(serviceName, columnName, id, kvsMap)
+ case Some(idValue) =>
+ idValue match {
+ case vId: VertexId =>
+ toVertex(vId.column.service.serviceName, vId.column.columnName, vId, kvsMap)
+
+ case _: Any if validType(idValue) =>
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+ val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
+
+ val (serviceName, columnName) =
+ if (names.length == 1) (DefaultService.serviceName, names(0))
+ else throw new RuntimeException("malformed data on vertex label.")
+
+ toVertex(serviceName, columnName, idValue, kvsMap)
+
+ case _ =>
+ logger.error(s"[S2Graph.addVertex]: ${idValue.getClass.getName}")
+ throw Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported
+ }
}
- Await.result(future, WaitTimeout)
+
+ addVertex(vertex)
}
def addVertex(id: VertexId,
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/b8033e76/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
index a94ead3..3db4930 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
@@ -4,40 +4,42 @@ import org.apache.tinkerpop.gremlin.structure.Graph.Features
case class S2DataTypeFeatures() extends Features.DataTypeFeatures {
- override def supportsStringValues(): Boolean = true
+ // primitive types
+ override def supportsBooleanValues(): Boolean = true
- override def supportsFloatValues(): Boolean = true
+ override def supportsByteValues(): Boolean = false
override def supportsDoubleValues(): Boolean = true
+ override def supportsFloatValues(): Boolean = true
+
override def supportsIntegerValues(): Boolean = true
override def supportsLongValues(): Boolean = true
- override def supportsBooleanValues(): Boolean = true
-
- override def supportsDoubleArrayValues(): Boolean = false
+ // non-primitive types
+ override def supportsMapValues(): Boolean = false
- override def supportsStringArrayValues(): Boolean = false
+ override def supportsMixedListValues(): Boolean = false
- override def supportsIntegerArrayValues(): Boolean = false
+ override def supportsBooleanArrayValues(): Boolean = false
- override def supportsByteValues(): Boolean = false
+ override def supportsByteArrayValues(): Boolean = false
- override def supportsUniformListValues(): Boolean = false
+ override def supportsDoubleArrayValues(): Boolean = false
- override def supportsMapValues(): Boolean = false
+ override def supportsFloatArrayValues(): Boolean = false
- override def supportsBooleanArrayValues(): Boolean = false
+ override def supportsIntegerArrayValues(): Boolean = false
- override def supportsSerializableValues(): Boolean = false
+ override def supportsStringArrayValues(): Boolean = false
override def supportsLongArrayValues(): Boolean = false
- override def supportsMixedListValues(): Boolean = false
+ override def supportsSerializableValues(): Boolean = true
- override def supportsFloatArrayValues(): Boolean = false
+ override def supportsStringValues(): Boolean = true
- override def supportsByteArrayValues(): Boolean = false
+ override def supportsUniformListValues(): Boolean = false
}
[37/46] incubator-s2graph git commit: release HBaseAdmin after using
it.
Posted by st...@apache.org.
release HBaseAdmin after using it.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/3407a81e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/3407a81e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/3407a81e
Branch: refs/heads/master
Commit: 3407a81ed9ea1468ab0359866d5e921ece3db8c7
Parents: 549279d
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 10:48:06 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 10:48:06 2017 +0900
----------------------------------------------------------------------
.../core/storage/hbase/AsynchbaseStorage.scala | 170 ++++++++++---------
1 file changed, 90 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/3407a81e/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
index e41fe27..5c9695d 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
@@ -29,7 +29,7 @@ import com.stumbleupon.async.{Callback, Deferred}
import com.typesafe.config.Config
import org.apache.commons.io.FileUtils
import org.apache.hadoop.conf.Configuration
-import org.apache.hadoop.hbase.client.{ConnectionFactory, Durability}
+import org.apache.hadoop.hbase.client.{Admin, ConnectionFactory, Durability}
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding
import org.apache.hadoop.hbase.regionserver.BloomType
@@ -560,97 +560,92 @@ class AsynchbaseStorage(override val graph: S2Graph,
zkAddr <- Seq(zkQuorum) ++ zkQuorumSlave.toSeq
} {
logger.info(s"create table: $tableName on $zkAddr, $cfs, $regionMultiplier, $compressionAlgorithm")
- val admin = getAdmin(zkAddr)
- val regionCount = totalRegionCount.getOrElse(admin.getClusterStatus.getServersSize * regionMultiplier)
- try {
- if (!admin.tableExists(TableName.valueOf(tableName))) {
- val desc = new HTableDescriptor(TableName.valueOf(tableName))
- desc.setDurability(Durability.ASYNC_WAL)
- for (cf <- cfs) {
- val columnDesc = new HColumnDescriptor(cf)
- .setCompressionType(Algorithm.valueOf(compressionAlgorithm.toUpperCase))
- .setBloomFilterType(BloomType.ROW)
- .setDataBlockEncoding(DataBlockEncoding.FAST_DIFF)
- .setMaxVersions(1)
- .setTimeToLive(2147483647)
- .setMinVersions(0)
- .setBlocksize(32768)
- .setBlockCacheEnabled(true)
+ withAdmin(zkAddr) { admin =>
+ val regionCount = totalRegionCount.getOrElse(admin.getClusterStatus.getServersSize * regionMultiplier)
+ try {
+ if (!admin.tableExists(TableName.valueOf(tableName))) {
+ val desc = new HTableDescriptor(TableName.valueOf(tableName))
+ desc.setDurability(Durability.ASYNC_WAL)
+ for (cf <- cfs) {
+ val columnDesc = new HColumnDescriptor(cf)
+ .setCompressionType(Algorithm.valueOf(compressionAlgorithm.toUpperCase))
+ .setBloomFilterType(BloomType.ROW)
+ .setDataBlockEncoding(DataBlockEncoding.FAST_DIFF)
+ .setMaxVersions(1)
+ .setTimeToLive(2147483647)
+ .setMinVersions(0)
+ .setBlocksize(32768)
+ .setBlockCacheEnabled(true)
// FIXME: For test!!
- .setInMemory(true)
- if (ttl.isDefined) columnDesc.setTimeToLive(ttl.get)
- if (replicationScopeOpt.isDefined) columnDesc.setScope(replicationScopeOpt.get)
- desc.addFamily(columnDesc)
- }
+ .setInMemory(true)
+ if (ttl.isDefined) columnDesc.setTimeToLive(ttl.get)
+ if (replicationScopeOpt.isDefined) columnDesc.setScope(replicationScopeOpt.get)
+ desc.addFamily(columnDesc)
+ }
- if (regionCount <= 1) admin.createTable(desc)
- else admin.createTable(desc, getStartKey(regionCount), getEndKey(regionCount), regionCount)
- } else {
- logger.info(s"$zkAddr, $tableName, $cfs already exist.")
+ if (regionCount <= 1) admin.createTable(desc)
+ else admin.createTable(desc, getStartKey(regionCount), getEndKey(regionCount), regionCount)
+ } else {
+ logger.info(s"$zkAddr, $tableName, $cfs already exist.")
+ }
+ } catch {
+ case e: Throwable =>
+ logger.error(s"$zkAddr, $tableName failed with $e", e)
+ throw e
}
- } catch {
- case e: Throwable =>
- logger.error(s"$zkAddr, $tableName failed with $e", e)
- throw e
- } finally {
- admin.close()
- admin.getConnection.close()
}
}
}
override def truncateTable(zkAddr: String, tableNameStr: String): Unit = {
- val tableName = TableName.valueOf(tableNameStr)
- val adminTry = Try(getAdmin(zkAddr))
- if (adminTry.isFailure) return
- val admin = adminTry.get
-
- if (!Try(admin.tableExists(tableName)).getOrElse(false)) {
- logger.info(s"No table to truncate ${tableNameStr}")
- return
- }
+ withAdmin(zkAddr) { admin =>
+ val tableName = TableName.valueOf(tableNameStr)
+ if (!Try(admin.tableExists(tableName)).getOrElse(false)) {
+ logger.info(s"No table to truncate ${tableNameStr}")
+ return
+ }
- Try(admin.isTableDisabled(tableName)).map {
- case true =>
- logger.info(s"${tableNameStr} is already disabled.")
+ Try(admin.isTableDisabled(tableName)).map {
+ case true =>
+ logger.info(s"${tableNameStr} is already disabled.")
- case false =>
- logger.info(s"Before disabling to trucate ${tableNameStr}")
- Try(admin.disableTable(tableName)).recover {
- case NonFatal(e) =>
- logger.info(s"Failed to disable ${tableNameStr}: ${e}")
- }
- logger.info(s"After disabling to trucate ${tableNameStr}")
- }
+ case false =>
+ logger.info(s"Before disabling to trucate ${tableNameStr}")
+ Try(admin.disableTable(tableName)).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to disable ${tableNameStr}: ${e}")
+ }
+ logger.info(s"After disabling to trucate ${tableNameStr}")
+ }
- logger.info(s"Before truncating ${tableNameStr}")
- Try(admin.truncateTable(tableName, true)).recover {
- case NonFatal(e) =>
- logger.info(s"Failed to truncate ${tableNameStr}: ${e}")
- }
- logger.info(s"After truncating ${tableNameStr}")
- Try(admin.close()).recover {
- case NonFatal(e) =>
- logger.info(s"Failed to close admin ${tableNameStr}: ${e}")
- }
- Try(admin.getConnection.close()).recover {
- case NonFatal(e) =>
- logger.info(s"Failed to close connection ${tableNameStr}: ${e}")
+ logger.info(s"Before truncating ${tableNameStr}")
+ Try(admin.truncateTable(tableName, true)).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to truncate ${tableNameStr}: ${e}")
+ }
+ logger.info(s"After truncating ${tableNameStr}")
+ Try(admin.close()).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to close admin ${tableNameStr}: ${e}")
+ }
+ Try(admin.getConnection.close()).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to close connection ${tableNameStr}: ${e}")
+ }
}
-
}
override def deleteTable(zkAddr: String, tableNameStr: String): Unit = {
- val admin = getAdmin(zkAddr)
- val tableName = TableName.valueOf(tableNameStr)
- if (!admin.tableExists(tableName)) {
- return
- }
- if (admin.isTableEnabled(tableName)) {
- admin.disableTable(tableName)
+ withAdmin(zkAddr) { admin =>
+ val tableName = TableName.valueOf(tableNameStr)
+ if (!admin.tableExists(tableName)) {
+ return
+ }
+ if (admin.isTableEnabled(tableName)) {
+ admin.disableTable(tableName)
+ }
+ admin.deleteTable(tableName)
}
- admin.deleteTable(tableName)
- admin.close()
}
/** Asynchbase implementation override default getVertices to use future Cache */
@@ -827,6 +822,15 @@ class AsynchbaseStorage(override val graph: S2Graph,
conn.getAdmin
}
+ private def withAdmin(zkAddr: String)(op: Admin => Unit): Unit = {
+ val admin = getAdmin(zkAddr)
+ try {
+ op(admin)
+ } finally {
+ admin.close()
+ admin.getConnection.close()
+ }
+ }
/**
* following configuration need to come together to use secured hbase cluster.
* 1. set hbase.security.auth.enable = true
@@ -850,16 +854,22 @@ class AsynchbaseStorage(override val graph: S2Graph,
}
private def enableTable(zkAddr: String, tableName: String) = {
- getAdmin(zkAddr).enableTable(TableName.valueOf(tableName))
+ withAdmin(zkAddr) { admin =>
+ admin.enableTable(TableName.valueOf(tableName))
+ }
}
private def disableTable(zkAddr: String, tableName: String) = {
- getAdmin(zkAddr).disableTable(TableName.valueOf(tableName))
+ withAdmin(zkAddr) { admin =>
+ admin.disableTable(TableName.valueOf(tableName))
+ }
}
private def dropTable(zkAddr: String, tableName: String) = {
- getAdmin(zkAddr).disableTable(TableName.valueOf(tableName))
- getAdmin(zkAddr).deleteTable(TableName.valueOf(tableName))
+ withAdmin(zkAddr) { admin =>
+ admin.disableTable(TableName.valueOf(tableName))
+ admin.deleteTable(TableName.valueOf(tableName))
+ }
}
private def getStartKey(regionCount: Int): Array[Byte] = {
[05/46] incubator-s2graph git commit: [VertexTest]: passed except
shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge.
Posted by st...@apache.org.
[VertexTest]: passed except shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/9ce28472
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/9ce28472
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/9ce28472
Branch: refs/heads/master
Commit: 9ce284729348ada3a6b2146844f97806159e2433
Parents: 20b51ce
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 5 22:54:25 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 5 22:54:25 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/QueryParam.scala | 2 +-
.../scala/org/apache/s2graph/core/S2Graph.scala | 56 ++++++++++++++---
.../org/apache/s2graph/core/S2Vertex.scala | 44 +++++++++++--
.../core/features/S2ElementFeatures.scala | 4 +-
.../features/S2VertexPropertyFeatures.scala | 2 +-
.../core/tinkerpop/S2GraphProvider.scala | 65 ++++++++++++++++----
.../core/tinkerpop/structure/S2GraphTest.scala | 56 ++++++++++++++++-
7 files changed, 195 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
index eb36258..0228b3b 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
@@ -270,7 +270,7 @@ case class QueryParam(labelName: String,
limit: Int = 100,
sample: Int = -1,
maxAttempt: Int = 2,
- rpcTimeout: Int = 1000,
+ rpcTimeout: Int = 60000,
cacheTTLInMillis: Long = -1L,
indexName: String = LabelIndex.DefaultName,
where: Try[Where] = Success(WhereParser.success),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/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 182b8ed..1d1150e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -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(60, TimeUnit.SECONDS)
+ val WaitTimeout = Duration(300, TimeUnit.SECONDS)
val scheduledEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())
val management = new Management(this)
@@ -654,7 +654,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
} logger.info(s"[Initialized]: $k, ${this.config.getAnyRef(k)}")
/* TODO */
- val DefaultService = management.createService("_s2graph", "localhost", "s2graph", 0, None).get
+ val DefaultService = management.createService("", "localhost", "s2graph", 0, None).get
val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, "vertex", Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
val DefaultColumnMetas = {
ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
@@ -672,11 +672,16 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "x", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "y", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
}
val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
- options = Option("""{"skipReverse": true}""")
+ options = Option("""{"skipReverse": false}""")
)
def getStorage(service: Service): Storage[_, _] = {
@@ -909,6 +914,20 @@ 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],
@@ -947,7 +966,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)
}
@@ -993,7 +1012,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)
@@ -1008,6 +1027,8 @@ 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 =>
@@ -1035,7 +1056,8 @@ 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.debug(s"delete edge from deleteAll: ${edgeToDelete.edge.toLogString}")
+ logger.error(s"delete edge from deleteAll: ${edgeToDelete.edge.toLogString}")
+ logger.error(s"delete edge from deleteAll edge: ${edge.toLogString}")
edgeToDelete
}
//Degree edge?
@@ -1234,11 +1256,14 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
operation: String = "insert"): S2Edge = {
val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName))
- val srcVertexIdInnerVal = toInnerVal(srcId, label.srcColumn.columnType, label.schemaVersion)
- val tgtVertexIdInnerVal = toInnerVal(tgtId, label.tgtColumn.columnType, label.schemaVersion)
+ val srcColumn = if (direction == "out") label.srcColumn else label.tgtColumn
+ val tgtColumn = if (direction == "out") label.tgtColumn else label.srcColumn
- val srcVertex = newVertex(SourceVertexId(label.srcColumn, srcVertexIdInnerVal), System.currentTimeMillis())
- val tgtVertex = newVertex(TargetVertexId(label.tgtColumn, tgtVertexIdInnerVal), System.currentTimeMillis())
+ val srcVertexIdInnerVal = toInnerVal(srcId, srcColumn.columnType, label.schemaVersion)
+ val tgtVertexIdInnerVal = toInnerVal(tgtId, tgtColumn.columnType, label.schemaVersion)
+
+ val srcVertex = newVertex(SourceVertexId(srcColumn, srcVertexIdInnerVal), System.currentTimeMillis())
+ val tgtVertex = newVertex(TargetVertexId(tgtColumn, tgtVertexIdInnerVal), System.currentTimeMillis())
val dir = GraphUtil.toDir(direction).getOrElse(throw new RuntimeException(s"$direction is not supported."))
val propsPlusTs = props ++ Map(LabelMeta.timestamp.name -> ts)
@@ -1551,11 +1576,22 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
override def configuration(): Configuration = apacheConfiguration
+ override def addVertex(label: String): Vertex = {
+ if (label == null) throw Element.Exceptions.labelCanNotBeNull
+ if (label.isEmpty) throw Element.Exceptions.labelCanNotBeEmpty
+
+ addVertex(Seq(T.label, label): _*)
+ }
+
override def addVertex(kvs: AnyRef*): structure.Vertex = {
if (!features().vertex().supportsUserSuppliedIds() && kvs.contains(T.id)) {
throw Vertex.Exceptions.userSuppliedIdsNotSupported
}
+
val kvsMap = S2Property.kvsToProps(kvs)
+ if (kvsMap.contains(T.label.name()) && kvsMap(T.label.name).toString.isEmpty)
+ throw Element.Exceptions.labelCanNotBeEmpty
+
val id = kvsMap.getOrElse(T.id.toString, Random.nextLong)
val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/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 643b469..797ed98 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -33,6 +33,7 @@ import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Property, T, Ver
import play.api.libs.json.Json
import scala.collection.JavaConverters._
+import scala.concurrent.Await
case class S2Vertex(graph: S2Graph,
id: VertexId,
@@ -181,22 +182,32 @@ case class S2Vertex(graph: S2Graph,
}
}
- override def addEdge(label: String, vertex: Vertex, kvs: AnyRef*): Edge = {
+ override def addEdge(labelName: String, vertex: Vertex, kvs: AnyRef*): Edge = {
+ val containsId = kvs.contains(T.id)
vertex match {
case otherV: S2Vertex =>
- if (!graph.features().edge().supportsUserSuppliedIds() && kvs.contains(T.id)) {
+ if (!graph.features().edge().supportsUserSuppliedIds() && containsId) {
throw Exceptions.userSuppliedIdsNotSupported()
}
val props = S2Property.kvsToProps(kvs)
//TODO: direction, operation, _timestamp need to be reserved property key.
- val direction = props.get("direction").getOrElse("out").toString
- val ts = props.get(LabelMeta.timestamp.name).map(_.toString.toLong).getOrElse(System.currentTimeMillis())
- val operation = props.get("operation").map(_.toString).getOrElse("insert")
try {
- graph.addEdgeInner(this, otherV, label, direction, props, ts, operation)
+ val direction = props.get("direction").getOrElse("out").toString
+ val ts = props.get(LabelMeta.timestamp.name).map(_.toString.toLong).getOrElse(System.currentTimeMillis())
+ val operation = props.get("operation").map(_.toString).getOrElse("insert")
+ val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName))
+ val dir = GraphUtil.toDir(direction).getOrElse(throw new RuntimeException(s"$direction is not supported."))
+ 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 = graph.newEdge(this, otherV, label, dir, op = op, version = ts, propsWithTs = propsWithTs)
+ val future = graph.mutateEdges(edge.relatedEdges, withWait = true)
+ Await.ready(future, graph.WaitTimeout)
+ edge
} catch {
case e: LabelNotExistException => throw new java.lang.IllegalArgumentException
}
@@ -239,6 +250,27 @@ case class S2Vertex(graph: S2Graph,
override def remove(): Unit = {
if (graph.features().vertex().supportsRemoveVertices()) {
// remove edge
+ // TODO: remove related edges also.
+ implicit val ec = graph.ec
+ val ts = System.currentTimeMillis()
+ val outLabels = Label.findBySrcColumnId(id.colId)
+ val inLabels = Label.findByTgtColumnId(id.colId)
+ val verticesToDelete = Seq(this.copy(op = GraphUtil.operations("delete")))
+ val outFuture = graph.deleteAllAdjacentEdges(verticesToDelete, outLabels, GraphUtil.directions("out"), ts)
+ val inFuture = graph.deleteAllAdjacentEdges(verticesToDelete, inLabels, GraphUtil.directions("in"), ts)
+ val vertexFuture = graph.mutateVertices(verticesToDelete, withWait = true)
+ val future = for {
+ outSuccess <- outFuture
+ inSuccess <- inFuture
+ vertexSuccess <- vertexFuture
+ } yield {
+ if (!outSuccess) throw new RuntimeException("Vertex.remove out direction edge delete failed.")
+ if (!inSuccess) throw new RuntimeException("Vertex.remove in direction edge delete failed.")
+ if (!vertexSuccess.forall(identity)) throw new RuntimeException("Vertex.remove vertex delete failed.")
+ true
+ }
+ Await.result(future, graph.WaitTimeout)
+
} else {
throw Vertex.Exceptions.vertexRemovalNotSupported()
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
index 06f1c68..7e66c62 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
@@ -3,7 +3,7 @@ package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
abstract class S2ElementFeatures extends Features.ElementFeatures {
- override def supportsStringIds(): Boolean = true
+ override def supportsStringIds(): Boolean = false
override def supportsCustomIds(): Boolean = true
@@ -15,7 +15,7 @@ abstract class S2ElementFeatures extends Features.ElementFeatures {
override def supportsUserSuppliedIds(): Boolean = true
- override def supportsAnyIds(): Boolean = true
+ override def supportsAnyIds(): Boolean = false
override def supportsNumericIds(): Boolean = false
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
index 592cc0b..fe74c85 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
@@ -18,7 +18,7 @@ class S2VertexPropertyFeatures extends S2PropertyFeatures with Features.VertexPr
override def supportsUuidIds(): Boolean = false
- override def supportsCustomIds(): Boolean = false
+ override def supportsCustomIds(): Boolean = true
override def supportsAnyIds(): Boolean = false
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/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 741be06..e0fc765 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
@@ -41,12 +41,14 @@ class S2GraphProvider extends AbstractGraphProvider {
if (graph != null) {
val s2Graph = graph.asInstanceOf[S2Graph]
if (s2Graph.isRunning) {
- val labels = Label.findAll()
- labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
- labelsWithSameTable.headOption.foreach { label =>
- s2Graph.management.truncateStorage(label.label)
- }
- }
+// val labels = Label.findAll()
+// labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
+// labelsWithSameTable.headOption.foreach { label =>
+// s2Graph.management.truncateStorage(label.label)
+// }
+// }
+// s2Graph.shutdown(modelDataDelete = true)
+ cleanupSchema(graph)
s2Graph.shutdown(modelDataDelete = true)
logger.info("S2Graph Shutdown")
}
@@ -61,6 +63,24 @@ class S2GraphProvider extends AbstractGraphProvider {
}
}
+ private def cleanupSchema(graph: Graph): Unit = {
+ val s2Graph = graph.asInstanceOf[S2Graph]
+ val mnt = s2Graph.getManagement()
+ val defaultService = s2Graph.DefaultService
+ 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", "knows")
+
+ Management.deleteService(defaultService.serviceName)
+ columnNames.foreach { columnName =>
+ Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+ }
+ labelNames.foreach { labelName =>
+ Management.deleteLabel(labelName)
+ }
+ }
+
override def loadGraphData(graph: Graph, loadGraphWith: LoadGraphWith, testClass: Class[_], testName: String): Unit = {
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
@@ -74,14 +94,17 @@ class S2GraphProvider extends AbstractGraphProvider {
var knowsProp = Vector(
Prop("weight", "0.0", "double"),
Prop("data", "-", "string"),
- Prop("year", "-1", "integer"),
+ Prop("year", "0", "integer"),
Prop("boolean", "false", "boolean"),
Prop("float", "0.0", "float"),
Prop("double", "0.0", "double"),
Prop("long", "0.0", "long"),
Prop("string", "-", "string"),
- Prop("integer", "-", "integer"),
- Prop("aKey", "-", "string")
+ Prop("integer", "0", "integer"),
+ Prop("aKey", "-", "string"),
+ Prop("stars", "0", "integer"),
+ Prop("since", "0", "integer"),
+ Prop("myEdgeId", "0", "integer")
)
// Change dataType for ColumnMeta('aKey') for PropertyFeatureSupportTest
@@ -115,12 +138,15 @@ class S2GraphProvider extends AbstractGraphProvider {
}
// knows props
- if (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}"""))
+
+ 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": true}"""))
+ 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": true}"""))
+ 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")))
@@ -186,6 +212,21 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Nil, "weak", 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, "weak", 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,
+ 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,
+ options = Option("""{"skipReverse": false}""")
+ )
super.loadGraphData(graph, loadGraphWith, testClass, testName)
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9ce28472/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 e69004c..28a16d3 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
@@ -24,7 +24,7 @@ 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.{Edge, T, Vertex}
+import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, T, Vertex}
import org.scalatest.{FunSuite, Matchers}
@@ -181,7 +181,59 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
// logger.error(x)
}
- test("addVertex with empty parameter") {
+// test("addVertex with empty parameter") {
+//
+// }
+ test("aaa") {
+ val mnt = graph.management
+ 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")
+
+ Management.deleteService(defaultService.serviceName)
+ columnNames.foreach { columnName =>
+ Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+ }
+ labelNames.foreach { labelName =>
+ Management.deleteLabel(labelName)
+ }
+
+ 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,
+ 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,
+ 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,
+ 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,
+ 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")
+ )
}
}
\ No newline at end of file
[02/46] incubator-s2graph git commit: - define initial version of
features. - setup gremlin-test environment.
Posted by st...@apache.org.
- define initial version of features.
- setup gremlin-test environment.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/d05d8a49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/d05d8a49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/d05d8a49
Branch: refs/heads/master
Commit: d05d8a49d6baeba5f6a0fe5c29d7b0338c839c11
Parents: b91b839
Author: DO YUNG YOON <st...@apache.org>
Authored: Sun Jan 15 01:09:19 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sun Jan 15 01:09:52 2017 +0900
----------------------------------------------------------------------
s2core/build.sbt | 4 +-
.../org/apache/s2graph/core/JSONParser.scala | 10 +-
.../org/apache/s2graph/core/Management.scala | 37 ++-
.../scala/org/apache/s2graph/core/S2Edge.scala | 101 +++++---
.../scala/org/apache/s2graph/core/S2Graph.scala | 253 ++++++++++++++++---
.../org/apache/s2graph/core/S2Property.scala | 60 ++++-
.../org/apache/s2graph/core/S2Vertex.scala | 107 ++++++--
.../apache/s2graph/core/S2VertexProperty.scala | 27 +-
.../core/features/S2DataTypeFeatures.scala | 43 ++++
.../s2graph/core/features/S2EdgeFeatures.scala | 11 +
.../core/features/S2EdgePropertyFeatures.scala | 7 +
.../core/features/S2ElementFeatures.scala | 23 ++
.../s2graph/core/features/S2GraphFeatures.scala | 19 ++
.../core/features/S2PropertyFeatures.scala | 7 +
.../core/features/S2VariableFeatures.scala | 7 +
.../s2graph/core/features/S2Variables.scala | 6 +
.../core/features/S2VertexFeatures.scala | 18 ++
.../features/S2VertexPropertyFeatures.scala | 24 ++
.../apache/s2graph/core/mysqls/ColumnMeta.scala | 24 +-
.../apache/s2graph/core/mysqls/LabelMeta.scala | 1 +
.../org/apache/s2graph/core/mysqls/Model.scala | 59 ++++-
.../apache/s2graph/core/mysqls/Service.scala | 4 +-
.../s2graph/core/mysqls/ServiceColumn.scala | 17 +-
.../apache/s2graph/core/storage/Storage.scala | 8 +-
.../core/storage/hbase/AsynchbaseStorage.scala | 87 ++++++-
.../tall/IndexEdgeDeserializable.scala | 14 +-
.../wide/IndexEdgeDeserializable.scala | 14 +-
.../apache/s2graph/core/types/VertexId.scala | 8 +-
.../s2graph/core/utils/SafeUpdateCache.scala | 2 +
.../core/Integrate/tinkerpop/S2GraphTest.scala | 130 ----------
.../s2graph/core/tinkerpop/S2GraphData.scala | 12 +
.../core/tinkerpop/S2GraphProvider.scala | 220 ++++++++++++++++
.../S2GraphStructureIntegrateTest.scala | 13 +
.../S2GraphStructureStandardTest.scala | 16 ++
.../core/tinkerpop/structure/S2GraphTest.scala | 187 ++++++++++++++
.../counter/core/RankingCounterSpec.scala | 2 +-
scalastyle-config.xml | 117 ---------
37 files changed, 1290 insertions(+), 409 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/build.sbt
----------------------------------------------------------------------
diff --git a/s2core/build.sbt b/s2core/build.sbt
index 6434acc..9ea975c 100644
--- a/s2core/build.sbt
+++ b/s2core/build.sbt
@@ -43,8 +43,10 @@ libraryDependencies ++= Seq(
"org.hbase" % "asynchbase" % "1.7.2" excludeLogging(),
"net.bytebuddy" % "byte-buddy" % "1.4.26",
"org.apache.tinkerpop" % "gremlin-core" % tinkerpopVersion,
+ "org.apache.tinkerpop" % "gremlin-test" % tinkerpopVersion % "test",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
- "org.specs2" %% "specs2-core" % specs2Version % "test"
+ "org.specs2" %% "specs2-core" % specs2Version % "test",
+ "mysql" % "mysql-connector-java" % "5.1.40"
)
libraryDependencies := {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
index 2effaf1..9d10dc7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
@@ -180,35 +180,43 @@ object JSONParser {
val dType = InnerVal.toInnerDataType(dataType)
val isNumeric = isNumericType(dType)
any match {
+ case a: InnerValLike => a
case n: BigDecimal =>
if (isNumeric) InnerVal.withNumber(n, version)
else if (dType == InnerVal.STRING) InnerVal.withStr(n.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = BigDecimal, [DataType]: $dataType, [Input]: $any")
case l: Long =>
if (isNumeric) InnerVal.withLong(l, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(l.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Long, [DataType]: $dataType, [Input]: $any")
case i: Int =>
if (isNumeric) InnerVal.withInt(i, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(i.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Int, [DataType]: $dataType, [Input]: $any")
case sh: Short =>
if (isNumeric) InnerVal.withInt(sh.toInt, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(sh.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Short, [DataType]: $dataType, [Input]: $any")
case b: Byte =>
if (isNumeric) InnerVal.withInt(b.toInt, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(b.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Byte, [DataType]: $dataType, [Input]: $any")
case f: Float =>
if (isNumeric) InnerVal.withFloat(f, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(f.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Float, [DataType]: $dataType, [Input]: $any")
case d: Double =>
if (isNumeric) InnerVal.withDouble(d, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(d.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Double, [DataType]: $dataType, [Input]: $any")
case bl: Boolean =>
if (dType == InnerVal.BOOLEAN) InnerVal.withBoolean(bl, version)
+ else if (dType == InnerVal.STRING) InnerVal.withStr(bl.toString, version)
else throw new IllegalDataTypeException(s"[ValueType] = Boolean, [DataType]: $dataType, [Input]: $any")
case _s: String =>
if (isNumeric) {
try {
- val s = TemplateHelper.replaceVariable(System.currentTimeMillis(), _s)
+ val s = TemplateHelper.replaceVariable(System.currentTimeMillis(), _s.toString)
InnerVal.withNumber(BigDecimal(s), version)
} catch {
case e: Exception =>
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/Management.scala b/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
index 064a3d1..63a1727 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
@@ -77,15 +77,15 @@ object Management {
schemaVersion: String = DEFAULT_VERSION) = {
Model withTx { implicit session =>
- val serviceOpt = Service.findByName(serviceName)
+ val serviceOpt = Service.findByName(serviceName, useCache = false)
serviceOpt match {
case None => throw new RuntimeException(s"create service $serviceName has not been created.")
case Some(service) =>
- val serviceColumn = ServiceColumn.findOrInsert(service.id.get, columnName, Some(columnType), schemaVersion)
+ val serviceColumn = ServiceColumn.findOrInsert(service.id.get, columnName, Some(columnType), schemaVersion, useCache = false)
for {
Prop(propName, defaultValue, dataType) <- props
} yield {
- ColumnMeta.findOrInsert(serviceColumn.id.get, propName, dataType)
+ ColumnMeta.findOrInsert(serviceColumn.id.get, propName, dataType, useCache = false)
}
}
}
@@ -278,7 +278,7 @@ class Management(graph: S2Graph) {
compressionAlgorithm: String = DefaultCompressionAlgorithm): Try[Service] = {
Model withTx { implicit session =>
- val service = Service.findOrInsert(serviceName, cluster, hTableName, preSplitSize, hTableTTL.orElse(Some(Integer.MAX_VALUE)), compressionAlgorithm)
+ val service = Service.findOrInsert(serviceName, cluster, hTableName, preSplitSize, hTableTTL.orElse(Some(Integer.MAX_VALUE)), compressionAlgorithm, useCache = false)
/** create hbase table for service */
graph.getStorage(service).createTable(service.cluster, service.hTableName, List("e", "v"), service.preSplitSize, service.hTableTTL, compressionAlgorithm)
service
@@ -297,13 +297,13 @@ class Management(graph: S2Graph) {
serviceName: String,
indices: Seq[Index],
props: Seq[Prop],
- consistencyLevel: String,
- hTableName: Option[String],
- hTableTTL: Option[Int],
+ consistencyLevel: String = "weak",
+ hTableName: Option[String] = None,
+ hTableTTL: Option[Int] = None,
schemaVersion: String = DEFAULT_VERSION,
- isAsync: Boolean,
+ isAsync: Boolean = false,
compressionAlgorithm: String = "gz",
- options: Option[String]): Try[Label] = {
+ options: Option[String] = None): Try[Label] = {
if (label.length > LABEL_NAME_MAX_LENGTH ) throw new LabelNameTooLongException(s"Label name ${label} too long.( max length : ${LABEL_NAME_MAX_LENGTH}} )")
if (hTableName.isEmpty && hTableTTL.isDefined) throw new RuntimeException("if want to specify ttl, give hbaseTableName also")
@@ -355,5 +355,24 @@ class Management(graph: S2Graph) {
storage.info
}
+ def truncateStorage(labelName: String): Unit = {
+ Try(Label.findByName(labelName, useCache = false)).map { labelOpt =>
+ labelOpt.map { label =>
+ val storage = graph.getStorage(label)
+ val zkAddr = label.service.cluster
+ storage.truncateTable(zkAddr, label.hbaseTableName)
+ }
+ }
+ }
+
+ def deleteStorage(labelName: String): Unit = {
+ Try(Label.findByName(labelName, useCache = false)).map { labelOpt =>
+ labelOpt.map { label =>
+ val storage = graph.getStorage(label)
+ val zkAddr = label.service.cluster
+ storage.deleteTable(zkAddr, label.hbaseTableName)
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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 7859218..e953718 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -22,17 +22,18 @@ package org.apache.s2graph.core
import java.util
import java.util.function.{Consumer, BiConsumer}
-import org.apache.s2graph.core.S2Edge.{Props, State}
+import org.apache.s2graph.core.S2Edge.{State, Props}
import org.apache.s2graph.core.JSONParser._
-import org.apache.s2graph.core.mysqls.{Label, LabelIndex, LabelMeta}
+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.{Edge, Graph, Vertex, Direction, Property}
-import play.api.libs.json.{JsNumber, JsObject, Json}
-
+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 scala.collection.JavaConverters._
import scala.collection.mutable.{Map => MutableMap}
+import scala.concurrent.Await
import scala.util.hashing.MurmurHash3
object SnapshotEdge {
@@ -423,21 +424,28 @@ case class S2Edge(innerGraph: S2Graph,
// def relatedEdges = List(this)
+ private def getServiceColumn(vertex: S2Vertex, defaultServiceColumn: ServiceColumn) =
+ if (vertex.id.column == ServiceColumn.Default) defaultServiceColumn else vertex.id.column
+
def srcForVertex = {
val belongLabelIds = Seq(labelWithDir.labelId)
if (labelWithDir.dir == GraphUtil.directions("in")) {
- innerGraph.newVertex(VertexId(innerLabel.tgtColumn, tgtVertex.innerId), tgtVertex.ts, tgtVertex.props, belongLabelIds = belongLabelIds)
+ val tgtColumn = getServiceColumn(tgtVertex, innerLabel.tgtColumn)
+ innerGraph.newVertex(VertexId(tgtColumn, tgtVertex.innerId), tgtVertex.ts, tgtVertex.props, belongLabelIds = belongLabelIds)
} else {
- innerGraph.newVertex(VertexId(innerLabel.srcColumn, srcVertex.innerId), srcVertex.ts, srcVertex.props, belongLabelIds = belongLabelIds)
+ val srcColumn = getServiceColumn(srcVertex, innerLabel.srcColumn)
+ innerGraph.newVertex(VertexId(srcColumn, srcVertex.innerId), srcVertex.ts, srcVertex.props, belongLabelIds = belongLabelIds)
}
}
def tgtForVertex = {
val belongLabelIds = Seq(labelWithDir.labelId)
if (labelWithDir.dir == GraphUtil.directions("in")) {
- innerGraph.newVertex(VertexId(innerLabel.srcColumn, srcVertex.innerId), srcVertex.ts, srcVertex.props, belongLabelIds = belongLabelIds)
+ val srcColumn = getServiceColumn(srcVertex, innerLabel.srcColumn)
+ innerGraph.newVertex(VertexId(srcColumn, srcVertex.innerId), srcVertex.ts, srcVertex.props, belongLabelIds = belongLabelIds)
} else {
- innerGraph.newVertex(VertexId(innerLabel.tgtColumn, tgtVertex.innerId), tgtVertex.ts, tgtVertex.props, belongLabelIds = belongLabelIds)
+ val tgtColumn = getServiceColumn(tgtVertex, innerLabel.tgtColumn)
+ innerGraph.newVertex(VertexId(tgtColumn, tgtVertex.innerId), tgtVertex.ts, tgtVertex.props, belongLabelIds = belongLabelIds)
}
}
@@ -481,7 +489,7 @@ case class S2Edge(innerGraph: S2Graph,
// val newLabelWithDir = LabelWithDirection(labelWithDir.labelId, GraphUtil.directions("out"))
- property(LabelMeta.timestamp.name, ts, ts)
+ propertyInner(LabelMeta.timestamp.name, ts, ts)
val ret = SnapshotEdge(innerGraph, smaller, larger, innerLabel,
GraphUtil.directions("out"), op, version, propsWithTs,
pendingEdgeOpt = pendingEdgeOpt, statusCode = statusCode, lockTs = lockTs, tsInnerValOpt = tsInnerValOpt)
@@ -534,15 +542,20 @@ case class S2Edge(innerGraph: S2Graph,
}
override def equals(other: Any): Boolean = other match {
- case e: Edge => e.id().equals(e.id())
+ case e: Edge => id().equals(e.id())
case _ => false
}
- override def toString(): String = {
- Map("srcVertex" -> srcVertex.toString, "tgtVertex" -> tgtVertex.toString, "label" -> labelName, "direction" -> direction,
- "operation" -> operation, "version" -> version, "props" -> propsWithTs.asScala.map(kv => kv._1 -> kv._2.value).toString,
- "parentEdges" -> parentEdges, "originalEdge" -> originalEdgeOpt, "statusCode" -> statusCode, "lockTs" -> lockTs
- ).toString
+// override def toString(): String = {
+// Map("srcVertex" -> srcVertex.toString, "tgtVertex" -> tgtVertex.toString, "label" -> labelName, "direction" -> direction,
+// "operation" -> operation, "version" -> version, "props" -> propsWithTs.asScala.map(kv => kv._1 -> kv._2.value).toString,
+// "parentEdges" -> parentEdges, "originalEdge" -> originalEdgeOpt, "statusCode" -> statusCode, "lockTs" -> lockTs
+// ).toString
+// }
+
+ override def toString: String = {
+ // E + L_BRACKET + edge.id() + R_BRACKET + L_BRACKET + edge.outVertex().id() + DASH + edge.label() + ARROW + edge.inVertex().id() + R_BRACKET;
+ s"e[${id}][${srcForVertex.id}-${innerLabel.label}->${tgtForVertex.id}]"
}
def checkProperty(key: String): Boolean = propsWithTs.containsKey(key)
@@ -564,14 +577,14 @@ case class S2Edge(innerGraph: S2Graph,
val edge = new S2Edge(innerGraph, srcVertex, tgtVertex, innerLabel, dir, op, version, S2Edge.EmptyProps,
parentEdges, originalEdgeOpt, pendingEdgeOpt, statusCode, lockTs, tsInnerValOpt)
S2Edge.fillPropsWithTs(edge, propsWithTs)
- edge.property(LabelMeta.timestamp.name, ts, ts)
+ edge.propertyInner(LabelMeta.timestamp.name, ts, ts)
edge
}
def copyEdgeWithState(state: State, ts: Long): S2Edge = {
val newEdge = copy(propsWithTs = S2Edge.EmptyProps)
S2Edge.fillPropsWithTs(newEdge, state)
- newEdge.property(LabelMeta.timestamp.name, ts, ts)
+ newEdge.propertyInner(LabelMeta.timestamp.name, ts, ts)
newEdge
}
@@ -584,8 +597,14 @@ case class S2Edge(innerGraph: S2Graph,
override def vertices(direction: Direction): util.Iterator[structure.Vertex] = {
val arr = new util.ArrayList[Vertex]()
direction match {
- case Direction.OUT => arr.add(srcVertex)
- case Direction.IN => arr.add(tgtVertex)
+ case Direction.OUT =>
+ val newVertexId = VertexId(ServiceColumn.findById(srcForVertex.id.colId), srcForVertex.innerId)
+ arr.add(srcVertex.copy(id = newVertexId))
+// arr.add(srcVertex)
+ case Direction.IN =>
+ val newVertexId = VertexId(ServiceColumn.findById(tgtForVertex.id.colId), tgtForVertex.innerId)
+ arr.add(tgtVertex.copy(id = newVertexId))
+// arr.add(tgtVertex)
case _ =>
arr.add(srcVertex)
arr.add(tgtVertex)
@@ -600,35 +619,57 @@ case class S2Edge(innerGraph: S2Graph,
}
override def property[V](key: String): Property[V] = {
- val labelMeta = innerLabel.metaPropsInvMap.getOrElse(key, throw new RuntimeException(s"$key is not configured on Edge."))
+ val labelMeta = innerLabel.metaPropsInvMap.getOrElse(key, throw new java.lang.IllegalStateException(s"$key is not configured on Edge."))
if (propsWithTs.containsKey(key)) propsWithTs.get(key).asInstanceOf[Property[V]]
else {
val default = innerLabel.metaPropsDefaultMapInner(labelMeta)
- property(key, default.innerVal.value, default.ts).asInstanceOf[Property[V]]
+ propertyInner(key, default.innerVal.value, default.ts).asInstanceOf[Property[V]]
}
}
+ // just for tinkerpop: save to storage, do not use for internal
override def property[V](key: String, value: V): Property[V] = {
- property(key, value, System.currentTimeMillis())
+ S2Property.assertValidProp(key, value)
+
+ val v = propertyInner(key, value, System.currentTimeMillis())
+ val newTs = props.get(LabelMeta.timestamp.name).map(_.toString.toLong + 1).getOrElse(System.currentTimeMillis())
+ val newEdge = this.copyEdge(ts = newTs)
+
+ Await.result(innerGraph.mutateEdges(Seq(newEdge), withWait = true), innerGraph.WaitTimeout)
+
+ v
}
- def property[V](key: String, value: V, ts: Long): Property[V] = {
+ def propertyInner[V](key: String, value: V, ts: Long): Property[V] = {
val labelMeta = innerLabel.metaPropsInvMap.getOrElse(key, throw new RuntimeException(s"$key is not configured on Edge."))
val newProp = new S2Property[V](this, labelMeta, key, value, ts)
propsWithTs.put(key, newProp)
newProp
}
- override def remove(): Unit = {}
+ override def remove(): Unit = {
+ if (graph.features().edge().supportsRemoveEdges()) {
+ // remove edge
+ } else {
+ throw Edge.Exceptions.edgeRemovalNotSupported()
+ }
+ }
override def graph(): Graph = innerGraph
- override def id(): AnyRef = EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), direction)
+ override def id(): AnyRef = {
+ // NOTE: xxxForVertex makes direction to be "out"
+ if (this.innerLabel.consistencyLevel == "strong") {
+ EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), "out", 0)
+ } else {
+ EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), "out", ts)
+ }
+ }
override def label(): String = innerLabel.label
}
-case class EdgeId(srcVertexId: InnerValLike, tgtVertexId: InnerValLike, labelName: String, direction: String)
+case class EdgeId(srcVertexId: InnerValLike, tgtVertexId: InnerValLike, labelName: String, direction: String, ts: Long)
object EdgeMutate {
@@ -724,7 +765,7 @@ object S2Edge {
state.foreach { case (k, v) => indexEdge.property(k.name, v.innerVal.value, v.ts) }
}
def fillPropsWithTs(edge: S2Edge, state: State): Unit = {
- state.foreach { case (k, v) => edge.property(k.name, v.innerVal.value, v.ts) }
+ state.foreach { case (k, v) => edge.propertyInner(k.name, v.innerVal.value, v.ts) }
}
def propsToState(props: Props): State = {
@@ -735,7 +776,7 @@ object S2Edge {
def stateToProps(edge: S2Edge, state: State): Props = {
state.foreach { case (k, v) =>
- edge.property(k.name, v.innerVal.value, v.ts)
+ edge.propertyInner(k.name, v.innerVal.value, v.ts)
}
edge.propsWithTs
}
@@ -878,7 +919,7 @@ object S2Edge {
propsWithTs = S2Edge.EmptyProps,
op = GraphUtil.defaultOpByte
)
- newPropsWithTs.foreach { case (k, v) => newEdge.property(k.name, v.innerVal.value, v.ts) }
+ newPropsWithTs.foreach { case (k, v) => newEdge.propertyInner(k.name, v.innerVal.value, v.ts) }
newEdge.relatedEdges.flatMap { relEdge => relEdge.edgesWithIndexValid }
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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 62e8098..bd6c45a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -20,10 +20,11 @@
package org.apache.s2graph.core
import java.util
+import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
import com.typesafe.config.{Config, ConfigFactory}
-import org.apache.commons.configuration.Configuration
+import org.apache.commons.configuration.{BaseConfiguration, Configuration}
import org.apache.s2graph.core.GraphExceptions.{FetchTimeoutException, LabelNotExistException}
import org.apache.s2graph.core.JSONParser._
import org.apache.s2graph.core.mysqls._
@@ -33,14 +34,16 @@ import org.apache.s2graph.core.types._
import org.apache.s2graph.core.utils.{DeferCache, Extensions, logger}
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer
import org.apache.tinkerpop.gremlin.structure
-import org.apache.tinkerpop.gremlin.structure.Graph.Variables
+import org.apache.tinkerpop.gremlin.structure.Graph.Features.EdgeFeatures
+import org.apache.tinkerpop.gremlin.structure.Graph.{Features, Variables}
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
-import org.apache.tinkerpop.gremlin.structure.{Edge, Graph, T, Transaction}
+import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, Property, T, Transaction, Vertex}
import play.api.libs.json.{JsObject, Json}
import scala.annotation.tailrec
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
+import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.concurrent._
import scala.concurrent.duration.Duration
@@ -52,7 +55,6 @@ object S2Graph {
type HashKey = (Int, Int, Int, Int, Boolean)
type FilterHashKey = (Int, Int)
-
val DefaultScore = 1.0
private val DefaultConfigs: Map[String, AnyRef] = Map(
@@ -60,8 +62,10 @@ object S2Graph {
"hbase.table.name" -> "s2graph",
"hbase.table.compression.algorithm" -> "gz",
"phase" -> "dev",
- "db.default.driver" -> "org.h2.Driver",
- "db.default.url" -> "jdbc:h2:file:./var/metastore;MODE=MYSQL",
+// "db.default.driver" -> "org.h2.Driver",
+// "db.default.url" -> "jdbc:h2:file:./var/metastore;MODE=MYSQL",
+ "db.default.driver" -> "com.mysql.jdbc.Driver",
+ "db.default.url" -> "jdbc:mysql://default:3306/graph_dev",
"db.default.password" -> "graph",
"db.default.user" -> "graph",
"cache.max.size" -> java.lang.Integer.valueOf(10000),
@@ -92,7 +96,34 @@ object S2Graph {
var DefaultConfig: Config = ConfigFactory.parseMap(DefaultConfigs)
+ def toTypeSafeConfig(configuration: Configuration): Config = {
+ val m = new mutable.HashMap[String, AnyRef]()
+ for {
+ key <- configuration.getKeys
+ value = configuration.getProperty(key)
+ } {
+ m.put(key, value)
+ }
+ val config = ConfigFactory.parseMap(m).withFallback(DefaultConfig)
+ config
+ }
+ def fromTypeSafeConfig(config: Config): Configuration = {
+ val configuration = new BaseConfiguration()
+ for {
+ e <- config.entrySet()
+ } {
+ configuration.setProperty(e.getKey, e.getValue.unwrapped())
+ }
+ configuration
+ }
+
+ def open(configuration: Configuration): S2Graph = {
+ val numOfThread = Runtime.getRuntime.availableProcessors()
+ val threadPool = Executors.newFixedThreadPool(numOfThread)
+ val ec = ExecutionContext.fromExecutor(threadPool)
+ new S2Graph(configuration)(ec)
+ }
def initStorage(graph: S2Graph, config: Config)(ec: ExecutionContext): Storage[_, _] = {
val storageBackend = config.getString("s2graph.storage.backend")
@@ -497,13 +528,62 @@ object S2Graph {
}
results
}
-
}
+@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
+@Graph.OptOuts(value = Array(
+// passed
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
+ 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.GraphConstructionTest", method="*", reason="no"), // pass
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"), // pass one error
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"), // pass all ignored
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"), // pass
+
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"), // pass
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"), // pass
+
+ // not yet supported
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.TransactionTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"),
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="*", reason="no"),
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest", method="*", reason="no"),
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGeneratorTest", method="*", reason="no")
+))
class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph {
import S2Graph._
+ private var apacheConfiguration: Configuration = _
+
+ def this(apacheConfiguration: Configuration)(ec: ExecutionContext) = {
+ this(S2Graph.toTypeSafeConfig(apacheConfiguration))(ec)
+ this.apacheConfiguration = apacheConfiguration
+ }
+
+ private val running = new AtomicBoolean(true)
+
val config = _config.withFallback(S2Graph.DefaultConfig)
Model.apply(config)
@@ -522,6 +602,9 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
val WaitTimeout = Duration(60, TimeUnit.SECONDS)
val scheduledEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())
+ val management = new Management(this)
+ def getManagement() = management
+
private def confWithFallback(conf: Config): Config = {
conf.withFallback(config)
}
@@ -572,6 +655,32 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
(k, v) = (entry.getKey, entry.getValue)
} logger.info(s"[Initialized]: $k, ${this.config.getAnyRef(k)}")
+ /* TODO */
+ val DefaultService = management.createService("_s2graph", "localhost", "s2graph", 0, None).get
+ val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, "vertex", Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
+ val DefaultColumnMetas = {
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "name", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "age", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "long", "long", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "float", "float", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
+ }
+
+ val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
+ DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": true}""")
+ )
+
def getStorage(service: Service): Storage[_, _] = {
storagePool.getOrElse(s"service:${service.serviceName}", defaultStorage)
}
@@ -1052,10 +1161,14 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
storage.writeToStorage(edge.innerLabel.service.cluster, kvs, withWait = true)
}
- def shutdown(): Unit = {
- flushStorage()
- Model.shutdown()
- }
+ def isRunning(): Boolean = running.get()
+
+ def shutdown(modelDataDelete: Boolean = false): Unit =
+ if (running.compareAndSet(true, false)) {
+ flushStorage()
+ Model.shutdown(modelDataDelete)
+ defaultStorage.shutdown()
+ }
def toGraphElement(s: String, labelMapping: Map[String, String] = Map.empty): Option[GraphElement] = Try {
val parts = GraphUtil.split(s)
@@ -1144,11 +1257,15 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
ts: Long = System.currentTimeMillis(),
operation: String = "insert"): S2Vertex = {
- val service = Service.findByName(serviceName).getOrElse(throw new RuntimeException(s"$serviceName is not found."))
- val column = ServiceColumn.find(service.id.get, columnName).getOrElse(throw new RuntimeException(s"$columnName is not found."))
+ val service = Service.findByName(serviceName).getOrElse(throw new java.lang.IllegalArgumentException(s"$serviceName is not found."))
+ val column = ServiceColumn.find(service.id.get, columnName).getOrElse(throw new java.lang.IllegalArgumentException(s"$columnName is not found."))
val op = GraphUtil.toOp(operation).getOrElse(throw new RuntimeException(s"$operation is not supported."))
- val srcVertexId = VertexId(column, toInnerVal(id, column.columnType, column.schemaVersion))
+ val srcVertexId = id match {
+ case vid: VertexId => id.asInstanceOf[VertexId]
+ case _ => VertexId(column, toInnerVal(id, column.columnType, column.schemaVersion))
+ }
+
val propsInner = column.propsToInnerVals(props) ++
Map(ColumnMeta.timestamp -> InnerVal.withLong(ts, column.schemaVersion))
@@ -1196,8 +1313,21 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
statusCode: Byte = 0,
lockTs: Option[Long] = None,
tsInnerValOpt: Option[InnerValLike] = None): S2Edge = {
- val edge = new S2Edge(this, srcVertex, tgtVertex, innerLabel, dir, op, version, S2Edge.EmptyProps,
- parentEdges, originalEdgeOpt, pendingEdgeOpt, statusCode, lockTs, tsInnerValOpt)
+ val edge = S2Edge(
+ this,
+ srcVertex,
+ tgtVertex,
+ innerLabel,
+ dir,
+ op,
+ version,
+ S2Edge.EmptyProps,
+ parentEdges,
+ originalEdgeOpt,
+ pendingEdgeOpt,
+ statusCode,
+ lockTs,
+ tsInnerValOpt)
S2Edge.fillPropsWithTs(edge, propsWithTs)
edge
}
@@ -1356,9 +1486,26 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
//TODO: default storage need to be fixed.
Await.result(defaultStorage.fetchVerticesAll(), WaitTimeout).iterator
} else {
- val vertices = for {
- vertexId <- vertexIds if vertexId.isInstanceOf[VertexId]
- } yield newVertex(vertexId.asInstanceOf[VertexId])
+ val (vIds, stringIds) = vertexIds.partition(_.isInstanceOf[VertexId])
+ val verticesFromIds = vIds.map(vertexId => newVertex(vertexId.asInstanceOf[VertexId]))
+ val verticesFromString = stringIds.flatMap { vId =>
+ if (vId.toString.contains(S2Vertex.VertexLabelDelimiter)) {
+ val Array(serviceName, columnName, id) =
+ if (vId.toString.take(2).mkString("") == "v[") vId.toString.drop(2).init.split(S2Vertex.VertexLabelDelimiter)
+ else {
+ if (vId.toString.contains(S2Vertex.VertexLabelDelimiter)) {
+ vId.toString.split(S2Vertex.VertexLabelDelimiter)
+ } else {
+ Array(DefaultService.serviceName, DefaultColumn.columnName, vId.toString)
+ }
+ }
+
+ Seq(toVertex(serviceName, columnName, id))
+ } else {
+ Nil
+ }
+ }
+ val vertices = verticesFromIds ++ verticesFromString
if (fetchVertices) {
val future = getVertices(vertices).map { vs =>
@@ -1375,7 +1522,9 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
override def edges(edgeIds: AnyRef*): util.Iterator[structure.Edge] = {
if (edgeIds.isEmpty) {
- Await.result(defaultStorage.fetchEdgesAll(), WaitTimeout).iterator
+ // FIXME
+ val edges = Await.result(defaultStorage.fetchEdgesAll(), WaitTimeout).iterator
+ edges.filterNot(_.isDegree).filterNot(_.direction == "in")
} else {
Await.result(edgesAsync(edgeIds: _*), WaitTimeout)
}
@@ -1395,24 +1544,31 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
ls.iterator()
}
}
- override def tx(): Transaction = ???
-
-
+ override def tx(): Transaction = {
+ if (!features.graph.supportsTransactions) throw Graph.Exceptions.transactionsNotSupported
+ ???
+ }
override def variables(): Variables = ???
- override def configuration(): Configuration = ???
+ override def configuration(): Configuration = apacheConfiguration
override def addVertex(kvs: AnyRef*): structure.Vertex = {
- val kvsMap = ElementHelper.asMap(kvs: _*).asScala.toMap
- val id = kvsMap.getOrElse(T.id.toString, throw new RuntimeException("T.id is required."))
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, throw new RuntimeException("ServiceName::ColumnName is required.")).toString
+ if (!features().vertex().supportsUserSuppliedIds() && kvs.contains(T.id)) {
+ throw Vertex.Exceptions.userSuppliedIdsNotSupported
+ }
+ val kvsMap = S2Property.kvsToProps(kvs)
+ val id = kvsMap.getOrElse(T.id.toString, Random.nextLong)
+
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+
val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
- if (names.length != 2) throw new RuntimeException("malformed data on vertex label.")
- val serviceName = names(0)
- val columnName = names(1)
+ val (serviceName, columnName) =
+ if (names.length == 1) (DefaultService.serviceName, names(0))
+ else throw new RuntimeException("malformed data on vertex label.")
val vertex = toVertex(serviceName, columnName, id, kvsMap)
+
val future = mutateVertices(Seq(vertex), withWait = true).map { vs =>
if (vs.forall(identity)) vertex
else throw new RuntimeException("addVertex failed.")
@@ -1433,11 +1589,46 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
Await.result(future, WaitTimeout)
}
+ def addVertex(vertex: S2Vertex): S2Vertex = {
+ val future = mutateVertices(Seq(vertex), withWait = true).map { rets =>
+ if (rets.forall(identity)) vertex
+ else throw new RuntimeException("addVertex failed.")
+ }
+ Await.result(future, WaitTimeout)
+ }
+
override def close(): Unit = {
shutdown()
}
override def compute[C <: GraphComputer](aClass: Class[C]): C = ???
- override def compute(): GraphComputer = ???
+ override def compute(): GraphComputer = {
+ if (!features.graph.supportsComputer) {
+ throw Graph.Exceptions.graphComputerNotSupported
+ }
+ ???
+ }
+
+ class S2GraphFeatures extends Features {
+ import org.apache.s2graph.core.{features => FS}
+ override def edge(): Features.EdgeFeatures = new FS.S2EdgeFeatures
+
+ override def graph(): Features.GraphFeatures = new FS.S2GraphFeatures
+
+ override def supports(featureClass: Class[_ <: Features.FeatureSet], feature: String): Boolean =
+ super.supports(featureClass, feature)
+
+ override def vertex(): Features.VertexFeatures = new FS.S2VertexFeatures
+
+ override def toString: String = {
+ s"FEATURES:\nEdgeFeatures:${edge}\nGraphFeatures:${graph}\nVertexFeatures:${vertex}"
+ }
+ }
+
+ private val s2Features = new S2GraphFeatures
+
+ override def features() = s2Features
+
+ override def toString(): String = "[s2graph]"
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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 6a47e46..b5fc110 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
@@ -21,11 +21,51 @@ package org.apache.s2graph.core
import org.apache.s2graph.core.mysqls.LabelMeta
-import org.apache.s2graph.core.types.{InnerValLikeWithTs, CanInnerValLike}
-import org.apache.tinkerpop.gremlin.structure.{Property}
+import org.apache.s2graph.core.types.{CanInnerValLike, InnerValLikeWithTs}
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
+import org.apache.tinkerpop.gremlin.structure._
import scala.util.hashing.MurmurHash3
+object S2Property {
+ def kvsToProps(kvs: Seq[AnyRef]): Map[String, AnyRef] = {
+ import scala.collection.JavaConverters._
+
+ ElementHelper.legalPropertyKeyValueArray(kvs: _*)
+ val keySet = collection.mutable.Set[Any]()
+ val kvsList = ElementHelper.asPairs(kvs: _*).asScala
+ var result = Map[String, AnyRef]()
+ kvsList.foreach { pair =>
+ val key = pair.getValue0
+ val value = pair.getValue1
+ ElementHelper.validateProperty(key, value)
+ if (keySet.contains(key)) throw VertexProperty.Exceptions.multiPropertiesNotSupported
+
+ assertValidProp(key, value)
+
+ keySet.add(key)
+ result = result + (key -> value)
+ }
+
+ result
+ }
+
+ def assertValidProp[A](key: Any, value: A): Unit = {
+ if (key == null) throw Property.Exceptions.propertyKeyCanNotBeEmpty()
+ if (!key.isInstanceOf[String]) throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()
+
+ if (value == null) throw Property.Exceptions.propertyValueCanNotBeNull()
+ if (value.isInstanceOf[Iterable[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
+ if (value.isInstanceOf[Array[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
+ if (value.isInstanceOf[java.util.List[_]]) throw new java.lang.IllegalArgumentException("not supported data type")
+ if (value.isInstanceOf[java.util.Map[_, _]]) throw new java.lang.IllegalArgumentException("not supported data type")
+
+ if (key.toString.isEmpty) throw Property.Exceptions.propertyKeyCanNotBeEmpty()
+ if (Graph.Hidden.isHidden(key.toString)) throw Property.Exceptions.propertyKeyCanNotBeAHiddenKey(Graph.Hidden.hide(key.toString))
+
+ }
+}
case class S2Property[V](element: S2Edge,
labelMeta: LabelMeta,
@@ -47,24 +87,26 @@ case class S2Property[V](element: S2Edge,
innerValWithTs.bytes
}
- override def isPresent: Boolean = ???
+ @volatile var isRemoved = false
+
+ override def isPresent: Boolean = !isRemoved
- override def remove(): Unit = ???
+ override def remove(): Unit = isRemoved = true
override def hashCode(): Int = {
MurmurHash3.stringHash(labelMeta.labelId + "," + labelMeta.id.get + "," + key + "," + value + "," + ts)
}
override def equals(other: Any): Boolean = other match {
- case p: S2Property[_] =>
- labelMeta.labelId == p.labelMeta.labelId &&
- labelMeta.seq == p.labelMeta.seq &&
- key == p.key && value == p.value && ts == p.ts
+ case p: Property[_] =>
+ key == p.key() && v == p.value()
case _ => false
}
override def toString(): String = {
- Map("labelMeta" -> labelMeta.toString, "key" -> key, "value" -> value, "ts" -> ts).toString
+// Map("labelMeta" -> labelMeta.toString, "key" -> key, "value" -> value, "ts" -> ts).toString
+ // vp[name->marko]
+ s"p[${key}->${value}]"
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/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 7fd2ac4..afee5d9 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -20,15 +20,18 @@
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.GraphExceptions.LabelNotExistException
import org.apache.s2graph.core.S2Vertex.Props
-import org.apache.s2graph.core.mysqls.{ColumnMeta, LabelMeta, Service, ServiceColumn}
+import org.apache.s2graph.core.mysqls._
import org.apache.s2graph.core.types._
+import org.apache.tinkerpop.gremlin.structure.Edge.Exceptions
+import org.apache.tinkerpop.gremlin.structure.Graph.Features.{ElementFeatures, VertexFeatures}
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
-import org.apache.tinkerpop.gremlin.structure.{Direction, Vertex, Edge, VertexProperty}
+import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Property, T, Vertex, VertexProperty}
import play.api.libs.json.Json
+
import scala.collection.JavaConverters._
case class S2Vertex(graph: S2Graph,
@@ -86,7 +89,7 @@ case class S2Vertex(graph: S2Graph,
override def equals(obj: Any) = {
obj match {
- case otherVertex: S2Vertex =>
+ case otherVertex: Vertex =>
val ret = id == otherVertex.id
// logger.debug(s"Vertex.equals: $this, $obj => $ret")
ret
@@ -95,7 +98,9 @@ case class S2Vertex(graph: S2Graph,
}
override def toString(): String = {
- Map("id" -> id.toString(), "ts" -> ts, "props" -> "", "op" -> op, "belongLabelIds" -> belongLabelIds).toString()
+ // V + L_BRACKET + vertex.id() + R_BRACKET;
+ // v[VertexId(1, 1481694411514)]
+ s"v[${id}]"
}
def toLogString(): String = {
@@ -132,50 +137,111 @@ case class S2Vertex(graph: S2Graph,
}
override def edges(direction: Direction, labelNames: String*): util.Iterator[Edge] = {
- graph.fetchEdges(this, labelNames, direction.name())
+ val labelNameList = {
+ 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)
+ } else {
+ labelNames
+ }
+ }
+ graph.fetchEdges(this, labelNameList, direction.name())
+ }
+
+ // do no save to storage
+ def propertyInner[V](cardinality: Cardinality, key: String, value: V, objects: AnyRef*): VertexProperty[V] = {
+ S2Property.assertValidProp(key, value)
+
+ cardinality match {
+ case Cardinality.single =>
+ val columnMeta = serviceColumn.metasInvMap.getOrElse(key, throw new RuntimeException(s"$key is not configured on Vertex."))
+ val newProps = new S2VertexProperty[V](this, columnMeta, key, value)
+ props.put(key, newProps)
+ newProps
+ case _ => throw new RuntimeException("only single cardinality is supported.")
+ }
}
override def property[V](cardinality: Cardinality, key: String, value: V, objects: AnyRef*): VertexProperty[V] = {
+ S2Property.assertValidProp(key, value)
+
cardinality match {
case Cardinality.single =>
val columnMeta = serviceColumn.metasInvMap.getOrElse(key, throw new RuntimeException(s"$key is not configured on Vertex."))
val newProps = new S2VertexProperty[V](this, columnMeta, key, value)
props.put(key, newProps)
+
+ // FIXME: save to persistent for tp test
+ graph.addVertex(this)
newProps
case _ => throw new RuntimeException("only single cardinality is supported.")
}
}
- override def addEdge(label: String, vertex: Vertex, kvs: AnyRef*): S2Edge = {
+ override def addEdge(label: String, vertex: Vertex, kvs: AnyRef*): Edge = {
vertex match {
case otherV: S2Vertex =>
- val props = ElementHelper.asMap(kvs: _*).asScala.toMap
+ if (!graph.features().edge().supportsUserSuppliedIds() && kvs.contains(T.id)) {
+ throw Exceptions.userSuppliedIdsNotSupported()
+ }
+
+ val props = S2Property.kvsToProps(kvs)
+
//TODO: direction, operation, _timestamp need to be reserved property key.
val direction = props.get("direction").getOrElse("out").toString
val ts = props.get(LabelMeta.timestamp.name).map(_.toString.toLong).getOrElse(System.currentTimeMillis())
val operation = props.get("operation").map(_.toString).getOrElse("insert")
- graph.addEdgeInner(this, otherV, label, direction, props, ts, operation)
+ try {
+ graph.addEdgeInner(this, otherV, label, direction, props, ts, operation)
+ } catch {
+ case e: LabelNotExistException => throw new java.lang.IllegalArgumentException
+ }
+ case null => throw new java.lang.IllegalArgumentException
case _ => throw new RuntimeException("only S2Graph vertex can be used.")
}
}
override def property[V](key: String): VertexProperty[V] = {
- props.get(key).asInstanceOf[S2VertexProperty[V]]
+ if (props.containsKey(key)) {
+ props.get(key).asInstanceOf[S2VertexProperty[V]]
+ } else {
+ VertexProperty.empty()
+ }
}
override def properties[V](keys: String*): util.Iterator[VertexProperty[V]] = {
- val ls = for {
- key <- keys
- } yield {
- property[V](key)
+ val ls = new util.ArrayList[VertexProperty[V]]()
+ if (keys.isEmpty) {
+ props.keySet().forEach(new Consumer[String] {
+ override def accept(key: String): Unit = {
+ if (!ColumnMeta.reservedMetaNamesSet(key)) ls.add(property[V](key))
+ }
+ })
+ } else {
+ keys.foreach { key => ls.add(property[V](key)) }
}
- ls.iterator.asJava
+ ls.iterator
}
- override def remove(): Unit = ???
+ override def label(): String = {
+ serviceColumn.columnName
+// if (serviceColumn.columnName == Vertex.DEFAULT_LABEL) Vertex.DEFAULT_LABEL // TP3 default vertex label name
+// else {
+// service.serviceName + S2Vertex.VertexLabelDelimiter + serviceColumn.columnName
+// }
+ }
- override def label(): String = service.serviceName + S2Vertex.VertexLabelDelimiter + serviceColumn.columnName
+ override def remove(): Unit = {
+ if (graph.features().vertex().supportsRemoveVertices()) {
+ // remove edge
+ } else {
+ throw Vertex.Exceptions.vertexRemovalNotSupported()
+ }
+ }
}
object S2Vertex {
@@ -196,13 +262,14 @@ object S2Vertex {
def fillPropsWithTs(vertex: S2Vertex, props: Props): Unit = {
props.forEach(new BiConsumer[String, S2VertexProperty[_]] {
override def accept(key: String, p: S2VertexProperty[_]): Unit = {
- vertex.property(Cardinality.single, key, p.value)
+// vertex.property(Cardinality.single, key, p.value)
+ vertex.propertyInner(Cardinality.single, key, p.value)
}
})
}
def fillPropsWithTs(vertex: S2Vertex, state: State): Unit = {
- state.foreach { case (k, v) => vertex.property(Cardinality.single, k.name, v.value) }
+ state.foreach { case (k, v) => vertex.propertyInner(Cardinality.single, k.name, v.value) }
}
def propsToState(props: Props): State = {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
index 9f8c682..c5258fb 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
@@ -27,6 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.{Property, VertexProperty, Vertex
import scala.util.hashing.MurmurHash3
+case class S2VertexPropertyId[V](columnMeta: ColumnMeta, value: V)
+
case class S2VertexProperty[V](element: S2Vertex,
columnMeta: ColumnMeta,
key: String,
@@ -42,27 +44,32 @@ case class S2VertexProperty[V](element: S2Vertex,
override def properties[U](strings: String*): util.Iterator[Property[U]] = ???
- override def property[V](key: String, value: V): Property[V] = ???
+ override def property[A](key: String, value: A): Property[A] = ???
+
+ override def remove(): Unit = {
+ if (!element.graph.features.vertex.properties.supportsRemoveProperty) {
+ throw Property.Exceptions.propertyRemovalNotSupported
+ }
+ isRemoved = true
+ }
- override def remove(): Unit = ???
+ override def id(): AnyRef = S2VertexPropertyId(columnMeta, v)
- override def id(): AnyRef = ???
+ @volatile var isRemoved = false
- override def isPresent: Boolean = ???
+ override def isPresent: Boolean = !isRemoved
override def hashCode(): Int = {
- MurmurHash3.stringHash(columnMeta.columnId + "," + columnMeta.id.get + "," + key + "," + value)
+ (element, id()).hashCode()
}
override def equals(other: Any): Boolean = other match {
- case p: S2VertexProperty[_] =>
- columnMeta.columnId == p.columnMeta.columnId &&
- columnMeta.seq == p.columnMeta.seq &&
- key == p.key && value == p.value
+ case p: VertexProperty[_] => element == p.element && id() == p.id()
case _ => false
}
override def toString(): String = {
- Map("columnMeta" -> columnMeta.toString, "key" -> key, "value" -> value).toString
+// Map("columnMeta" -> columnMeta.toString, "key" -> key, "value" -> value).toString
+ s"vp[${key}->${value}]"
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
new file mode 100644
index 0000000..a79da46
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
@@ -0,0 +1,43 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+case class S2DataTypeFeatures() extends Features.DataTypeFeatures {
+
+ override def supportsStringValues(): Boolean = true
+
+ override def supportsFloatValues(): Boolean = true
+
+ override def supportsDoubleValues(): Boolean = true
+
+ override def supportsIntegerValues(): Boolean = true
+
+ override def supportsLongValues(): Boolean = true
+
+ override def supportsBooleanValues(): Boolean = true
+
+ override def supportsDoubleArrayValues(): Boolean = false
+
+ override def supportsStringArrayValues(): Boolean = false
+
+ override def supportsIntegerArrayValues(): Boolean = false
+
+ override def supportsByteValues(): Boolean = false
+
+ override def supportsUniformListValues(): Boolean = false
+
+ override def supportsMapValues(): Boolean = false
+
+ override def supportsBooleanArrayValues(): Boolean = false
+
+ override def supportsSerializableValues(): Boolean = true
+
+ override def supportsLongArrayValues(): Boolean = false
+
+ override def supportsMixedListValues(): Boolean = false
+
+ override def supportsFloatArrayValues(): Boolean = false
+
+ override def supportsByteArrayValues(): Boolean = false
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
new file mode 100644
index 0000000..825b333
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
@@ -0,0 +1,11 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+class S2EdgeFeatures extends S2ElementFeatures with Features.EdgeFeatures {
+ override def supportsRemoveEdges(): Boolean = true
+
+ override def supportsAddEdges(): Boolean = true
+
+ override def properties(): Features.EdgePropertyFeatures = new S2EdgePropertyFeatures
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
new file mode 100644
index 0000000..556bbdc
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
@@ -0,0 +1,7 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+class S2EdgePropertyFeatures extends S2PropertyFeatures with Features.EdgePropertyFeatures {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
new file mode 100644
index 0000000..bbb6a79
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
@@ -0,0 +1,23 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+abstract class S2ElementFeatures extends Features.ElementFeatures {
+ override def supportsStringIds(): Boolean = true
+
+ override def supportsCustomIds(): Boolean = false
+
+ override def supportsUuidIds(): Boolean = false
+
+ override def supportsAddProperty(): Boolean = true
+
+ override def supportsRemoveProperty(): Boolean = true
+
+ override def supportsUserSuppliedIds(): Boolean = true
+
+ override def supportsAnyIds(): Boolean = false
+
+ override def supportsNumericIds(): Boolean = false
+
+// override def willAllowId(id: scala.Any): Boolean = super.willAllowId(id)
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
new file mode 100644
index 0000000..e9aa247
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
@@ -0,0 +1,19 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+import org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeatures
+
+
+class S2GraphFeatures extends GraphFeatures {
+ override def supportsComputer(): Boolean = false
+
+ override def supportsThreadedTransactions(): Boolean = false
+
+ override def supportsTransactions(): Boolean = false
+
+ override def supportsPersistence(): Boolean = true
+
+ override def variables(): Features.VariableFeatures = super.variables()
+
+ override def supportsConcurrentAccess(): Boolean = false
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
new file mode 100644
index 0000000..cf3316f
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
@@ -0,0 +1,7 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+class S2PropertyFeatures extends S2DataTypeFeatures with Features.PropertyFeatures {
+ override def supportsProperties(): Boolean = true
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
new file mode 100644
index 0000000..6cbf129
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
@@ -0,0 +1,7 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+class S2VariableFeatures extends S2DataTypeFeatures with Features.VariableFeatures {
+ override def supportsVariables(): Boolean = false
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
new file mode 100644
index 0000000..8a9c42b
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
@@ -0,0 +1,6 @@
+package org.apache.s2graph.core.features
+
+
+class S2Variables {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
new file mode 100644
index 0000000..14024fd
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
@@ -0,0 +1,18 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality
+
+class S2VertexFeatures extends S2ElementFeatures with Features.VertexFeatures {
+ override def supportsAddVertices(): Boolean = true
+
+ override def supportsRemoveVertices(): Boolean = true
+
+ override def getCardinality(key: String): Cardinality = Cardinality.single
+
+ override def supportsMultiProperties(): Boolean = false
+
+ override def supportsMetaProperties(): Boolean = false
+
+ override def properties(): Features.VertexPropertyFeatures = new S2VertexPropertyFeatures()
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
new file mode 100644
index 0000000..592cc0b
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
@@ -0,0 +1,24 @@
+package org.apache.s2graph.core.features
+
+import org.apache.tinkerpop.gremlin.structure.Graph.Features
+
+class S2VertexPropertyFeatures extends S2PropertyFeatures with Features.VertexPropertyFeatures {
+
+ override def supportsStringIds(): Boolean = true
+
+ override def supportsUserSuppliedIds(): Boolean = true
+
+ override def supportsAddProperty(): Boolean = true
+
+ override def willAllowId(id: scala.Any): Boolean = true
+
+ override def supportsNumericIds(): Boolean = false
+
+ override def supportsRemoveProperty(): Boolean = true
+
+ override def supportsUuidIds(): Boolean = false
+
+ override def supportsCustomIds(): Boolean = false
+
+ override def supportsAnyIds(): Boolean = false
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
index 09d02d1..a92c93b 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
@@ -24,13 +24,14 @@ import scalikejdbc._
object ColumnMeta extends Model[ColumnMeta] {
- val timeStampSeq = 0.toByte
- val countSeq = -1.toByte
+ val timeStampSeq = -1.toByte
val lastModifiedAtColumnSeq = 0.toByte
val lastModifiedAtColumn = ColumnMeta(Some(0), 0, "lastModifiedAt", lastModifiedAtColumnSeq, "long")
val maxValue = Byte.MaxValue
- val timestamp = ColumnMeta(None, -1, "_timestamp", timeStampSeq, "long")
+ val timestamp = ColumnMeta(None, -1, "_timestamp", timeStampSeq.toByte, "long")
+ val reservedMetas = Seq(timestamp, lastModifiedAtColumn)
+ val reservedMetaNamesSet = reservedMetas.map(_.name).toSet
def apply(rs: WrappedResultSet): ColumnMeta = {
ColumnMeta(Some(rs.int("id")), rs.int("column_id"), rs.string("name"), rs.byte("seq"), rs.string("data_type").toLowerCase())
@@ -56,11 +57,16 @@ object ColumnMeta extends Model[ColumnMeta] {
}
}
- def findByName(columnId: Int, name: String)(implicit session: DBSession = AutoSession) = {
+ def findByName(columnId: Int, name: String, useCache: Boolean = true)(implicit session: DBSession = AutoSession) = {
// val cacheKey = s"columnId=$columnId:name=$name"
val cacheKey = "columnId=" + columnId + ":name=" + name
- withCache(cacheKey)( sql"""select * from column_metas where column_id = ${columnId} and name = ${name}"""
- .map { rs => ColumnMeta(rs) }.single.apply())
+ if (useCache) {
+ withCache(cacheKey)( sql"""select * from column_metas where column_id = ${columnId} and name = ${name}"""
+ .map { rs => ColumnMeta(rs) }.single.apply())
+ } else {
+ sql"""select * from column_metas where column_id = ${columnId} and name = ${name}"""
+ .map { rs => ColumnMeta(rs) }.single.apply()
+ }
}
def insert(columnId: Int, name: String, dataType: String)(implicit session: DBSession = AutoSession) = {
@@ -73,8 +79,8 @@ object ColumnMeta extends Model[ColumnMeta] {
}
}
- def findOrInsert(columnId: Int, name: String, dataType: String)(implicit session: DBSession = AutoSession): ColumnMeta = {
- findByName(columnId, name) match {
+ def findOrInsert(columnId: Int, name: String, dataType: String, useCache: Boolean = true)(implicit session: DBSession = AutoSession): ColumnMeta = {
+ findByName(columnId, name, useCache) match {
case Some(c) => c
case None =>
insert(columnId, name, dataType)
@@ -97,7 +103,7 @@ object ColumnMeta extends Model[ColumnMeta] {
val columnMeta = findById(id)
val (columnId, name) = (columnMeta.columnId, columnMeta.name)
sql"""delete from column_metas where id = ${id}""".execute.apply()
- val cacheKeys = List(s"id=$id", s"columnId=$columnId:name=$name", s"colunmId=$columnId")
+ val cacheKeys = List(s"id=$id", s"columnId=$columnId:name=$name", s"columnId=$columnId")
cacheKeys.foreach { key =>
expireCache(key)
expireCaches(key)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/mysqls/LabelMeta.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/LabelMeta.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/LabelMeta.scala
index 4a7e931..a16334a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/LabelMeta.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/LabelMeta.scala
@@ -73,6 +73,7 @@ object LabelMeta extends Model[LabelMeta] {
// Each reserved column(_timestamp, timestamp) has same seq number, starts with '_' has high priority
val reservedMetas = List(empty, label, direction, lastDeletedAt, from, fromHash, to, degree, timestamp, count).flatMap { lm => List(lm, lm.copy(name = lm.name.drop(1))) }.reverse
val reservedMetasInner = List(empty, label, direction, lastDeletedAt, from, fromHash, to, degree, timestamp, count)
+ val reservedMetaNamesSet = reservedMetasInner.map(_.name).toSet
val defaultRequiredMetaNames = Set("from", "_from", "to", "_to", "_from_hash", "label", "direction", "timestamp", "_timestamp")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Model.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Model.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Model.scala
index 7a18a49..e21072e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Model.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Model.scala
@@ -20,17 +20,18 @@
package org.apache.s2graph.core.mysqls
import java.util.concurrent.Executors
+import java.util.concurrent.atomic.AtomicLong
-import com.typesafe.config.{ConfigFactory, Config}
+import com.typesafe.config.{Config, ConfigFactory}
import org.apache.s2graph.core.JSONParser
import org.apache.s2graph.core.utils.{SafeUpdateCache, logger}
-import play.api.libs.json.{Json, JsObject, JsValue}
+import play.api.libs.json.{JsObject, JsValue, Json}
import scalikejdbc._
import scala.concurrent.ExecutionContext
import scala.io.Source
import scala.language.{higherKinds, implicitConversions}
-import scala.util.{Success, Failure, Try}
+import scala.util.{Failure, Success, Try}
object Model {
var maxSize = 10000
@@ -40,6 +41,8 @@ object Model {
val ec = ExecutionContext.fromExecutor(threadPool)
val useUTF8Encoding = "?useUnicode=true&characterEncoding=utf8"
+ private val ModelReferenceCount = new AtomicLong(0L)
+
def apply(config: Config) = {
maxSize = config.getInt("cache.max.size")
ttl = config.getInt("cache.ttl.seconds")
@@ -58,6 +61,8 @@ object Model {
settings)
checkSchema()
+
+ ModelReferenceCount.incrementAndGet()
}
def checkSchema(): Unit = {
@@ -107,9 +112,37 @@ object Model {
}
}
- def shutdown() = {
- ConnectionPool.closeAll()
- }
+ def shutdown(modelDataDelete: Boolean = false) =
+ if (ModelReferenceCount.decrementAndGet() <= 0) {
+ // FIXME: When Model is served by embedded database and deleteData is set, Model deletes
+ // the underlying database. Its purpose is clearing runtime footprint when running tests.
+ if (modelDataDelete) {
+ withTx { implicit session =>
+ sql"SHOW TABLES"
+ .map(rs => rs.string(1))
+ .list
+ .apply()
+ .map { table => s"TRUNCATE TABLE $table" }
+ } match {
+ case Success(stmts) =>
+ val newStmts = List("SET FOREIGN_KEY_CHECKS = 0") ++ stmts ++ List("SET FOREIGN_KEY_CHECKS = 1")
+ withTx { implicit session =>
+ newStmts.foreach { stmt =>
+ session.execute(stmt)
+ }
+ } match {
+ case Success(_) =>
+ logger.info(s"Success to truncate models: $stmts")
+ case Failure(e) =>
+ throw new IllegalStateException(s"Failed to truncate models", e)
+ }
+ case Failure(e) =>
+ throw new IllegalStateException(s"Failed to list models", e)
+ }
+ }
+ clearCache()
+ ConnectionPool.closeAll()
+ }
def loadCache() = {
Service.findAll()
@@ -120,6 +153,15 @@ object Model {
ColumnMeta.findAll()
}
+ def clearCache() = {
+ Service.expireAll()
+ ServiceColumn.expireAll()
+ Label.expireAll()
+ LabelMeta.expireAll()
+ LabelIndex.expireAll()
+ ColumnMeta.expireAll()
+ }
+
def extraOptions(options: Option[String]): Map[String, JsValue] = options match {
case None => Map.empty
case Some(v) =>
@@ -169,6 +211,11 @@ trait Model[V] extends SQLSyntaxSupport[V] {
val expireCaches = listCache.invalidate _
+ def expireAll() = {
+ listCache.invalidateAll()
+ optionCache.invalidateAll()
+ }
+
def putsToCache(kvs: List[(String, V)]) = kvs.foreach {
case (key, value) => optionCache.put(key, Option(value))
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
index 7fdda45..20330c4 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
@@ -73,8 +73,8 @@ object Service extends Model[Service] {
}
def findOrInsert(serviceName: String, cluster: String, hTableName: String,
- preSplitSize: Int, hTableTTL: Option[Int], compressionAlgorithm: String)(implicit session: DBSession = AutoSession): Service = {
- findByName(serviceName) match {
+ preSplitSize: Int, hTableTTL: Option[Int], compressionAlgorithm: String, useCache: Boolean = true)(implicit session: DBSession = AutoSession): Service = {
+ findByName(serviceName, useCache) match {
case Some(s) => s
case None =>
insert(serviceName, cluster, hTableName, preSplitSize, hTableTTL, compressionAlgorithm)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
index f791f22..8614132 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
@@ -42,11 +42,16 @@ object ServiceColumn extends Model[ServiceColumn] {
// find(service.id.get, columnName, useCache)
// }
- def findById(id: Int)(implicit session: DBSession = AutoSession): ServiceColumn = {
-// val cacheKey = s"id=$id"
+ def findById(id: Int, useCache: Boolean = true)(implicit session: DBSession = AutoSession): ServiceColumn = {
val cacheKey = "id=" + id
- withCache(cacheKey)(sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn(x) }.single.apply).get
+
+ if (useCache) {
+ withCache(cacheKey)(sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn(x) }.single.apply).get
+ } else {
+ sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn(x) }.single.apply.get
+ }
}
+
def find(serviceId: Int, columnName: String, useCache: Boolean = true)(implicit session: DBSession = AutoSession): Option[ServiceColumn] = {
// val cacheKey = s"serviceId=$serviceId:columnName=$columnName"
val cacheKey = "serviceId=" + serviceId + ":columnName=" + columnName
@@ -67,7 +72,7 @@ object ServiceColumn extends Model[ServiceColumn] {
values(${serviceId}, ${columnName}, ${columnType}, ${schemaVersion})""".execute.apply()
}
def delete(id: Int)(implicit session: DBSession = AutoSession) = {
- val serviceColumn = findById(id)
+ val serviceColumn = findById(id, useCache = false)
val (serviceId, columnName) = (serviceColumn.serviceId, serviceColumn.columnName)
sql"""delete from service_columns where id = ${id}""".execute.apply()
val cacheKeys = List(s"id=$id", s"serviceId=$serviceId:columnName=$columnName")
@@ -76,8 +81,8 @@ object ServiceColumn extends Model[ServiceColumn] {
expireCaches(key)
}
}
- def findOrInsert(serviceId: Int, columnName: String, columnType: Option[String], schemaVersion: String = HBaseType.DEFAULT_VERSION)(implicit session: DBSession = AutoSession): ServiceColumn = {
- find(serviceId, columnName) match {
+ def findOrInsert(serviceId: Int, columnName: String, columnType: Option[String], schemaVersion: String = HBaseType.DEFAULT_VERSION, useCache: Boolean = true)(implicit session: DBSession = AutoSession): ServiceColumn = {
+ find(serviceId, columnName, useCache) match {
case Some(sc) => sc
case None =>
insert(serviceId, columnName, columnType, schemaVersion)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
index fb75765..a9b523c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
@@ -266,9 +266,11 @@ abstract class Storage[Q, R](val graph: S2Graph,
replicationScopeOpt: Option[Int] = None,
totalRegionCount: Option[Int] = None): Unit
+ def truncateTable(zkAddr: String, tableNameStr: String): Unit = {}
+ def deleteTable(zkAddr: String, tableNameStr: String): Unit = {}
-
+ def shutdown(): Unit
/** Public Interface */
def getVertices(vertices: Seq[S2Vertex]): Future[Seq[S2Vertex]] = {
@@ -1096,7 +1098,7 @@ abstract class Storage[Q, R](val graph: S2Graph,
}
def buildDegreePuts(edge: S2Edge, degreeVal: Long): Seq[SKeyValue] = {
- edge.property(LabelMeta.degree.name, degreeVal, edge.ts)
+ edge.propertyInner(LabelMeta.degree.name, degreeVal, edge.ts)
val kvs = edge.edgesWithIndexValid.flatMap { indexEdge =>
indexEdgeSerializer(indexEdge).toKeyValues.map(_.copy(operation = SKeyValue.Put, durability = indexEdge.label.durability))
}
@@ -1112,4 +1114,6 @@ abstract class Storage[Q, R](val graph: S2Graph,
}
def info: Map[String, String] = Map("className" -> this.getClass.getSimpleName)
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
index d4ae451..ede1933 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
@@ -32,22 +32,23 @@ import org.apache.hadoop.hbase.io.compress.Compression.Algorithm
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding
import org.apache.hadoop.hbase.regionserver.BloomType
import org.apache.hadoop.hbase.util.Bytes
-import org.apache.hadoop.hbase.{HBaseConfiguration, HColumnDescriptor, HTableDescriptor, TableName}
+import org.apache.hadoop.hbase.{TableName, HColumnDescriptor, HBaseConfiguration, HTableDescriptor}
import org.apache.hadoop.security.UserGroupInformation
+
import org.apache.s2graph.core._
import org.apache.s2graph.core.mysqls.{Label, LabelMeta, ServiceColumn}
import org.apache.s2graph.core.storage._
import org.apache.s2graph.core.storage.hbase.AsynchbaseStorage.{AsyncRPC, ScanWithRange}
-import org.apache.s2graph.core.types.{HBaseType, VertexId}
+import org.apache.s2graph.core.types.{VertexId, HBaseType}
import org.apache.s2graph.core.utils._
import org.hbase.async.FilterList.Operator.MUST_PASS_ALL
import org.hbase.async._
-
import scala.collection.JavaConversions._
import scala.collection.mutable.ArrayBuffer
import scala.concurrent._
import scala.concurrent.duration.Duration
import scala.util.Try
+import scala.util.control.NonFatal
import scala.util.hashing.MurmurHash3
@@ -84,6 +85,10 @@ object AsynchbaseStorage {
client
}
+ def shutdown(client: HBaseClient): Unit = {
+ client.shutdown().join()
+ }
+
case class ScanWithRange(scan: Scanner, offset: Int, limit: Int)
type AsyncRPC = Either[GetRequest, ScanWithRange]
}
@@ -466,6 +471,13 @@ class AsynchbaseStorage(override val graph: S2Graph,
}
+ override def shutdown(): Unit = {
+ flush()
+ clients.foreach { client =>
+ AsynchbaseStorage.shutdown(client)
+ }
+ }
+
override def createTable(_zkAddr: String,
tableName: String,
cfs: List[String],
@@ -495,6 +507,8 @@ class AsynchbaseStorage(override val graph: S2Graph,
.setMinVersions(0)
.setBlocksize(32768)
.setBlockCacheEnabled(true)
+ // FIXME: For test!!
+ .setInMemory(true)
if (ttl.isDefined) columnDesc.setTimeToLive(ttl.get)
if (replicationScopeOpt.isDefined) columnDesc.setScope(replicationScopeOpt.get)
desc.addFamily(columnDesc)
@@ -516,6 +530,59 @@ class AsynchbaseStorage(override val graph: S2Graph,
}
}
+ override def truncateTable(zkAddr: String, tableNameStr: String): Unit = {
+ val tableName = TableName.valueOf(tableNameStr)
+ val adminTry = Try(getAdmin(zkAddr))
+ if (adminTry.isFailure) return
+ val admin = adminTry.get
+
+ if (!Try(admin.tableExists(tableName)).getOrElse(false)) {
+ logger.info(s"No table to truncate ${tableNameStr}")
+ return
+ }
+
+ Try(admin.isTableDisabled(tableName)).map {
+ case true =>
+ logger.info(s"${tableNameStr} is already disabled.")
+
+ case false =>
+ logger.info(s"Before disabling to trucate ${tableNameStr}")
+ Try(admin.disableTable(tableName)).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to disable ${tableNameStr}: ${e}")
+ }
+ logger.info(s"After disabling to trucate ${tableNameStr}")
+ }
+
+ logger.info(s"Before truncating ${tableNameStr}")
+ Try(admin.truncateTable(tableName, true)).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to truncate ${tableNameStr}: ${e}")
+ }
+ logger.info(s"After truncating ${tableNameStr}")
+ Try(admin.close()).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to close admin ${tableNameStr}: ${e}")
+ }
+ Try(admin.getConnection.close()).recover {
+ case NonFatal(e) =>
+ logger.info(s"Failed to close connection ${tableNameStr}: ${e}")
+ }
+
+ }
+
+ override def deleteTable(zkAddr: String, tableNameStr: String): Unit = {
+ val admin = getAdmin(zkAddr)
+ val tableName = TableName.valueOf(tableNameStr)
+ if (!admin.tableExists(tableName)) {
+ return
+ }
+ if (admin.isTableEnabled(tableName)) {
+ admin.disableTable(tableName)
+ }
+ admin.deleteTable(tableName)
+ admin.close()
+ }
/** Asynchbase implementation override default getVertices to use future Cache */
override def getVertices(vertices: Seq[S2Vertex]): Future[Seq[S2Vertex]] = {
@@ -549,7 +616,9 @@ class AsynchbaseStorage(override val graph: S2Graph,
scan.setFamily(Serializable.edgeCf)
scan.setMaxVersions(1)
- scan.nextRows(10000).toFuture(emptyKeyValuesLs).map { kvsLs =>
+ scan.nextRows(10000).toFuture(emptyKeyValuesLs).map {
+ case null => Seq.empty
+ case kvsLs =>
kvsLs.flatMap { kvs =>
kvs.flatMap { kv =>
indexEdgeDeserializer.fromKeyValues(Seq(kv), None)
@@ -567,10 +636,12 @@ class AsynchbaseStorage(override val graph: S2Graph,
scan.setFamily(Serializable.vertexCf)
scan.setMaxVersions(1)
- scan.nextRows(10000).toFuture(emptyKeyValuesLs).map { kvsLs =>
- kvsLs.flatMap { kvs =>
- vertexDeserializer.fromKeyValues(kvs, None)
- }
+ scan.nextRows(10000).toFuture(emptyKeyValuesLs).map {
+ case null => Seq.empty
+ case kvsLs =>
+ kvsLs.flatMap { kvs =>
+ vertexDeserializer.fromKeyValues(kvs, None)
+ }
}
}
Future.sequence(futures).map(_.flatten)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d05d8a49/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/tall/IndexEdgeDeserializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/tall/IndexEdgeDeserializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/tall/IndexEdgeDeserializable.scala
index 8f47f97..6095cea 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/tall/IndexEdgeDeserializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/tall/IndexEdgeDeserializable.scala
@@ -74,8 +74,8 @@ class IndexEdgeDeserializable(graph: S2Graph,
val degreeVal = bytesToLongFunc(kv.value, 0)
val tgtVertexId = VertexId(ServiceColumn.Default, InnerVal.withStr("0", schemaVer))
- edge.property(LabelMeta.timestamp.name, version, version)
- edge.property(LabelMeta.degree.name, degreeVal, version)
+ edge.propertyInner(LabelMeta.timestamp.name, version, version)
+ edge.propertyInner(LabelMeta.degree.name, degreeVal, version)
edge.tgtVertex = graph.newVertex(tgtVertexId, version)
edge.op = GraphUtil.defaultOpByte
edge.tsInnerValOpt = Option(InnerVal.withLong(tsVal, schemaVer))
@@ -119,9 +119,9 @@ class IndexEdgeDeserializable(graph: S2Graph,
if (k == LabelMeta.timestamp) tsVal = v.value.asInstanceOf[BigDecimal].longValue()
if (k == LabelMeta.degree) {
- edge.property(LabelMeta.degree.name, v.value, version)
+ edge.propertyInner(LabelMeta.degree.name, v.value, version)
} else {
- edge.property(meta.name, v.value, version)
+ edge.propertyInner(meta.name, v.value, version)
}
}
@@ -129,13 +129,13 @@ class IndexEdgeDeserializable(graph: S2Graph,
if (op == GraphUtil.operations("incrementCount")) {
// val countVal = Bytes.toLong(kv.value)
val countVal = bytesToLongFunc(kv.value, 0)
- edge.property(LabelMeta.count.name, countVal, version)
+ edge.propertyInner(LabelMeta.count.name, countVal, version)
} else {
val (props, endAt) = bytesToKeyValues(kv.value, 0, kv.value.length, schemaVer, label)
props.foreach { case (k, v) =>
if (k == LabelMeta.timestamp) tsVal = v.value.asInstanceOf[BigDecimal].longValue()
- edge.property(k.name, v.value, version)
+ edge.propertyInner(k.name, v.value, version)
}
}
@@ -146,7 +146,7 @@ class IndexEdgeDeserializable(graph: S2Graph,
TargetVertexId(ServiceColumn.Default, vId.innerVal)
} else tgtVertexIdRaw
- edge.property(LabelMeta.timestamp.name, tsVal, version)
+ edge.propertyInner(LabelMeta.timestamp.name, tsVal, version)
edge.tgtVertex = graph.newVertex(tgtVertexId, version)
edge.op = op
edge.tsInnerValOpt = Option(InnerVal.withLong(tsVal, schemaVer))
[12/46] incubator-s2graph git commit: Figure out how to skip specific
method on each test. decide value equals on EdgeId, VertexId.
Posted by st...@apache.org.
Figure out how to skip specific method on each test.
decide value equals on EdgeId, VertexId.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/507cfcfc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/507cfcfc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/507cfcfc
Branch: refs/heads/master
Commit: 507cfcfca9a180c19c44b6c569b2aec97d2a3691
Parents: c508def
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 14 12:01:53 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 14 12:01:53 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 24 ++++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/507cfcfc/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 49e2272..5669b2e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -535,22 +535,22 @@ object S2Graph {
//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
-// // passed: all, failed: none
-//
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
-// // passed: all, failed: none
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+ // passed: all, failed: none
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
+ // passed: all, failed: none
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
+ // passed: all, failed: none
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
+ // passed: all, failed: none
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
// passed: , failed: shouldEnableFeatureOnEdgeIfNotEnabled, shouldEnableFeatureOnVertexIfNotEnabled, shouldSupportUserSuppliedIdsOfTypeAny
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest$BasicVertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
// passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"),
[39/46] incubator-s2graph git commit: [SUITE_PROCESS_STANDARD.filter]
passed all except 3 cases. add them as OptOut for now.
Posted by st...@apache.org.
[SUITE_PROCESS_STANDARD.filter] passed all except 3 cases. add them as OptOut for now.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/aedc4452
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/aedc4452
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/aedc4452
Branch: refs/heads/master
Commit: aedc4452bea5356da7f095a33442170072dd5d09
Parents: 3c20b3f
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 11:12:37 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 11:12:37 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/aedc4452/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 bfc0d35..b899911 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -570,10 +570,10 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest$Traversals", method = "g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX", reason = "please find bug on this case."),
// passed: all, failed: g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest$Traversals", method = "*", reason = "no"),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest$Traversals", method = "g_V_properties_drop", reason = "please find bug on this case."),
// passed: all, failed: g_V_properties_drop
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterTest$Traversals", method = "*", reason = "no"),
@@ -600,8 +600,8 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.TailTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTest$Traversals", method = "*", reason = "no"),
-// passed: all, failed: g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path, g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTest$Traversals", method = "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX", reason = "please identify bug on this case."),
+// passed: all, failed: g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX
/* map */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeTest$Traversals", method = "*", reason = "no"),
[40/46] incubator-s2graph git commit: remove hard coded vertexCache.
Posted by st...@apache.org.
remove hard coded vertexCache.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/fd1bdc48
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/fd1bdc48
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/fd1bdc48
Branch: refs/heads/master
Commit: fd1bdc483a8a6fe6f55f757f42e70f95fb076cd7
Parents: aedc445
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 15:20:42 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 15:20:42 2017 +0900
----------------------------------------------------------------------
.../main/scala/org/apache/s2graph/core/QueryParam.scala | 2 +-
.../src/main/scala/org/apache/s2graph/core/S2Graph.scala | 7 ++++---
.../s2graph/core/storage/hbase/AsynchbaseStorage.scala | 11 +++++++----
3 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/fd1bdc48/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
index 0228b3b..1e0d3b2 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
@@ -270,7 +270,7 @@ case class QueryParam(labelName: String,
limit: Int = 100,
sample: Int = -1,
maxAttempt: Int = 2,
- rpcTimeout: Int = 60000,
+ rpcTimeout: Int = 600000,
cacheTTLInMillis: Long = -1L,
indexName: String = LabelIndex.DefaultName,
where: Try[Where] = Success(WhereParser.success),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/fd1bdc48/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 b899911..483c8c4 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -55,6 +55,7 @@ object S2Graph {
type FilterHashKey = (Int, Int)
val DefaultScore = 1.0
+ val FetchAllLimit = 10000000
private val DefaultConfigs: Map[String, AnyRef] = Map(
"hbase.zookeeper.quorum" -> "localhost",
@@ -65,11 +66,11 @@ object S2Graph {
"db.default.url" -> "jdbc:h2:file:./var/metastore;MODE=MYSQL",
"db.default.password" -> "graph",
"db.default.user" -> "graph",
- "cache.max.size" -> java.lang.Integer.valueOf(10000),
- "cache.ttl.seconds" -> java.lang.Integer.valueOf(60),
+ "cache.max.size" -> java.lang.Integer.valueOf(0),
+ "cache.ttl.seconds" -> java.lang.Integer.valueOf(-1),
"hbase.client.retries.number" -> java.lang.Integer.valueOf(20),
"hbase.rpcs.buffered_flush_interval" -> java.lang.Short.valueOf(100.toShort),
- "hbase.rpc.timeout" -> java.lang.Integer.valueOf(60000),
+ "hbase.rpc.timeout" -> java.lang.Integer.valueOf(600000),
"max.retry.number" -> java.lang.Integer.valueOf(100),
"lock.expire.time" -> java.lang.Integer.valueOf(1000 * 60 * 10),
"max.back.off" -> java.lang.Integer.valueOf(100),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/fd1bdc48/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
index 5c9695d..dbb6e4c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
@@ -663,10 +663,13 @@ class AsynchbaseStorage(override val graph: S2Graph,
get.setFailfast(true)
get.maxVersions(1)
- val cacheKey = MurmurHash3.stringHash(get.toString)
- vertexCache.getOrElseUpdate(cacheKey, cacheTTL = 10000)(fetchVertexKeyValues(Left(get))).map { kvs =>
+ fetchVertexKeyValues(Left(get)).map { kvs =>
fromResult(kvs, vertex.serviceColumn.schemaVersion)
}
+// val cacheKey = MurmurHash3.stringHash(get.toString)
+// vertexCache.getOrElseUpdate(cacheKey, cacheTTL = -1)(fetchVertexKeyValues(Left(get))).map { kvs =>
+// fromResult(kvs, vertex.serviceColumn.schemaVersion)
+// }
}
Future.sequence(futures).map { result => result.toList.flatten }
@@ -680,7 +683,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
scan.setFamily(Serializable.edgeCf)
scan.setMaxVersions(1)
- scan.nextRows(100000).toFuture(emptyKeyValuesLs).map {
+ scan.nextRows(S2Graph.FetchAllLimit).toFuture(emptyKeyValuesLs).map {
case null => Seq.empty
case kvsLs =>
kvsLs.flatMap { kvs =>
@@ -704,7 +707,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
scan.setFamily(Serializable.vertexCf)
scan.setMaxVersions(1)
- scan.nextRows(10000).toFuture(emptyKeyValuesLs).map {
+ scan.nextRows(S2Graph.FetchAllLimit).toFuture(emptyKeyValuesLs).map {
case null => Seq.empty
case kvsLs =>
kvsLs.flatMap { kvs =>
[18/46] incubator-s2graph git commit: [ReferenceVertexPropertyTest]
passed all.
Posted by st...@apache.org.
[ReferenceVertexPropertyTest] 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/2232beb7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/2232beb7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/2232beb7
Branch: refs/heads/master
Commit: 2232beb7d8c38904b521339008876c1313a6e628
Parents: ee22c60
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 26 15:37:18 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 26 15:37:18 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2232beb7/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 78eb2b2..de87b43 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -569,14 +569,13 @@ object S2Graph {
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:
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
+ // passed: all, skip: shouldNotEvaluateToEqualDifferentId
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"),
+
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"),
// passed: all, failed: none
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"),
[22/46] incubator-s2graph git commit: [SerializationTest] passed all,
GryoTest.shouldSerializeTree failed.
Posted by st...@apache.org.
[SerializationTest] passed all, GryoTest.shouldSerializeTree failed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/a9c50168
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/a9c50168
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/a9c50168
Branch: refs/heads/master
Commit: a9c50168979bacb7e40c3acf32d387a1d3fae33b
Parents: 9d175a7
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu Apr 27 19:47:50 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu Apr 27 19:47:50 2017 +0900
----------------------------------------------------------------------
.../s2graph/core/io/S2GraphSimpleModule.java | 118 ++++++++++++++++++
.../scala/org/apache/s2graph/core/S2Edge.scala | 41 ++++---
.../scala/org/apache/s2graph/core/S2Graph.scala | 105 +++-------------
.../apache/s2graph/core/S2GraphIoRegistry.scala | 58 +++++++++
.../apache/s2graph/core/S2VertexProperty.scala | 12 +-
.../apache/s2graph/core/io/Conversions.scala | 123 +++++++++++++++++++
.../apache/s2graph/core/mysqls/ColumnMeta.scala | 16 +--
.../apache/s2graph/core/mysqls/Service.scala | 10 +-
.../s2graph/core/mysqls/ServiceColumn.scala | 25 ++--
.../s2graph/core/types/InnerValLike.scala | 1 -
.../apache/s2graph/core/types/VertexId.scala | 23 +++-
.../apache/s2graph/core/io/ConversionTest.scala | 115 +++++++++++++++++
.../core/tinkerpop/S2GraphProvider.scala | 8 +-
13 files changed, 515 insertions(+), 140 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
----------------------------------------------------------------------
diff --git a/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java b/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
new file mode 100644
index 0000000..e1c1741
--- /dev/null
+++ b/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
@@ -0,0 +1,118 @@
+package org.apache.s2graph.core.io;
+
+
+import org.apache.s2graph.core.EdgeId;
+import org.apache.s2graph.core.S2VertexPropertyId;
+import org.apache.s2graph.core.types.VertexId;
+import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
+import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
+import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
+import org.apache.tinkerpop.shaded.jackson.databind.*;
+import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeDeserializer;
+import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
+import org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule;
+import java.io.IOException;
+
+public class S2GraphSimpleModule extends SimpleModule {
+ private S2GraphSimpleModule() {
+ addSerializer(EdgeId.class, new EdgeIdSerializer());
+ addSerializer(VertexId.class, new VertexIdSerializer());
+ addSerializer(S2VertexPropertyId.class, new S2VertexPropertyIdSerializer());
+
+ addDeserializer(EdgeId.class, new EdgeIdDeserializer());
+ addDeserializer(VertexId.class, new VertexIdDeserializer());
+ addDeserializer(S2VertexPropertyId.class, new S2VertexPropertyIdDeserializer());
+ }
+
+ private static final S2GraphSimpleModule INSTANCE = new S2GraphSimpleModule();
+
+ public static final S2GraphSimpleModule getInstance() {
+ return INSTANCE;
+ }
+
+ public static class EdgeIdSerializer extends JsonSerializer<EdgeId> {
+
+ @Override
+ public void serialize(EdgeId edgeId, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
+ String s = edgeId.toString();
+ jsonGenerator.writeString(s);
+ }
+
+ @Override
+ public void serializeWithType(EdgeId value, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ typeSer.writeCustomTypePrefixForScalar(value, gen, EdgeId.class.getName());
+ serialize(value, gen, serializers);
+ typeSer.writeCustomTypeSuffixForScalar(value, gen, EdgeId.class.getName());
+ }
+ }
+ public static class EdgeIdDeserializer extends JsonDeserializer<EdgeId> {
+ @Override
+ public EdgeId deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ String s = jsonParser.getValueAsString();
+ return EdgeId.fromString(s);
+ }
+
+ @Override
+ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException {
+ return typeDeserializer.deserializeTypedFromScalar(p, ctxt);
+ }
+ }
+ public static class VertexIdSerializer extends JsonSerializer<VertexId> {
+
+ @Override
+ public void serialize(VertexId vertexId, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ String s = vertexId.toString();
+ jsonGenerator.writeString(s);
+ }
+
+ @Override
+ public void serializeWithType(VertexId value, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ typeSer.writeCustomTypePrefixForScalar(value, gen, VertexId.class.getName());
+ serialize(value, gen, serializers);
+ typeSer.writeCustomTypeSuffixForScalar(value, gen, VertexId.class.getName());
+ }
+ }
+ public static class VertexIdDeserializer extends JsonDeserializer<VertexId> {
+
+ @Override
+ public VertexId deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ String s = jsonParser.getValueAsString();
+ return VertexId.fromString(s);
+ }
+
+ @Override
+ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException {
+ return typeDeserializer.deserializeTypedFromScalar(p, ctxt);
+ }
+ }
+ public static class S2VertexPropertyIdSerializer extends JsonSerializer<S2VertexPropertyId> {
+
+ @Override
+ public void serialize(S2VertexPropertyId s2VertexPropertyId, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
+ jsonGenerator.writeString(s2VertexPropertyId.toString());
+ }
+
+ @Override
+ public void serializeWithType(S2VertexPropertyId value,
+ JsonGenerator gen,
+ SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+
+ typeSer.writeCustomTypePrefixForScalar(value, gen, S2VertexPropertyId.class.getName());
+ serialize(value, gen, serializers);
+ typeSer.writeCustomTypeSuffixForScalar(value, gen, S2VertexPropertyId.class.getName());
+ }
+ }
+ public static class S2VertexPropertyIdDeserializer extends JsonDeserializer<S2VertexPropertyId> {
+
+ @Override
+ public S2VertexPropertyId deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ return S2VertexPropertyId.fromString(jsonParser.getValueAsString());
+ }
+
+ @Override
+ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException {
+ return typeDeserializer.deserializeTypedFromScalar(p, ctxt);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/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 edb3783..e6da0bb 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -28,6 +28,7 @@ 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.s2graph.core.io.Conversions._
import org.apache.tinkerpop.gremlin.structure
import org.apache.tinkerpop.gremlin.structure.util.StringFactory
import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Graph, Property, T, Vertex}
@@ -701,22 +702,34 @@ case class S2Edge(innerGraph: S2Graph,
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
- )
+// 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
+// )
+ val js = Json.parse(s)
+ s2EdgeIdReads.reads(Json.parse(s)).get
}
}
-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) {
+ override def toString: String = {
+ import io.Conversions._
+ // Seq(srcVertexId.toIdString(), tgtVertexId.toIdString(), labelName, direction, ts.toString).mkString(EdgeId.EdgeIdDelimiter)
+ s2EdgeIdWrites.writes(this).toString()
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/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 a45d080..2635eba 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -36,8 +36,8 @@ import org.apache.s2graph.core.utils.{DeferCache, Extensions, logger}
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer
import org.apache.tinkerpop.gremlin.structure
import org.apache.tinkerpop.gremlin.structure.Graph.{Features, Variables}
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper
-import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, Property, T, Transaction, Vertex}
+import org.apache.tinkerpop.gremlin.structure.io.{GraphReader, GraphWriter, Io, Mapper}
+import org.apache.tinkerpop.gremlin.structure.{Edge, Element, Graph, T, Transaction, Vertex}
import play.api.libs.json.{JsObject, Json}
import scala.annotation.tailrec
@@ -584,10 +584,8 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
- // not yet supported
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"), // all failed since implementation is missing.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest", method="*", reason="no"), // 10/16 failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.TransactionTest", method="*", reason="no"), // all ignored since supportTransaction is false.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest$GryoTest", method="shouldSerializeTree", reason="order of children is reversed. not sure why."),
+ // passed: all, failed: $GryoTest.shouldSerializeTree
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
@@ -1403,58 +1401,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
S2Edge.fillPropsWithTs(snapshotEdge, propsWithTs)
snapshotEdge
}
-//
-// /**
-// * internal helper to actually store a single edge based on given peramters.
-// *
-// * Note that this is used from S2Vertex to implement blocking interface from Tp3.
-// * Once tp3 provide AsyncStep, then this can be changed to return Java's CompletableFuture.
-// *
-// * @param srcVertex
-// * @param tgtVertex
-// * @param labelName
-// * @param direction
-// * @param props
-// * @param ts
-// * @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
-// }
-// }
-
def newVertexId(serviceName: String)(columnName: String)(id: Any): VertexId = {
val service = Service.findByName(serviceName).getOrElse(throw new RuntimeException(s"$serviceName is not found."))
@@ -1511,41 +1457,27 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
/**
* used by graph.traversal().V()
- * @param vertexIds: array of VertexId values. note that last parameter can be used to control if actually fetch vertices from storage or not.
+ * @param ids: array of VertexId values. note that last parameter can be used to control if actually fetch vertices from storage or not.
* since S2Graph use user-provided id as part of edge, it is possible to
* fetch edge without fetch start vertex. default is false which means we are not fetching vertices from storage.
* @return
*/
- override def vertices(vertexIds: AnyRef*): util.Iterator[structure.Vertex] = {
- val fetchVertices = vertexIds.lastOption.map { lastParam =>
+ override def vertices(ids: AnyRef*): util.Iterator[structure.Vertex] = {
+ val fetchVertices = ids.lastOption.map { lastParam =>
if (lastParam.isInstanceOf[Boolean]) lastParam.asInstanceOf[Boolean]
else true
}.getOrElse(true)
- if (vertexIds.isEmpty) {
+ if (ids.isEmpty) {
//TODO: default storage need to be fixed.
Await.result(defaultStorage.fetchVerticesAll(), WaitTimeout).iterator
} else {
- val (vIds, stringIds) = vertexIds.partition(_.isInstanceOf[VertexId])
- val verticesFromIds = vIds.map(vertexId => newVertex(vertexId.asInstanceOf[VertexId]))
- val verticesFromString = stringIds.flatMap { vId =>
- if (vId.toString.contains(S2Vertex.VertexLabelDelimiter)) {
- val Array(serviceName, columnName, id) =
- if (vId.toString.take(2).mkString("") == "v[") vId.toString.drop(2).init.split(S2Vertex.VertexLabelDelimiter)
- else {
- if (vId.toString.contains(S2Vertex.VertexLabelDelimiter)) {
- vId.toString.split(S2Vertex.VertexLabelDelimiter)
- } else {
- Array(DefaultService.serviceName, DefaultColumn.columnName, vId.toString)
- }
- }
-
- Seq(toVertex(serviceName, columnName, id))
- } else {
- Nil
- }
+ val vertices = ids.collect {
+ case s2Vertex: S2Vertex => s2Vertex
+ case vId: VertexId => newVertex(vId)
+ case vertex: Vertex => newVertex(vertex.id().asInstanceOf[VertexId])
+ case other @ _ => newVertex(VertexId.fromString(other.toString))
}
- val vertices = verticesFromIds ++ verticesFromString
if (fetchVertices) {
val future = getVertices(vertices).map { vs =>
@@ -1574,6 +1506,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
case s2Edge: S2Edge => s2Edge.id().asInstanceOf[EdgeId]
case id: EdgeId => id
case s: String => EdgeId.fromString(s)
+ case s: java.lang.String => EdgeId.fromString(s)
}
val edgesToFetch = for {
id <- s2EdgeIds
@@ -1592,7 +1525,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
???
}
- override def variables(): Variables = new S2GraphVariables()
+ override def variables(): Variables = new S2GraphVariables
override def configuration(): Configuration = apacheConfiguration
@@ -1705,10 +1638,10 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
override def toString(): String = "[s2graph]"
-// override def io[I <: Io[_ <: GraphReader.ReaderBuilder[_ <: GraphReader], _ <: GraphWriter.WriterBuilder[_ <: GraphWriter], _ <: Mapper.Builder[_]]](builder: Io.Builder[I]): I = {
-// builder.graph(this).registry(new S2GraphIoRegistry).create().asInstanceOf[I]
-//
-// }
+ override def io[I <: Io[_ <: GraphReader.ReaderBuilder[_ <: GraphReader], _ <: GraphWriter.WriterBuilder[_ <: GraphWriter], _ <: Mapper.Builder[_]]](builder: Io.Builder[I]): I = {
+ builder.graph(this).registry(new S2GraphIoRegistry).create().asInstanceOf[I]
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
new file mode 100644
index 0000000..1b25928
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
@@ -0,0 +1,58 @@
+package org.apache.s2graph.core
+
+
+import org.apache.s2graph.core.io.S2GraphSimpleModule
+import org.apache.s2graph.core.types.VertexId
+import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo
+import org.apache.tinkerpop.shaded.kryo.io.{Input, Output}
+import org.apache.tinkerpop.shaded.kryo.{Kryo, Serializer}
+
+object S2GraphIoRegistry {
+ lazy val instance = new S2GraphIoRegistry
+}
+
+class S2GraphIoRegistry extends AbstractIoRegistry {
+
+ // val simpleModule = new S2GraphSimpleModule
+ register(classOf[GraphSONIo], null, S2GraphSimpleModule.getInstance())
+ // register(classOf[GraphSONIo], null, simpleModule)
+
+ register(classOf[GryoIo], classOf[S2VertexPropertyId], new S2VertexPropertyIdKryoSerializer)
+ register(classOf[GryoIo], classOf[VertexId], new VertexIdKryoSerializer)
+ register(classOf[GryoIo], classOf[EdgeId], new EdgeIdKryoSerializer)
+
+ class S2VertexPropertyIdKryoSerializer extends Serializer[S2VertexPropertyId] {
+ override def read(kryo: Kryo, input: Input, aClass: Class[S2VertexPropertyId]): S2VertexPropertyId = {
+ S2VertexPropertyId.fromString(input.readString())
+ }
+
+ override def write(kryo: Kryo, output: Output, t: S2VertexPropertyId): Unit = {
+ output.writeString(t.toString)
+ }
+ }
+
+ class VertexIdKryoSerializer extends Serializer[VertexId] {
+ override def read(kryo: Kryo, input: Input, aClass: Class[VertexId]): VertexId = {
+ VertexId.fromString(input.readString())
+ }
+
+ override def write(kryo: Kryo, output: Output, t: VertexId): Unit = {
+ output.writeString(t.toString())
+ }
+ }
+
+
+ class EdgeIdKryoSerializer extends Serializer[EdgeId] {
+ override def read(kryo: Kryo, input: Input, aClass: Class[EdgeId]): EdgeId = {
+ EdgeId.fromString(input.readString())
+ }
+
+ override def write(kryo: Kryo, output: Output, t: EdgeId): Unit = {
+ output.writeString(t.toString)
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
index 84e6de7..d0b56a0 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
@@ -24,8 +24,18 @@ import java.util
import org.apache.s2graph.core.mysqls.ColumnMeta
import org.apache.s2graph.core.types.{CanInnerValLike, InnerValLike}
import org.apache.tinkerpop.gremlin.structure.{Property, VertexProperty}
+import play.api.libs.json.Json
-case class S2VertexPropertyId(columnMeta: ColumnMeta, value: InnerValLike)
+object S2VertexPropertyId {
+ def fromString(s: String): S2VertexPropertyId = {
+ io.Conversions.s2VertexPropertyIdReads.reads(Json.parse(s)).get
+ }
+}
+case class S2VertexPropertyId(columnMeta: ColumnMeta, value: InnerValLike) {
+ override def toString: String = {
+ io.Conversions.s2VertexPropertyIdWrites.writes(this).toString()
+ }
+}
case class S2VertexProperty[V](element: S2Vertex,
columnMeta: ColumnMeta,
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
new file mode 100644
index 0000000..f9cc861
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
@@ -0,0 +1,123 @@
+package org.apache.s2graph.core.io
+
+import org.apache.s2graph.core.{EdgeId, JSONParser, S2VertexPropertyId}
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
+import org.apache.s2graph.core.types.{InnerValLike, VertexId}
+import play.api.libs.json._
+import play.api.libs.json.Reads._
+import play.api.libs.json.Writes._
+import play.api.libs.functional.syntax._
+
+object Conversions {
+ /* Serializer for inner value class */
+ implicit object InnerValLikeReads extends Reads[InnerValLike] {
+ def reads(json: JsValue) = {
+ val value = (json \ "value").as[JsValue]
+ val dataType = (json \ "dataType").as[String]
+ val schemaVersion = (json \ "schemaVersion").as[String]
+ val innerVal = JSONParser.jsValueToInnerVal(value, dataType, schemaVersion).get
+ JsSuccess(innerVal)
+ }
+ }
+ implicit object InnerValLikeWrites extends Writes[InnerValLike] {
+ override def writes(o: InnerValLike): JsValue = {
+ Json.obj("value" -> JSONParser.anyValToJsValue(o.value),
+ "dataType" -> o.dataType,
+ "schemaVersion" -> o.schemaVersion)
+ }
+ }
+
+ /* Serializer for Models */
+
+ implicit val serviceReads: Reads[Service] = (
+ (JsPath \ "id").readNullable[Int] and
+ (JsPath \ "serviceName").read[String] and
+ (JsPath \ "accessToken").read[String] and
+ (JsPath \ "cluster").read[String] and
+ (JsPath \ "hTableName").read[String] and
+ (JsPath \ "preSplitSize").read[Int] and
+ (JsPath \ "hTableTTL").readNullable[Int] and
+ (JsPath \ "options").readNullable[String]
+ )(Service.apply _)
+
+ implicit val serviceWrites: Writes[Service] = (
+ (JsPath \ "id").writeNullable[Int] and
+ (JsPath \ "serviceName").write[String] and
+ (JsPath \ "accessToken").write[String] and
+ (JsPath \ "cluster").write[String] and
+ (JsPath \ "hTableName").write[String] and
+ (JsPath \ "preSplitSize").write[Int] and
+ (JsPath \ "hTableTTL").writeNullable[Int] and
+ (JsPath \ "options").writeNullable[String]
+ )(unlift(Service.unapply))
+
+ implicit val serviceColumnReads: Reads[ServiceColumn] = (
+ (JsPath \ "id").readNullable[Int] and
+ (JsPath \ "serviceId").read[Int] and
+ (JsPath \ "columnName").read[String] and
+ (JsPath \ "columnType").read[String] and
+ (JsPath \ "schemaVersion").read[String]
+ )(ServiceColumn.apply _)
+
+ implicit val serviceColumnWrites: Writes[ServiceColumn] = (
+ (JsPath \ "id").writeNullable[Int] and
+ (JsPath \ "serviceId").write[Int] and
+ (JsPath \ "columnName").write[String] and
+ (JsPath \ "columnType").write[String] and
+ (JsPath \ "schemaVersion").write[String]
+ )(unlift(ServiceColumn.unapply))
+
+ implicit val columnMetaReads: Reads[ColumnMeta] = (
+ (JsPath \ "id").readNullable[Int] and
+ (JsPath \ "columnId").read[Int] and
+ (JsPath \ "name").read[String] and
+ (JsPath \ "seq").read[Byte] and
+ (JsPath \ "dataType").read[String]
+ )(ColumnMeta.apply _)
+
+ implicit val columnMetaWrites: Writes[ColumnMeta] = (
+ (JsPath \ "id").writeNullable[Int] and
+ (JsPath \ "columnId").write[Int] and
+ (JsPath \ "name").write[String] and
+ (JsPath \ "seq").write[Byte] and
+ (JsPath \ "dataType").write[String]
+ )(unlift(ColumnMeta.unapply))
+
+ /* Graph Class */
+ implicit val s2VertexPropertyIdReads: Reads[S2VertexPropertyId] = (
+ (JsPath \ "column").read[ColumnMeta] and
+ (JsPath \ "value").read[InnerValLike]
+ )(S2VertexPropertyId.apply _)
+
+ implicit val s2VertexPropertyIdWrites: Writes[S2VertexPropertyId] = (
+ (JsPath \ "column").write[ColumnMeta] and
+ (JsPath \ "value").write[InnerValLike]
+ )(unlift(S2VertexPropertyId.unapply))
+
+ implicit val s2VertexIdReads: Reads[VertexId] = (
+ (JsPath \ "column").read[ServiceColumn] and
+ (JsPath \ "value").read[InnerValLike]
+ )(VertexId.apply _)
+
+ implicit val s2VertexIdWrites: Writes[VertexId] = (
+ (JsPath \ "column").write[ServiceColumn] and
+ (JsPath \ "value").write[InnerValLike]
+ )(unlift(VertexId.unapply))
+
+ implicit val s2EdgeIdReads: Reads[EdgeId] = (
+ (JsPath \ "srcVertexId").read[InnerValLike] and
+ (JsPath \ "tgtVertexId").read[InnerValLike] and
+ (JsPath \ "labelName").read[String] and
+ (JsPath \ "direction").read[String] and
+ (JsPath \ "ts").read[Long]
+ )(EdgeId.apply _)
+
+ implicit val s2EdgeIdWrites: Writes[EdgeId] = (
+ (JsPath \ "srcVertexId").write[InnerValLike] and
+ (JsPath \ "tgtVertexId").write[InnerValLike] and
+ (JsPath \ "labelName").write[String] and
+ (JsPath \ "direction").write[String] and
+ (JsPath \ "ts").write[Long]
+ )(unlift(EdgeId.unapply))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
index a92c93b..14ad381 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ColumnMeta.scala
@@ -33,7 +33,7 @@ object ColumnMeta extends Model[ColumnMeta] {
val reservedMetas = Seq(timestamp, lastModifiedAtColumn)
val reservedMetaNamesSet = reservedMetas.map(_.name).toSet
- def apply(rs: WrappedResultSet): ColumnMeta = {
+ def valueOf(rs: WrappedResultSet): ColumnMeta = {
ColumnMeta(Some(rs.int("id")), rs.int("column_id"), rs.string("name"), rs.byte("seq"), rs.string("data_type").toLowerCase())
}
@@ -41,7 +41,7 @@ object ColumnMeta extends Model[ColumnMeta] {
// val cacheKey = s"id=$id"
val cacheKey = "id=" + id
withCache(cacheKey) {
- sql"""select * from column_metas where id = ${id}""".map { rs => ColumnMeta(rs) }.single.apply
+ sql"""select * from column_metas where id = ${id}""".map { rs => ColumnMeta.valueOf(rs) }.single.apply
}.get
}
@@ -50,10 +50,10 @@ object ColumnMeta extends Model[ColumnMeta] {
val cacheKey = "columnId=" + columnId
if (useCache) {
withCaches(cacheKey)( sql"""select *from column_metas where column_id = ${columnId} order by seq ASC"""
- .map { rs => ColumnMeta(rs) }.list.apply())
+ .map { rs => ColumnMeta.valueOf(rs) }.list.apply())
} else {
sql"""select * from column_metas where column_id = ${columnId} order by seq ASC"""
- .map { rs => ColumnMeta(rs) }.list.apply()
+ .map { rs => ColumnMeta.valueOf(rs) }.list.apply()
}
}
@@ -62,10 +62,10 @@ object ColumnMeta extends Model[ColumnMeta] {
val cacheKey = "columnId=" + columnId + ":name=" + name
if (useCache) {
withCache(cacheKey)( sql"""select * from column_metas where column_id = ${columnId} and name = ${name}"""
- .map { rs => ColumnMeta(rs) }.single.apply())
+ .map { rs => ColumnMeta.valueOf(rs) }.single.apply())
} else {
sql"""select * from column_metas where column_id = ${columnId} and name = ${name}"""
- .map { rs => ColumnMeta(rs) }.single.apply()
+ .map { rs => ColumnMeta.valueOf(rs) }.single.apply()
}
}
@@ -93,7 +93,7 @@ object ColumnMeta extends Model[ColumnMeta] {
val cacheKey = "columnId=" + columnId + ":seq=" + seq
lazy val columnMetaOpt = sql"""
select * from column_metas where column_id = ${columnId} and seq = ${seq}
- """.map { rs => ColumnMeta(rs) }.single.apply()
+ """.map { rs => ColumnMeta.valueOf(rs) }.single.apply()
if (useCache) withCache(cacheKey)(columnMetaOpt)
else columnMetaOpt
@@ -111,7 +111,7 @@ object ColumnMeta extends Model[ColumnMeta] {
}
def findAll()(implicit session: DBSession = AutoSession) = {
- val ls = sql"""select * from column_metas""".map { rs => ColumnMeta(rs) }.list().apply()
+ val ls = sql"""select * from column_metas""".map { rs => ColumnMeta.valueOf(rs) }.list().apply()
putsToCache(ls.map { x =>
val cacheKey = s"id=${x.id.get}"
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
index 20330c4..e745cb0 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/Service.scala
@@ -27,26 +27,26 @@ import play.api.libs.json.Json
import scalikejdbc._
object Service extends Model[Service] {
- def apply(rs: WrappedResultSet): Service = {
+ def valueOf(rs: WrappedResultSet): Service = {
Service(rs.intOpt("id"), rs.string("service_name"), rs.string("access_token"),
rs.string("cluster"), rs.string("hbase_table_name"), rs.int("pre_split_size"), rs.intOpt("hbase_table_ttl"))
}
def findByAccessToken(accessToken: String)(implicit session: DBSession = AutoSession): Option[Service] = {
val cacheKey = s"accessToken=$accessToken"
- withCache(cacheKey)( sql"""select * from services where access_token = ${accessToken}""".map { rs => Service(rs) }.single.apply)
+ withCache(cacheKey)( sql"""select * from services where access_token = ${accessToken}""".map { rs => Service.valueOf(rs) }.single.apply)
}
def findById(id: Int)(implicit session: DBSession = AutoSession): Service = {
val cacheKey = "id=" + id
- withCache(cacheKey)( sql"""select * from services where id = ${id}""".map { rs => Service(rs) }.single.apply).get
+ withCache(cacheKey)( sql"""select * from services where id = ${id}""".map { rs => Service.valueOf(rs) }.single.apply).get
}
def findByName(serviceName: String, useCache: Boolean = true)(implicit session: DBSession = AutoSession): Option[Service] = {
val cacheKey = "serviceName=" + serviceName
lazy val serviceOpt = sql"""
select * from services where service_name = ${serviceName}
- """.map { rs => Service(rs) }.single.apply()
+ """.map { rs => Service.valueOf(rs) }.single.apply()
if (useCache) withCache(cacheKey)(serviceOpt)
else serviceOpt
@@ -85,7 +85,7 @@ object Service extends Model[Service] {
}
def findAll()(implicit session: DBSession = AutoSession) = {
- val ls = sql"""select * from services""".map { rs => Service(rs) }.list.apply
+ val ls = sql"""select * from services""".map { rs => Service.valueOf(rs) }.list.apply
putsToCache(ls.map { x =>
val cacheKey = s"id=${x.id.get}"
(cacheKey -> x)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
index 32ca653..be1ae9a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
@@ -19,37 +19,26 @@
package org.apache.s2graph.core.mysqls
-/**
- * Created by shon on 6/3/15.
- */
-
-import org.apache.s2graph.core.JSONParser
import org.apache.s2graph.core.JSONParser._
import org.apache.s2graph.core.types.{HBaseType, InnerValLike, InnerValLikeWithTs}
-import org.apache.s2graph.core.utils.logger
import play.api.libs.json.Json
import scalikejdbc._
+
object ServiceColumn extends Model[ServiceColumn] {
val Default = ServiceColumn(Option(0), -1, "default", "string", "v4")
- def apply(rs: WrappedResultSet): ServiceColumn = {
+ def valueOf(rs: WrappedResultSet): ServiceColumn = {
ServiceColumn(rs.intOpt("id"), rs.int("service_id"), rs.string("column_name"), rs.string("column_type").toLowerCase(), rs.string("schema_version"))
}
-// def findByServiceAndColumn(serviceName: String,
-// columnName: String,
-// useCache: Boolean = true)(implicit session: DBSession): Option[ServiceColumn] = {
-// val service = Service.findByName(serviceName).getOrElse(throw new RuntimeException(s"$serviceName is not found."))
-// find(service.id.get, columnName, useCache)
-// }
def findById(id: Int, useCache: Boolean = true)(implicit session: DBSession = AutoSession): ServiceColumn = {
val cacheKey = "id=" + id
if (useCache) {
- withCache(cacheKey)(sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn(x) }.single.apply).get
+ withCache(cacheKey)(sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn.valueOf(x) }.single.apply).get
} else {
- sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn(x) }.single.apply.get
+ sql"""select * from service_columns where id = ${id}""".map { x => ServiceColumn.valueOf(x) }.single.apply.get
}
}
@@ -60,12 +49,12 @@ object ServiceColumn extends Model[ServiceColumn] {
withCache(cacheKey) {
sql"""
select * from service_columns where service_id = ${serviceId} and column_name = ${columnName}
- """.map { rs => ServiceColumn(rs) }.single.apply()
+ """.map { rs => ServiceColumn.valueOf(rs) }.single.apply()
}
} else {
sql"""
select * from service_columns where service_id = ${serviceId} and column_name = ${columnName}
- """.map { rs => ServiceColumn(rs) }.single.apply()
+ """.map { rs => ServiceColumn.valueOf(rs) }.single.apply()
}
}
def insert(serviceId: Int, columnName: String, columnType: Option[String], schemaVersion: String)(implicit session: DBSession = AutoSession) = {
@@ -94,7 +83,7 @@ object ServiceColumn extends Model[ServiceColumn] {
}
}
def findAll()(implicit session: DBSession = AutoSession) = {
- val ls = sql"""select * from service_columns""".map { rs => ServiceColumn(rs) }.list.apply
+ val ls = sql"""select * from service_columns""".map { rs => ServiceColumn.valueOf(rs) }.list.apply
putsToCache(ls.map { x =>
var cacheKey = s"id=${x.id.get}"
(cacheKey -> x)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
index f653901..3f9e7b5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
@@ -20,7 +20,6 @@
package org.apache.s2graph.core.types
import org.apache.hadoop.hbase.util._
-import org.apache.s2graph.core.utils.logger
object InnerVal extends HBaseDeserializableWithIsVertexId {
import HBaseType._
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
index 31bdce6..628a149 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
@@ -23,9 +23,13 @@ import org.apache.hadoop.hbase.util.Bytes
import org.apache.s2graph.core.{GraphUtil, S2Vertex}
import org.apache.s2graph.core.mysqls.ServiceColumn
import org.apache.s2graph.core.types.HBaseType._
+import org.apache.s2graph.core.io.Conversions._
+import play.api.libs.json.Json
object VertexId extends HBaseDeserializable {
import HBaseType._
+
+
def fromBytes(bytes: Array[Byte],
offset: Int,
len: Int,
@@ -49,6 +53,20 @@ object VertexId extends HBaseDeserializable {
def toTargetVertexId(vid: VertexId) = {
TargetVertexId(vid.column, vid.innerId)
}
+
+ def unapply(vertexId: VertexId): Option[(ServiceColumn, InnerValLike)] = {
+ Some((vertexId.column, vertexId.innerId))
+ }
+
+ def fromString(s: String): VertexId = {
+
+// val Array(serviceId, columnName, innerValStr) = s.split(S2Vertex.VertexLabelDelimiter)
+// val service = Service.findById(serviceId.toInt)
+// val column = ServiceColumn.find(service.id.get, columnName).getOrElse(throw new LabelNotExistException(columnName))
+// val innerId = JSONParser.toInnerVal(innerValStr, column.columnType, column.schemaVersion)
+// VertexId(column, innerId)
+ s2VertexIdReads.reads(Json.parse(s)).get
+ }
}
class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HBaseSerializable {
@@ -67,9 +85,10 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
def bytes: Array[Byte] = Bytes.add(hashBytes, innerId.bytes, colIdBytes)
override def toString(): String = {
+ s2VertexIdWrites.writes(this).toString()
// column.id.get.toString() + "," + innerId.toString()
- val del = S2Vertex.VertexLabelDelimiter
- s"${column.serviceId}${del}${column.columnName}${del}${innerId}"
+// val del = S2Vertex.VertexLabelDelimiter
+// Seq(column.serviceId, column.columnName, innerId.toIdString()).mkString(del)
}
override def hashCode(): Int = {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
new file mode 100644
index 0000000..b305108
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
@@ -0,0 +1,115 @@
+package org.apache.s2graph.core.io
+
+//import org.apache.s2graph.core.{EdgeId, S2VertexPropertyId}
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
+import org.apache.s2graph.core.types.{InnerVal, VertexId}
+import org.apache.s2graph.core.utils.logger
+import org.scalatest.{FunSuite, Matchers}
+
+//class ConversionsTest extends FunSuite with Matchers {
+// import Conversions._
+// import org.apache.s2graph.core.types.HBaseType._
+//
+// test("innerVal test") {
+// val value = InnerVal.withStr("a,b,c", DEFAULT_VERSION)
+//
+// val writer = InnerValLikeWrites
+// val reader = InnerValLikeReads
+// val json = writer.writes(value)
+// val deserialized = reader.reads(json).get
+//
+// println(s"[Given]: $value")
+// println(s"[GivenJson]: $json")
+// println(s"[Deserialized]: $deserialized")
+// println(s"[DeserializedJson]: ${writer.writes(deserialized)}")
+//
+// value shouldBe (deserialized)
+// }
+//
+// test("serviceColumn test") {
+// val value = Service(Option(1), "serviceName", "accessToken", "cluster", "hTableName", 10, Option(10), None)
+// val writer = serviceWrites
+// val reader = serviceReads
+// val json = writer.writes(value)
+// val deserialized = reader.reads(json).get
+//
+// println(s"[Given]: $value")
+// println(s"[GivenJson]: $json")
+// println(s"[Deserialized]: $deserialized")
+// println(s"[DeserializedJson]: ${writer.writes(deserialized)}")
+//
+// value shouldBe (deserialized)
+//
+// }
+//
+// test("s2VertexPropertyId test") {
+//// val column = ServiceColumn(Option(10), 1, "vertex", "string", DEFAULT_VERSION)
+// val columnMeta = ColumnMeta(Option(1), 1, "name", 1.toByte, "string")
+// val innerVal = InnerVal.withStr("shon", DEFAULT_VERSION)
+// val value = S2VertexPropertyId(columnMeta, innerVal)
+//
+// val writer = s2VertexPropertyIdWrites
+// val reader = s2VertexPropertyIdReads
+// val json = writer.writes(value)
+// val deserialized = reader.reads(json).get
+//
+// println(s"[Given]: $value")
+// println(s"[GivenJson]: $json")
+// println(s"[Deserialized]: $deserialized")
+// println(s"[DeserializedJson]: ${writer.writes(deserialized)}")
+//
+// value shouldBe (deserialized)
+// }
+//
+// test("s2VertexId test") {
+// val column = ServiceColumn(Option(10), 1, "vertex", "string", DEFAULT_VERSION)
+// val innerVal = InnerVal.withStr("vertex.1", DEFAULT_VERSION)
+// val value = VertexId(column, innerVal)
+//
+// val writer = s2VertexIdWrites
+// val reader = s2VertexIdReads
+// val json = writer.writes(value)
+// val deserialized = reader.reads(json).get
+//
+// println(s"[Given]: $value")
+// println(s"[GivenJson]: $json")
+// println(s"[Deserialized]: $deserialized")
+// println(s"[DeserializedJson]: ${writer.writes(deserialized)}")
+//
+// value shouldBe (deserialized)
+// }
+//
+// test("EdgeId test") {
+// val s =
+// s"""
+// |{
+// | "srcVertexId": {
+// | "value": 1,
+// | "dataType": "long",
+// | "schemaVersion": "v3"
+// | },
+// | "tgtVertexId": {
+// | "value": 2,
+// | "dataType": "bigDecimal",
+// | "schemaVersion": "v3"
+// | },
+// | "labelName": "knows",
+// | "direction": "out",
+// | "ts": 0
+// |}
+// """.stripMargin
+// val value = EdgeId.fromString(s)
+//
+// val writer = s2EdgeIdWrites
+// val reader = s2EdgeIdReads
+// val json = writer.writes(value)
+// val deserialized = reader.reads(json).get
+//
+// println(s"[Given]: $value")
+// println(s"[GivenJson]: $json")
+// println(s"[Deserialized]: $deserialized")
+// println(s"[DeserializedJson]: ${writer.writes(deserialized)}")
+//
+// value shouldBe (deserialized)
+// }
+//}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a9c50168/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 dc24cb6..5165252 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
@@ -139,16 +139,14 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
}
- if (testClass.getSimpleName == "ReferenceEdgeTest") {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
+ if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else if (testClass.getSimpleName.contains("CommunityGeneratorTest")) {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": true}"""))
- } else if (testClass.getSimpleName == "DetachedEdgeTest" || testClass.getSimpleName.contains("GraphSONTest")) {
+ } else if (testClass.getSimpleName == "DetachedEdgeTest" ||
+ testClass.getSimpleName.contains("GraphSONTest")) {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else {
[23/46] incubator-s2graph git commit: [IoCustomTest] all ignored.
Posted by st...@apache.org.
[IoCustomTest] all ignored.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/3a0272f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/3a0272f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/3a0272f8
Branch: refs/heads/master
Commit: 3a0272f8b85ca2e77ec6e7188039c0af5f290e31
Parents: a9c5016
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu Apr 27 19:50:26 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu Apr 27 19:50:26 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/3a0272f8/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 2635eba..0aa570d 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -588,7 +588,7 @@ object S2Graph {
// passed: all, failed: $GryoTest.shouldSerializeTree
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"), // all failed.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"), // all failed.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"), // all failed.
[32/46] incubator-s2graph git commit: [Branch + Filter] passed most
of them.
Posted by st...@apache.org.
[Branch + Filter] passed most of them.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/bc502615
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/bc502615
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/bc502615
Branch: refs/heads/master
Commit: bc50261593c6c427ced56f40d0bada0f9dc0e2fe
Parents: 38ec51d
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed May 3 09:05:19 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed May 3 09:05:19 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 57 ++++++++++++++------
.../apache/s2graph/core/types/VertexId.scala | 2 +-
2 files changed, 42 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/bc502615/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 a0d8f37..7d673de 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -540,42 +540,67 @@ object S2Graph {
))
@Graph.OptOuts(value = Array(
/** Process */
+ /* branch */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchTest$Traversals", method = "*", reason = "no"),
// passed: all
-
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseTest$Traversals", method = "*", reason = "no"),
- // passed: , failed: g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name
-
+ // passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest$Traversals", method = "*", reason = "no"),
// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalTest$Traversals", method = "*", reason = "no"),
-// failed: g_V_localXmatchXproject__created_person__person_name_nameX_selectXname_projectX_by_byXnameX,
-// g_V_localXbothEXcreatedX_limitX1XX_otherV_name
-// g_VX4X_localXbothEX1_createdX_limitX1XX
-//g_VX4X_localXbothEXknows_createdX_limitX1XX
+// passed: all, failed: g_VX4X_localXbothEX1_createdX_limitX1XX, g_V_localXbothEXcreatedX_limitX1XX_otherV_name, g_VX4X_localXbothEXknows_createdX_limitX1XX
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatTest$Traversals", method = "*", reason = "no"),
-// failed: g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionTest$Traversals", method = "*", reason = "no"),
-//failed: g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX_groupCount,
-//g_V_unionXout__inX_name
-//g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX
-//g_V_unionXrepeatXunionXoutXcreatedX__inXcreatedXX_timesX2X__repeatXunionXinXcreatedX__outXcreatedXX_timesX2XX_label_groupCount
-//g_VX1X_unionXrepeatXoutX_timesX2X__outX_name
+// passed: all
+ /* filter */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndTest$Traversals", method = "*", reason = "no"),
-// failed: g_V_asXaX_outXknowsX_and_outXcreatedX_inXcreatedX_asXaX_name
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest$Traversals", method = "*", reason = "no"),
// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
-// failed: all
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_properties_drop
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.SampleTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.SimplePathTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.TailTest$Traversals", method = "*", reason = "no"),
+// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path, g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX
+ /* map */
/** Structure */
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/bc502615/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
index f93df4a..4130fe0 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
@@ -69,7 +69,7 @@ object VertexId extends HBaseDeserializable {
}
}
-class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HBaseSerializable {
+class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HBaseSerializable with Comparable[VertexId] {
val storeHash: Boolean = true
val storeColId: Boolean = true
val colId = column.id.get
[27/46] incubator-s2graph git commit: refactoring S2GraphProvider.
Posted by st...@apache.org.
refactoring S2GraphProvider.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/b0236487
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/b0236487
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/b0236487
Branch: refs/heads/master
Commit: b0236487a7f38cd68242e68fbddcbfbeb2ed410d
Parents: 46cafb7
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 28 22:49:29 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 28 23:29:11 2017 +0900
----------------------------------------------------------------------
.../core/tinkerpop/S2GraphProvider.scala | 39 +++++++-------------
1 file changed, 14 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/b0236487/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 3934264..bcec609 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
@@ -143,21 +143,7 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findByName(defaultServiceColumn.id.get, "aKey", useCache = false).foreach(cm => ColumnMeta.delete(cm.id.get))
ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
}
-
- if (testClass.getSimpleName == "IoGraphTest") {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getSimpleName == "DifferentDistributionsTest") {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getSimpleName.contains("CommunityGeneratorTest")) {
- mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": true}"""))
- } else if (testClass.getSimpleName == "DetachedEdgeTest" ||
- testClass.getSimpleName.contains("GraphSONTest")) {
+ if (loadGraphWith != null && loadGraphWith.value() == GraphData.MODERN) {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else {
@@ -166,14 +152,6 @@ class S2GraphProvider extends AbstractGraphProvider {
}
-// 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")))
@@ -181,8 +159,19 @@ class S2GraphProvider extends AbstractGraphProvider {
val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
// val vertexColumn = Management.createServiceColumn(service.serviceName, "vertex", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "-1", "integer"), Prop("lang", "scala", "string")))
- val created = mnt.createLabel("created", defaultService.serviceName, "person", "integer", defaultService.serviceName, "software", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+ val created =
+ if (loadGraphWith != null && loadGraphWith.value() == GraphData.MODERN) {
+ mnt.createLabel("created",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "software", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+ } else {
+ mnt.createLabel("created",
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+ }
+
val bought = mnt.createLabel("bought", defaultService.serviceName, "person", "integer", defaultService.serviceName, "product", "integer",
true, defaultService.serviceName, Nil, Seq(Prop("x", "-", "string"), Prop("y", "-", "string")), "strong", None, None,
[19/46] incubator-s2graph git commit: [ReferenceGraphTest]: all
ignored.
Posted by st...@apache.org.
[ReferenceGraphTest]: all ignored.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/818cfec4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/818cfec4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/818cfec4
Branch: refs/heads/master
Commit: 818cfec4d5e9ab31bdcb59b7e8fbcbeda8b65875
Parents: 2232beb
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 26 15:38:22 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 26 15:38:22 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/818cfec4/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 de87b43..dfd22ca 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -578,7 +578,7 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"),
// passed: all, failed: none
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"),
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
[38/46] incubator-s2graph git commit: [SUITE_PROCESS_STANDARD.branch]
passed all.
Posted by st...@apache.org.
[SUITE_PROCESS_STANDARD.branch] 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/3c20b3fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/3c20b3fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/3c20b3fd
Branch: refs/heads/master
Commit: 3c20b3fdea8f081820b5098a6effc25ba8003049
Parents: 3407a81
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 10:55:44 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 11:12:28 2017 +0900
----------------------------------------------------------------------
.../src/main/scala/org/apache/s2graph/core/S2Graph.scala | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/3c20b3fd/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 7556165..bfc0d35 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -540,16 +540,18 @@ object S2Graph {
))
@Graph.OptOuts(value = Array(
/** Process */
- /* branch */
+ /* branch: passed all. */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchTest$Traversals", method = "*", reason = "no"),
- // passed: all
+// passed: all
+
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseTest$Traversals", method = "*", reason = "no"),
- // passed: all
+// passed: all
+
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest$Traversals", method = "*", reason = "no"),
// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalTest$Traversals", method = "*", reason = "no"),
-// passed: all, failed: g_VX4X_localXbothEX1_createdX_limitX1XX, g_V_localXbothEXcreatedX_limitX1XX_otherV_name, g_VX4X_localXbothEXknows_createdX_limitX1XX
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatTest$Traversals", method = "*", reason = "no"),
// passed: all
@@ -557,6 +559,7 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionTest$Traversals", method = "*", reason = "no"),
// passed: all
+
/* filter */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndTest$Traversals", method = "*", reason = "no"),
// passed: all
[10/46] incubator-s2graph git commit: [DetachedVertexTest]: passed
all.
Posted by st...@apache.org.
[DetachedVertexTest]: 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/cbcb46c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/cbcb46c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/cbcb46c8
Branch: refs/heads/master
Commit: cbcb46c8e4dc292573f9eacd4facdef4b5b83beb
Parents: 302fc96
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 12 23:34:36 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 12 23:34:36 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 16 +++---
.../org/apache/s2graph/core/S2Property.scala | 2 +-
.../org/apache/s2graph/core/S2Vertex.scala | 16 ++++--
.../core/tinkerpop/structure/S2GraphTest.scala | 54 ++++++++++++++++++++
4 files changed, 77 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cbcb46c8/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 0b16b23..f1f00e7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -530,16 +530,20 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
-// 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.PropertyTest", method="*", reason="no"), // pass
-
+ // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
+
+ // not passed
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", 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.util.detached.DetachedEdgeTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"), // pass one error
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"), // pass all ignored
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"), // pass
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cbcb46c8/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 defa476..bca1303 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
@@ -40,7 +40,7 @@ object S2Property {
val key = pair.getValue0
val value = pair.getValue1
ElementHelper.validateProperty(key, value)
- if (keySet.contains(key)) throw VertexProperty.Exceptions.multiPropertiesNotSupported
+// if (keySet.contains(key)) throw VertexProperty.Exceptions.multiPropertiesNotSupported
assertValidProp(key, value)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cbcb46c8/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 b80a54c..3c771f5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -26,14 +26,14 @@ import org.apache.s2graph.core.GraphExceptions.LabelNotExistException
import org.apache.s2graph.core.S2Vertex.Props
import org.apache.s2graph.core.mysqls._
import org.apache.s2graph.core.types._
+import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.structure.Edge.Exceptions
-import org.apache.tinkerpop.gremlin.structure.Graph.Features.{ElementFeatures, VertexFeatures}
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality
-import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Property, T, Vertex, VertexProperty}
+import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Graph, Property, T, Vertex, VertexProperty}
import play.api.libs.json.Json
import scala.collection.JavaConverters._
-import scala.concurrent.Await
+import scala.concurrent.{Await, Future}
case class S2Vertex(graph: S2Graph,
id: VertexId,
@@ -209,7 +209,15 @@ case class S2Vertex(graph: S2Graph,
val op = GraphUtil.toOp(operation).getOrElse(throw new RuntimeException(s"$operation is not supported."))
val edge = graph.newEdge(this, otherV, label, dir, op = op, version = ts, propsWithTs = propsWithTs)
- // edge.relatedEdges
+// //TODO: return type of mutateEdges can contains information if snapshot edge already exist.
+// // instead call checkEdges, we can exploit this feature once we refactor return type.
+// implicit val ec = graph.ec
+// val future = graph.checkEdges(Seq(edge)).flatMap { stepResult =>
+// if (stepResult.edgeWithScores.nonEmpty)
+// Future.failed(throw Graph.Exceptions.edgeWithIdAlreadyExists(edge.id()))
+// else
+// graph.mutateEdges(Seq(edge), withWait = true)
+// }
val future = graph.mutateEdges(Seq(edge), withWait = true)
Await.ready(future, graph.WaitTimeout)
edge
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/cbcb46c8/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 5454e24..cadfd37 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
@@ -23,6 +23,7 @@ import org.apache.s2graph.core.Management.JsonModel.Prop
import org.apache.s2graph.core._
import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.structure.Graph.Features.EdgePropertyFeatures
import org.apache.tinkerpop.gremlin.structure._
import org.apache.tinkerpop.gremlin.structure.util.Attachable
import org.apache.tinkerpop.gremlin.structure.util.detached.{DetachedEdge, DetachedFactory}
@@ -363,4 +364,57 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
assert(toDetach.equals(attached))
assert(!attached.isInstanceOf[DetachedEdge])
}
+
+// test("ddd") {
+//// @Test
+//// @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+//// @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+//// @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = EdgeFeatures.FEATURE_ADD_PROPERTY)
+//// def shouldEnableFeatureOnEdgeIfNotEnabled() = {
+//// graph.features.supports(classOf[EdgePropertyFeatures], "BooleanValues")
+////// assumeThat(graph.features().supports(EdgePropertyFeatures.class, featureName), is(false));
+////// try {
+////// final Edge edge = createEdgeForPropertyFeatureTests();
+////// edge.property("aKey", value);
+////// fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgePropertyFeatures.class.getSimpleName(), featureName));
+////// } catch (Exception e) {
+////// validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e);
+////// }
+//// }
+// val ret = graph.features.supports(classOf[EdgePropertyFeatures], "BooleanValues")
+// logger.error(s"[Support]: $ret")
+////
+//// @Test
+//// @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+//// @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
+//// public void shouldEnableFeatureOnVertexIfNotEnabled() throws Exception {
+//// assumeThat(graph.features().supports(VertexPropertyFeatures.class, featureName), is(false));
+//// try {
+//// graph.addVertex("aKey", value);
+//// fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), featureName));
+//// } catch (Exception e) {
+//// validateException(Property.Exceptions.dataTypeOfPropertyValueNotSupported(value), e);
+//// }
+//// }
+////
+////
+////
+//// @Test
+//// @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+//// @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+//// @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
+//// public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
+//// try {
+//// final Date id = new Date();
+//// graph.addVertex(T.id, id);
+////
+//// // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+//// // to throw the exception
+//// if (!graph.features().vertex().willAllowId(id))
+//// fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+//// } catch (Exception e) {
+//// validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
+//// }
+//// }
+// }
}
\ No newline at end of file
[46/46] incubator-s2graph git commit: [S2GRAPH-136] Validate
TinkerPop3 interface with gremlin-test suite.
Posted by st...@apache.org.
[S2GRAPH-136] Validate TinkerPop3 interface with gremlin-test suite.
JIRA:
[S2GRAPH-136] https://issues.apache.org/jira/browse/S2GRAPH-136
Pull Request:
Closes #112
Author
DO YUNG YOON <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/26e4d43c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/26e4d43c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/26e4d43c
Branch: refs/heads/master
Commit: 26e4d43cf2ac417378260853e42887de9934dfd3
Parents: e918621
Author: DO YUNG YOON <st...@apache.org>
Authored: Sat May 6 22:54:37 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sun Jul 2 00:26:30 2017 +0900
----------------------------------------------------------------------
.rat-excludes | 2 ++
.travis.yml | 17 +++++++++++++++-
CHANGES | 2 ++
.../s2graph/core/io/S2GraphSimpleModule.java | 21 ++++++++++++++++++++
.../apache/s2graph/core/S2GraphIoRegistry.scala | 19 ++++++++++++++++++
.../core/features/S2DataTypeFeatures.scala | 19 ++++++++++++++++++
.../s2graph/core/features/S2EdgeFeatures.scala | 19 ++++++++++++++++++
.../core/features/S2EdgePropertyFeatures.scala | 19 ++++++++++++++++++
.../core/features/S2ElementFeatures.scala | 19 ++++++++++++++++++
.../s2graph/core/features/S2GraphFeatures.scala | 19 ++++++++++++++++++
.../core/features/S2GraphVariables.scala | 21 +++++++++++++++++++-
.../core/features/S2PropertyFeatures.scala | 19 ++++++++++++++++++
.../core/features/S2VariableFeatures.scala | 19 ++++++++++++++++++
.../s2graph/core/features/S2Variables.scala | 19 ++++++++++++++++++
.../core/features/S2VertexFeatures.scala | 19 ++++++++++++++++++
.../features/S2VertexPropertyFeatures.scala | 19 ++++++++++++++++++
.../apache/s2graph/core/io/Conversions.scala | 19 ++++++++++++++++++
.../apache/s2graph/core/io/ConversionTest.scala | 19 ++++++++++++++++++
.../s2graph/core/tinkerpop/S2GraphData.scala | 19 ++++++++++++++++++
.../core/tinkerpop/S2GraphProvider.scala | 19 ++++++++++++++++++
.../process/S2GraphProcessStandardTest.scala | 21 +++++++++++++++++++-
.../S2GraphStructureIntegrateTest.scala | 19 ++++++++++++++++++
.../S2GraphStructureStandardTest.scala | 21 +++++++++++++++++++-
23 files changed, 405 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/.rat-excludes
----------------------------------------------------------------------
diff --git a/.rat-excludes b/.rat-excludes
index 1976fcc..1cddda0 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -17,3 +17,5 @@ s2counter_core/target
s2counter_loader/target
loader/target
spark/target
+storage/
+var/
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index d43ad47..7555a76 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
language: scala
env:
- - HBASE_VERSION=1.2.4
+ - HBASE_VERSION=1.2.5
cache:
directories:
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4a0d5ce..35ed7d4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -240,6 +240,8 @@ Release 0.1.0 - unreleased
S2GRAPH-130: Edge.propsWithTs data type should be changed into mutable to support setter interface exist in tp3 (Committed by DOYUNG YOON).
S2GRAPH-131: Add actual implementation on interfaces from TinkerPop3 structure package. (Committed by DOYUNG YOON).
+
+ S2GRAPH-136: Validate TinkerPop3 interface with gremlin-test suite. (Committed by DOYUNG YOON).
TEST
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
----------------------------------------------------------------------
diff --git a/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java b/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
index e1c1741..c21a1d0 100644
--- a/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
+++ b/s2core/src/main/java/org/apache/s2graph/core/io/S2GraphSimpleModule.java
@@ -1,6 +1,27 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.io;
+
import org.apache.s2graph.core.EdgeId;
import org.apache.s2graph.core.S2VertexPropertyId;
import org.apache.s2graph.core.types.VertexId;
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
index 1b25928..2313a4a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphIoRegistry.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
index a3ff088..5a41344 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
index 825b333..e398167 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgeFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
index 556bbdc..048b5fc 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2EdgePropertyFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
index 7e66c62..215fdeb 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
index e9aa247..e2c4179 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
index 8e963f5..7c0d8a8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import java.util
@@ -38,4 +57,4 @@ class S2GraphVariables extends Graph.Variables {
override def toString: String = {
s"variables[size:${variables.keys.size()}]"
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
index cf3316f..ff47dea 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2PropertyFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
index 6cbf129..146f910 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VariableFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
index 8a9c42b..e33ad91 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2Variables.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
index 14024fd..f04eb46 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
index b354561..048fb10 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2VertexPropertyFeatures.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.features
import org.apache.tinkerpop.gremlin.structure.Graph.Features
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
index 2033e49..f314083 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/io/Conversions.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.io
import org.apache.s2graph.core.{EdgeId, JSONParser, S2VertexPropertyId}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
index b305108..bc53e2f 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/io/ConversionTest.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.io
//import org.apache.s2graph.core.{EdgeId, S2VertexPropertyId}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
index b9af825..d020bb0 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphData.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.tinkerpop
import java.lang.annotation.Annotation
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/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 5d68656..87eac0e 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
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.tinkerpop
import java.util
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
index 5a8fc5c..495f161 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.tinkerpop.process
import org.apache.s2graph.core.S2Graph
@@ -13,4 +32,4 @@ import org.junit.runners.MethodSorters
@GraphProviderClass(provider = classOf[S2GraphProvider], graph = classOf[S2Graph])
class S2GraphProcessStandardTest {
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
index a909878..4b88714 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureIntegrateTest.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.tinkerpop.structure
import org.apache.s2graph.core.S2Graph
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/26e4d43c/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
index ed5a532..ed9ab8d 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/structure/S2GraphStructureStandardTest.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.core.tinkerpop.structure
import org.apache.s2graph.core.S2Graph
@@ -13,4 +32,4 @@ import org.junit.runners.MethodSorters
@GraphProviderClass(provider = classOf[S2GraphProvider], graph = classOf[S2Graph])
class S2GraphStructureStandardTest {
-}
\ No newline at end of file
+}
[29/46] incubator-s2graph git commit: [SUITE_STRUCTURE_STANDARD]
passed.
Posted by st...@apache.org.
[SUITE_STRUCTURE_STANDARD] passed.
[SUITE_PROCESS_STANDARD] start.
move test related schema into S2GraphProvider from S2Graph.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/e77cbc82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/e77cbc82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/e77cbc82
Branch: refs/heads/master
Commit: e77cbc8212733ca47f8e105b72b46075b0959f83
Parents: b023648
Author: DO YUNG YOON <st...@apache.org>
Authored: Sun Apr 30 10:54:29 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sun Apr 30 11:40:48 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 49 +++------
.../core/tinkerpop/S2GraphProvider.scala | 100 ++++++++++++-------
.../core/tinkerpop/structure/S2GraphTest.scala | 78 +++++++--------
3 files changed, 118 insertions(+), 109 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e77cbc82/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 e30be74..f05f2cb 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -19,7 +19,6 @@
package org.apache.s2graph.core
-import java.lang.annotation.Annotation
import java.util
import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
@@ -97,6 +96,10 @@ object S2Graph {
val threadPool = Executors.newFixedThreadPool(numOfThread)
val ec = ExecutionContext.fromExecutor(threadPool)
+ val DefaultServiceName = ""
+ val DefaultColumnName = "vertex"
+ val DefaultLabelName = "_s2graph"
+
def toTypeSafeConfig(configuration: Configuration): Config = {
val m = new mutable.HashMap[String, AnyRef]()
for {
@@ -536,7 +539,15 @@ object S2Graph {
new Graph.OptIn(value = Graph.OptIn.SUITE_STRUCTURE_STANDARD)
))
@Graph.OptOuts(value = Array(
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+ /** Process */
+// new Graph.OptOut(
+// test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
+// method = "g_V_valueMap_matchXa_selectXnameX_bX",
+// reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute."),
+
+ /** Structure */
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateEquality", reason="reference equals on EdgeId is not supported."),
// passed: all, failed: none
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
@@ -717,36 +728,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
(k, v) = (entry.getKey, entry.getValue)
} logger.info(s"[Initialized]: $k, ${this.config.getAnyRef(k)}")
- /* TODO */
- val DefaultService = management.createService("", "localhost", "s2graph", 0, None).get
- val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, "vertex", Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
- val DefaultColumnMetas = {
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "name", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "age", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "long", "long", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "float", "float", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "x", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "y", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
- }
-
- val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
- DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
- options = Option("""{"skipReverse": false}""")
- )
def getStorage(service: Service): Storage[_, _] = {
storagePool.getOrElse(s"service:${service.serviceName}", defaultStorage)
@@ -1576,11 +1557,11 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
case vId: VertexId =>
toVertex(vId.column.service.serviceName, vId.column.columnName, vId, kvsMap)
case _ =>
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumnName).toString
val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
val (serviceName, columnName) =
- if (names.length == 1) (DefaultService.serviceName, names(0))
+ if (names.length == 1) (DefaultServiceName, names(0))
else throw new RuntimeException("malformed data on vertex label.")
toVertex(serviceName, columnName, idValue, kvsMap)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e77cbc82/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 bcec609..d0761e1 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
@@ -1,25 +1,20 @@
package org.apache.s2graph.core.tinkerpop
-import java.io.File
import java.util
-import java.util.concurrent.atomic.AtomicLong
+import com.typesafe.config.ConfigFactory
import org.apache.commons.configuration.Configuration
import org.apache.s2graph.core.Management.JsonModel.Prop
+import org.apache.s2graph.core.S2Graph.{DefaultColumnName, DefaultServiceName}
import org.apache.s2graph.core._
-import org.apache.s2graph.core.mysqls.{ColumnMeta, Label, ServiceColumn}
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
import org.apache.s2graph.core.types.{HBaseType, InnerVal, VertexId}
+import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData
import org.apache.tinkerpop.gremlin.structure.{Element, Graph, T}
import org.apache.tinkerpop.gremlin.{AbstractGraphProvider, LoadGraphWith}
import scala.collection.JavaConverters._
-import scala.util.{Failure, Success, Try}
-import com.typesafe.config.ConfigFactory
-import org.apache.commons.io.FileUtils
-import org.apache.s2graph.core.utils.logger
-
-import scala.concurrent.ExecutionContext
object S2GraphProvider {
val Implementation: Set[Class[_]] = Set(
@@ -52,7 +47,7 @@ class S2GraphProvider extends AbstractGraphProvider {
// }
// }
// s2Graph.shutdown(modelDataDelete = true)
- cleanupSchema(graph)
+ cleanupSchema
s2Graph.shutdown(modelDataDelete = true)
logger.info("S2Graph Shutdown")
}
@@ -67,18 +62,51 @@ class S2GraphProvider extends AbstractGraphProvider {
}
}
- private def cleanupSchema(graph: Graph): Unit = {
- val s2Graph = graph.asInstanceOf[S2Graph]
- val mnt = s2Graph.getManagement()
- val defaultService = s2Graph.DefaultService
- val defaultServiceColumn = s2Graph.DefaultColumn
+ def initDefaultSchema(graph: S2Graph): Unit = {
+ val management = graph.management
+
+// Management.deleteService(DefaultServiceName)
+ val DefaultService = management.createService(DefaultServiceName, "localhost", "s2graph", 0, None).get
+
+// Management.deleteColumn(DefaultServiceName, DefaultColumnName)
+ val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, DefaultColumnName, Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
+
+ val DefaultColumnMetas = {
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "name", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "age", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "long", "long", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "float", "float", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "x", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "y", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
+ }
+
+// Management.deleteLabel("_s2graph")
+ val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
+ DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": false}""")
+ ).get
+ }
- 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", "hates", "link")
+ private def cleanupSchema: Unit = {
+ val columnNames = Set(S2Graph.DefaultColumnName, "person", "software", "product", "dog")
+ val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks", "hates", "link")
- Management.deleteService(defaultService.serviceName)
columnNames.foreach { columnName =>
- Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+ Management.deleteColumn(S2Graph.DefaultServiceName, columnName)
}
labelNames.foreach { labelName =>
Management.deleteLabel(labelName)
@@ -90,12 +118,13 @@ class S2GraphProvider extends AbstractGraphProvider {
override def loadGraphData(graph: Graph, loadGraphWith: LoadGraphWith, testClass: Class[_], testName: String): Unit = {
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
- val defaultService = s2Graph.DefaultService
- val defaultServiceColumn = s2Graph.DefaultColumn
+ cleanupSchema
initTestSchema(testClass, testName)
+ initDefaultSchema(s2Graph)
- Management.deleteLabel("knows")
+ val defaultService = Service.findByName(S2Graph.DefaultServiceName).getOrElse(throw new IllegalStateException("default service is not initialized."))
+ val defaultServiceColumn = ServiceColumn.find(defaultService.id.get, S2Graph.DefaultColumnName).getOrElse(throw new IllegalStateException("default column is not initialized."))
var knowsProp = Vector(
Prop("weight", "0.0", "double"),
@@ -181,20 +210,19 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Seq(Prop("xxx", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
- val self = if (testClass.getSimpleName == "StarGraphTest") {
- mnt.createLabel("self", defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
- options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getSimpleName.contains("GraphTest")) {
- mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "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, Seq(Prop("acl", "-", "string")), "weak", None, None,
- options = Option("""{"skipReverse": true}"""))
- }
+ val self =
+ if (loadGraphWith != null && loadGraphWith.value() == GraphData.CLASSIC) {
+ mnt.createLabel("self",
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": true}"""))
+ } else {
+ mnt.createLabel("self", defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ }
val friends =
if (testClass.getSimpleName == "IoVertexTest") {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e77cbc82/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 cadfd37..e6083e9 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
@@ -325,45 +325,45 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
def convertToEdgeId(g: GraphTraversalSource, outVertexName: String, edgeLabel: String, inVertexName: String): AnyRef = {
g.V().has("name", outVertexName).outE(edgeLabel).as("e").inV.has("name", inVertexName).select[Edge]("e").next().id()
}
- test("ccc") {
- val mnt = graph.management
- 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")
-
- Management.deleteService(defaultService.serviceName)
- columnNames.foreach { columnName =>
- Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
- }
- labelNames.foreach { labelName =>
- Management.deleteLabel(labelName)
- }
- 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 knows = mnt.createLabel("knows",
- defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
-
- val created = mnt.createLabel("created",
- defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
-
- val g = graph.traversal()
- val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "josh")
- val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "lop")
- val e = v1.addEdge("created", v4)
-
- val toDetach = g.E(convertToEdgeId(g, "josh", "created", "lop")).next()
- val outV = toDetach.vertices(Direction.OUT).next()
- val detachedEdge = DetachedFactory.detach(toDetach, true)
- val attached = detachedEdge.attach(Attachable.Method.get(outV))
-
- assert(toDetach.equals(attached))
- assert(!attached.isInstanceOf[DetachedEdge])
- }
+// test("ccc") {
+// val mnt = graph.management
+// 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")
+//
+// Management.deleteService(defaultService.serviceName)
+// columnNames.foreach { columnName =>
+// Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+// }
+// labelNames.foreach { labelName =>
+// Management.deleteLabel(labelName)
+// }
+// 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 knows = mnt.createLabel("knows",
+// defaultService.serviceName, "person", "integer",
+// defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+//
+// val created = mnt.createLabel("created",
+// defaultService.serviceName, "person", "integer",
+// defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+//
+// val g = graph.traversal()
+// val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "josh")
+// val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "lop")
+// val e = v1.addEdge("created", v4)
+//
+// val toDetach = g.E(convertToEdgeId(g, "josh", "created", "lop")).next()
+// val outV = toDetach.vertices(Direction.OUT).next()
+// val detachedEdge = DetachedFactory.detach(toDetach, true)
+// val attached = detachedEdge.attach(Attachable.Method.get(outV))
+//
+// assert(toDetach.equals(attached))
+// assert(!attached.isInstanceOf[DetachedEdge])
+// }
// test("ddd") {
//// @Test
[25/46] incubator-s2graph git commit: start
S2GraphProcessStandardTest suite.
Posted by st...@apache.org.
start S2GraphProcessStandardTest suite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/c7ab13e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/c7ab13e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/c7ab13e7
Branch: refs/heads/master
Commit: c7ab13e74c8b2233e1630da7ec8e5b0e37b1df25
Parents: 103f05e
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 28 02:42:23 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 28 02:42:23 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 14 ++++++++------
.../process/S2GraphProcessStandardTest.scala | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c7ab13e7/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 80285d5..efa7377 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -19,6 +19,7 @@
package org.apache.s2graph.core
+import java.lang.annotation.Annotation
import java.util
import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
@@ -527,12 +528,13 @@ object S2Graph {
}
}
+
//@Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD)
-//@Graph.OptIn(Graph.OptIn.SUITE_PROCESS_COMPUTER)
-//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_STANDARD)
-//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_COMPUTER)
-//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
-@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
+//@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
+@Graph.OptIns(value = Array(
+ new Graph.OptIn(value = Graph.OptIn.SUITE_PROCESS_STANDARD),
+ new Graph.OptIn(value = Graph.OptIn.SUITE_STRUCTURE_STANDARD)
+))
@Graph.OptOuts(value = Array(
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
// passed: all, failed: none
@@ -620,7 +622,7 @@ object S2Graph {
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="shouldReadWriteDetachedEdge", specific="graphson-v2-embedded", reason="no"),
// passed: all, except graphson-v2-embedded.
- // TODO:
+ // TODO:
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"), // all failed.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c7ab13e7/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
new file mode 100644
index 0000000..5a8fc5c
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/process/S2GraphProcessStandardTest.scala
@@ -0,0 +1,16 @@
+package org.apache.s2graph.core.tinkerpop.process
+
+import org.apache.s2graph.core.S2Graph
+import org.apache.s2graph.core.tinkerpop.S2GraphProvider
+import org.apache.tinkerpop.gremlin.GraphProviderClass
+import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite
+import org.junit.FixMethodOrder
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(classOf[ProcessStandardSuite])
+@GraphProviderClass(provider = classOf[S2GraphProvider], graph = classOf[S2Graph])
+class S2GraphProcessStandardTest {
+
+}
\ No newline at end of file
[33/46] incubator-s2graph git commit: list up all test cases for
Process test suite.
Posted by st...@apache.org.
list up all test cases for Process test suite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/dad98bc9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/dad98bc9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/dad98bc9
Branch: refs/heads/master
Commit: dad98bc99d3462b6a345a44aa82bae639e5e5270
Parents: bc50261
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed May 3 12:33:28 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed May 3 12:33:28 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 143 +++++++++++++++++++
.../core/tinkerpop/S2GraphProvider.scala | 99 +++++++++++--
2 files changed, 231 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/dad98bc9/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 7d673de..66a8d46 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -601,6 +601,149 @@ object S2Graph {
// passed: all, failed: g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path, g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX
/* map */
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CoalesceTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_both_both_count, g_V_repeatXoutX_timesX3X_count, g_V_repeatXoutX_timesX8X_count
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.FoldTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.LoopsTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MapTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MapKeysTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MapValuesTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX,
+ //g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX
+ //g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX, g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_maxX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanTest$Traversals", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MinTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_minX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest$Traversals", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest$Traversals", method = "*", reason = "no"),
+// passed: all, failed: g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name
+//
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "*", reason = "no"),
+// failed: grateful_V_out_out_profileXmetricsX, g_V_repeat_both_profileXmetricsX, grateful_V_out_out_profile, g_V_repeat_both_profile
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "*", reason = "no"),
+// failed: g_VX4X_bothE_otherV, g_VX1_2_3_4X_name, g_V_out_outE_inV_inE_inV_both_name, g_VX4X_bothEXcreatedX, g_VX4X_both
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+ /* sideEffect */
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "*", reason = "no"),
+// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "*", reason = "no"),
+// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX,
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "*", reason = "no"),
+// failed: g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX, g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+ // new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+
+ /* compliance */
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategyProcessTest", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest", method = "*", reason = "no"),
+// failed: shouldGenerateDefaultIdOnAddVWithSpecifiedId, shouldGenerateDefaultIdOnAddVWithGeneratedCustomId, shouldGenerateDefaultIdOnGraphAddVWithGeneratedDefaultId,
+// shouldGenerateDefaultIdOnAddVWithGeneratedDefaultId, shouldGenerateDefaultIdOnGraphAddVWithGeneratedCustomId, shouldGenerateDefaultIdOnGraphAddVWithSpecifiedId
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ReadOnlyStrategyProcessTest", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest", method = "*", reason = "no"),
+// failed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategyProcessTest", method = "*", reason = "no"),
+// failed: all
/** Structure */
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/dad98bc9/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 6ac12c8..fdd04af 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
@@ -55,6 +55,10 @@ object S2GraphProvider {
ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "some", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "this", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "that", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "any", "string", useCache = false)
}
// Management.deleteLabel("_s2graph")
@@ -65,8 +69,12 @@ object S2GraphProvider {
}
def cleanupSchema: Unit = {
- val columnNames = Set(S2Graph.DefaultColumnName, "person", "software", "product", "dog")
- val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks", "hates", "link")
+ val columnNames = Set(S2Graph.DefaultColumnName, "person", "software", "product", "dog",
+ "animal", "song", "artist", "STEPHEN")
+
+ val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator",
+ "test1", "test2", "test3", "pets", "walks", "hates", "link",
+ "codeveloper", "createdBy", "existsWith", "writtenBy", "sungBy", "followedBy", "uses")
columnNames.foreach { columnName =>
Management.deleteColumn(S2Graph.DefaultServiceName, columnName)
@@ -91,12 +99,12 @@ class S2GraphProvider extends AbstractGraphProvider {
if (graph != null) {
val s2Graph = graph.asInstanceOf[S2Graph]
if (s2Graph.isRunning) {
-// val labels = Label.findAll()
-// labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
-// labelsWithSameTable.headOption.foreach { label =>
-// s2Graph.management.truncateStorage(label.label)
-// }
-// }
+ val labels = Label.findAll()
+ labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
+ labelsWithSameTable.headOption.foreach { label =>
+ s2Graph.management.truncateStorage(label.label)
+ }
+ }
// s2Graph.shutdown(modelDataDelete = true)
S2GraphProvider.cleanupSchema
s2Graph.shutdown(modelDataDelete = true)
@@ -181,7 +189,7 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
}
-
+ // columns
val personColumn = Management.createServiceColumn(defaultService.serviceName, "person", "integer",
Seq(Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
val softwareColumn = Management.createServiceColumn(defaultService.serviceName, "software", "integer",
@@ -189,8 +197,19 @@ class S2GraphProvider extends AbstractGraphProvider {
val productColumn = Management.createServiceColumn(defaultService.serviceName, "product", "integer", Nil)
val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
+ val animalColumn = Management.createServiceColumn(defaultService.serviceName, "animal", "integer", Seq(Prop("age", "0", "integer"), Prop("name", "-", "string")))
+ val songColumn = Management.createServiceColumn(defaultService.serviceName, "song", "integer",
+ Seq(Prop("name", "-", "string"), Prop("songType", "-", "string"), Prop("performances", "0", "integer"))
+ )
+ val artistColumn = Management.createServiceColumn(defaultService.serviceName, "artist", "integer",
+ Seq(Prop("name", "-", "string"))
+ )
+ val stephenColumn = Management.createServiceColumn(defaultService.serviceName, "STEPHEN", "integer",
+ Seq(Prop("name", "-", "string"))
+ )
// val vertexColumn = Management.createServiceColumn(service.serviceName, "vertex", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "-1", "integer"), Prop("lang", "scala", "string")))
+ // labels
val createdProps = Seq(Prop("weight", "0.0", "double"), Prop("name", "-", "string"))
val created =
@@ -215,17 +234,20 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Seq(Prop("xxx", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
+ val selfProps = Seq(Prop("__id", "-", "string"), Prop("acl", "-", "string"),
+ Prop("test", "-", "string"), Prop("name", "-", "string"), Prop("some", "-", "string"))
+
val self =
if (loadGraphWith != null && loadGraphWith.value() == GraphData.CLASSIC) {
mnt.createLabel("self",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ true, defaultService.serviceName, Nil, selfProps, "strong", None, None,
options = Option("""{"skipReverse": true}"""))
} else {
mnt.createLabel("self", defaultService.serviceName, "person", "integer",
defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ true, defaultService.serviceName, Nil, selfProps, "strong", None, None,
options = Option("""{"skipReverse": false}"""))
}
@@ -326,6 +348,61 @@ class S2GraphProvider extends AbstractGraphProvider {
options = Option("""{"skipReverse": false}""")
)
+ val codeveloper = mnt.createLabel("codeveloper",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("year", "0", "integer")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val createdBy = mnt.createLabel("createdBy",
+ defaultService.serviceName, "software", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("weight", "0.0", "double"),
+ Prop("year", "0", "integer"),
+ Prop("acl", "-", "string")
+ ), "strong", None, None)
+
+ val existsWith = mnt.createLabel("existsWith",
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Seq(Prop("time", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val followedBy = mnt.createLabel("followedBy",
+ defaultService.serviceName, "song", "integer",
+ defaultService.serviceName, "song", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val writtenBy = mnt.createLabel("writtenBy",
+ defaultService.serviceName, "song", "integer",
+ defaultService.serviceName, "artist", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val sungBy = mnt.createLabel("sungBy",
+ defaultService.serviceName, "song", "integer",
+ defaultService.serviceName, "artist", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val uses = mnt.createLabel("uses",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "software", "integer",
+ true, defaultService.serviceName, Nil, Nil, "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
super.loadGraphData(graph, loadGraphWith, testClass, testName)
}
[04/46] incubator-s2graph git commit: tmp.
Posted by st...@apache.org.
tmp.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/20b51cef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/20b51cef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/20b51cef
Branch: refs/heads/master
Commit: 20b51cef03661db67bd9c10cff9d2429097a3fc9
Parents: 1a15af3
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 5 00:18:26 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 5 00:18:26 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 6 +++---
s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala | 7 ++++---
.../org/apache/s2graph/core/features/S2DataTypeFeatures.scala | 2 +-
.../org/apache/s2graph/core/features/S2ElementFeatures.scala | 5 +++--
4 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/20b51cef/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 cfd85b1..182b8ed 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -531,11 +531,11 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
// passed
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
+ 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.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
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/20b51cef/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 afee5d9..643b469 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -216,9 +216,10 @@ case class S2Vertex(graph: S2Graph,
override def properties[V](keys: String*): util.Iterator[VertexProperty[V]] = {
val ls = new util.ArrayList[VertexProperty[V]]()
if (keys.isEmpty) {
- props.keySet().forEach(new Consumer[String] {
- override def accept(key: String): Unit = {
- if (!ColumnMeta.reservedMetaNamesSet(key)) ls.add(property[V](key))
+ props.forEach(new BiConsumer[String, VertexProperty[_]] {
+ override def accept(key: String, property: VertexProperty[_]): Unit = {
+ if (!ColumnMeta.reservedMetaNamesSet(key) && property.isPresent)
+ ls.add(property.asInstanceOf[VertexProperty[V]])
}
})
} else {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/20b51cef/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
index a79da46..a94ead3 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2DataTypeFeatures.scala
@@ -30,7 +30,7 @@ case class S2DataTypeFeatures() extends Features.DataTypeFeatures {
override def supportsBooleanArrayValues(): Boolean = false
- override def supportsSerializableValues(): Boolean = true
+ override def supportsSerializableValues(): Boolean = false
override def supportsLongArrayValues(): Boolean = false
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/20b51cef/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
index bbb6a79..06f1c68 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2ElementFeatures.scala
@@ -5,7 +5,7 @@ import org.apache.tinkerpop.gremlin.structure.Graph.Features
abstract class S2ElementFeatures extends Features.ElementFeatures {
override def supportsStringIds(): Boolean = true
- override def supportsCustomIds(): Boolean = false
+ override def supportsCustomIds(): Boolean = true
override def supportsUuidIds(): Boolean = false
@@ -15,9 +15,10 @@ abstract class S2ElementFeatures extends Features.ElementFeatures {
override def supportsUserSuppliedIds(): Boolean = true
- override def supportsAnyIds(): Boolean = false
+ override def supportsAnyIds(): Boolean = true
override def supportsNumericIds(): Boolean = false
+ override def willAllowId(id: scala.Any): Boolean = true
// override def willAllowId(id: scala.Any): Boolean = super.willAllowId(id)
}
[34/46] incubator-s2graph git commit: 63/582 failed.
Posted by st...@apache.org.
63/582 failed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/a5b34e97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/a5b34e97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/a5b34e97
Branch: refs/heads/master
Commit: a5b34e97fd44683bfc77f8cf0adc4f20164dbf46
Parents: dad98bc
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed May 3 14:30:43 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed May 3 16:43:05 2017 +0900
----------------------------------------------------------------------
----------------------------------------------------------------------
[28/46] incubator-s2graph git commit: move test related schema into
S2GraphProvider from S2Graph.
Posted by st...@apache.org.
move test related schema into S2GraphProvider from S2Graph.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/0e47e118
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/0e47e118
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/0e47e118
Branch: refs/heads/master
Commit: 0e47e118476b7bd85f8f934f57440939115f881e
Parents: b023648
Author: DO YUNG YOON <st...@apache.org>
Authored: Sun Apr 30 10:54:29 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sun Apr 30 10:54:29 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 49 +++------
.../core/tinkerpop/S2GraphProvider.scala | 100 ++++++++++++-------
.../core/tinkerpop/structure/S2GraphTest.scala | 78 +++++++--------
3 files changed, 118 insertions(+), 109 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0e47e118/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 e30be74..f05f2cb 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -19,7 +19,6 @@
package org.apache.s2graph.core
-import java.lang.annotation.Annotation
import java.util
import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
@@ -97,6 +96,10 @@ object S2Graph {
val threadPool = Executors.newFixedThreadPool(numOfThread)
val ec = ExecutionContext.fromExecutor(threadPool)
+ val DefaultServiceName = ""
+ val DefaultColumnName = "vertex"
+ val DefaultLabelName = "_s2graph"
+
def toTypeSafeConfig(configuration: Configuration): Config = {
val m = new mutable.HashMap[String, AnyRef]()
for {
@@ -536,7 +539,15 @@ object S2Graph {
new Graph.OptIn(value = Graph.OptIn.SUITE_STRUCTURE_STANDARD)
))
@Graph.OptOuts(value = Array(
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+ /** Process */
+// new Graph.OptOut(
+// test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
+// method = "g_V_valueMap_matchXa_selectXnameX_bX",
+// reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute."),
+
+ /** Structure */
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateEquality", reason="reference equals on EdgeId is not supported."),
// passed: all, failed: none
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
@@ -717,36 +728,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
(k, v) = (entry.getKey, entry.getValue)
} logger.info(s"[Initialized]: $k, ${this.config.getAnyRef(k)}")
- /* TODO */
- val DefaultService = management.createService("", "localhost", "s2graph", 0, None).get
- val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, "vertex", Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
- val DefaultColumnMetas = {
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "name", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "age", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "long", "long", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "float", "float", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "x", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "y", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
- }
-
- val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
- DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
- options = Option("""{"skipReverse": false}""")
- )
def getStorage(service: Service): Storage[_, _] = {
storagePool.getOrElse(s"service:${service.serviceName}", defaultStorage)
@@ -1576,11 +1557,11 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
case vId: VertexId =>
toVertex(vId.column.service.serviceName, vId.column.columnName, vId, kvsMap)
case _ =>
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumnName).toString
val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
val (serviceName, columnName) =
- if (names.length == 1) (DefaultService.serviceName, names(0))
+ if (names.length == 1) (DefaultServiceName, names(0))
else throw new RuntimeException("malformed data on vertex label.")
toVertex(serviceName, columnName, idValue, kvsMap)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0e47e118/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 bcec609..d0761e1 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
@@ -1,25 +1,20 @@
package org.apache.s2graph.core.tinkerpop
-import java.io.File
import java.util
-import java.util.concurrent.atomic.AtomicLong
+import com.typesafe.config.ConfigFactory
import org.apache.commons.configuration.Configuration
import org.apache.s2graph.core.Management.JsonModel.Prop
+import org.apache.s2graph.core.S2Graph.{DefaultColumnName, DefaultServiceName}
import org.apache.s2graph.core._
-import org.apache.s2graph.core.mysqls.{ColumnMeta, Label, ServiceColumn}
+import org.apache.s2graph.core.mysqls.{ColumnMeta, Service, ServiceColumn}
import org.apache.s2graph.core.types.{HBaseType, InnerVal, VertexId}
+import org.apache.s2graph.core.utils.logger
import org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData
import org.apache.tinkerpop.gremlin.structure.{Element, Graph, T}
import org.apache.tinkerpop.gremlin.{AbstractGraphProvider, LoadGraphWith}
import scala.collection.JavaConverters._
-import scala.util.{Failure, Success, Try}
-import com.typesafe.config.ConfigFactory
-import org.apache.commons.io.FileUtils
-import org.apache.s2graph.core.utils.logger
-
-import scala.concurrent.ExecutionContext
object S2GraphProvider {
val Implementation: Set[Class[_]] = Set(
@@ -52,7 +47,7 @@ class S2GraphProvider extends AbstractGraphProvider {
// }
// }
// s2Graph.shutdown(modelDataDelete = true)
- cleanupSchema(graph)
+ cleanupSchema
s2Graph.shutdown(modelDataDelete = true)
logger.info("S2Graph Shutdown")
}
@@ -67,18 +62,51 @@ class S2GraphProvider extends AbstractGraphProvider {
}
}
- private def cleanupSchema(graph: Graph): Unit = {
- val s2Graph = graph.asInstanceOf[S2Graph]
- val mnt = s2Graph.getManagement()
- val defaultService = s2Graph.DefaultService
- val defaultServiceColumn = s2Graph.DefaultColumn
+ def initDefaultSchema(graph: S2Graph): Unit = {
+ val management = graph.management
+
+// Management.deleteService(DefaultServiceName)
+ val DefaultService = management.createService(DefaultServiceName, "localhost", "s2graph", 0, None).get
+
+// Management.deleteColumn(DefaultServiceName, DefaultColumnName)
+ val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, DefaultColumnName, Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
+
+ val DefaultColumnMetas = {
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "name", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "age", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "long", "long", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "float", "float", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "double", "double", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "integer", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "aKey", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "x", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "y", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
+ }
+
+// Management.deleteLabel("_s2graph")
+ val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
+ DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
+ options = Option("""{"skipReverse": false}""")
+ ).get
+ }
- 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", "hates", "link")
+ private def cleanupSchema: Unit = {
+ val columnNames = Set(S2Graph.DefaultColumnName, "person", "software", "product", "dog")
+ val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks", "hates", "link")
- Management.deleteService(defaultService.serviceName)
columnNames.foreach { columnName =>
- Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+ Management.deleteColumn(S2Graph.DefaultServiceName, columnName)
}
labelNames.foreach { labelName =>
Management.deleteLabel(labelName)
@@ -90,12 +118,13 @@ class S2GraphProvider extends AbstractGraphProvider {
override def loadGraphData(graph: Graph, loadGraphWith: LoadGraphWith, testClass: Class[_], testName: String): Unit = {
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
- val defaultService = s2Graph.DefaultService
- val defaultServiceColumn = s2Graph.DefaultColumn
+ cleanupSchema
initTestSchema(testClass, testName)
+ initDefaultSchema(s2Graph)
- Management.deleteLabel("knows")
+ val defaultService = Service.findByName(S2Graph.DefaultServiceName).getOrElse(throw new IllegalStateException("default service is not initialized."))
+ val defaultServiceColumn = ServiceColumn.find(defaultService.id.get, S2Graph.DefaultColumnName).getOrElse(throw new IllegalStateException("default column is not initialized."))
var knowsProp = Vector(
Prop("weight", "0.0", "double"),
@@ -181,20 +210,19 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Seq(Prop("xxx", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
- val self = if (testClass.getSimpleName == "StarGraphTest") {
- mnt.createLabel("self", defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
- options = Option("""{"skipReverse": false}"""))
- } else if (testClass.getSimpleName.contains("GraphTest")) {
- mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "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, Seq(Prop("acl", "-", "string")), "weak", None, None,
- options = Option("""{"skipReverse": true}"""))
- }
+ val self =
+ if (loadGraphWith != null && loadGraphWith.value() == GraphData.CLASSIC) {
+ mnt.createLabel("self",
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": true}"""))
+ } else {
+ mnt.createLabel("self", defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ }
val friends =
if (testClass.getSimpleName == "IoVertexTest") {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0e47e118/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 cadfd37..e6083e9 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
@@ -325,45 +325,45 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
def convertToEdgeId(g: GraphTraversalSource, outVertexName: String, edgeLabel: String, inVertexName: String): AnyRef = {
g.V().has("name", outVertexName).outE(edgeLabel).as("e").inV.has("name", inVertexName).select[Edge]("e").next().id()
}
- test("ccc") {
- val mnt = graph.management
- 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")
-
- Management.deleteService(defaultService.serviceName)
- columnNames.foreach { columnName =>
- Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
- }
- labelNames.foreach { labelName =>
- Management.deleteLabel(labelName)
- }
- 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 knows = mnt.createLabel("knows",
- defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
-
- val created = mnt.createLabel("created",
- defaultService.serviceName, "person", "integer",
- defaultService.serviceName, "person", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
-
- val g = graph.traversal()
- val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "josh")
- val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "lop")
- val e = v1.addEdge("created", v4)
-
- val toDetach = g.E(convertToEdgeId(g, "josh", "created", "lop")).next()
- val outV = toDetach.vertices(Direction.OUT).next()
- val detachedEdge = DetachedFactory.detach(toDetach, true)
- val attached = detachedEdge.attach(Attachable.Method.get(outV))
-
- assert(toDetach.equals(attached))
- assert(!attached.isInstanceOf[DetachedEdge])
- }
+// test("ccc") {
+// val mnt = graph.management
+// 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")
+//
+// Management.deleteService(defaultService.serviceName)
+// columnNames.foreach { columnName =>
+// Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+// }
+// labelNames.foreach { labelName =>
+// Management.deleteLabel(labelName)
+// }
+// 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 knows = mnt.createLabel("knows",
+// defaultService.serviceName, "person", "integer",
+// defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+//
+// val created = mnt.createLabel("created",
+// defaultService.serviceName, "person", "integer",
+// defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+//
+// val g = graph.traversal()
+// val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "josh")
+// val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "lop")
+// val e = v1.addEdge("created", v4)
+//
+// val toDetach = g.E(convertToEdgeId(g, "josh", "created", "lop")).next()
+// val outV = toDetach.vertices(Direction.OUT).next()
+// val detachedEdge = DetachedFactory.detach(toDetach, true)
+// val attached = detachedEdge.attach(Attachable.Method.get(outV))
+//
+// assert(toDetach.equals(attached))
+// assert(!attached.isInstanceOf[DetachedEdge])
+// }
// test("ddd") {
//// @Test
[36/46] incubator-s2graph git commit: 55 failed.
Posted by st...@apache.org.
55 failed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/549279d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/549279d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/549279d9
Branch: refs/heads/master
Commit: 549279d91cb0195357d02855ba5a49b55ea63564
Parents: 7f34d7b
Author: DO YUNG YOON <st...@apache.org>
Authored: Thu May 4 01:03:54 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Thu May 4 01:03:54 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 4 +--
.../org/apache/s2graph/core/S2Vertex.scala | 6 +++-
.../core/tinkerpop/S2GraphProvider.scala | 32 +++++++++++++++++++-
3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/549279d9/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 ca336a7..fa9ff62 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -538,8 +538,8 @@ case class S2Edge(innerGraph: S2Graph,
}
def toLogString: String = {
- val allPropsWithName = defaultPropsWithName ++ Json.toJson(propsWithName).asOpt[JsObject].getOrElse(Json.obj())
- List(ts, GraphUtil.fromOp(op), "e", srcVertex.innerId, tgtVertex.innerId, innerLabel.label, allPropsWithName).mkString("\t")
+// val allPropsWithName = defaultPropsWithName ++ Json.toJson(propsWithName).asOpt[JsObject].getOrElse(Json.obj())
+ List(ts, GraphUtil.fromOp(op), "e", srcVertex.innerId, tgtVertex.innerId, innerLabel.label, propsWithTs).mkString("\t")
}
override def hashCode(): Int = {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/549279d9/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 64d298d..5277851 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -150,7 +150,11 @@ case class S2Vertex(graph: S2Graph,
Label.findBySrcColumnId(id.colId).map(l => l.label -> direction.name)
}
} else {
- labelNames.map(_ -> direction.name())
+ direction match {
+ case Direction.BOTH =>
+ Seq(Direction.OUT, Direction.IN).flatMap { dir => labelNames.map(_ -> dir.name()) }
+ case _ => labelNames.map(_ -> direction.name())
+ }
}
graph.fetchEdges(this, labelNameWithDirs)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/549279d9/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 37e011c..db55c03 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
@@ -74,7 +74,7 @@ object S2GraphProvider {
val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator",
"test1", "test2", "test3", "pets", "walks", "hates", "link",
- "codeveloper", "createdBy", "existsWith", "writtenBy", "sungBy", "followedBy", "uses")
+ "codeveloper", "createdBy", "existsWith", "writtenBy", "sungBy", "followedBy", "uses", "likes", "foo", "bar")
columnNames.foreach { columnName =>
Management.deleteColumn(S2Graph.DefaultServiceName, columnName)
@@ -403,6 +403,36 @@ class S2GraphProvider extends AbstractGraphProvider {
options = Option("""{"skipReverse": false}""")
)
+ val likes = mnt.createLabel("likes",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("year", "0", "integer")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val foo = mnt.createLabel("foo",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("year", "0", "integer")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
+ val bar = mnt.createLabel("bar",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("year", "0", "integer")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+
super.loadGraphData(graph, loadGraphWith, testClass, testName)
}
[26/46] incubator-s2graph git commit: Bug fix on Thread pool creation
on S2Graph.open.
Posted by st...@apache.org.
Bug fix on Thread pool creation on S2Graph.open.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/46cafb75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/46cafb75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/46cafb75
Branch: refs/heads/master
Commit: 46cafb756cf96535a04a706ce5b17fbf3936aef5
Parents: c7ab13e
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 28 20:02:22 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 28 21:35:36 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 6 +++---
s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/46cafb75/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 efa7377..e30be74 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -93,6 +93,9 @@ object S2Graph {
)
var DefaultConfig: Config = ConfigFactory.parseMap(DefaultConfigs)
+ val numOfThread = Runtime.getRuntime.availableProcessors()
+ val threadPool = Executors.newFixedThreadPool(numOfThread)
+ val ec = ExecutionContext.fromExecutor(threadPool)
def toTypeSafeConfig(configuration: Configuration): Config = {
val m = new mutable.HashMap[String, AnyRef]()
@@ -117,9 +120,6 @@ object S2Graph {
}
def open(configuration: Configuration): S2Graph = {
- val numOfThread = Runtime.getRuntime.availableProcessors()
- val threadPool = Executors.newFixedThreadPool(numOfThread)
- val ec = ExecutionContext.fromExecutor(threadPool)
new S2Graph(configuration)(ec)
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/46cafb75/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 aca9826..07d2bbf 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Property.scala
@@ -31,6 +31,7 @@ import scala.util.hashing.MurmurHash3
object S2Property {
def validType(t: Any): Boolean = t match {
+ case _: EdgeId => true
case _: VertexId => true
case _: java.lang.Integer => true
case _: java.lang.Long => true
[11/46] incubator-s2graph git commit: [Passed]: EdgeTest,
GraphConstructionTest, VertexPropertyTest, PropertyTest.
Posted by st...@apache.org.
[Passed]: EdgeTest, GraphConstructionTest, VertexPropertyTest, PropertyTest.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/c508def0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/c508def0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/c508def0
Branch: refs/heads/master
Commit: c508def0ebaf79ed6a7f6507117bfca63c0b02e2
Parents: cbcb46c
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 14 11:45:16 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 14 11:45:16 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 2 +-
.../scala/org/apache/s2graph/core/S2Graph.scala | 90 +++++++++++++-------
.../core/tinkerpop/S2GraphProvider.scala | 2 +-
3 files changed, 63 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c508def0/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 6321dd5..3b000f6 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -682,7 +682,7 @@ case class S2Edge(innerGraph: S2Graph,
override def id(): AnyRef = {
// NOTE: xxxForVertex makes direction to be "out"
- val timestamp = if (this.innerLabel.consistencyLevel == "string") 0l else ts
+ val timestamp = if (this.innerLabel.consistencyLevel == "strong") 0l else ts
EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), direction, timestamp)
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c508def0/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 f1f00e7..49e2272 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -528,49 +528,81 @@ object S2Graph {
}
}
+//@Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD)
+//@Graph.OptIn(Graph.OptIn.SUITE_PROCESS_COMPUTER)
+//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_STANDARD)
+//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_COMPUTER)
+//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
- // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
+// // passed: all, failed: none
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
+ // passed: , failed: shouldEnableFeatureOnEdgeIfNotEnabled, shouldEnableFeatureOnVertexIfNotEnabled, shouldSupportUserSuppliedIdsOfTypeAny
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
+ // passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="*", reason="no"),
+ // passed: all, failed: shouldNotEvaluateToEqualDifferentId
+
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
+ // passed: all, failed: none
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"),
+ // passed: all, failed: none, all ignored
- // not passed
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"),
+ // passed: , failed: shouldNotBeEqualPropertiesAsThereIsDifferentKey
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest", method="*", reason="no"), // pss
+ 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.util.detached.DetachedEdgeTest", method="*", reason="no"), // pass
+ 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.detached.DetachedGraphTest", method="*", reason="no"), // pass all ignored
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="*", reason="no"),
+ // passed: , failed: shouldNotEvaluateToEqualDifferentId, shouldConstructReferenceEdge
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"),
+ // passed: all, failed: none
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"),
+ // passed: all, failed: none, all ignored
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
+ // passed: all, failed: none, all ignored
// not yet supported
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.TransactionTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest", method="*", reason="no"), // 10/16 failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.TransactionTest", method="*", reason="no"), // all ignored since supportTransaction is false.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"), // all failed since implementation is missing.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"), // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"), // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"), // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no"), // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest", method="*", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest", method="*", reason="no"), // failed on shouldHandleSelfLoops
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest", method="*", reason="no"),
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGeneratorTest", method="*", reason="no")
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest", method="*", reason="no"), // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGeneratorTest", method="*", reason="no") // all failed.
))
class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c508def0/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 865717d..0ab3dc7 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", "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 =>
[21/46] incubator-s2graph git commit: [VariablesTest] passed all.
Posted by st...@apache.org.
[VariablesTest] 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/9d175a76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/9d175a76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/9d175a76
Branch: refs/heads/master
Commit: 9d175a768853299574f649a67acccd789f467e72
Parents: 8cb6209
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 26 15:44:51 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 26 15:44:51 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 6 ++-
.../core/features/S2GraphVariables.scala | 41 ++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9d175a76/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 2586173..a45d080 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -27,6 +27,7 @@ import com.typesafe.config.{Config, ConfigFactory}
import org.apache.commons.configuration.{BaseConfiguration, Configuration}
import org.apache.s2graph.core.GraphExceptions.{FetchTimeoutException, LabelNotExistException}
import org.apache.s2graph.core.JSONParser._
+import org.apache.s2graph.core.features.S2GraphVariables
import org.apache.s2graph.core.mysqls._
import org.apache.s2graph.core.storage.hbase.AsynchbaseStorage
import org.apache.s2graph.core.storage.{SKeyValue, Storage}
@@ -584,9 +585,10 @@ object S2Graph {
// passed: all, failed: none, all ignored
// not yet supported
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"), // all failed since implementation is missing.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest", method="*", reason="no"), // 10/16 failed.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.TransactionTest", method="*", reason="no"), // all ignored since supportTransaction is false.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VariablesTest", method="*", reason="no"), // all failed since implementation is missing.
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"), // all failed.
@@ -1590,7 +1592,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
???
}
- override def variables(): Variables = ???
+ override def variables(): Variables = new S2GraphVariables()
override def configuration(): Configuration = apacheConfiguration
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/9d175a76/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
new file mode 100644
index 0000000..8e963f5
--- /dev/null
+++ b/s2core/src/main/scala/org/apache/s2graph/core/features/S2GraphVariables.scala
@@ -0,0 +1,41 @@
+package org.apache.s2graph.core.features
+
+import java.util
+import java.util.Optional
+import scala.collection.JavaConversions._
+import org.apache.tinkerpop.gremlin.structure.Graph
+
+class S2GraphVariables extends Graph.Variables {
+ import scala.collection.mutable
+ private val variables = mutable.Map.empty[String, Any]
+
+ override def set(key: String, value: scala.Any): Unit = {
+ if (key == null) throw Graph.Variables.Exceptions.variableKeyCanNotBeNull()
+ if (key.isEmpty) throw Graph.Variables.Exceptions.variableKeyCanNotBeEmpty()
+ if (value == null) throw Graph.Variables.Exceptions.variableValueCanNotBeNull()
+
+ variables.put(key, value)
+ }
+
+ override def keys(): util.Set[String] = variables.keySet
+
+ override def remove(key: String): Unit = {
+ if (key == null) throw Graph.Variables.Exceptions.variableKeyCanNotBeNull()
+ if (key.isEmpty) throw Graph.Variables.Exceptions.variableKeyCanNotBeEmpty()
+
+ variables.remove(key)
+ }
+
+ override def get[R](key: String): Optional[R] = {
+ if (key == null) throw Graph.Variables.Exceptions.variableKeyCanNotBeNull()
+ if (key.isEmpty) throw Graph.Variables.Exceptions.variableKeyCanNotBeEmpty()
+ variables.get(key) match {
+ case None => Optional.empty()
+ case Some(value) => if (value == null) Optional.empty() else Optional.of(value.asInstanceOf[R])
+ }
+ }
+
+ override def toString: String = {
+ s"variables[size:${variables.keys.size()}]"
+ }
+}
\ No newline at end of file
[31/46] incubator-s2graph git commit: bug fix on S2Edge.vertices.
Posted by st...@apache.org.
bug fix on S2Edge.vertices.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/38ec51dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/38ec51dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/38ec51dc
Branch: refs/heads/master
Commit: 38ec51dca0bbc21893142878807345c8f7286742
Parents: ed035a3
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed May 3 08:23:39 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed May 3 08:23:39 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 23 +++--
.../scala/org/apache/s2graph/core/S2Graph.scala | 49 +++++++--
.../core/tinkerpop/S2GraphProvider.scala | 102 ++++++++++---------
.../core/tinkerpop/structure/S2GraphTest.scala | 75 +++++++++++++-
4 files changed, 180 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/38ec51dc/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 5712754..28a0b06 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -561,6 +561,7 @@ case class S2Edge(innerGraph: S2Graph,
override def toString: String = {
// E + L_BRACKET + edge.id() + R_BRACKET + L_BRACKET + edge.outVertex().id() + DASH + edge.label() + ARROW + edge.inVertex().id() + R_BRACKET;
s"e[${id}][${srcForVertex.id}-${innerLabel.label}->${tgtForVertex.id}]"
+ // s"e[${srcForVertex.id}-${innerLabel.label}->${tgtForVertex.id}]"
}
def checkProperty(key: String): Boolean = propsWithTs.containsKey(key)
@@ -604,18 +605,20 @@ case class S2Edge(innerGraph: S2Graph,
direction match {
case Direction.OUT =>
- val newVertexId = this.direction match {
- case "out" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
- case "in" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
- case _ => throw new IllegalArgumentException("direction can only be out/in.")
- }
+// val newVertexId = this.direction match {
+// case "out" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
+// case "in" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
+// case _ => throw new IllegalArgumentException("direction can only be out/in.")
+// }
+ val newVertexId = edgeId.srcVertexId
innerGraph.getVertex(newVertexId).foreach(arr.add)
case Direction.IN =>
- val newVertexId = this.direction match {
- case "in" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
- case "out" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
- case _ => throw new IllegalArgumentException("direction can only be out/in.")
- }
+// val newVertexId = this.direction match {
+// case "in" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
+// case "out" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
+// case _ => throw new IllegalArgumentException("direction can only be out/in.")
+// }
+ val newVertexId = edgeId.tgtVertexId
innerGraph.getVertex(newVertexId).foreach(arr.add)
case _ =>
import scala.collection.JavaConversions._
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/38ec51dc/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 f05f2cb..a0d8f37 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -540,10 +540,42 @@ object S2Graph {
))
@Graph.OptOuts(value = Array(
/** Process */
-// new Graph.OptOut(
-// test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
-// method = "g_V_valueMap_matchXa_selectXnameX_bX",
-// reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute."),
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchTest$Traversals", method = "*", reason = "no"),
+ // passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseTest$Traversals", method = "*", reason = "no"),
+ // passed: , failed: g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalTest$Traversals", method = "*", reason = "no"),
+// failed: g_V_localXmatchXproject__created_person__person_name_nameX_selectXname_projectX_by_byXnameX,
+// g_V_localXbothEXcreatedX_limitX1XX_otherV_name
+// g_VX4X_localXbothEX1_createdX_limitX1XX
+//g_VX4X_localXbothEXknows_createdX_limitX1XX
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatTest$Traversals", method = "*", reason = "no"),
+// failed: g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionTest$Traversals", method = "*", reason = "no"),
+//failed: g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX_groupCount,
+//g_V_unionXout__inX_name
+//g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX
+//g_V_unionXrepeatXunionXoutXcreatedX__inXcreatedXX_timesX2X__repeatXunionXinXcreatedX__outXcreatedXX_timesX2XX_label_groupCount
+//g_VX1X_unionXrepeatXoutX_timesX2X__outX_name
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndTest$Traversals", method = "*", reason = "no"),
+// failed: g_V_asXaX_outXknowsX_and_outXcreatedX_inXcreatedX_asXaX_name
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
+// failed: all
+
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
+
/** Structure */
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest$BasicEdgeTest", method="shouldValidateIdEquality", reason="reference equals on EdgeId is not supported."),
@@ -1459,11 +1491,16 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
def fetchEdgesAsync(vertex: S2Vertex, labelNameWithDirs: Seq[(String, String)]): Future[util.Iterator[Edge]] = {
val queryParams = labelNameWithDirs.map { case (l, direction) =>
- QueryParam(labelName = l, direction = direction)
+ QueryParam(labelName = l, direction = direction.toLowerCase)
}
val query = Query.toQuery(Seq(vertex), queryParams)
-
+// val queryRequests = queryParams.map { param => QueryRequest(query, 0, vertex, param) }
+// val ls = new util.ArrayList[Edge]()
+// fetches(queryRequests, Map.empty).map { stepResultLs =>
+// stepResultLs.foreach(_.edgeWithScores.foreach(es => ls.add(es.edge)))
+// ls.iterator()
+// }
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/38ec51dc/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 74edd6d..6ac12c8 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
@@ -25,51 +25,13 @@ object S2GraphProvider {
classOf[S2VertexProperty[_]],
classOf[S2Graph]
)
-}
-
-class S2GraphProvider extends AbstractGraphProvider {
-
- override def getBaseConfiguration(s: String, aClass: Class[_], s1: String, graphData: GraphData): util.Map[String, AnyRef] = {
- val config = ConfigFactory.load()
- val m = new java.util.HashMap[String, AnyRef]()
- m.put(Graph.GRAPH, classOf[S2Graph].getName)
-// m.put("db.default.url", "jdbc:h2:mem:db1;MODE=MYSQL")
- m
- }
-
- override def clear(graph: Graph, configuration: Configuration): Unit =
- if (graph != null) {
- val s2Graph = graph.asInstanceOf[S2Graph]
- if (s2Graph.isRunning) {
-// val labels = Label.findAll()
-// labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
-// labelsWithSameTable.headOption.foreach { label =>
-// s2Graph.management.truncateStorage(label.label)
-// }
-// }
-// s2Graph.shutdown(modelDataDelete = true)
- cleanupSchema
- s2Graph.shutdown(modelDataDelete = true)
- logger.info("S2Graph Shutdown")
- }
- }
-
- override def getImplementations: util.Set[Class[_]] = S2GraphProvider.Implementation.asJava
-
- def initTestSchema(testClass: Class[_], testName: String) = {
- val testClassName = testClass.getSimpleName
- testClass.getSimpleName match {
- case _ =>
- }
- }
-
def initDefaultSchema(graph: S2Graph): Unit = {
val management = graph.management
-// Management.deleteService(DefaultServiceName)
+ // Management.deleteService(DefaultServiceName)
val DefaultService = management.createService(DefaultServiceName, "localhost", "s2graph", 0, None).get
-// Management.deleteColumn(DefaultServiceName, DefaultColumnName)
+ // Management.deleteColumn(DefaultServiceName, DefaultColumnName)
val DefaultColumn = ServiceColumn.findOrInsert(DefaultService.id.get, DefaultColumnName, Some("string"), HBaseType.DEFAULT_VERSION, useCache = false)
val DefaultColumnMetas = {
@@ -95,14 +57,14 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
}
-// Management.deleteLabel("_s2graph")
+ // Management.deleteLabel("_s2graph")
val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, true, DefaultService.serviceName, Nil, Nil, "weak", None, None,
options = Option("""{"skipReverse": false}""")
).get
}
- private def cleanupSchema: Unit = {
+ def cleanupSchema: Unit = {
val columnNames = Set(S2Graph.DefaultColumnName, "person", "software", "product", "dog")
val labelNames = Set(S2Graph.DefaultLabelName, "knows", "created", "bought", "test", "self", "friends", "friend", "hate", "collaborator", "test1", "test2", "test3", "pets", "walks", "hates", "link")
@@ -113,6 +75,43 @@ class S2GraphProvider extends AbstractGraphProvider {
Management.deleteLabel(labelName)
}
}
+}
+
+class S2GraphProvider extends AbstractGraphProvider {
+
+ override def getBaseConfiguration(s: String, aClass: Class[_], s1: String, graphData: GraphData): util.Map[String, AnyRef] = {
+ val config = ConfigFactory.load()
+ val m = new java.util.HashMap[String, AnyRef]()
+ m.put(Graph.GRAPH, classOf[S2Graph].getName)
+// m.put("db.default.url", "jdbc:h2:mem:db1;MODE=MYSQL")
+ m
+ }
+
+ override def clear(graph: Graph, configuration: Configuration): Unit =
+ if (graph != null) {
+ val s2Graph = graph.asInstanceOf[S2Graph]
+ if (s2Graph.isRunning) {
+// val labels = Label.findAll()
+// labels.groupBy(_.hbaseTableName).values.foreach { labelsWithSameTable =>
+// labelsWithSameTable.headOption.foreach { label =>
+// s2Graph.management.truncateStorage(label.label)
+// }
+// }
+// s2Graph.shutdown(modelDataDelete = true)
+ S2GraphProvider.cleanupSchema
+ s2Graph.shutdown(modelDataDelete = true)
+ logger.info("S2Graph Shutdown")
+ }
+ }
+
+ override def getImplementations: util.Set[Class[_]] = S2GraphProvider.Implementation.asJava
+
+ def initTestSchema(testClass: Class[_], testName: String) = {
+ val testClassName = testClass.getSimpleName
+ testClass.getSimpleName match {
+ case _ =>
+ }
+ }
// override def openTestGraph(config: Configuration): Graph = new S2Graph(config)(ExecutionContext.global)
@@ -120,9 +119,9 @@ class S2GraphProvider extends AbstractGraphProvider {
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
- cleanupSchema
+ S2GraphProvider.cleanupSchema
initTestSchema(testClass, testName)
- initDefaultSchema(s2Graph)
+ S2GraphProvider.initDefaultSchema(s2Graph)
val defaultService = Service.findByName(S2Graph.DefaultServiceName).getOrElse(throw new IllegalStateException("default service is not initialized."))
val defaultServiceColumn = ServiceColumn.find(defaultService.id.get, S2Graph.DefaultColumnName).getOrElse(throw new IllegalStateException("default column is not initialized."))
@@ -141,7 +140,8 @@ class S2GraphProvider extends AbstractGraphProvider {
Prop("stars", "0", "integer"),
Prop("since", "0", "integer"),
Prop("myEdgeId", "0", "integer"),
- Prop("data", "-", "string")
+ Prop("data", "-", "string"),
+ Prop("name", "-", "string")
)
// Change dataType for ColumnMeta('aKey') for PropertyFeatureSupportTest
@@ -183,23 +183,27 @@ class S2GraphProvider extends AbstractGraphProvider {
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")))
+ Seq(Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
+ val softwareColumn = Management.createServiceColumn(defaultService.serviceName, "software", "integer",
+ Seq(Prop("name", "-", "string"), Prop("lang", "-", "string")))
+
val productColumn = Management.createServiceColumn(defaultService.serviceName, "product", "integer", Nil)
val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
// val vertexColumn = Management.createServiceColumn(service.serviceName, "vertex", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "-1", "integer"), Prop("lang", "scala", "string")))
+ val createdProps = Seq(Prop("weight", "0.0", "double"), Prop("name", "-", "string"))
+
val created =
if (loadGraphWith != null && loadGraphWith.value() == GraphData.MODERN) {
mnt.createLabel("created",
defaultService.serviceName, "person", "integer",
defaultService.serviceName, "software", "integer",
- true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+ true, defaultService.serviceName, Nil, createdProps, "strong", None, None)
} else {
mnt.createLabel("created",
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
- true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+ true, defaultService.serviceName, Nil, createdProps, "strong", None, None)
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/38ec51dc/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 e6083e9..2a04df3 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,14 +19,18 @@
package org.apache.s2graph.core.tinkerpop.structure
+import java.util.function.Predicate
+
+import org.apache.s2graph.core.GraphExceptions.LabelNotExistException
import org.apache.s2graph.core.Management.JsonModel.Prop
import org.apache.s2graph.core._
+import org.apache.s2graph.core.mysqls.{Service, ServiceColumn}
+import org.apache.s2graph.core.tinkerpop.S2GraphProvider
import org.apache.s2graph.core.utils.logger
+import org.apache.tinkerpop.gremlin.process.traversal.Scope
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.structure.Graph.Features.EdgePropertyFeatures
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.{in, out}
import org.apache.tinkerpop.gremlin.structure._
-import org.apache.tinkerpop.gremlin.structure.util.Attachable
-import org.apache.tinkerpop.gremlin.structure.util.detached.{DetachedEdge, DetachedFactory}
import org.scalatest.{FunSuite, Matchers}
@@ -409,7 +413,7 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
//// graph.addVertex(T.id, id);
////
//// // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-//// // to throw the exception
+//// // to throw the excepStion
//// if (!graph.features().vertex().willAllowId(id))
//// fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
//// } catch (Exception e) {
@@ -417,4 +421,67 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
//// }
//// }
// }
+ test("Modern") {
+ val mnt = graph.management
+ S2GraphProvider.cleanupSchema
+ S2GraphProvider.initDefaultSchema(graph)
+
+ val softwareColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "software", "integer", Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("lang", "-", "string")))
+ val personColumn = Management.createServiceColumn(S2Graph.DefaultServiceName, "person", "integer",
+ Seq(Prop(T.id.toString, "-1", "integer"), Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
+
+ val knows = mnt.createLabel("knows",
+ S2Graph.DefaultServiceName, "person", "integer",
+ S2Graph.DefaultServiceName, "person", "integer",
+ true, S2Graph.DefaultServiceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+
+ val created = mnt.createLabel("created",
+ S2Graph.DefaultServiceName, "person", "integer",
+ S2Graph.DefaultServiceName, "person", "integer",
+ true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+
+ val g = graph.traversal()
+ val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "marko", "age", Int.box(29))
+ val v2 = graph.addVertex(T.label, "person", T.id, Int.box(2), "name", "vadas", "age", Int.box(27))
+ val v3 = graph.addVertex(T.label, "software", T.id, Int.box(3), "name", "lop", "lang", "java")
+ val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "josh", "josh", Int.box(32))
+ val v5 = graph.addVertex(T.label, "software", T.id, Int.box(5), "name", "ripple", "lang", "java")
+ val v6 = graph.addVertex(T.label, "person", T.id, Int.box(6), "name", "peter", "age", Int.box(35))
+
+ val e1 = v1.addEdge("created", v3, "weight", Double.box(0.4))
+
+ val e2 = v1.addEdge("knows", v2, "weight", Double.box(0.5))
+ val e3 = v1.addEdge("knows", v4, "weight", Double.box(1.0))
+
+
+ val e4 = v2.addEdge("knows", v1, "weight", Double.box(0.5))
+
+ val e5 = v3.addEdge("created", v1, "weight", Double.box(0.4))
+ val e6 = v3.addEdge("created", v4, "weight", Double.box(0.4))
+ val e7 = v3.addEdge("created", v6, "weight", Double.box(0.2))
+
+ val e8 = v4.addEdge("knows", v1, "weight", Double.box(1.0))
+ val e9 = v4.addEdge("created", v5, "weight", Double.box(1.0))
+ val e10 = v4.addEdge("created", v3, "weight", Double.box(0.4))
+
+ val e11 = v5.addEdge("created", v4, "weight", Double.box(1.0))
+
+ val e12 = v6.addEdge("created", v3, "weight", Double.box(0.2))
+
+ val ls = graph.traversal().V().choose(new Predicate[Vertex] {
+ override def test(t: Vertex): Boolean =
+ t.label().equals("person")
+ }, out("knows"), in("created")).values("name").asAdmin()
+
+ val l = ls.toList
+ logger.error(s"[Size]: ${l.size}")
+ logger.error(l.toArray.toSeq.mkString("\n"))
+ println(ls.toList)
+ ls
+// val traversal = g.V().out().as("x").in().as("y").select("x", "y").by("name").fold()
+// .dedup(Scope.local, "x", "y").unfold();
+
+// val ls = traversal.toList
+// ls
+ }
}
\ No newline at end of file
[06/46] incubator-s2graph git commit: [EdgeTest]: passed all.
Posted by st...@apache.org.
[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
[03/46] incubator-s2graph git commit: change S2Graph to use local
embedded HMaster when hbase.zookeeper.quorum is localhost.
Posted by st...@apache.org.
change S2Graph to use local embedded HMaster when hbase.zookeeper.quorum is localhost.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/1a15af36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/1a15af36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/1a15af36
Branch: refs/heads/master
Commit: 1a15af36b42909fff1aaf2fbacf23d01edfe6155
Parents: d05d8a4
Author: DO YUNG YOON <st...@apache.org>
Authored: Sat Mar 4 14:42:22 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Sat Mar 4 22:29:22 2017 +0900
----------------------------------------------------------------------
.gitignore | 2 +
s2core/build.sbt | 4 +-
.../scala/org/apache/s2graph/core/S2Graph.scala | 14 ++--
.../core/storage/hbase/AsynchbaseStorage.scala | 67 ++++++++++++++++++++
.../core/tinkerpop/S2GraphProvider.scala | 9 ---
5 files changed, 77 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1a15af36/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 1f0f5b2..9f295f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,3 +106,5 @@ server.pid
/dist/
.cache
+### Local Embedded HBase Data ###
+storage/
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1a15af36/s2core/build.sbt
----------------------------------------------------------------------
diff --git a/s2core/build.sbt b/s2core/build.sbt
index 9ea975c..9cfc966 100644
--- a/s2core/build.sbt
+++ b/s2core/build.sbt
@@ -42,11 +42,11 @@ libraryDependencies ++= Seq(
"io.netty" % "netty" % "3.9.4.Final" force(),
"org.hbase" % "asynchbase" % "1.7.2" excludeLogging(),
"net.bytebuddy" % "byte-buddy" % "1.4.26",
- "org.apache.tinkerpop" % "gremlin-core" % tinkerpopVersion,
+ "org.apache.tinkerpop" % "gremlin-core" % tinkerpopVersion excludeLogging(),
"org.apache.tinkerpop" % "gremlin-test" % tinkerpopVersion % "test",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"org.specs2" %% "specs2-core" % specs2Version % "test",
- "mysql" % "mysql-connector-java" % "5.1.40"
+ "org.apache.hadoop" % "hadoop-hdfs" % hadoopVersion
)
libraryDependencies := {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1a15af36/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 bd6c45a..cfd85b1 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -21,7 +21,7 @@ package org.apache.s2graph.core
import java.util
import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
-import java.util.concurrent.{Executors, TimeUnit}
+import java.util.concurrent.{ExecutorService, Executors, TimeUnit}
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.commons.configuration.{BaseConfiguration, Configuration}
@@ -62,10 +62,8 @@ object S2Graph {
"hbase.table.name" -> "s2graph",
"hbase.table.compression.algorithm" -> "gz",
"phase" -> "dev",
-// "db.default.driver" -> "org.h2.Driver",
-// "db.default.url" -> "jdbc:h2:file:./var/metastore;MODE=MYSQL",
- "db.default.driver" -> "com.mysql.jdbc.Driver",
- "db.default.url" -> "jdbc:mysql://default:3306/graph_dev",
+ "db.default.driver" -> "org.h2.Driver",
+ "db.default.url" -> "jdbc:h2:file:./var/metastore;MODE=MYSQL",
"db.default.password" -> "graph",
"db.default.user" -> "graph",
"cache.max.size" -> java.lang.Integer.valueOf(10000),
@@ -533,8 +531,8 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
// passed
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"), // pass
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"), // pass
+// 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
@@ -547,7 +545,7 @@ object S2Graph {
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"), // pass
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"), // pass
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdgeTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"), // pass
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1a15af36/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
index ede1933..dab5aae 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
@@ -23,9 +23,11 @@ package org.apache.s2graph.core.storage.hbase
import java.util
import java.util.Base64
+import java.util.concurrent.{TimeUnit, ExecutorService, Executors}
import com.stumbleupon.async.{Callback, Deferred}
import com.typesafe.config.Config
+import org.apache.commons.io.FileUtils
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.hbase.client.{ConnectionFactory, Durability}
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm
@@ -91,6 +93,61 @@ object AsynchbaseStorage {
case class ScanWithRange(scan: Scanner, offset: Int, limit: Int)
type AsyncRPC = Either[GetRequest, ScanWithRange]
+
+ def initLocalHBase(config: Config,
+ overwrite: Boolean = true): ExecutorService = {
+ import java.net.Socket
+ import java.io.{File, IOException}
+
+ lazy val hbaseExecutor = {
+ val executor = Executors.newSingleThreadExecutor()
+
+ Runtime.getRuntime.addShutdownHook(new Thread() {
+ override def run(): Unit = {
+ executor.shutdown()
+ }
+ })
+
+ val hbaseAvailable = try {
+ val (host, port) = config.getString("hbase.zookeeper.quorum").split(":") match {
+ case Array(h, p) => (h, p.toInt)
+ case Array(h) => (h, 2181)
+ }
+
+ val socket = new Socket(host, port)
+ socket.close()
+ true
+ } catch {
+ case e: IOException => false
+ }
+
+ if (!hbaseAvailable) {
+ // start HBase
+ executor.submit(new Runnable {
+ override def run(): Unit = {
+ val cwd = new File(".").getAbsolutePath
+ if (overwrite) {
+ val dataDir = new File(s"$cwd/storage/s2graph")
+ FileUtils.deleteDirectory(dataDir)
+ }
+
+ System.setProperty("proc_master", "")
+ System.setProperty("hbase.log.dir", s"$cwd/storage/s2graph/hbase/")
+ System.setProperty("hbase.log.file", s"$cwd/storage/s2graph/hbase.log")
+ System.setProperty("hbase.tmp.dir", s"$cwd/storage/s2graph/hbase/")
+ System.setProperty("hbase.home.dir", "")
+ System.setProperty("hbase.id.str", "s2graph")
+ System.setProperty("hbase.root.logger", "INFO,RFA")
+
+ org.apache.hadoop.hbase.master.HMaster.main(Array[String]("start"))
+ }
+ })
+ }
+
+ executor
+ }
+ hbaseExecutor
+ }
}
@@ -100,6 +157,12 @@ class AsynchbaseStorage(override val graph: S2Graph,
import Extensions.DeferOps
+ val hbaseExecutor: ExecutorService =
+ if (config.getString("hbase.zookeeper.quorum") == "localhost")
+ AsynchbaseStorage.initLocalHBase(config)
+ else
+ null
+
/**
* Asynchbase client setup.
* note that we need two client, one for bulk(withWait=false) and another for withWait=true
@@ -476,6 +539,10 @@ class AsynchbaseStorage(override val graph: S2Graph,
clients.foreach { client =>
AsynchbaseStorage.shutdown(client)
}
+ if (hbaseExecutor != null) {
+ hbaseExecutor.shutdown()
+ hbaseExecutor.awaitTermination(1, TimeUnit.MINUTES)
+ }
}
override def createTable(_zkAddr: String,
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1a15af36/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 5a997e8..741be06 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
@@ -32,20 +32,11 @@ class S2GraphProvider extends AbstractGraphProvider {
override def getBaseConfiguration(s: String, aClass: Class[_], s1: String, graphData: GraphData): util.Map[String, AnyRef] = {
val config = ConfigFactory.load()
-// val dbUrl =
-// if (config.hasPath("db.default.url")) config.getString("db.default.url")
-// else "jdbc:mysql://localhost:3306/graph_dev"
-
- val dbUrl = "jdbc:mysql://localhost:3306/graph_dev"
val m = new java.util.HashMap[String, AnyRef]()
m.put(Graph.GRAPH, classOf[S2Graph].getName)
- m.put("db.default.url", dbUrl)
- m.put("db.default.driver", "com.mysql.jdbc.Driver")
m
}
- private val H2Prefix = "jdbc:h2:file:"
-
override def clear(graph: Graph, configuration: Configuration): Unit =
if (graph != null) {
val s2Graph = graph.asInstanceOf[S2Graph]
[08/46] incubator-s2graph git commit: bug fix on Edge.vertices.
Posted by st...@apache.org.
bug fix on Edge.vertices.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/350e2e6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/350e2e6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/350e2e6a
Branch: refs/heads/master
Commit: 350e2e6a2ade36ee11a29a0bbb1bacf2b2d7e345
Parents: 4425859
Author: DO YUNG YOON <st...@apache.org>
Authored: Mon Apr 10 23:04:10 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Mon Apr 10 23:05:32 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/QueryResult.scala | 44 +++-
.../scala/org/apache/s2graph/core/S2Edge.scala | 31 ++-
.../scala/org/apache/s2graph/core/S2Graph.scala | 43 ++--
.../org/apache/s2graph/core/S2Vertex.scala | 3 +-
.../s2graph/core/mysqls/ServiceColumn.scala | 3 +-
.../apache/s2graph/core/storage/Storage.scala | 3 +-
.../core/storage/hbase/AsynchbaseStorage.scala | 31 ++-
.../serde/vertex/VertexDeserializable.scala | 5 +-
.../serde/vertex/VertexSerializable.scala | 4 +-
.../s2graph/core/utils/SafeUpdateCache.scala | 4 +-
.../core/tinkerpop/S2GraphProvider.scala | 19 +-
.../core/tinkerpop/structure/S2GraphTest.scala | 254 ++++++++++++-------
12 files changed, 281 insertions(+), 163 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/QueryResult.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/QueryResult.scala b/s2core/src/main/scala/org/apache/s2graph/core/QueryResult.scala
index bad8361..a7f485c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryResult.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryResult.scala
@@ -27,24 +27,42 @@ import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.collection.{Seq, mutable}
object QueryResult {
+ def fromVertices(graph: S2Graph, vertices: Seq[S2Vertex], queryParams: Seq[QueryParam]): StepResult = {
+ val edgeWithScores = vertices.flatMap { vertex =>
+ queryParams.map { queryParam =>
+ val label = queryParam.label
+ val currentTs = System.currentTimeMillis()
+ val propsWithTs = Map(LabelMeta.timestamp ->
+ InnerValLikeWithTs(InnerVal.withLong(currentTs, label.schemaVersion), currentTs))
+
+ val edge = graph.newEdge(vertex, vertex, label, queryParam.labelWithDir.dir, propsWithTs = propsWithTs)
+ val edgeWithScore = EdgeWithScore(edge, S2Graph.DefaultScore, queryParam.label)
+ edgeWithScore
+
+ }
+ }
+ StepResult(edgeWithScores = edgeWithScores, grouped = Nil, degreeEdges = Nil, false)
+ }
+
def fromVertices(graph: S2Graph,
query: Query): StepResult = {
if (query.steps.isEmpty || query.steps.head.queryParams.isEmpty) {
StepResult.Empty
} else {
- val queryParam = query.steps.head.queryParams.head
- val label = queryParam.label
- val currentTs = System.currentTimeMillis()
- val propsWithTs = Map(LabelMeta.timestamp ->
- InnerValLikeWithTs(InnerVal.withLong(currentTs, label.schemaVersion), currentTs))
- val edgeWithScores = for {
- vertex <- query.vertices
- } yield {
- val edge = graph.newEdge(vertex, vertex, label, queryParam.labelWithDir.dir, propsWithTs = propsWithTs)
- val edgeWithScore = EdgeWithScore(edge, S2Graph.DefaultScore, queryParam.label)
- edgeWithScore
- }
- StepResult(edgeWithScores = edgeWithScores, grouped = Nil, degreeEdges = Nil, false)
+ fromVertices(graph, query.vertices, query.steps.head.queryParams)
+// val queryParam = query.steps.head.queryParams.head
+// val label = queryParam.label
+// val currentTs = System.currentTimeMillis()
+// val propsWithTs = Map(LabelMeta.timestamp ->
+// InnerValLikeWithTs(InnerVal.withLong(currentTs, label.schemaVersion), currentTs))
+// val edgeWithScores = for {
+// vertex <- query.vertices
+// } yield {
+// val edge = graph.newEdge(vertex, vertex, label, queryParam.labelWithDir.dir, propsWithTs = propsWithTs)
+// val edgeWithScore = EdgeWithScore(edge, S2Graph.DefaultScore, queryParam.label)
+// edgeWithScore
+// }
+// StepResult(edgeWithScores = edgeWithScores, grouped = Nil, degreeEdges = Nil, false)
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/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 162ada5..6321dd5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -596,18 +596,26 @@ case class S2Edge(innerGraph: S2Graph,
override def vertices(direction: Direction): util.Iterator[structure.Vertex] = {
val arr = new util.ArrayList[Vertex]()
+
direction match {
case Direction.OUT =>
- val newVertexId = VertexId(ServiceColumn.findById(srcForVertex.id.colId), srcForVertex.innerId)
- arr.add(srcVertex.copy(id = newVertexId))
-// arr.add(srcVertex)
+ val newVertexId = this.direction match {
+ case "out" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
+ case "in" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
+ case _ => throw new IllegalArgumentException("direction can only be out/in.")
+ }
+ innerGraph.getVertex(newVertexId).foreach(arr.add)
case Direction.IN =>
- val newVertexId = VertexId(ServiceColumn.findById(tgtForVertex.id.colId), tgtForVertex.innerId)
- arr.add(tgtVertex.copy(id = newVertexId))
-// arr.add(tgtVertex)
+ val newVertexId = this.direction match {
+ case "in" => VertexId(innerLabel.srcColumn, srcVertex.innerId)
+ case "out" => VertexId(innerLabel.tgtColumn, tgtVertex.innerId)
+ case _ => throw new IllegalArgumentException("direction can only be out/in.")
+ }
+ innerGraph.getVertex(newVertexId).foreach(arr.add)
case _ =>
- arr.add(srcVertex)
- arr.add(tgtVertex)
+ import scala.collection.JavaConversions._
+ vertices(Direction.OUT).foreach(arr.add)
+ vertices(Direction.IN).foreach(arr.add)
}
arr.iterator()
}
@@ -674,11 +682,8 @@ 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(), direction, 0)
- } else {
- EdgeId(srcForVertex.innerId, tgtForVertex.innerId, label(), direction, ts)
- }
+ val timestamp = if (this.innerLabel.consistencyLevel == "string") 0l else ts
+ EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), direction, timestamp)
}
override def label(): String = innerLabel.label
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/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 2771415..7e037b8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -70,7 +70,7 @@ object S2Graph {
"cache.ttl.seconds" -> java.lang.Integer.valueOf(60),
"hbase.client.retries.number" -> java.lang.Integer.valueOf(20),
"hbase.rpcs.buffered_flush_interval" -> java.lang.Short.valueOf(100.toShort),
- "hbase.rpc.timeout" -> java.lang.Integer.valueOf(1000),
+ "hbase.rpc.timeout" -> java.lang.Integer.valueOf(60000),
"max.retry.number" -> java.lang.Integer.valueOf(100),
"lock.expire.time" -> java.lang.Integer.valueOf(1000 * 60 * 10),
"max.back.off" -> java.lang.Integer.valueOf(100),
@@ -530,8 +530,9 @@ object S2Graph {
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
- // 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.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.FeatureSupportTest", method="*", reason="no"), // pass
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"), // pass
@@ -1370,22 +1371,22 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
S2Edge.fillPropsWithTs(snapshotEdge, propsWithTs)
snapshotEdge
}
-
- /**
- * internal helper to actually store a single edge based on given peramters.
- *
- * Note that this is used from S2Vertex to implement blocking interface from Tp3.
- * Once tp3 provide AsyncStep, then this can be changed to return Java's CompletableFuture.
- *
- * @param srcVertex
- * @param tgtVertex
- * @param labelName
- * @param direction
- * @param props
- * @param ts
- * @param operation
- * @return
- */
+//
+// /**
+// * internal helper to actually store a single edge based on given peramters.
+// *
+// * Note that this is used from S2Vertex to implement blocking interface from Tp3.
+// * Once tp3 provide AsyncStep, then this can be changed to return Java's CompletableFuture.
+// *
+// * @param srcVertex
+// * @param tgtVertex
+// * @param labelName
+// * @param direction
+// * @param props
+// * @param ts
+// * @param operation
+// * @return
+// */
// private[core] def addEdgeInner(srcVertex: S2Vertex,
// tgtVertex: S2Vertex,
// labelName: String,
@@ -1466,6 +1467,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
val queryParams = labelNameWithDirs.map { case (l, direction) =>
QueryParam(labelName = l, direction = direction)
}
+
val query = Query.toQuery(Seq(vertex), queryParams)
getEdges(query).map { stepResult =>
@@ -1529,8 +1531,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
override def edges(edgeIds: AnyRef*): util.Iterator[structure.Edge] = {
if (edgeIds.isEmpty) {
// FIXME
- val edges = Await.result(defaultStorage.fetchEdgesAll(), WaitTimeout).iterator
- edges.filterNot(_.isDegree).filterNot(_.direction == "in")
+ Await.result(defaultStorage.fetchEdgesAll(), WaitTimeout).iterator
} else {
Await.result(edgesAsync(edgeIds: _*), WaitTimeout)
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/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 e13f581..b80a54c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -209,7 +209,8 @@ case class S2Vertex(graph: S2Graph,
val op = GraphUtil.toOp(operation).getOrElse(throw new RuntimeException(s"$operation is not supported."))
val edge = graph.newEdge(this, otherV, label, dir, op = op, version = ts, propsWithTs = propsWithTs)
- val future = graph.mutateEdges(edge.relatedEdges, withWait = true)
+ // edge.relatedEdges
+ val future = graph.mutateEdges(Seq(edge), withWait = true)
Await.ready(future, graph.WaitTimeout)
edge
} catch {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
index 8614132..32ca653 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/mysqls/ServiceColumn.scala
@@ -25,7 +25,8 @@ package org.apache.s2graph.core.mysqls
import org.apache.s2graph.core.JSONParser
import org.apache.s2graph.core.JSONParser._
-import org.apache.s2graph.core.types.{HBaseType, InnerValLikeWithTs, InnerValLike}
+import org.apache.s2graph.core.types.{HBaseType, InnerValLike, InnerValLikeWithTs}
+import org.apache.s2graph.core.utils.logger
import play.api.libs.json.Json
import scalikejdbc._
object ServiceColumn extends Model[ServiceColumn] {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
index a9b523c..a8dec7e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/Storage.scala
@@ -285,6 +285,7 @@ abstract class Storage[Q, R](val graph: S2Graph,
val queryParam = QueryParam.Empty
val q = Query.toQuery(Seq(vertex), Seq(queryParam))
val queryRequest = QueryRequest(q, stepIdx = -1, vertex, queryParam)
+
fetchVertexKeyValues(queryRequest).map { kvs =>
fromResult(kvs, vertex.serviceColumn.schemaVersion)
} recoverWith { case ex: Throwable =>
@@ -321,7 +322,7 @@ abstract class Storage[Q, R](val graph: S2Graph,
mutateRet <- Future.sequence(mutateEdgeFutures)
} yield mutateRet
- composed.map(_.forall(identity)).map { ret => idxs.map(idx => idx -> ret) }
+ composed.map(_.forall(identity)).map { ret => idxs.map( idx => idx -> ret) }
}
Future.sequence(mutateEdges).map { squashedRets =>
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
index dab5aae..e41fe27 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/hbase/AsynchbaseStorage.scala
@@ -23,7 +23,7 @@ package org.apache.s2graph.core.storage.hbase
import java.util
import java.util.Base64
-import java.util.concurrent.{TimeUnit, ExecutorService, Executors}
+import java.util.concurrent.{ExecutorService, Executors, TimeUnit}
import com.stumbleupon.async.{Callback, Deferred}
import com.typesafe.config.Config
@@ -34,17 +34,17 @@ import org.apache.hadoop.hbase.io.compress.Compression.Algorithm
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding
import org.apache.hadoop.hbase.regionserver.BloomType
import org.apache.hadoop.hbase.util.Bytes
-import org.apache.hadoop.hbase.{TableName, HColumnDescriptor, HBaseConfiguration, HTableDescriptor}
+import org.apache.hadoop.hbase.{HBaseConfiguration, HColumnDescriptor, HTableDescriptor, TableName}
import org.apache.hadoop.security.UserGroupInformation
-
import org.apache.s2graph.core._
import org.apache.s2graph.core.mysqls.{Label, LabelMeta, ServiceColumn}
import org.apache.s2graph.core.storage._
import org.apache.s2graph.core.storage.hbase.AsynchbaseStorage.{AsyncRPC, ScanWithRange}
-import org.apache.s2graph.core.types.{VertexId, HBaseType}
+import org.apache.s2graph.core.types.{HBaseType, VertexId}
import org.apache.s2graph.core.utils._
import org.hbase.async.FilterList.Operator.MUST_PASS_ALL
import org.hbase.async._
+
import scala.collection.JavaConversions._
import scala.collection.mutable.ArrayBuffer
import scala.concurrent._
@@ -96,8 +96,8 @@ object AsynchbaseStorage {
def initLocalHBase(config: Config,
overwrite: Boolean = true): ExecutorService = {
- import java.net.Socket
import java.io.{File, IOException}
+ import java.net.Socket
lazy val hbaseExecutor = {
val executor = Executors.newSingleThreadExecutor()
@@ -277,6 +277,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
override def fetchSnapshotEdgeKeyValues(queryRequest: QueryRequest): Future[Seq[SKeyValue]] = {
val edge = toRequestEdge(queryRequest, Nil)
val rpc = buildRequest(queryRequest, edge)
+
fetchKeyValues(rpc)
}
@@ -445,6 +446,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
val edge = toRequestEdge(queryRequest, parentEdges)
val request = buildRequest(queryRequest, edge)
+
val (intervalMaxBytes, intervalMinBytes) = queryParam.buildInterval(Option(edge))
val requestCacheKey = Bytes.add(toCacheKeyBytes(request), intervalMaxBytes, intervalMinBytes)
@@ -655,10 +657,8 @@ class AsynchbaseStorage(override val graph: S2Graph,
override def getVertices(vertices: Seq[S2Vertex]): Future[Seq[S2Vertex]] = {
def fromResult(kvs: Seq[SKeyValue],
version: String): Option[S2Vertex] = {
-
if (kvs.isEmpty) None
else vertexDeserializer.fromKeyValues(kvs, None)
-// .map(S2Vertex(graph, _))
}
val futures = vertices.map { vertex =>
@@ -677,20 +677,25 @@ class AsynchbaseStorage(override val graph: S2Graph,
Future.sequence(futures).map { result => result.toList.flatten }
}
+ //TODO: Limited to 100000 edges per hbase table. fix this later.
override def fetchEdgesAll(): Future[Seq[S2Edge]] = {
val futures = Label.findAll().groupBy(_.hbaseTableName).toSeq.map { case (hTableName, labels) =>
+ val distinctLabels = labels.toSet
val scan = AsynchbasePatcher.newScanner(client, hTableName)
scan.setFamily(Serializable.edgeCf)
scan.setMaxVersions(1)
- scan.nextRows(10000).toFuture(emptyKeyValuesLs).map {
+ scan.nextRows(100000).toFuture(emptyKeyValuesLs).map {
case null => Seq.empty
case kvsLs =>
- kvsLs.flatMap { kvs =>
- kvs.flatMap { kv =>
- indexEdgeDeserializer.fromKeyValues(Seq(kv), None)
+ kvsLs.flatMap { kvs =>
+ kvs.flatMap { kv =>
+ val sKV = implicitly[CanSKeyValue[KeyValue]].toSKeyValue(kv)
+
+ indexEdgeDeserializer.fromKeyValues(Seq(kv), None)
+ .filter(e => distinctLabels(e.innerLabel) && e.direction == "out" && !e.isDegree)
+ }
}
- }
}
}
@@ -699,6 +704,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
override def fetchVerticesAll(): Future[Seq[S2Vertex]] = {
val futures = ServiceColumn.findAll().groupBy(_.service.hTableName).toSeq.map { case (hTableName, columns) =>
+ val distinctColumns = columns.toSet
val scan = AsynchbasePatcher.newScanner(client, hTableName)
scan.setFamily(Serializable.vertexCf)
scan.setMaxVersions(1)
@@ -708,6 +714,7 @@ class AsynchbaseStorage(override val graph: S2Graph,
case kvsLs =>
kvsLs.flatMap { kvs =>
vertexDeserializer.fromKeyValues(kvs, None)
+ .filter(v => distinctColumns(v.serviceColumn))
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexDeserializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexDeserializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexDeserializable.scala
index b4a00e6..f8921a8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexDeserializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexDeserializable.scala
@@ -23,7 +23,8 @@ import org.apache.s2graph.core.mysqls.{ColumnMeta, Label}
import org.apache.s2graph.core.storage.StorageDeserializable._
import org.apache.s2graph.core.storage.{CanSKeyValue, Deserializable}
import org.apache.s2graph.core.types.{HBaseType, InnerVal, InnerValLike, VertexId}
-import org.apache.s2graph.core.{S2Graph, QueryParam, S2Vertex}
+import org.apache.s2graph.core.utils.logger
+import org.apache.s2graph.core.{QueryParam, S2Graph, S2Vertex}
import scala.collection.mutable.ListBuffer
@@ -33,7 +34,6 @@ class VertexDeserializable(graph: S2Graph,
cacheElementOpt: Option[S2Vertex]): Option[S2Vertex] = {
try {
val kvs = _kvs.map { kv => implicitly[CanSKeyValue[T]].toSKeyValue(kv) }
-
val kv = kvs.head
val version = HBaseType.DEFAULT_VERSION
val (vertexId, _) = VertexId.fromBytes(kv.row, 0, kv.row.length, version)
@@ -64,6 +64,7 @@ class VertexDeserializable(graph: S2Graph,
assert(maxTs != Long.MinValue)
val vertex = graph.newVertex(vertexId, maxTs, S2Vertex.EmptyProps, belongLabelIds = belongLabelIds)
S2Vertex.fillPropsWithTs(vertex, propsMap.toMap)
+
Option(vertex)
} catch {
case e: Exception => None
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexSerializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexSerializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexSerializable.scala
index 1dbcd00..ee147f1 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexSerializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/vertex/VertexSerializable.scala
@@ -22,6 +22,8 @@ package org.apache.s2graph.core.storage.serde.vertex
import org.apache.s2graph.core.S2Vertex
import org.apache.s2graph.core.storage.StorageSerializable._
import org.apache.s2graph.core.storage.{SKeyValue, Serializable}
+import org.apache.s2graph.core.utils.logger
+
import scala.collection.JavaConverters._
case class VertexSerializable(vertex: S2Vertex, intToBytes: Int => Array[Byte] = intToBytes) extends Serializable[S2Vertex] {
@@ -45,6 +47,6 @@ case class VertexSerializable(vertex: S2Vertex, intToBytes: Int => Array[Byte] =
val belongsTo = vertex.belongLabelIds.map { labelId => intToBytes(S2Vertex.toPropKey(labelId)) -> Array.empty[Byte] }
(base ++ belongsTo).map { case (qualifier, value) =>
SKeyValue(vertex.hbaseTableName.getBytes, row, cf, qualifier, value, vertex.ts)
- } toSeq
+ }.toSeq
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala b/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
index c54dcde..a98104c 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/utils/SafeUpdateCache.scala
@@ -20,10 +20,12 @@
package org.apache.s2graph.core.utils
import java.util.concurrent.atomic.AtomicBoolean
+
import com.google.common.cache.CacheBuilder
+
+import scala.collection.JavaConversions._
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}
-import scala.collection.JavaConversions._
object SafeUpdateCache {
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/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 18bf998..865717d 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
@@ -34,6 +34,7 @@ class S2GraphProvider extends AbstractGraphProvider {
val config = ConfigFactory.load()
val m = new java.util.HashMap[String, AnyRef]()
m.put(Graph.GRAPH, classOf[S2Graph].getName)
+// m.put("db.default.url", "jdbc:h2:mem:db1;MODE=MYSQL")
m
}
@@ -64,8 +65,6 @@ 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
@@ -139,12 +138,15 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
}
- // knows props
-// 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 == "DetachedEdgeTest") {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+ } else {
+ mnt.createLabel("knows", defaultService.serviceName, "vertex", "string", defaultService.serviceName, "vertex", "string",
+ 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}"""))
@@ -153,7 +155,8 @@ class S2GraphProvider extends AbstractGraphProvider {
// 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 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")))
val productColumn = Management.createServiceColumn(defaultService.serviceName, "product", "integer", Nil)
val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/350e2e6a/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 46f58a8..5454e24 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,21 +19,18 @@
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._
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.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.structure._
+import org.apache.tinkerpop.gremlin.structure.util.Attachable
+import org.apache.tinkerpop.gremlin.structure.util.detached.{DetachedEdge, DetachedFactory}
import org.scalatest.{FunSuite, Matchers}
class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
- import scala.collection.JavaConversions._
import scala.concurrent.ExecutionContext.Implicits.global
initTests()
@@ -187,7 +184,147 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
// test("addVertex with empty parameter") {
//
// }
- test("aaa") {
+// test("aaa") {
+// val mnt = graph.management
+// 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")
+//
+// Management.deleteService(defaultService.serviceName)
+// columnNames.foreach { columnName =>
+// Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+// }
+// labelNames.foreach { labelName =>
+// Management.deleteLabel(labelName)
+// }
+//
+// 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")), 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, 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")), 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, consistencyLevel = "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,
+// Seq(
+// Prop("name", "-", "string"),
+// Prop("location", "-", "string"),
+// Prop("status", "-", "string")
+// ),
+// "strong", None, None,
+// options = Option("""{"skipReverse": false}""")
+// )
+//
+// val v1 = graph.addVertex("name", "marko")
+// val v2 = graph.addVertex("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 { e => logger.error(s"[Edge]: $e")}
+// }
+
+// test("bb") {
+// val mnt = graph.management
+// 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")
+//
+// Management.deleteService(defaultService.serviceName)
+// columnNames.foreach { columnName =>
+// Management.deleteColumn(defaultServiceColumn.service.serviceName, columnName)
+// }
+// labelNames.foreach { labelName =>
+// Management.deleteLabel(labelName)
+// }
+// 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 knows = mnt.createLabel("knows",
+// defaultService.serviceName, "person", "integer",
+// defaultService.serviceName, "person", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+//
+// val created = mnt.createLabel("created", defaultService.serviceName, "person", "integer", defaultService.serviceName, "software", "integer",
+// true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
+//
+//// val v1 = graph.toVertex(graph.DefaultService.serviceName, "person", 1)
+//// val v4 = graph.toVertex(graph.DefaultService.serviceName, "person", 4)
+//// val ts = System.currentTimeMillis()
+//// val edge = graph.newEdge(v1, v4, knows.get,
+//// GraphUtil.directions("out"), GraphUtil.operations("insert"),
+//// propsWithTs = Map(LabelMeta.timestamp -> InnerValLikeWithTs.withLong(ts, ts, knows.get.schemaVersion)))
+// val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "marko")
+// val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "vadas")
+//
+// val g = graph.traversal()
+// v1.addEdge("knows", v4, "year", Int.box(2002))
+//
+// def convertToEdgeId(outVertexName: String, edgeLabel: String, inVertexName: String): AnyRef = {
+// g.V().has("name", outVertexName).outE(edgeLabel).as("e").inV.has("name", inVertexName).select[Edge]("e").next().id()
+// }
+//
+// g.V().has("name", "marko").outE("knows").as("e").inV.foreach(e => logger.error(s"[Edge]: $e"))
+//
+//// .as("e").inV.has("name", "vadas").select[Edge]("e").next().id()
+//// g.E(convertToEdgeId("marko", "knows", "vadas")).foreach(e => logger.error(s"[EDGE]: $e"))
+//// val x = DetachedFactory.detach(g.E(convertToEdgeId("marko", "knows", "vadas")).next(), true)
+////// .hashCode()
+//// val y = DetachedFactory.detach(g.E(convertToEdgeId("marko", "knows", "vadas")).next(), true)
+//// .hashCode()
+//// logger.error(s"[X]: $x")
+//// logger.error(s"[Y]: $y")
+//
+//// g.E().foreach(e => logger.error(s"[Edge]: $e"))
+//// g.V().has("name", "marko").outE("knows").foreach(v => logger.error(s"[OutVertex]: $v"))
+//// g.V().has("name", "vadas").inE("knows").foreach(v => logger.error(s"[InVertex]: $v"))
+//
+//
+// @Test
+// @LoadGraphWith(GraphData.MODERN)
+// @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+// def shouldConstructDetachedEdgeAsReference() {
+//
+// graph.traversal().E(convertToEdgeId("marko", "knows", "vadas")).next().property("year", 2002);
+// val detachedEdge = DetachedFactory.detach(g.E(convertToEdgeId("marko", "knows", "vadas")).next(), false);
+//// assertEquals(convertToEdgeId("marko", "knows", "vadas"), detachedEdge.id());
+//// assertEquals("knows", detachedEdge.label());
+//// assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.OUT).next().getClass());
+//// assertEquals(convertToVertexId("marko"), detachedEdge.vertices(Direction.OUT).next().id());
+//// assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());
+//// assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.IN).next().getClass());
+//// assertEquals(convertToVertexId("vadas"), detachedEdge.vertices(Direction.IN).next().id());
+//// assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());
+////
+//// assertEquals(0, IteratorUtils.count(detachedEdge.properties()));
+// }
+//// shouldConstructDetachedEdgeAsReference()
+// }
+ def convertToEdgeId(g: GraphTraversalSource, outVertexName: String, edgeLabel: String, inVertexName: String): AnyRef = {
+ g.V().has("name", outVertexName).outE(edgeLabel).as("e").inV.has("name", inVertexName).select[Edge]("e").next().id()
+ }
+ test("ccc") {
val mnt = graph.management
val defaultService = graph.DefaultService
val defaultServiceColumn = graph.DefaultColumn
@@ -201,90 +338,29 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
labelNames.foreach { labelName =>
Management.deleteLabel(labelName)
}
-
+ 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 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")), 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, 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")), 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, consistencyLevel = "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,
- 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")
-// )
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("since", "0", "integer"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None)
+ val created = mnt.createLabel("created",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None)
-// 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"))
+ val g = graph.traversal()
+ val v1 = graph.addVertex(T.label, "person", T.id, Int.box(1), "name", "josh")
+ val v4 = graph.addVertex(T.label, "person", T.id, Int.box(4), "name", "lop")
+ val e = v1.addEdge("created", v4)
- graph.edges().foreach(e => e.remove)
+ val toDetach = g.E(convertToEdgeId(g, "josh", "created", "lop")).next()
+ val outV = toDetach.vertices(Direction.OUT).next()
+ val detachedEdge = DetachedFactory.detach(toDetach, true)
+ val attached = detachedEdge.attach(Attachable.Method.get(outV))
- graph.edges().foreach(e => logger.error(s"[Edge]: $e"))
+ assert(toDetach.equals(attached))
+ assert(!attached.isInstanceOf[DetachedEdge])
}
-
}
\ No newline at end of file
[24/46] incubator-s2graph git commit: [IoVertexTest + IoEdgeTest]
passed except graphson-v2-embedded.
Posted by st...@apache.org.
[IoVertexTest + IoEdgeTest] passed except graphson-v2-embedded.
[CommunityGeneratorTest] passed except shouldGenerateDifferentGraph.
[DistributionGeneratorTest] non deterministic.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/103f05ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/103f05ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/103f05ee
Branch: refs/heads/master
Commit: 103f05eef4c8bbdf6cb4c31fd4f3003ea99284be
Parents: 3a0272f
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 28 02:27:56 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 28 02:27:56 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Edge.scala | 7 ++-
.../scala/org/apache/s2graph/core/S2Graph.scala | 58 ++++++++++++++++----
.../org/apache/s2graph/core/S2Vertex.scala | 5 +-
.../apache/s2graph/core/types/VertexId.scala | 4 +-
.../core/tinkerpop/S2GraphProvider.scala | 31 +++++++++--
5 files changed, 85 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/103f05ee/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 e6da0bb..eca8f18 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -635,7 +635,10 @@ case class S2Edge(innerGraph: S2Graph,
}
})
} else {
- keys.foreach { key => ls.add(property(key)) }
+ keys.foreach { key =>
+ val prop = property[V](key)
+ if (prop.isPresent) ls.add(prop)
+ }
}
ls.iterator()
}
@@ -685,7 +688,7 @@ case class S2Edge(innerGraph: S2Graph,
override def graph(): Graph = innerGraph
- lazy val edgeId: AnyRef = {
+ lazy val edgeId: EdgeId = {
// NOTE: xxxForVertex makes direction to be "out"
val timestamp = if (this.innerLabel.consistencyLevel == "strong") 0l else ts
// EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/103f05ee/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 0aa570d..80285d5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -20,7 +20,7 @@
package org.apache.s2graph.core
import java.util
-import java.util.concurrent.atomic.AtomicBoolean
+import java.util.concurrent.atomic.{AtomicBoolean, AtomicLong}
import java.util.concurrent.{Executors, TimeUnit}
import com.typesafe.config.{Config, ConfigFactory}
@@ -584,21 +584,47 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest", method="*", reason="no"),
+ // passed: all,
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(NormalDistribution{stdDeviation=2.0, mean=0.0},PowerLawDistribution{gamma=2.4, multiplier=0.0},0.1)", reason="graphson-v2-embedded is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(NormalDistribution{stdDeviation=2.0, mean=0.0},PowerLawDistribution{gamma=2.4, multiplier=0.0},0.5)", reason="graphson-v2-embedded is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(NormalDistribution{stdDeviation=2.0, mean=0.0},NormalDistribution{stdDeviation=4.0, mean=0.0},0.5)", reason="graphson-v2-embedded is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(NormalDistribution{stdDeviation=2.0, mean=0.0},NormalDistribution{stdDeviation=4.0, mean=0.0},0.1)", reason="graphson-v2-embedded is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(PowerLawDistribution{gamma=2.3, multiplier=0.0},PowerLawDistribution{gamma=2.4, multiplier=0.0},0.25)", reason="graphson-v2-embedded is not supported."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest$DifferentDistributionsTest", method="shouldGenerateDifferentGraph", specific="test(PowerLawDistribution{gamma=2.3, multiplier=0.0},NormalDistribution{stdDeviation=4.0, mean=0.0},0.25)", reason="graphson-v2-embedded is not supported."),
+ // passed: all, except shouldGenerateDifferentGraph method.
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGeneratorTest", method="*", reason="non-deterministic test."),
+ // all failed.
+
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.SerializationTest$GryoTest", method="shouldSerializeTree", reason="order of children is reversed. not sure why."),
// passed: all, failed: $GryoTest.shouldSerializeTree
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"),
+ // all ignored.
-// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoCustomTest", method="*", reason="no"), // all ignored.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="*", reason="no"), // all failed.
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoPropertyTest", method="*", reason="no"),
+ // all passed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest", method="*", reason="no"), // failed on shouldHandleSelfLoops
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteVertexWithBOTHEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteVertexWithINEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteDetachedVertexAsReferenceNoEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteVertexNoEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteVertexWithOUTEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoVertexTest", method="shouldReadWriteDetachedVertexNoEdges", specific="graphson-v2-embedded", reason="Vertex.id() is deserialized as string, not class in graphson-v2-embedded."),
+ // passed: all, except graphson-v2-embedded.
+
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="shouldReadWriteDetachedEdgeAsReference", specific="graphson-v2-embedded", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="shouldReadWriteEdge", specific="graphson-v2-embedded", reason="no"),
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest", method="shouldReadWriteDetachedEdge", specific="graphson-v2-embedded", reason="no"),
+ // passed: all, except graphson-v2-embedded.
+
+ // TODO:
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoGraphTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.CommunityGeneratorTest", method="*", reason="no"), // all failed.
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGeneratorTest", method="*", reason="no") // all failed.
+ new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.io.IoTest", method="*", reason="no")
+ // all failed.
))
class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph {
@@ -632,8 +658,13 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
val scheduledEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())
val management = new Management(this)
+
def getManagement() = management
+ private val localLongId = new AtomicLong()
+
+ def nextLocalLongId = localLongId.getAndIncrement()
+
private def confWithFallback(conf: Config): Config = {
conf.withFallback(config)
}
@@ -707,6 +738,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
ColumnMeta.findOrInsert(DefaultColumn.id.get, "location", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "status", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "myId", "integer", useCache = false)
+ ColumnMeta.findOrInsert(DefaultColumn.id.get, "acl", "string", useCache = false)
}
val DefaultLabel = management.createLabel("_s2graph", DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType,
@@ -1201,6 +1233,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
flushStorage()
Model.shutdown(modelDataDelete)
defaultStorage.shutdown()
+ localLongId.set(0l)
}
def toGraphElement(s: String, labelMapping: Map[String, String] = Map.empty): Option[GraphElement] = Try {
@@ -1571,7 +1604,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
val vertex = kvsMap.get(T.id.name()) match {
case None => // do nothing
- val id = Random.nextLong
+ val id = nextLocalLongId
makeVertex(Long.box(id), kvsMap)
case Some(idValue) if S2Property.validType(idValue) =>
makeVertex(idValue, kvsMap)
@@ -1582,6 +1615,9 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
addVertexInner(vertex)
}
+
+
+
def addVertex(id: VertexId,
ts: Long = System.currentTimeMillis(),
props: S2Vertex.Props = S2Vertex.EmptyProps,
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/103f05ee/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 9a9dfa8..64d298d 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -249,7 +249,10 @@ case class S2Vertex(graph: S2Graph,
}
})
} else {
- keys.foreach { key => ls.add(property[V](key)) }
+ keys.foreach { key =>
+ val prop = property[V](key)
+ if (prop.isPresent) ls.add(prop)
+ }
}
ls.iterator
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/103f05ee/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
index 628a149..f93df4a 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
@@ -102,7 +102,9 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
}
override def equals(obj: Any): Boolean = {
val ret = obj match {
- case other: VertexId => column.id.get == other.column.id.get && innerId.toIdString() == other.innerId.toIdString()
+ case other: VertexId =>
+ val ret = column.id.get == other.column.id.get && innerId.toIdString() == other.innerId.toIdString()
+ ret
case _ => false
}
// logger.debug(s"VertexId.equals: $this, $obj => $ret")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/103f05ee/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 5165252..3934264 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
@@ -19,6 +19,8 @@ import com.typesafe.config.ConfigFactory
import org.apache.commons.io.FileUtils
import org.apache.s2graph.core.utils.logger
+import scala.concurrent.ExecutionContext
+
object S2GraphProvider {
val Implementation: Set[Class[_]] = Set(
classOf[S2Edge],
@@ -28,6 +30,7 @@ object S2GraphProvider {
classOf[S2Graph]
)
}
+
class S2GraphProvider extends AbstractGraphProvider {
override def getBaseConfiguration(s: String, aClass: Class[_], s1: String, graphData: GraphData): util.Map[String, AnyRef] = {
@@ -82,6 +85,8 @@ class S2GraphProvider extends AbstractGraphProvider {
}
}
+// override def openTestGraph(config: Configuration): Graph = new S2Graph(config)(ExecutionContext.global)
+
override def loadGraphData(graph: Graph, loadGraphWith: LoadGraphWith, testClass: Class[_], testName: String): Unit = {
val s2Graph = graph.asInstanceOf[S2Graph]
val mnt = s2Graph.getManagement()
@@ -139,7 +144,13 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
}
- if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
+ if (testClass.getSimpleName == "IoGraphTest") {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+ } else if (testClass.getSimpleName == "DifferentDistributionsTest") {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+ } else if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else if (testClass.getSimpleName.contains("CommunityGeneratorTest")) {
@@ -196,10 +207,20 @@ class S2GraphProvider extends AbstractGraphProvider {
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,
- "strong", None, None,
- options = Option("""{"skipReverse": false}"""))
+ val friends =
+ if (testClass.getSimpleName == "IoVertexTest") {
+ mnt.createLabel("friends",
+ defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("weight", "0.0", "double")),
+ "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ } else {
+ mnt.createLabel("friends", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
+ true, defaultService.serviceName, Nil, Nil,
+ "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ }
val friend = if (testClass.getSimpleName.contains("IoEdgeTest")) {
mnt.createLabel("friend", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
[44/46] incubator-s2graph git commit: Tinkerpop version up from 3.2.3
to 3.2.4.
Posted by st...@apache.org.
Tinkerpop version up from 3.2.3 to 3.2.4.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/94c91429
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/94c91429
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/94c91429
Branch: refs/heads/master
Commit: 94c9142950150aa9c0861ad8caefb0f26a0af9f1
Parents: 38682a8
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri May 5 15:46:44 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri May 5 15:46:44 2017 +0900
----------------------------------------------------------------------
project/Common.scala | 2 +-
.../scala/org/apache/s2graph/core/S2Graph.scala | 61 ++++++++++----------
.../core/tinkerpop/S2GraphProvider.scala | 2 +-
3 files changed, 32 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/94c91429/project/Common.scala
----------------------------------------------------------------------
diff --git a/project/Common.scala b/project/Common.scala
index 036d5c9..c714aab 100644
--- a/project/Common.scala
+++ b/project/Common.scala
@@ -26,7 +26,7 @@ object Common {
val hbaseVersion = "1.2.2"
val hadoopVersion = "2.7.3"
- val tinkerpopVersion = "3.2.3"
+ val tinkerpopVersion = "3.2.4"
/** use Log4j 1.2.17 as the SLF4j backend in runtime, with bridging libraries to forward JCL and JUL logs to SLF4j */
val loggingRuntime = Seq(
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/94c91429/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 fc67be5..176aa47 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -570,8 +570,8 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.CyclicPathTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest$Traversals", method = "g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX", reason = "please find bug on this case."),
-// passed: all, failed: g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupTest$Traversals", method = "*", reason = "no"),
+// passed: all
new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest$Traversals", method = "g_V_properties_drop", reason = "please find bug on this case."),
// passed: all, failed: g_V_properties_drop
@@ -600,8 +600,8 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.TailTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTest$Traversals", method = "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX", reason = "please identify bug on this case."),
-// passed: all, failed: g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTest$Traversals", method = "*", reason = "no"),
+// passed: all,
/* map */
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeTest$Traversals", method = "*", reason = "no"),
@@ -616,9 +616,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantTest$Traversals", method = "*", reason = "no"),
// passed: all
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", reason = "somehow count becomes double. fix this. "),
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX3X_count", reason = "count differ very little. fix this."),
-// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX8X_count", reason = "count differ very litter. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", reason = "count differ very little. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX3X_count", reason = "count differ very little. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX8X_count", reason = "count differ very litter. fix this."),
// passed: all, failed: g_V_both_both_count, g_V_repeatXoutX_timesX3X_count, g_V_repeatXoutX_timesX8X_count
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapTest$Traversals", method = "*", reason = "no"),
@@ -642,13 +642,11 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MapValuesTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX", reason = "fix this."),
-// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$CountMatchTraversals", method = "*", reason = "no"),
+// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX", reason = "fix this."),
-// passed: all, failed: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX, g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX, g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$GreedyMatchTraversals", method = "*", reason = "no"),
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxTest$Traversals", method = "*", reason = "no"),
// passed: all
@@ -662,16 +660,20 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest$Traversals", method = "*", reason = "no"),
// failed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest$Traversals", method = "g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name", reason = "no"),
-// passed: all, failed: g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest$Traversals", method = "*", reason = "no"),
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profileXmetricsX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_repeat_both_profileXmetricsX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profile", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_repeat_both_profile", reason = "fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "testProfileStrategyCallback", reason = "NullPointerException. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_whereXinXcreatedX_count_isX1XX_name_profile", reason = "java.lang.AssertionError: There should be 3 top-level metrics. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX", reason = "expected 2, actual 6. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profileXmetricsX", reason = "expected 8049, actual 8046. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profile", reason = "expected 8049, actual 8046. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "modern_V_out_out_profileXmetricsX", reason = "expected 2, actual 6. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "modern_V_out_out_profile", reason = "expected 2, actual 6. fix this."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "testProfileStrategyCallbackSideEffect", reason = "NullPointerException. fix this."),
// failed: grateful_V_out_out_profileXmetricsX, g_V_repeat_both_profileXmetricsX, grateful_V_out_out_profile, g_V_repeat_both_profile
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest$Traversals", method = "*", reason = "no"),
@@ -696,17 +698,14 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", reason = "fix this."),
-// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest$Traversals", method = "*", reason = "no"),
+// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", reason = "fix this."),
-// failed: g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX, g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0$Traversals", method = "*", reason = "no"),
+// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX", reason = "double count. fix this. "),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name", reason = "double count. fix this. "),
-// failed: g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX, g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest$Traversals", method = "*", reason = "no"),
+// passed: all
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest$Traversals", method = "*", reason = "no"),
// passed: all
@@ -723,9 +722,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX", reason = "double count. fix this."),
-// failed: all
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup", reason = "Expected 5, Actual 6."),
+ new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals", method = "g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX", reason = "Expected 3, Actual 6"),
+// passed: all, failed: g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup, g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeTest$Traversals", method = "*", reason = "no"),
// passed: all
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/94c91429/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 c66a546..bb30b75 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
@@ -193,7 +193,7 @@ class S2GraphProvider extends AbstractGraphProvider {
val personColumn = Management.createServiceColumn(defaultService.serviceName, "person", "integer",
Seq(Prop("name", "-", "string"), Prop("age", "0", "integer"), Prop("location", "-", "string")))
val softwareColumn = Management.createServiceColumn(defaultService.serviceName, "software", "integer",
- Seq(Prop("name", "-", "string"), Prop("lang", "-", "string")))
+ Seq(Prop("name", "-", "string"), Prop("lang", "-", "string"), Prop("temp", "-", "string")))
val productColumn = Management.createServiceColumn(defaultService.serviceName, "product", "integer", Nil)
val dogColumn = Management.createServiceColumn(defaultService.serviceName, "dog", "integer", Nil)
[17/46] incubator-s2graph git commit: [ReferenceEdgeTest] passed all,
except shouldNotEvaluateToEqualDifferentId. reference equals is not
supported.
Posted by st...@apache.org.
[ReferenceEdgeTest] passed all, except shouldNotEvaluateToEqualDifferentId. reference equals is not supported.
- add dataType, schemaVersion in InnerValLike trait.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/ee22c608
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/ee22c608
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/ee22c608
Branch: refs/heads/master
Commit: ee22c6087859eb71cfcf8964aadb02aac61a7847
Parents: 1328546
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 26 15:33:16 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 26 15:33:16 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/JSONParser.scala | 15 +++-
.../scala/org/apache/s2graph/core/S2Edge.scala | 10 +--
.../scala/org/apache/s2graph/core/S2Graph.scala | 12 +++-
.../org/apache/s2graph/core/S2Vertex.scala | 2 +-
.../apache/s2graph/core/S2VertexProperty.scala | 10 ++-
.../s2graph/core/types/InnerValLike.scala | 72 +++++---------------
.../apache/s2graph/core/types/VertexId.scala | 4 +-
.../apache/s2graph/core/types/v1/InnerVal.scala | 3 +
.../apache/s2graph/core/types/v2/InnerVal.scala | 25 +++----
.../core/tinkerpop/S2GraphProvider.scala | 60 ++++++++++++----
10 files changed, 110 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
index 90574f2..2324e8e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/JSONParser.scala
@@ -115,7 +115,7 @@ object JSONParser {
// }
// }
def isNumericType(dType: String): Boolean = {
- dType == InnerVal.LONG || dType == InnerVal.INT ||
+ dType == InnerVal.BIGDECIMAL || dType == InnerVal.LONG || dType == InnerVal.INT ||
dType == InnerVal.SHORT || dType == InnerVal.BYTE ||
dType == InnerVal.FLOAT || dType == InnerVal.DOUBLE
}
@@ -124,6 +124,15 @@ object JSONParser {
def innerValToAny(innerValLike: InnerValLike, dataType: String): Any = {
val dType = InnerVal.toInnerDataType(dataType)
dType match {
+ case InnerVal.BIGDECIMAL =>
+ innerValLike.value match {
+ case b: BigDecimal => b
+ case l: Long => BigDecimal(l)
+ case i: Int => BigDecimal(i)
+ case f: Float => BigDecimal(f)
+ case d: Double => BigDecimal(d)
+ case _ => throw new RuntimeException(s"not supported data type: $innerValLike, ${innerValLike.value.getClass}, $dataType")
+ }
case InnerVal.LONG =>
innerValLike.value match {
case b: BigDecimal => b.toLong
@@ -244,7 +253,7 @@ object JSONParser {
dType match {
case InnerVal.STRING => Some(InnerVal.withStr(jsValue.toString, version))
// case t if InnerVal.NUMERICS.contains(t) =>
- case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
+ case InnerVal.BIGDECIMAL | InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
Some(InnerVal.withNumber(n.value, version))
case _ => None
}
@@ -254,7 +263,7 @@ object JSONParser {
case InnerVal.STRING => Some(InnerVal.withStr(s, version))
case InnerVal.BOOLEAN => Some(InnerVal.withBoolean(s.toBoolean, version))
// case t if InnerVal.NUMERICS.contains(t) =>
- case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
+ case InnerVal.BIGDECIMAL | InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE =>
Some(InnerVal.withNumber(BigDecimal(s), version))
case _ => None
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/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 6b389f7..edb3783 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -30,7 +30,7 @@ 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.{Direction, Edge, Graph, Property, Vertex}
+import org.apache.tinkerpop.gremlin.structure.{Direction, Edge, Graph, Property, T, Vertex}
import play.api.libs.json.{JsNumber, JsObject, Json}
import scala.collection.JavaConverters._
@@ -330,7 +330,7 @@ case class S2Edge(innerGraph: S2Graph,
lazy val tgtId = tgtVertex.innerIdVal
lazy val labelName = innerLabel.label
lazy val direction = GraphUtil.fromDirection(dir)
-
+
def toIndexEdge(labelIndexSeq: Byte): IndexEdge = IndexEdge(innerGraph, srcVertex, tgtVertex, innerLabel, dir, op, version, labelIndexSeq, propsWithTs)
def serializePropsWithTs(): Array[Byte] = HBaseSerializable.propsToKeyValuesWithTs(propsWithTs.asScala.map(kv => kv._2.labelMeta.seq -> kv._2.innerValWithTs).toSeq)
@@ -629,7 +629,7 @@ case class S2Edge(innerGraph: S2Graph,
if (keys.isEmpty) {
propsWithTs.forEach(new BiConsumer[String, S2Property[_]] {
override def accept(key: String, property: S2Property[_]): Unit = {
- if (!LabelMeta.reservedMetaNamesSet(key) && property.isPresent)
+ if (!LabelMeta.reservedMetaNamesSet(key) && property.isPresent && key != T.id.name)
ls.add(property.asInstanceOf[S2Property[V]])
}
})
@@ -689,9 +689,9 @@ case class S2Edge(innerGraph: S2Graph,
val timestamp = if (this.innerLabel.consistencyLevel == "strong") 0l else ts
// EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
if (direction == "out")
- EdgeId(srcVertex.innerId, tgtVertex.innerId, label(), "out", timestamp)
+ EdgeId(srcVertex.id.innerId, tgtVertex.id.innerId, label(), "out", timestamp)
else
- EdgeId(tgtVertex.innerId, srcVertex.innerId, label(), "out", timestamp)
+ EdgeId(tgtVertex.id.innerId, srcVertex.id.innerId, label(), "out", timestamp)
}
override def id(): AnyRef = edgeId
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/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 20e19e4..78eb2b2 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -572,8 +572,8 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphTest", method="*", reason="no"),
// passed: , failed:
-// 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"),
+ 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
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexPropertyTest", method="*", reason="no"),
@@ -695,7 +695,6 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
ColumnMeta.findOrInsert(DefaultColumn.id.get, "lang", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "oid", "integer", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "communityIndex", "integer", useCache = false)
- ColumnMeta.findOrInsert(DefaultColumn.id.get, "test", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "testing", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "string", "string", useCache = false)
ColumnMeta.findOrInsert(DefaultColumn.id.get, "boolean", "boolean", useCache = false)
@@ -1704,4 +1703,11 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
override def features() = s2Features
override def toString(): String = "[s2graph]"
+
+// override def io[I <: Io[_ <: GraphReader.ReaderBuilder[_ <: GraphReader], _ <: GraphWriter.WriterBuilder[_ <: GraphWriter], _ <: Mapper.Builder[_]]](builder: Io.Builder[I]): I = {
+// builder.graph(this).registry(new S2GraphIoRegistry).create().asInstanceOf[I]
+//
+// }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/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 529ece4..9a9dfa8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -244,7 +244,7 @@ case class S2Vertex(graph: S2Graph,
if (keys.isEmpty) {
props.forEach(new BiConsumer[String, VertexProperty[_]] {
override def accept(key: String, property: VertexProperty[_]): Unit = {
- if (!ColumnMeta.reservedMetaNamesSet(key) && property.isPresent)
+ if (!ColumnMeta.reservedMetaNamesSet(key) && property.isPresent && key != T.id.name)
ls.add(property.asInstanceOf[VertexProperty[V]])
}
})
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
index c5258fb..84e6de7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2VertexProperty.scala
@@ -22,12 +22,10 @@ package org.apache.s2graph.core
import java.util
import org.apache.s2graph.core.mysqls.ColumnMeta
-import org.apache.s2graph.core.types.CanInnerValLike
-import org.apache.tinkerpop.gremlin.structure.{Property, VertexProperty, Vertex => TpVertex}
+import org.apache.s2graph.core.types.{CanInnerValLike, InnerValLike}
+import org.apache.tinkerpop.gremlin.structure.{Property, VertexProperty}
-import scala.util.hashing.MurmurHash3
-
-case class S2VertexPropertyId[V](columnMeta: ColumnMeta, value: V)
+case class S2VertexPropertyId(columnMeta: ColumnMeta, value: InnerValLike)
case class S2VertexProperty[V](element: S2Vertex,
columnMeta: ColumnMeta,
@@ -53,7 +51,7 @@ case class S2VertexProperty[V](element: S2Vertex,
isRemoved = true
}
- override def id(): AnyRef = S2VertexPropertyId(columnMeta, v)
+ override def id(): AnyRef = S2VertexPropertyId(columnMeta, innerVal)
@volatile var isRemoved = false
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
index c37728c..f653901 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/InnerValLike.scala
@@ -40,12 +40,13 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
val INT = "integer"
val SHORT = "short"
val BYTE = "byte"
- val NUMERICS = Set(DOUBLE, FLOAT, LONG, INT, SHORT, BYTE)
+ val BIGDECIMAL = "bigDecimal"
+ val NUMERICS = Set(DOUBLE, FLOAT, LONG, INT, SHORT, BYTE, BIGDECIMAL)
val BOOLEAN = "boolean"
def isNumericType(dataType: String): Boolean = {
dataType match {
- case InnerVal.BYTE | InnerVal.SHORT | InnerVal.INT | InnerVal.LONG | InnerVal.FLOAT | InnerVal.DOUBLE => true
+ case BYTE | SHORT | INT | LONG | FLOAT | DOUBLE | BIGDECIMAL=> true
case _ => false
}
}
@@ -60,6 +61,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
case "short" | "int16" | "integer16" => SHORT
case "byte" | "b" | "tinyint" | "int8" | "integer8" => BYTE
case "boolean" | "bool" => BOOLEAN
+ case "bigdecimal" => BIGDECIMAL
case _ => throw new RuntimeException(s"can`t convert $dataType into InnerDataType")
}
}
@@ -91,7 +93,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withLong(l: Long, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(l))
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(l), LONG, version)
// case VERSION1 => v1.InnerVal(Some(l), None, None)
case _ => throw notSupportedEx(version)
}
@@ -99,7 +101,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withInt(i: Int, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(i))
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(i), INT, version)
// case VERSION1 => v1.InnerVal(Some(i.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -107,7 +109,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withFloat(f: Float, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(f.toDouble))
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(f.toDouble), FLOAT, version)
// case VERSION1 => v1.InnerVal(Some(f.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -115,7 +117,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withDouble(d: Double, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(d))
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(BigDecimal(d), DOUBLE, version)
// case VERSION1 => v1.InnerVal(Some(d.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -123,7 +125,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withNumber(num: BigDecimal, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(num)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(num, BIGDECIMAL, version)
// case VERSION1 => v1.InnerVal(Some(num.toLong), None, None)
case _ => throw notSupportedEx(version)
}
@@ -131,7 +133,7 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withBoolean(b: Boolean, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(b)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(b, BOOLEAN, version)
// case VERSION1 => v1.InnerVal(None, None, Some(b))
case _ => throw notSupportedEx(version)
}
@@ -139,70 +141,28 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
def withBlob(blob: Array[Byte], version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(blob)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(blob, BLOB, version)
case _ => throw notSupportedEx(version)
}
}
def withStr(s: String, version: String): InnerValLike = {
version match {
- case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(s)
+ case VERSION2 | VERSION3 | VERSION4 => v2.InnerVal(s, STRING, version)
// case VERSION1 => v1.InnerVal(None, Some(s), None)
case _ => throw notSupportedEx(version)
}
}
-
-// def withInnerVal(innerVal: InnerValLike, version: String): InnerValLike = {
-// val bytes = innerVal.bytes
-// version match {
-// case VERSION2 => v2.InnerVal.fromBytes(bytes, 0, bytes.length, version)._1
-// case VERSION1 => v1.InnerVal.fromBytes(bytes, 0, bytes.length, version)._1
-// case _ => throw notSupportedEx(version)
-// }
-// }
-
- /** nasty implementation for backward compatability */
-// def convertVersion(innerVal: InnerValLike, dataType: String, toVersion: String): InnerValLike = {
-// val ret = toVersion match {
-// case VERSION2 | VERSION3 | VERSION4 =>
-// if (innerVal.isInstanceOf[v1.InnerVal]) {
-// val obj = innerVal.asInstanceOf[v1.InnerVal]
-// obj.valueType match {
-// case "long" => InnerVal.withLong(obj.longV.get, toVersion)
-// case "string" => InnerVal.withStr(obj.strV.get, toVersion)
-// case "boolean" => InnerVal.withBoolean(obj.boolV.get, toVersion)
-// case _ => throw new Exception(s"InnerVal should be [long/integeer/short/byte/string/boolean]")
-// }
-// } else {
-// innerVal
-// }
-//// case VERSION1 =>
-//// if (innerVal.isInstanceOf[v2.InnerVal]) {
-//// val obj = innerVal.asInstanceOf[v2.InnerVal]
-//// obj.value match {
-//// case str: String => InnerVal.withStr(str, toVersion)
-//// case b: Boolean => InnerVal.withBoolean(b, toVersion)
-//// case n: BigDecimal => InnerVal.withNumber(n, toVersion)
-//// case n: Long => InnerVal.withNumber(n, toVersion)
-//// case n: Double => InnerVal.withNumber(n, toVersion)
-//// case n: Int => InnerVal.withNumber(n, toVersion)
-//// case _ => throw notSupportedEx(s"v2 to v1: $obj -> $toVersion")
-//// }
-//// } else {
-//// innerVal
-//// }
-// case _ => throw notSupportedEx(toVersion)
-// }
-//// logger.debug(s"convertVersion: $innerVal, $dataType, $toVersion, $ret, ${innerVal.bytes.toList}, ${ret.bytes.toList}")
-// ret
-// }
-
}
trait InnerValLike extends HBaseSerializable {
val value: Any
+ val dataType: String
+
+ val schemaVersion: String
+
def compare(other: InnerValLike): Int
def +(other: InnerValLike): InnerValLike
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
index 9d3ea72..31bdce6 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/VertexId.scala
@@ -69,7 +69,7 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
override def toString(): String = {
// column.id.get.toString() + "," + innerId.toString()
val del = S2Vertex.VertexLabelDelimiter
- s"${column.service.serviceName}${del}${column.columnName}${del}${innerId}"
+ s"${column.serviceId}${del}${column.columnName}${del}${innerId}"
}
override def hashCode(): Int = {
@@ -83,7 +83,7 @@ class VertexId (val column: ServiceColumn, val innerId: InnerValLike) extends HB
}
override def equals(obj: Any): Boolean = {
val ret = obj match {
- case other: VertexId => colId == other.colId && innerId.toIdString() == other.innerId.toIdString()
+ case other: VertexId => column.id.get == other.column.id.get && innerId.toIdString() == other.innerId.toIdString()
case _ => false
}
// logger.debug(s"VertexId.equals: $this, $obj => $ret")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
index 361b9cf..60cb1cc 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/v1/InnerVal.scala
@@ -176,6 +176,9 @@ case class InnerVal(longV: Option[Long], strV: Option[String], boolV: Option[Boo
case (None, None, Some(b)) => b
case _ => throw new Exception(s"InnerVal should be [long/integeer/short/byte/string/boolean]")
}
+ val dataType = valueType
+
+ val schemaVersion = "v1"
def valueType = (longV, strV, boolV) match {
case (Some(l), None, None) => "long"
case (None, Some(s), None) => "string"
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala b/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
index 9d9bdf2..95888d7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/types/v2/InnerVal.scala
@@ -26,7 +26,7 @@ import org.apache.s2graph.core.types.{HBaseDeserializableWithIsVertexId, HBaseSe
object InnerVal extends HBaseDeserializableWithIsVertexId {
import HBaseType._
-
+ import types.InnerVal._
val order = Order.DESCENDING
def fromBytes(bytes: Array[Byte],
@@ -43,21 +43,21 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
case Order.DESCENDING => bytes(offset) == 0
case _ => bytes(offset) == -1
}
- (InnerVal(boolean), 1)
+ (InnerVal(boolean, BOOLEAN, version), 1)
}
else {
if (OrderedBytes.isNumeric(pbr)) {
val numeric = OrderedBytes.decodeNumericAsBigDecimal(pbr)
- if (isVertexId) (InnerVal(numeric.longValue()), pbr.getPosition - startPos)
- else (InnerVal(BigDecimal(numeric)), pbr.getPosition - startPos)
+ if (isVertexId) (InnerVal(numeric.longValue(), LONG, version), pbr.getPosition - startPos)
+ else (InnerVal(BigDecimal(numeric), BIGDECIMAL, version), pbr.getPosition - startPos)
// (InnerVal(numeric.doubleValue()), pbr.getPosition - startPos)
// (InnerVal(BigDecimal(numeric)), pbr.getPosition - startPos)
} else if (OrderedBytes.isText(pbr)) {
val str = OrderedBytes.decodeString(pbr)
- (InnerVal(str), pbr.getPosition - startPos)
+ (InnerVal(str, STRING, version), pbr.getPosition - startPos)
} else if (OrderedBytes.isBlobVar(pbr)) {
val blobVar = OrderedBytes.decodeBlobVar(pbr)
- (InnerVal(blobVar), pbr.getPosition - startPos)
+ (InnerVal(blobVar, BLOB, version), pbr.getPosition - startPos)
} else {
throw new RuntimeException("!!")
}
@@ -65,7 +65,9 @@ object InnerVal extends HBaseDeserializableWithIsVertexId {
}
}
-case class InnerVal(value: Any) extends HBaseSerializable with InnerValLike {
+case class InnerVal(value: Any,
+ dataType: String,
+ schemaVersion: String) extends HBaseSerializable with InnerValLike {
import types.InnerVal._
@@ -76,9 +78,10 @@ case class InnerVal(value: Any) extends HBaseSerializable with InnerValLike {
/* since OrderedBytes header start from 0x05, it is safe to use -1, 0
* for decreasing order (true, false) */
// Bytes.toBytes(b)
+ //TODO: 0, 1 is also safe?
order match {
- case Order.DESCENDING => if (b) Array(0.toByte) else Array(-1.toByte)
- case _ => if (!b) Array(0.toByte) else Array(-1.toByte)
+ case Order.DESCENDING => if (b) Array(0.toByte) else Array(1.toByte)
+ case _ => if (!b) Array(0.toByte) else Array((1.toByte))
}
case d: Double =>
val num = BigDecimal(d)
@@ -105,8 +108,6 @@ case class InnerVal(value: Any) extends HBaseSerializable with InnerValLike {
val pbr = numByteRange(num)
val len = OrderedBytes.encodeNumeric(pbr, num.bigDecimal, order)
pbr.getBytes().take(len)
-
-
case b: BigDecimal =>
val pbr = numByteRange(b)
val len = OrderedBytes.encodeNumeric(pbr, b.bigDecimal, order)
@@ -155,7 +156,7 @@ case class InnerVal(value: Any) extends HBaseSerializable with InnerValLike {
throw new RuntimeException(s"+ $this, $other")
(value, other.value) match {
- case (v1: BigDecimal, v2: BigDecimal) => new InnerVal(BigDecimal(v1.bigDecimal.add(v2.bigDecimal)))
+ case (v1: BigDecimal, v2: BigDecimal) => new InnerVal(BigDecimal(v1.bigDecimal.add(v2.bigDecimal)), dataType, schemaVersion)
case _ => throw new RuntimeException("+ operation on inner val is for big decimal pair")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/ee22c608/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 e838447..dc24cb6 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
@@ -105,7 +105,8 @@ class S2GraphProvider extends AbstractGraphProvider {
Prop("aKey", "-", "string"),
Prop("stars", "0", "integer"),
Prop("since", "0", "integer"),
- Prop("myEdgeId", "0", "integer")
+ Prop("myEdgeId", "0", "integer"),
+ Prop("data", "-", "string")
)
// Change dataType for ColumnMeta('aKey') for PropertyFeatureSupportTest
@@ -138,7 +139,16 @@ class S2GraphProvider extends AbstractGraphProvider {
ColumnMeta.findOrInsert(defaultServiceColumn.id.get, "aKey", dataType, useCache = false)
}
- if (testClass.getSimpleName == "DetachedEdgeTest") {
+ if (testClass.getSimpleName == "ReferenceEdgeTest") {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+ } else if (testClass.getName.contains("SerializationTest") || testClass.getSimpleName == "IoPropertyTest") {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
+ } else if (testClass.getSimpleName.contains("CommunityGeneratorTest")) {
+ mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": true}"""))
+ } else if (testClass.getSimpleName == "DetachedEdgeTest" || testClass.getSimpleName.contains("GraphSONTest")) {
mnt.createLabel("knows", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}"""))
} else {
@@ -173,13 +183,18 @@ class S2GraphProvider extends AbstractGraphProvider {
true, defaultService.serviceName, Nil, Seq(Prop("xxx", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
- val self = if (testClass.getSimpleName.contains("GraphTest")) {
+ val self = if (testClass.getSimpleName == "StarGraphTest") {
+ mnt.createLabel("self", defaultService.serviceName, "person", "integer",
+ defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ } else 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,
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "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,
+ true, defaultService.serviceName, Nil, Seq(Prop("acl", "-", "string")), "weak", None, None,
options = Option("""{"skipReverse": true}"""))
}
@@ -188,16 +203,31 @@ class S2GraphProvider extends AbstractGraphProvider {
"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,
- Seq(
- Prop("name", "-", "string"),
- Prop("location", "-", "string"),
- Prop("status", "-", "string")
- ),
- "strong", None, None,
- options = Option("""{"skipReverse": false}""")
- )
+ val friend = if (testClass.getSimpleName.contains("IoEdgeTest")) {
+ mnt.createLabel("friend", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer",
+ true, defaultService.serviceName, Nil,
+ Seq(
+ Prop("name", "-", "string"),
+ Prop("location", "-", "string"),
+ Prop("status", "-", "string"),
+ Prop("weight", "0.0", "double"),
+ Prop("acl", "-", "string")
+ ), "strong", None, None,
+ options = Option("""{"skipReverse": false}"""))
+ } else {
+ 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"),
+ Prop("weight", "0.0", "double"),
+ Prop("acl", "-", "string")
+ ),
+ "strong", None, None,
+ options = Option("""{"skipReverse": false}""")
+ )
+ }
val hate = mnt.createLabel("hate", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType,
true, defaultService.serviceName, Nil, Nil, "strong", None, None,
[20/46] incubator-s2graph git commit: [ReferenceVertexTest] passed
all.
Posted by st...@apache.org.
[ReferenceVertexTest] 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/8cb62097
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/8cb62097
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/8cb62097
Branch: refs/heads/master
Commit: 8cb6209756f86b3058085fe352d35032e3cc3bb4
Parents: 818cfec
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Apr 26 15:39:53 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Apr 26 15:39:53 2017 +0900
----------------------------------------------------------------------
s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/8cb62097/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 dfd22ca..2586173 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -580,7 +580,7 @@ object S2Graph {
// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceGraphTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexTest", method="*", reason="no"),
// passed: all, failed: none, all ignored
// not yet supported
[43/46] incubator-s2graph git commit: bug fix on S2Vertex.vertices.
Posted by st...@apache.org.
bug fix on S2Vertex.vertices.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/38682a81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/38682a81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/38682a81
Branch: refs/heads/master
Commit: 38682a8123d18b2259c0280f694b82e9ac0af9bc
Parents: e77862b
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri May 5 12:20:32 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri May 5 12:20:32 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 14 ++++++-------
.../org/apache/s2graph/core/S2Vertex.scala | 21 ++++++++++++++------
2 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/38682a81/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 95186e8..fc67be5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -616,9 +616,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", reason = "somehow count becomes double. fix this. "),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX3X_count", reason = "count differ very little. fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX8X_count", reason = "count differ very litter. fix this."),
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", reason = "somehow count becomes double. fix this. "),
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX3X_count", reason = "count differ very little. fix this."),
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_repeatXoutX_timesX8X_count", reason = "count differ very litter. fix this."),
// passed: all, failed: g_V_both_both_count, g_V_repeatXoutX_timesX3X_count, g_V_repeatXoutX_timesX8X_count
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapTest$Traversals", method = "*", reason = "no"),
@@ -683,11 +683,9 @@ object S2Graph {
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest$Traversals", method = "*", reason = "no"),
// passed: all
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_VX4X_bothE_otherV", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_V_out_outE_inV_inE_inV_both_name", reason = "fix this."),
- new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "g_VX4X_both", reason = "fix this."),
-// failed: g_VX4X_bothE_otherV, g_VX1_2_3_4X_name, g_V_out_outE_inV_inE_inV_both_name, g_VX4X_bothEXcreatedX, g_VX4X_both
-
+// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest$Traversals", method = "*", reason = "no"),
+// passed: all
+
// new Graph.OptOut(test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest$Traversals", method = "*", reason = "no"),
// passed: all
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/38682a81/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 bb60522..269cf84 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -125,13 +125,22 @@ case class S2Vertex(graph: S2Graph,
val arr = new util.ArrayList[Vertex]()
edges(direction, edgeLabels: _*).forEachRemaining(new Consumer[Edge] {
override def accept(edge: Edge): Unit = {
- direction match {
- case Direction.OUT => arr.add(edge.inVertex())
- case Direction.IN => arr.add(edge.outVertex())
- case _ =>
- arr.add(edge.inVertex())
- arr.add(edge.outVertex())
+ val s2Edge = edge.asInstanceOf[S2Edge]
+
+ s2Edge.direction match {
+ case "out" => arr.add(edge.inVertex())
+ case "in" => arr.add(edge.outVertex())
+ case _ => throw new IllegalStateException("only out/in direction can be found in S2Edge")
}
+// direction match {
+// case Direction.OUT => arr.add(edge.inVertex())
+// case Direction.IN => arr.add(edge.outVertex())
+// case _ =>
+// val inV = edge.inVertex()
+// val outV = edge.outVertex()
+// if (id != inV.id()) arr.add(inV)
+// if (id != outV.id()) arr.add(outV)
+// }
}
})
arr.iterator()
[14/46] incubator-s2graph git commit: trying multiple tests.
Posted by st...@apache.org.
trying multiple tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/bfc05ba7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/bfc05ba7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/bfc05ba7
Branch: refs/heads/master
Commit: bfc05ba743566cf2286a5888c8a1aca3c03e1411
Parents: b8033e7
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Apr 14 15:58:20 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Apr 14 15:58:20 2017 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/core/S2Graph.scala | 130 +++++++++----------
.../org/apache/s2graph/core/S2Vertex.scala | 2 +-
2 files changed, 63 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/bfc05ba7/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 ec02dd5..8b48064 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -532,39 +532,38 @@ object S2Graph {
//@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
@Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD)
@Graph.OptOuts(value = Array(
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
- // passed: all, failed: none
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
- // passed: all, failed: none
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
- // passed: all, failed: none
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
- // passed: all, failed: none
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
- // passed: all, failed: none
- // shouldEnableFeatureOnEdgeIfNotEnabled, shouldEnableFeatureOnVertexIfNotEnabled, shouldSupportUserSuppliedIdsOfTypeAny
-
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.EdgeTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.GraphConstructionTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.PropertyTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexPropertyTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.FeatureSupportTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.VertexTest$BasicVertexTest", method="shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge", reason="S2Vertex.addEdge behave as upsert."),
- // passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
-
+// // passed: , failed: shouldHaveExceptionConsistencyWhenAssigningSameIdOnEdge
+//
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdgeTest", method="shouldNotEvaluateToEqualDifferentId", reason="reference equals is not supported."),
- // passed: all, failed: shouldNotEvaluateToEqualDifferentId
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
- // passed: all, failed: none
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"),
- // passed: all, failed: none, all ignored
-
+// // passed: all, failed: shouldNotEvaluateToEqualDifferentId
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexTest", method="*", reason="no"),
+// // passed: all, failed: none
+//
+// new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest", method="*", reason="no"),
+// // passed: all, failed: none, all ignored
+//
new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPropertyTest", method="shouldNotBeEqualPropertiesAsThereIsDifferentKey", reason="reference equals is not supported."),
- // passed: , failed: shouldNotBeEqualPropertiesAsThereIsDifferentKey
-
- new Graph.OptOut(test="org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexPropertyTest", method="*", reason="no"),
- // passed: all, failed: none
+// // passed: , failed: shouldNotBeEqualPropertiesAsThereIsDifferentKey
+//
+// 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"),
// passed: , failed:
@@ -1599,6 +1598,32 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
addVertex(Seq(T.label, label): _*)
}
+ def makeVertex(idValue: AnyRef, kvsMap: Map[String, AnyRef]): S2Vertex = {
+ idValue match {
+ case vId: VertexId =>
+ toVertex(vId.column.service.serviceName, vId.column.columnName, vId, kvsMap)
+ case _ =>
+ val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
+
+ val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
+ val (serviceName, columnName) =
+ if (names.length == 1) (DefaultService.serviceName, names(0))
+ else throw new RuntimeException("malformed data on vertex label.")
+
+ toVertex(serviceName, columnName, idValue, kvsMap)
+ }
+ }
+
+ def validType(t: Any): Boolean = t match {
+ case _: VertexId => true
+ case _: String => true
+ case _: java.lang.Integer => true
+ case _: java.lang.Long => true
+ case _: scala.Long => true
+ case _: scala.Int => true
+ case _ => false
+ }
+
override def addVertex(kvs: AnyRef*): structure.Vertex = {
if (!features().vertex().supportsUserSuppliedIds() && kvs.contains(T.id)) {
throw Vertex.Exceptions.userSuppliedIdsNotSupported
@@ -1609,48 +1634,17 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
if (kvsMap.contains(T.label.name()) && kvsMap(T.label.name).toString.isEmpty)
throw Element.Exceptions.labelCanNotBeEmpty
- def validType(t: Any): Boolean = t match {
- case t: String => true
- case t: java.lang.Integer => true
- case t: java.lang.Long => true
- case t: scala.Long => true
- case t: scala.Int => true
- case _ => false
- }
-
val vertex = kvsMap.get(T.id.name()) match {
case None => // do nothing
val id = Random.nextLong
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
-
- val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
- val (serviceName, columnName) =
- if (names.length == 1) (DefaultService.serviceName, names(0))
- else throw new RuntimeException("malformed data on vertex label.")
-
- toVertex(serviceName, columnName, id, kvsMap)
- case Some(idValue) =>
- idValue match {
- case vId: VertexId =>
- toVertex(vId.column.service.serviceName, vId.column.columnName, vId, kvsMap)
-
- case _: Any if validType(idValue) =>
- val serviceColumnNames = kvsMap.getOrElse(T.label.toString, DefaultColumn.columnName).toString
- val names = serviceColumnNames.split(S2Vertex.VertexLabelDelimiter)
-
- val (serviceName, columnName) =
- if (names.length == 1) (DefaultService.serviceName, names(0))
- else throw new RuntimeException("malformed data on vertex label.")
-
- toVertex(serviceName, columnName, idValue, kvsMap)
-
- case _ =>
- logger.error(s"[S2Graph.addVertex]: ${idValue.getClass.getName}")
- throw Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported
- }
+ makeVertex(Long.box(id), kvsMap)
+ case Some(idValue) if validType(idValue) =>
+ makeVertex(idValue, kvsMap)
+ case _ =>
+ throw Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported
}
- addVertex(vertex)
+ addVertexInner(vertex)
}
def addVertex(id: VertexId,
@@ -1666,7 +1660,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends Graph
Await.result(future, WaitTimeout)
}
- def addVertex(vertex: S2Vertex): S2Vertex = {
+ def addVertexInner(vertex: S2Vertex): S2Vertex = {
val future = mutateVertices(Seq(vertex), withWait = true).map { rets =>
if (rets.forall(identity)) vertex
else throw new RuntimeException("addVertex failed.")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/bfc05ba7/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 3c771f5..7d6433d 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Vertex.scala
@@ -180,7 +180,7 @@ case class S2Vertex(graph: S2Graph,
props.put(key, newProps)
// FIXME: save to persistent for tp test
- graph.addVertex(this)
+ graph.addVertexInner(this)
newProps
case _ => throw new RuntimeException("only single cardinality is supported.")
}
[35/46] incubator-s2graph git commit: bug fix on edges.
Posted by st...@apache.org.
bug fix on edges.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/7f34d7b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/7f34d7b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/7f34d7b1
Branch: refs/heads/master
Commit: 7f34d7b1a349b29027689a842e822cb96818af5d
Parents: e77cbc8 a5b34e9
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed May 3 16:44:13 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed May 3 21:44:46 2017 +0900
----------------------------------------------------------------------
.../org/apache/s2graph/core/JSONParser.scala | 3 +-
.../scala/org/apache/s2graph/core/S2Edge.scala | 37 +--
.../scala/org/apache/s2graph/core/S2Graph.scala | 223 +++++++++++++++-
.../apache/s2graph/core/io/Conversions.scala | 8 +-
.../apache/s2graph/core/types/VertexId.scala | 2 +-
.../core/tinkerpop/S2GraphProvider.scala | 257 +++++++++++++------
.../core/tinkerpop/structure/S2GraphTest.scala | 75 +++++-
7 files changed, 487 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7f34d7b1/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
----------------------------------------------------------------------
diff --cc s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
index eca8f18,28a0b06..ca336a7
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@@ -647,8 -650,8 +650,9 @@@ case class S2Edge(innerGraph: S2Graph
val labelMeta = innerLabel.metaPropsInvMap.getOrElse(key, throw new java.lang.IllegalStateException(s"$key is not configured on Edge."))
if (propsWithTs.containsKey(key)) propsWithTs.get(key).asInstanceOf[Property[V]]
else {
-- val default = innerLabel.metaPropsDefaultMapInner(labelMeta)
-- propertyInner(key, default.innerVal.value, default.ts).asInstanceOf[Property[V]]
++ Property.empty()
++// val default = innerLabel.metaPropsDefaultMapInner(labelMeta)
++// propertyInner(key, default.innerVal.value, default.ts).asInstanceOf[Property[V]]
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7f34d7b1/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
----------------------------------------------------------------------
diff --cc s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
index f05f2cb,66a8d46..7556165
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@@ -1463,12 -1663,17 +1663,17 @@@ class S2Graph(_config: Config)(implici
}
val query = Query.toQuery(Seq(vertex), queryParams)
-
-// val queryRequests = queryParams.map { param => QueryRequest(query, 0, vertex, param) }
-// val ls = new util.ArrayList[Edge]()
-// fetches(queryRequests, Map.empty).map { stepResultLs =>
-// stepResultLs.foreach(_.edgeWithScores.foreach(es => ls.add(es.edge)))
-// ls.iterator()
-// }
-- getEdges(query).map { stepResult =>
-- val ls = new util.ArrayList[Edge]()
-- stepResult.edgeWithScores.foreach(es => ls.add(es.edge))
++ val queryRequests = queryParams.map { param => QueryRequest(query, 0, vertex, param) }
++ val ls = new util.ArrayList[Edge]()
++ fetches(queryRequests, Map.empty).map { stepResultLs =>
++ stepResultLs.foreach(_.edgeWithScores.foreach(es => ls.add(es.edge)))
ls.iterator()
}
++// getEdges(query).map { stepResult =>
++// val ls = new util.ArrayList[Edge]()
++// stepResult.edgeWithScores.foreach(es => ls.add(es.edge))
++// ls.iterator()
++// }
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7f34d7b1/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
----------------------------------------------------------------------
diff --cc s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
index d0761e1,fdd04af..37e011c
--- a/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/tinkerpop/S2GraphProvider.scala
@@@ -336,6 -423,6 +423,10 @@@ class S2GraphProvider extends AbstractG
}
override def convertLabel(label: String): String = {
-- label
++ label match {
++ case "blah1" => S2Graph.DefaultLabelName
++ case "blah2" => S2Graph.DefaultLabelName
++ case _ => label
++ }
}
}