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/31 01:05:29 UTC

[15/25] incubator-s2graph git commit: add hiddenIndexFields on buildGlobalIndex.

add hiddenIndexFields on buildGlobalIndex.


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

Branch: refs/heads/master
Commit: 124003d9b68d2ec2cd895ad99e5bb6cb6822eead
Parents: 4e085e4
Author: DO YUNG YOON <st...@apache.org>
Authored: Fri Jul 28 19:20:38 2017 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Fri Jul 28 19:20:38 2017 +0900

----------------------------------------------------------------------
 .../scala/org/apache/s2graph/core/Management.scala   |  9 +++++----
 .../apache/s2graph/core/index/IndexProvider.scala    |  2 ++
 .../s2graph/core/index/IndexProviderTest.scala       | 15 +++++++++++++--
 .../s2graph/core/tinkerpop/S2GraphProvider.scala     |  1 +
 .../core/tinkerpop/structure/S2GraphTest.scala       |  5 +++--
 5 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/124003d9/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 6713baf..6e2667f 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/Management.scala
@@ -19,12 +19,13 @@
 
 package org.apache.s2graph.core
 
-import org.apache.s2graph.core.GraphExceptions.{LabelNameTooLongException, InvalidHTableException, LabelAlreadyExistException, LabelNotExistException}
+import org.apache.s2graph.core.GraphExceptions.{InvalidHTableException, LabelAlreadyExistException, LabelNameTooLongException, LabelNotExistException}
 import org.apache.s2graph.core.Management.JsonModel.{Index, Prop}
 import org.apache.s2graph.core.mysqls._
 import org.apache.s2graph.core.types.HBaseType._
 import org.apache.s2graph.core.types._
 import org.apache.s2graph.core.JSONParser._
+import org.apache.s2graph.core.index.IndexProvider
 import org.apache.s2graph.core.utils.logger
 import play.api.libs.json.Reads._
 import play.api.libs.json._
@@ -349,10 +350,10 @@ class Management(graph: S2Graph) {
   }
 
   def buildGlobalIndex(name: String, propNames: Seq[String]): GlobalIndex = {
-    GlobalIndex.findBy(name) match {
+    GlobalIndex.findBy(name, false) match {
       case None =>
-        val idxId = GlobalIndex.insert(name, propNames)
-        GlobalIndex.findBy(name).get
+        val idxId = GlobalIndex.insert(name, propNames ++ IndexProvider.hiddenIndexFields)
+        GlobalIndex.findBy(name, false).get
       case Some(oldIndex) => oldIndex
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/124003d9/s2core/src/main/scala/org/apache/s2graph/core/index/IndexProvider.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/index/IndexProvider.scala b/s2core/src/main/scala/org/apache/s2graph/core/index/IndexProvider.scala
index 360ea65..7f2602f 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/index/IndexProvider.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/index/IndexProvider.scala
@@ -47,6 +47,8 @@ object IndexProvider {
   val labelField = "_label_"
   val serviceField = "_service_"
   val serviceColumnField = "_serviceColumn_"
+
+  val hiddenIndexFields = Set(vidField, eidField, labelField, serviceField, serviceColumnField)
   val hitsPerPage = 100000
 
   def apply(config: Config): IndexProvider = {

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/124003d9/s2core/src/test/scala/org/apache/s2graph/core/index/IndexProviderTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/index/IndexProviderTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/index/IndexProviderTest.scala
index d098458..480f7a2 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/index/IndexProviderTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/index/IndexProviderTest.scala
@@ -20,11 +20,14 @@
 package org.apache.s2graph.core.index
 
 import org.apache.s2graph.core.Integrate.IntegrateCommon
-import org.apache.s2graph.core.S2Vertex
+import org.apache.s2graph.core.{Query, QueryParam, S2Vertex, Step}
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer
-import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.{Order, P}
 import org.apache.s2graph.core.mysqls._
 import org.apache.s2graph.core.types.{InnerVal, InnerValLikeWithTs}
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper
+import org.apache.tinkerpop.gremlin.structure.T
+
 import scala.collection.JavaConversions._
 
 class IndexProviderTest extends IntegrateCommon {
@@ -218,4 +221,12 @@ class IndexProviderTest extends IntegrateCommon {
     println(s"[[QueryString]: ${queryString}")
   }
 
+  test("has label") {
+    //    has("song", "name", "OH BOY").out("followedBy").out("followedBy").order.by("performances").by("songType", Order.decr)
+    val hasContainers = Seq(new HasContainer(T.label.getAccessor, P.eq("song")),
+                            new HasContainer("name", P.eq("OH BOY")))
+    val queryString = IndexProvider.buildQueryString(hasContainers)
+    println(s"[[QueryString]: ${queryString}")
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/124003d9/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 00768b3..3157e18 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
@@ -27,6 +27,7 @@ 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.index.IndexProvider
 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

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/124003d9/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 60b48d2..badfbfe 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
@@ -41,7 +41,7 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
   initTests()
 
   val g = new S2Graph(config)
-  lazy val gIndex = management.buildGlobalIndex("S2GraphTest", Seq("weight"))
+  lazy val gIndex = management.buildGlobalIndex("S2GraphTest2", Seq("weight"))
   def printEdges(edges: Seq[Edge]): Unit = {
     edges.foreach { edge =>
       logger.debug(s"[FetchedEdge]: $edge")
@@ -466,7 +466,8 @@ class S2GraphTest extends FunSuite with Matchers with TestCommonWithModels {
 
     val e12 = v6.addEdge("created", v3, "weight", Double.box(0.2))
 
-    val ls = graph.traversal().E().has("weight", P.eq(Double.box(0.5)))
+    val ls = graph.traversal().E().has("knows", "weight", P.eq(Double.box(0.5)))
+
 //    return graph.traversal.V().hasLabel("person").has("age", P.not(P.lte(10).and(P.not(P.between(11, 20)))).and(P.lt(29).or(P.eq(35)))).values("name")
     val l = ls.toList
     println(s"[Size]: ${l.size}")