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 2018/04/24 02:10:48 UTC

[1/3] incubator-s2graph git commit: refactoring

Repository: incubator-s2graph
Updated Branches:
  refs/heads/master b8f990504 -> a18ec278e


refactoring


Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/70da1500
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/70da1500
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/70da1500

Branch: refs/heads/master
Commit: 70da15004ebf33a8590b89d9e916ba2d1e70da1f
Parents: a07c4d2
Author: daewon <da...@apache.org>
Authored: Mon Apr 23 18:02:51 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Mon Apr 23 18:02:51 2018 +0900

----------------------------------------------------------------------
 .../s2graph/core/index/ESIndexProvider.scala    | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/70da1500/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala b/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
index fbf76ef..27039e5 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
@@ -29,8 +29,9 @@ import org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait.Predicate
 import org.apache.s2graph.core.io.Conversions
 import org.apache.s2graph.core.mysqls._
 import org.apache.s2graph.core.types.VertexId
-import org.apache.s2graph.core.{EdgeId, S2EdgeLike, S2VertexLike, VertexQueryParam}
+import org.apache.s2graph.core._
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer
+import org.apache.tinkerpop.gremlin.structure.Property
 import play.api.libs.json.{Json, Reads}
 
 import scala.collection.JavaConverters._
@@ -67,10 +68,10 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
       props.foreach { case (dim, s2VertexProperty) =>
         // skip reserved fields.
         if (s2VertexProperty.columnMeta.seq > 0) {
-          s2VertexProperty.columnMeta.dataType match {
-            case "string" => fields += (dim -> s2VertexProperty.innerVal.value.toString)
-            case _ => fields += (dim -> s2VertexProperty.innerVal.value)
-          }
+          val innerVal = vertex.propertyValue(dim).get
+          val cType = s2VertexProperty.columnMeta.dataType
+
+          fields += (dim -> JSONParser.innerValToAny(innerVal, cType))
         }
       }
 
@@ -92,10 +93,10 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
 
       props.foreach { case (dim, s2Property) =>
         if (s2Property.labelMeta.seq > 0) {
-          s2Property.labelMeta.dataType match {
-            case "string" => fields += (dim -> s2Property.innerVal.value.toString)
-            case _ => fields += (dim -> s2Property.innerVal.value)
-          }
+          val innerVal = edge.propertyValue(dim).get.innerVal
+          val cType = s2Property.labelMeta.dataType
+
+          fields += (dim -> JSONParser.innerValToAny(innerVal, cType))
         }
       }
 
@@ -197,7 +198,7 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
     val field = vidField
     val empty = new util.ArrayList[VertexId]()
 
-    vertexQueryParam.searchString match  {
+    vertexQueryParam.searchString match {
       case Some(queryString) =>
         fetchInner[VertexId](queryString, GlobalIndex.VertexIndexName, field, Conversions.s2VertexIdReads)(v => VertexId.isValid(v).isDefined)
       case None => Future.successful(empty)


[2/3] incubator-s2graph git commit: add vertexQueryParam on esIndexProvider

Posted by st...@apache.org.
add vertexQueryParam on esIndexProvider


Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/37b4a45b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/37b4a45b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/37b4a45b

Branch: refs/heads/master
Commit: 37b4a45bb47db48d05cfbcdafb8f0867c1d33cca
Parents: 70da150
Author: daewon <da...@apache.org>
Authored: Mon Apr 23 18:42:13 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Mon Apr 23 18:42:28 2018 +0900

----------------------------------------------------------------------
 .../org/apache/s2graph/core/QueryParam.scala    |  4 +++
 .../s2graph/core/index/ESIndexProvider.scala    | 27 ++++++++++++++++----
 .../core/index/LuceneIndexProvider.scala        |  2 +-
 .../apache/s2graph/graphql/ScenarioTest.scala   | 25 ++++++++++++++++++
 4 files changed, 52 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/37b4a45b/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 faf04db..6d24c3f 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
@@ -293,6 +293,10 @@ object QueryParam {
   }
 }
 
+object VertexQueryParam {
+  def Empty: VertexQueryParam = VertexQueryParam(0, 1, None)
+}
+
 case class VertexQueryParam(offset: Int,
                             limit: Int,
                             searchString: Option[String],

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/37b4a45b/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala b/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
index 27039e5..e67d529 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/index/ESIndexProvider.scala
@@ -152,11 +152,11 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
     }
   }
 
-  private def fetchInner[T](queryString: String, indexKey: String, field: String, reads: Reads[T])(validate: (T => Boolean)): Future[util.List[T]] = {
+  private def fetchInner[T](queryString: String, offset: Int, limit: Int, indexKey: String, field: String, reads: Reads[T])(validate: (T => Boolean)): Future[util.List[T]] = {
     val ids = new java.util.HashSet[T]
 
     client.execute {
-      search(indexKey).query(queryString)
+      search(indexKey).query(queryString).from(offset).limit(limit)
     }.map { ret =>
       ret match {
         case Left(failure) =>
@@ -181,7 +181,13 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
     val field = eidField
 
     val queryString = buildQueryString(hasContainers)
-    fetchInner[EdgeId](queryString, GlobalIndex.EdgeIndexName, field, Conversions.s2EdgeIdReads)(e => EdgeId.isValid(e).isDefined)
+    fetchInner[EdgeId](
+      queryString,
+      0,
+      1000,
+      GlobalIndex.EdgeIndexName,
+      field,
+      Conversions.s2EdgeIdReads)(e => EdgeId.isValid(e).isDefined)
   }
 
   override def fetchVertexIds(hasContainers: util.List[HasContainer]): util.List[VertexId] =
@@ -191,7 +197,12 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
     val field = vidField
     val queryString = buildQueryString(hasContainers)
 
-    fetchInner[VertexId](queryString, GlobalIndex.VertexIndexName, field, Conversions.s2VertexIdReads)(v => VertexId.isValid(v).isDefined)
+    fetchInner[VertexId](queryString,
+      0,
+      1000,
+      GlobalIndex.VertexIndexName,
+      field,
+      Conversions.s2VertexIdReads)(v => VertexId.isValid(v).isDefined)
   }
 
   override def fetchVertexIdsAsyncRaw(vertexQueryParam: VertexQueryParam): Future[util.List[VertexId]] = {
@@ -200,7 +211,13 @@ class ESIndexProvider(config: Config)(implicit ec: ExecutionContext) extends Ind
 
     vertexQueryParam.searchString match {
       case Some(queryString) =>
-        fetchInner[VertexId](queryString, GlobalIndex.VertexIndexName, field, Conversions.s2VertexIdReads)(v => VertexId.isValid(v).isDefined)
+        fetchInner[VertexId](
+          queryString,
+          vertexQueryParam.offset,
+          vertexQueryParam.limit,
+          GlobalIndex.VertexIndexName,
+          field,
+          Conversions.s2VertexIdReads)(v => VertexId.isValid(v).isDefined)
       case None => Future.successful(empty)
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/37b4a45b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala
index 1b9d087..c417022 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala
@@ -183,7 +183,7 @@ class LuceneIndexProvider(config: Config) extends IndexProvider {
       val reader = DirectoryReader.open(getOrElseDirectory(indexKey))
       val searcher = new IndexSearcher(reader)
       val collector = TopScoreDocCollector.create(MAX_RESULTS)
-      val startIndex = offset * limit
+      val startIndex = offset
 
       searcher.search(q, collector)
 

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/37b4a45b/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala b/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
index 58e473d..940f11c 100644
--- a/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
+++ b/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
@@ -437,6 +437,31 @@ class ScenarioTest extends FunSpec with Matchers with BeforeAndAfterAll {
         actual shouldBe expected
       }
 
+      it("should fetch vertices: offset, limit") {
+        val query =
+          graphql"""
+
+          query FetchVertices {
+            kakao {
+              user(search: "gender: M OR gender: F or gender: T", offset: 1, limit: 2) {
+                id
+                age
+                gender
+                props {
+                  age
+                }
+              }
+            }
+          }
+        """
+
+        val actual = testGraph.queryAsJs(query)
+        val expected = 2
+
+        // The user order may vary depending on the indexProvider(es, lucene).
+        (actual \\ "gender").size shouldBe expected
+      }
+
       it("should fetch vertices using VertexIndex: 'gender in (F, M)') from kakao.user") {
         def query(search: String) = {
           QueryParser.parse(


[3/3] incubator-s2graph git commit: [S2GRAPH-209]: GlobalIndex supports field data types such as Numeric to enable Range Query.

Posted by st...@apache.org.
[S2GRAPH-209]: GlobalIndex supports field data types such as Numeric to enable Range Query.

JIRA:
    [S2GRAPH-209] https://issues.apache.org/jira/browse/S2GRAPH-209

Pull Request:
    Closes #160

Author
    daewon <da...@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/a18ec278
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/a18ec278
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/a18ec278

Branch: refs/heads/master
Commit: a18ec278eab148f24968322f4d35c01c86092f7e
Parents: b8f9905 37b4a45
Author: DO YUNG YOON <st...@apache.org>
Authored: Tue Apr 24 11:07:50 2018 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Tue Apr 24 11:09:59 2018 +0900

----------------------------------------------------------------------
 CHANGES                                         |  1 +
 .../org/apache/s2graph/core/QueryParam.scala    |  4 ++
 .../s2graph/core/index/ESIndexProvider.scala    | 48 ++++++++++++++------
 .../core/index/LuceneIndexProvider.scala        |  2 +-
 .../apache/s2graph/graphql/ScenarioTest.scala   | 25 ++++++++++
 5 files changed, 64 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a18ec278/CHANGES
----------------------------------------------------------------------
diff --cc CHANGES
index 2485fe8,1c1933f..9e79041
--- a/CHANGES
+++ b/CHANGES
@@@ -73,7 -72,6 +73,8 @@@ Release Notes - S2Graph - Version 0.2.
      * [S2GRAPH-200] - docker image could not include extra jars.
      * [S2GRAPH-204] - Avoid N + 1 queries in GraphQL
      * [S2GRAPH-207] - Provides a way to query data with the value of the Vertex property in a GraphQL query
 +    * [S2GRAPH-193] - Add README for S2Jobs sub-project
++    * [S2GRAPH-209] - GlobalIndex supports field data types such as Numeric to enable Range Query
  
  ** New Feature
      * [S2GRAPH-123] - Support different index on out/in direction.