Add preload all fetchers and mutators that registered in serviceColumn/label while initialize new S2Graph instance.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/16feda80 Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/16feda80 Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/16feda80 Branch: refs/heads/master Commit: 16feda80fceb7604932b32a2884c7551f570a38b Parents: e823041 Author: DO YUNG YOON <steams...@apache.org> Authored: Thu May 10 15:40:06 2018 +0900 Committer: DO YUNG YOON <steams...@apache.org> Committed: Thu May 10 15:41:26 2018 +0900 ---------------------------------------------------------------------- .../org/apache/s2graph/core/GraphUtil.scala | 7 ++ .../org/apache/s2graph/core/Management.scala | 34 ++++----- .../scala/org/apache/s2graph/core/S2Graph.scala | 28 ++++++++ .../apache/s2graph/core/S2GraphFactory.scala | 9 ++- .../s2graph/core/rest/RequestParser.scala | 8 ++- .../org/apache/s2graph/core/schema/Label.scala | 6 +- .../s2graph/core/TestCommonWithModels.scala | 14 ++-- .../s2graph/core/fetcher/EdgeFetcherTest.scala | 30 ++++---- .../core/tinkerpop/S2GraphProvider.scala | 73 +++++++++----------- .../core/tinkerpop/structure/S2GraphTest.scala | 6 +- .../graphql/repository/GraphRepository.scala | 2 +- .../apache/s2graph/s2jobs/BaseSparkTest.scala | 11 +-- 12 files changed, 136 insertions(+), 92 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/main/scala/org/apache/s2graph/core/GraphUtil.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/org/apache/s2graph/core/GraphUtil.scala b/s2core/src/main/scala/org/apache/s2graph/core/GraphUtil.scala index a4f6bde..e08bb4e 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/GraphUtil.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/GraphUtil.scala @@ -164,4 +164,11 @@ object GraphUtil { } } + def stringToOption(s: Option[String]): Option[String] = { + s.filter(_.trim.nonEmpty) + } + + def stringToOption(s: String): Option[String] = { + Option(s).filter(_.trim.nonEmpty) + } } http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/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 f534423..f64e058 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/Management.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/Management.scala @@ -304,15 +304,16 @@ class Management(graph: S2GraphLike) { val importEx = ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor()) import Management._ + import GraphUtil._ def updateEdgeFetcher(labelName: String, options: String): Unit = { val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName)) - updateEdgeFetcher(label, options) + updateEdgeFetcher(label, stringToOption(options)) } - def updateEdgeFetcher(label: Label, options: String): Unit = { - val newLabel = Label.updateOption(label, options) + def updateEdgeFetcher(label: Label, options: Option[String]): Unit = { + val newLabel = options.map(Label.updateOption(label, _)).getOrElse(label) graph.resourceManager.getOrElseUpdateEdgeFetcher(newLabel, cacheTTLInSecs = Option(-1)) } @@ -320,22 +321,22 @@ class Management(graph: S2GraphLike) { val service = Service.findByName(serviceName).getOrElse(throw new IllegalArgumentException(s"$serviceName is not exist.")) val column = ServiceColumn.find(service.id.get, columnName).getOrElse(throw new IllegalArgumentException(s"$columnName is not exist.")) - updateVertexFetcher(column, options) + updateVertexFetcher(column, stringToOption(options)) } - def updateVertexFetcher(column: ServiceColumn, options: String): Unit = { - val newColumn = ServiceColumn.updateOption(column, options) + def updateVertexFetcher(column: ServiceColumn, options: Option[String]): Unit = { + val newColumn = options.map(ServiceColumn.updateOption(column, _)).getOrElse(column) graph.resourceManager.getOrElseUpdateVertexFetcher(newColumn, cacheTTLInSecs = Option(-1)) } def updateEdgeMutator(labelName: String, options: String): Unit = { val label = Label.findByName(labelName).getOrElse(throw new LabelNotExistException(labelName)) - updateEdgeMutator(label, options) + updateEdgeMutator(label, stringToOption(options)) } - def updateEdgeMutator(label: Label, options: String): Unit = { - val newLabel = Label.updateOption(label, options) + def updateEdgeMutator(label: Label, options: Option[String]): Unit = { + val newLabel = options.map(Label.updateOption(label, _)).getOrElse(label) graph.resourceManager.getOrElseUpdateEdgeMutator(newLabel, cacheTTLInSecs = Option(-1)) } @@ -343,11 +344,11 @@ class Management(graph: S2GraphLike) { val service = Service.findByName(serviceName).getOrElse(throw new IllegalArgumentException(s"$serviceName is not exist.")) val column = ServiceColumn.find(service.id.get, columnName).getOrElse(throw new IllegalArgumentException(s"$columnName is not exist.")) - updateVertexMutator(column, options) + updateVertexMutator(column, stringToOption(options)) } - def updateVertexMutator(column: ServiceColumn, options: String): Unit = { - val newColumn = ServiceColumn.updateOption(column, options) + def updateVertexMutator(column: ServiceColumn, options: Option[String]): Unit = { + val newColumn = options.map(ServiceColumn.updateOption(column, _)).getOrElse(column) graph.resourceManager.getOrElseUpdateVertexMutator(newColumn, cacheTTLInSecs = Option(-1)) } @@ -452,9 +453,9 @@ class Management(graph: S2GraphLike) { createLabel(labelName, srcColumn.service.serviceName, srcColumn.columnName, srcColumn.columnType, tgtColumn.service.serviceName, tgtColumn.columnName, tgtColumn.columnType, - isDirected, serviceName, indices, props, consistencyLevel, + serviceName, indices, props, isDirected, consistencyLevel, Option(hTableName), Option(hTableTTL).filter(_ > -1), - schemaVersion, false, compressionAlgorithm, Option(options) + schemaVersion, false, compressionAlgorithm, stringToOption(options) ).get } @@ -466,10 +467,10 @@ class Management(graph: S2GraphLike) { tgtServiceName: String, tgtColumnName: String, tgtColumnType: String, - isDirected: Boolean = true, serviceName: String, indices: Seq[Index], props: Seq[Prop], + isDirected: Boolean = true, consistencyLevel: String = "weak", hTableName: Option[String] = None, hTableTTL: Option[Int] = None, @@ -523,8 +524,9 @@ class Management(graph: S2GraphLike) { createLabel(newLabelName, old.srcService.serviceName, old.srcColumnName, old.srcColumnType, old.tgtService.serviceName, old.tgtColumnName, old.tgtColumnType, - old.isDirected, old.serviceName, + old.serviceName, allIndices, allProps, + old.isDirected, old.consistencyLevel, hTableName, old.hTableTTL, old.schemaVersion, old.isAsync, old.compressionAlgorithm, old.options) } http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/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 09fd55e..004b6e8 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala @@ -159,6 +159,30 @@ object S2Graph { } ConfigFactory.parseMap(kvs) } + + def initMutators(graph: S2GraphLike): Unit = { + val management = graph.management + + ServiceColumn.findAll().foreach { column => + management.updateVertexMutator(column, column.options) + } + + Label.findAll().foreach { label => + management.updateEdgeMutator(label, label.options) + } + } + + def initFetchers(graph: S2GraphLike): Unit = { + val management = graph.management + + ServiceColumn.findAll().foreach { column => + management.updateVertexFetcher(column, column.options) + } + + Label.findAll().foreach { label => + management.updateEdgeFetcher(label, label.options) + } + } } class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends S2GraphLike { @@ -197,6 +221,9 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends S2Grap conf.withFallback(config) } + S2Graph.initMutators(this) + S2Graph.initFetchers(this) + val defaultStorage: Storage = S2Graph.initStorage(this, config)(ec) for { @@ -248,6 +275,7 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends S2Grap storagePool.getOrElse(s"label:${label.label}", defaultStorage) } + /* Currently, each getter on Fetcher and Mutator missing proper implementation * Please discuss what is proper way to maintain resources here and provide * right implementation(S2GRAPH-213). http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/main/scala/org/apache/s2graph/core/S2GraphFactory.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphFactory.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphFactory.scala index 0a667ef..e79b831 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphFactory.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphFactory.scala @@ -97,7 +97,8 @@ object S2GraphFactory { // 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, + DefaultService.serviceName, DefaultColumn.columnName, DefaultColumn.columnType, DefaultService.serviceName, Nil, Nil, + isDirected = true, consistencyLevel = "weak", hTableName = None, hTableTTL = None, options = Option("""{"skipReverse": false}""") ) } @@ -111,12 +112,14 @@ object S2GraphFactory { val knows = mnt.createLabel("knows", S2Graph.DefaultServiceName, "person", "integer", S2Graph.DefaultServiceName, "person", "integer", - true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None) + S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double"), Prop("year", "0", "integer")), + isDirected = true, consistencyLevel = "strong", hTableName = None, hTableTTL = None) val created = mnt.createLabel("created", S2Graph.DefaultServiceName, "person", "integer", S2Graph.DefaultServiceName, "software", "integer", - true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), "strong", None, None) + S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), + isDirected = true, consistencyLevel = "strong", hTableName = None, hTableTTL = None) } def cleanupDefaultSchema(): Unit = { http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/main/scala/org/apache/s2graph/core/rest/RequestParser.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/org/apache/s2graph/core/rest/RequestParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/rest/RequestParser.scala index f59abc0..7f8b280 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/rest/RequestParser.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/rest/RequestParser.scala @@ -652,9 +652,11 @@ class RequestParser(graph: S2GraphLike) { val compressionAlgorithm = (jsValue \ "compressionAlgorithm").asOpt[String].getOrElse(DefaultCompressionAlgorithm) val options = (jsValue \ "options").asOpt[JsValue].map(_.toString()) - graph.management.createLabel(labelName, srcServiceName, srcColumnName, srcColumnType, - tgtServiceName, tgtColumnName, tgtColumnType, isDirected, serviceName, - indices, allProps, consistencyLevel, hTableName, hTableTTL, schemaVersion, isAsync, compressionAlgorithm, options) + graph.management.createLabel(labelName, + srcServiceName, srcColumnName, srcColumnType, + tgtServiceName, tgtColumnName, tgtColumnType, serviceName, + indices, allProps, isDirected, + consistencyLevel, hTableName, hTableTTL, schemaVersion, isAsync, compressionAlgorithm, options) } def toIndexElements(jsValue: JsValue) = Try { http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/main/scala/org/apache/s2graph/core/schema/Label.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/org/apache/s2graph/core/schema/Label.scala b/s2core/src/main/scala/org/apache/s2graph/core/schema/Label.scala index f3ce5e0..a359958 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/schema/Label.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/schema/Label.scala @@ -33,6 +33,8 @@ import scalikejdbc._ object Label extends SQLSyntaxSupport[Label] { import Schema._ + import GraphUtil._ + val className = Label.getClass.getSimpleName val maxHBaseTableNames = 2 @@ -43,7 +45,7 @@ object Label extends SQLSyntaxSupport[Label] { rs.int("tgt_service_id"), rs.string("tgt_column_name"), rs.string("tgt_column_type"), rs.boolean("is_directed"), rs.string("service_name"), rs.int("service_id"), rs.string("consistency_level"), rs.string("hbase_table_name"), rs.intOpt("hbase_table_ttl"), rs.string("schema_version"), rs.boolean("is_async"), - rs.string("compressionAlgorithm"), rs.stringOpt("options")) + rs.string("compressionAlgorithm"), stringToOption(rs.stringOpt("options"))) } def deleteAll(label: Label)(implicit session: DBSession) = { @@ -264,7 +266,7 @@ object Label extends SQLSyntaxSupport[Label] { } def updateOption(label: Label, options: String)(implicit session: DBSession = AutoSession) = { - scala.util.Try(Json.parse(options)).getOrElse(throw new RuntimeException("invalid Json option")) + scala.util.Try(Json.parse(options)).getOrElse(throw new RuntimeException(s"invalid Json option: $options")) logger.info(s"update options of label ${label.label}, ${options}") val cnt = sql"""update labels set options = $options where id = ${label.id.get}""".update().apply() val updatedLabel = findById(label.id.get, useCache = false) http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/test/scala/org/apache/s2graph/core/TestCommonWithModels.scala ---------------------------------------------------------------------- diff --git a/s2core/src/test/scala/org/apache/s2graph/core/TestCommonWithModels.scala b/s2core/src/test/scala/org/apache/s2graph/core/TestCommonWithModels.scala index 488b294..fb8de32 100644 --- a/s2core/src/test/scala/org/apache/s2graph/core/TestCommonWithModels.scala +++ b/s2core/src/test/scala/org/apache/s2graph/core/TestCommonWithModels.scala @@ -139,25 +139,25 @@ trait TestCommonWithModels { implicit val session = AutoSession management.createLabel(labelName, serviceName, columnName, columnType, serviceName, columnName, columnType, - isDirected = true, serviceName, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) + serviceName, testIdxProps, testProps, isDirected = true, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) management.createLabel(labelNameV2, serviceNameV2, columnNameV2, columnTypeV2, serviceNameV2, tgtColumnNameV2, tgtColumnTypeV2, - isDirected = true, serviceNameV2, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) + serviceNameV2, testIdxProps, testProps, isDirected = true, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) management.createLabel(labelNameV3, serviceNameV3, columnNameV3, columnTypeV3, serviceNameV3, tgtColumnNameV3, tgtColumnTypeV3, - isDirected = true, serviceNameV3, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", None) + serviceNameV3, testIdxProps, testProps, isDirected = true, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", None) management.createLabel(labelNameV4, serviceNameV4, columnNameV4, columnTypeV4, serviceNameV4, tgtColumnNameV4, tgtColumnTypeV4, - isDirected = true, serviceNameV4, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION4, false, "lg4", None) + serviceNameV4, testIdxProps, testProps, isDirected = true, consistencyLevel, Some(hTableName), hTableTTL, VERSION4, false, "lg4", None) management.createLabel(undirectedLabelName, serviceName, columnName, columnType, serviceName, tgtColumnName, tgtColumnType, - isDirected = false, serviceName, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", None) + serviceName, testIdxProps, testProps, isDirected = false, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", None) management.createLabel(undirectedLabelNameV2, serviceNameV2, columnNameV2, columnTypeV2, serviceNameV2, tgtColumnNameV2, tgtColumnTypeV2, - isDirected = false, serviceName, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) + serviceName, testIdxProps, testProps, isDirected = false, consistencyLevel, Some(hTableName), hTableTTL, VERSION2, false, "lg4", None) management.createLabel(labelNameSecure, serviceName, columnName, columnType, serviceName, tgtColumnName, tgtColumnType, - isDirected = false, serviceName, testIdxProps, testProps, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", + serviceName, testIdxProps, testProps, isDirected = false, consistencyLevel, Some(hTableName), hTableTTL, VERSION3, false, "lg4", Option("""{ "tokens": ["xxx-yyy", "aaa-bbb"] }""")) } http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2core/src/test/scala/org/apache/s2graph/core/fetcher/EdgeFetcherTest.scala ---------------------------------------------------------------------- diff --git a/s2core/src/test/scala/org/apache/s2graph/core/fetcher/EdgeFetcherTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/EdgeFetcherTest.scala index 930c517..d78538d 100644 --- a/s2core/src/test/scala/org/apache/s2graph/core/fetcher/EdgeFetcherTest.scala +++ b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/EdgeFetcherTest.scala @@ -55,21 +55,25 @@ class EdgeFetcherTest extends IntegrateCommon { val label = management.createLabel( labelName, - serviceColumn, - serviceColumn, - true, service.serviceName, - Seq.empty[Index].asJava, - Seq.empty[Prop].asJava, - "strong", - null, - -1, - "v3", - "gz", - options - ) + serviceColumn.columnName, + serviceColumn.columnType, + service.serviceName, + serviceColumn.columnName, + serviceColumn.columnType, + service.serviceName, + Seq.empty[Index], + Seq.empty[Prop], + isDirected = true, + consistencyLevel = "strong", + hTableName = None, + hTableTTL = None, + schemaVersion = "v3", + compressionAlgorithm = "gz", + options = Option(options) + ).get - graph.management.updateEdgeFetcher(label, options) + graph.management.updateEdgeFetcher(label, Option(options)) val vertex = graph.elementBuilder.toVertex(service.serviceName, serviceColumn.columnName, "daewon") http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/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 0467f7d..766e3c4 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 @@ -147,10 +147,10 @@ class S2GraphProvider extends AbstractGraphProvider { } 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}""")) + defaultService.serviceName, Nil, knowsProp, true, "strong", None, None, options = Option("""{"skipReverse": false}""")) } else { mnt.createLabel("knows", defaultService.serviceName, "vertex", "integer", defaultService.serviceName, "vertex", "integer", - true, defaultService.serviceName, Nil, knowsProp, "strong", None, None, options = Option("""{"skipReverse": false}""")) + defaultService.serviceName, Nil, knowsProp, true, "strong", None, None, options = Option("""{"skipReverse": false}""")) } // columns @@ -193,24 +193,24 @@ class S2GraphProvider extends AbstractGraphProvider { mnt.createLabel("created", defaultService.serviceName, "person", "integer", defaultService.serviceName, "software", "integer", - true, defaultService.serviceName, Nil, createdProps, "strong", None, None) + defaultService.serviceName, Nil, createdProps, true, "strong", None, None) } else { mnt.createLabel("created", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, createdProps, "strong", None, None) + defaultService.serviceName, Nil, createdProps, true, "strong", None, None) } val boughtProps = Seq(Prop("x", "-", "string"), Prop("y", "-", "string")) allProps ++= boughtProps val bought = mnt.createLabel("bought", defaultService.serviceName, "person", "integer", defaultService.serviceName, "product", "integer", - true, defaultService.serviceName, Nil, boughtProps, "strong", None, None, + defaultService.serviceName, Nil, boughtProps, true, "strong", None, None, options = Option("""{"skipReverse": true}""")) val testProps = Seq(Prop("xxx", "-", "string")) allProps ++= testProps val test = mnt.createLabel("test", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, testProps, "weak", None, None, + defaultService.serviceName, Nil, testProps, true, "weak", None, None, options = Option("""{"skipReverse": true}""")) val selfProps = Seq(Prop("__id", "-", "string"), Prop("acl", "-", "string"), @@ -222,12 +222,12 @@ class S2GraphProvider extends AbstractGraphProvider { mnt.createLabel("self", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, selfProps, "strong", None, None, + defaultService.serviceName, Nil, selfProps, true, "strong", None, None, options = Option("""{"skipReverse": true}""")) } else { mnt.createLabel("self", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, selfProps, "strong", None, None, + defaultService.serviceName, Nil, selfProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""")) } @@ -239,13 +239,13 @@ class S2GraphProvider extends AbstractGraphProvider { mnt.createLabel("friends", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, friendsProps, + defaultService.serviceName, Nil, friendsProps, true, "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, + defaultService.serviceName, Nil, Nil, true, "strong", None, None, options = Option("""{"skipReverse": false}""")) } @@ -264,15 +264,13 @@ class S2GraphProvider extends AbstractGraphProvider { mnt.createLabel("friend", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - friendProps, "strong", None, None, + defaultService.serviceName, Nil, friendProps, true, "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, - friendProps, "strong", None, None, + defaultService.serviceName, Nil, friendProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) } @@ -280,7 +278,7 @@ class S2GraphProvider extends AbstractGraphProvider { val hateProps = Nil val hate = mnt.createLabel("hate", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, hateProps, "strong", None, None, + defaultService.serviceName, Nil, hateProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -288,36 +286,35 @@ class S2GraphProvider extends AbstractGraphProvider { allProps ++= collaboratorProps val collaborator = mnt.createLabel("collaborator", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, - collaboratorProps, "strong", None, None, + defaultService.serviceName, Nil, collaboratorProps, true, "strong", None, None, options = Option("""{"skipReverse": true}""") ) val test1Props = Nil val test1 = mnt.createLabel("test1", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, test1Props, "weak", None, None, + defaultService.serviceName, Nil, test1Props, true, "weak", None, None, options = Option("""{"skipReverse": false}""") ) val test2Props = Nil val test2 = mnt.createLabel("test2", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, test2Props, "weak", None, None, + defaultService.serviceName, Nil, test2Props, true, "weak", None, None, options = Option("""{"skipReverse": false}""") ) val test3Props = Nil val test3 = mnt.createLabel("test3", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, test3Props, "weak", None, None, + defaultService.serviceName, Nil, test3Props, true, "weak", None, None, options = Option("""{"skipReverse": false}""") ) val petsProps = Nil val pets = mnt.createLabel("pets", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, petsProps, "strong", None, None, + defaultService.serviceName, Nil, petsProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -326,26 +323,25 @@ class S2GraphProvider extends AbstractGraphProvider { val walks = mnt.createLabel("walks", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, - walksProps, "strong", None, None, + defaultService.serviceName, Nil, walksProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) val livesWithProps = Nil val livesWith = mnt.createLabel("livesWith", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, livesWithProps, "strong", None, None, + defaultService.serviceName, Nil, livesWithProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) val hatesProps = Nil val hates = mnt.createLabel("hates", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, hatesProps, "weak", None, None, + defaultService.serviceName, Nil, hatesProps, true, "weak", None, None, options = Option("""{"skipReverse": false}""") ) val linkProps = Nil val link = mnt.createLabel("link", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, linkProps, "strong", None, None, + defaultService.serviceName, Nil, linkProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -355,8 +351,7 @@ class S2GraphProvider extends AbstractGraphProvider { val codeveloper = mnt.createLabel("codeveloper", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - codeveloperProps, "strong", None, None, + defaultService.serviceName, Nil, codeveloperProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -370,8 +365,7 @@ class S2GraphProvider extends AbstractGraphProvider { val createdBy = mnt.createLabel("createdBy", defaultService.serviceName, "software", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - createdByProps, "strong", None, None) + defaultService.serviceName, Nil, createdByProps, true, "strong", None, None) val existsWithProps = Seq(Prop("time", "-", "string")) allProps ++= existsWithProps @@ -379,7 +373,7 @@ class S2GraphProvider extends AbstractGraphProvider { val existsWith = mnt.createLabel("existsWith", defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, defaultService.serviceName, defaultServiceColumn.columnName, defaultServiceColumn.columnType, - true, defaultService.serviceName, Nil, existsWithProps, "strong", None, None, + defaultService.serviceName, Nil, existsWithProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -389,7 +383,7 @@ class S2GraphProvider extends AbstractGraphProvider { val followedBy = mnt.createLabel("followedBy", defaultService.serviceName, "song", "integer", defaultService.serviceName, "song", "integer", - true, defaultService.serviceName, Nil, followedByProps, "strong", None, None, + defaultService.serviceName, Nil, followedByProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -399,7 +393,7 @@ class S2GraphProvider extends AbstractGraphProvider { val writtenBy = mnt.createLabel("writtenBy", defaultService.serviceName, "song", "integer", defaultService.serviceName, "artist", "integer", - true, defaultService.serviceName, Nil, writtenByProps, "strong", None, None, + defaultService.serviceName, Nil, writtenByProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -409,7 +403,7 @@ class S2GraphProvider extends AbstractGraphProvider { val sungBy = mnt.createLabel("sungBy", defaultService.serviceName, "song", "integer", defaultService.serviceName, "artist", "integer", - true, defaultService.serviceName, Nil, sungByProps, "strong", None, None, + defaultService.serviceName, Nil, sungByProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -417,7 +411,7 @@ class S2GraphProvider extends AbstractGraphProvider { val uses = mnt.createLabel("uses", defaultService.serviceName, "person", "integer", defaultService.serviceName, "software", "integer", - true, defaultService.serviceName, Nil, usesProps, "strong", None, None, + defaultService.serviceName, Nil, usesProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -427,8 +421,7 @@ class S2GraphProvider extends AbstractGraphProvider { val likes = mnt.createLabel("likes", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - likesProps, "strong", None, None, + defaultService.serviceName, Nil, likesProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -438,8 +431,7 @@ class S2GraphProvider extends AbstractGraphProvider { val foo = mnt.createLabel("foo", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - fooProps, "strong", None, None, + defaultService.serviceName, Nil, fooProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) @@ -449,8 +441,7 @@ class S2GraphProvider extends AbstractGraphProvider { val bar = mnt.createLabel("bar", defaultService.serviceName, "person", "integer", defaultService.serviceName, "person", "integer", - true, defaultService.serviceName, Nil, - barProps, "strong", None, None, + defaultService.serviceName, Nil, barProps, true, "strong", None, None, options = Option("""{"skipReverse": false}""") ) http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/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 a77c6f3..51ddba2 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 @@ -428,12 +428,14 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels { val knows = mnt.createLabel("knows", S2Graph.DefaultServiceName, "person", "integer", S2Graph.DefaultServiceName, "person", "integer", - true, S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double"), Prop("year", "0", "integer")), consistencyLevel = "strong", None, None) + S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double"), Prop("year", "0", "integer")), + true, 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) + S2Graph.DefaultServiceName, Nil, Seq(Prop("weight", "0.0", "double")), + true, "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)) http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala ---------------------------------------------------------------------- diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala index 90037cf..0b5a2e9 100644 --- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala +++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala @@ -256,10 +256,10 @@ class GraphRepository(val graph: S2GraphLike) { tgtServiceProp.serviceName, tgtServiceColumn.columnName, tgtServiceColumn.columnType, - isDirected, serviceName, indices, allProps, + isDirected, consistencyLevel, hTableName, hTableTTL, http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/16feda80/s2jobs/src/test/scala/org/apache/s2graph/s2jobs/BaseSparkTest.scala ---------------------------------------------------------------------- diff --git a/s2jobs/src/test/scala/org/apache/s2graph/s2jobs/BaseSparkTest.scala b/s2jobs/src/test/scala/org/apache/s2graph/s2jobs/BaseSparkTest.scala index 8dfbe1e..e6779fa 100644 --- a/s2jobs/src/test/scala/org/apache/s2graph/s2jobs/BaseSparkTest.scala +++ b/s2jobs/src/test/scala/org/apache/s2graph/s2jobs/BaseSparkTest.scala @@ -121,10 +121,13 @@ class BaseSparkTest extends FunSuite with Matchers with BeforeAndAfterAll with D val serviceColumn = management.createServiceColumn(service.serviceName, "user", "string", Nil) Try { - management.createLabel("friends", serviceColumn, serviceColumn, isDirected = true, - serviceName = service.serviceName, indices = new java.util.ArrayList[Index], - props = Seq(Prop("since", "0", "long"), Prop("score", "0", "integer")).asJava, consistencyLevel = "strong", hTableName = tableName, - hTableTTL = -1, schemaVersion = schemaVersion, compressionAlgorithm = compressionAlgorithm, options = "") + management.createLabel("friends", + serviceColumn.service.serviceName, serviceColumn.columnName, serviceColumn.columnType, + serviceColumn.service.serviceName, serviceColumn.columnName, serviceColumn.columnType, + serviceName = service.serviceName, indices = Nil, + props = Seq(Prop("since", "0", "long"), Prop("score", "0", "integer")), + isDirected = true, consistencyLevel = "strong", hTableName = Option(tableName), + hTableTTL = None, schemaVersion = schemaVersion, compressionAlgorithm = compressionAlgorithm, options = None) } Label.findByName("friends").getOrElse(throw new IllegalArgumentException("friends label is not initialized."))