You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by da...@apache.org on 2018/04/11 08:08:07 UTC

[1/5] incubator-s2graph git commit: add queryParam

Repository: incubator-s2graph
Updated Branches:
  refs/heads/master 3d941d654 -> 6d231e299


add queryParam


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

Branch: refs/heads/master
Commit: d6c72ab838970724751cf8ea53cf90f1a587bc4a
Parents: 3d941d6
Author: daewon <da...@apache.org>
Authored: Fri Apr 6 13:17:32 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Apr 6 13:17:32 2018 +0900

----------------------------------------------------------------------
 .../scala/org/apache/s2graph/core/S2Edge.scala  | 108 ++++++++++---------
 .../org/apache/s2graph/core/S2EdgeBuilder.scala |   4 -
 .../org/apache/s2graph/core/S2EdgeLike.scala    |   4 -
 .../tall/SnapshotEdgeDeserializable.scala       |   5 +-
 .../s2graph/graphql/bind/Unmarshaller.scala     |  24 ++++-
 .../graphql/repository/GraphRepository.scala    |   6 +-
 .../apache/s2graph/graphql/types/S2Type.scala   |  23 +++-
 7 files changed, 100 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/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 3323c4a..58b1ce1 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -19,29 +19,21 @@
 
 package org.apache.s2graph.core
 
-import java.util
-import java.util.function.{BiConsumer, Consumer}
 
-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.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}
 import play.api.libs.json.{JsNumber, JsObject, Json}
 
 import scala.collection.JavaConverters._
-import scala.collection.mutable.{Map => MutableMap}
-import scala.concurrent.Await
 import scala.util.hashing.MurmurHash3
 
 object SnapshotEdge {
   def apply(e: S2EdgeLike): SnapshotEdge = {
-    val (smaller, larger) = (e.srcForVertexInner, e.tgtForVertexInner)
+    val (smaller, larger) = (srcForVertexInner(e), tgtForVertexInner(e))
 
     val snapshotEdge = SnapshotEdge(e.innerGraph, smaller, larger, e.innerLabel,
       GraphUtil.directions("out"), e.getOp(), e.getVersion(), e.getPropsWithTs(),
@@ -72,6 +64,29 @@ object SnapshotEdge {
 
     copy
   }
+
+  private def srcForVertexInner(e: S2EdgeLike): S2VertexLike = {
+    val belongLabelIds = Seq(e.getLabelId())
+    if (e.getDir() == GraphUtil.directions("in")) {
+      val tgtColumn = S2Edge.getServiceColumn(e.tgtVertex, e.innerLabel.tgtColumn)
+      e.innerGraph.elementBuilder.newVertex(VertexId(tgtColumn, e.tgtVertex.innerId), e.tgtVertex.ts, e.tgtVertex.props, belongLabelIds = belongLabelIds)
+    } else {
+      val srcColumn = S2Edge.getServiceColumn(e.srcVertex, e.innerLabel.srcColumn)
+      e.innerGraph.elementBuilder.newVertex(VertexId(srcColumn, e.srcVertex.innerId), e.srcVertex.ts, e.srcVertex.props, belongLabelIds = belongLabelIds)
+    }
+  }
+
+  private def tgtForVertexInner(e: S2EdgeLike): S2VertexLike = {
+    val belongLabelIds = Seq(e.getLabelId())
+    if (e.getDir() == GraphUtil.directions("in")) {
+      val srcColumn = S2Edge.getServiceColumn(e.srcVertex, e.innerLabel.srcColumn)
+      e.innerGraph.elementBuilder.newVertex(VertexId(srcColumn, e.srcVertex.innerId), e.srcVertex.ts, e.srcVertex.props, belongLabelIds = belongLabelIds)
+    } else {
+      val tgtColumn = S2Edge.getServiceColumn(e.tgtVertex, e.innerLabel.tgtColumn)
+      e.innerGraph.elementBuilder.newVertex(VertexId(tgtColumn, e.tgtVertex.innerId), e.tgtVertex.ts, e.tgtVertex.props, belongLabelIds = belongLabelIds)
+    }
+  }
+
 }
 
 case class SnapshotEdge(graph: S2GraphLike,
@@ -90,9 +105,9 @@ case class SnapshotEdge(graph: S2GraphLike,
   lazy val operation = GraphUtil.fromOp(op)
   lazy val edge = toEdge
   lazy val labelWithDir = LabelWithDirection(label.id.get, dir)
-//  if (!propsWithTs.contains(LabelMeta.timestamp.name)) throw new Exception("Timestamp is required.")
+  //  if (!propsWithTs.contains(LabelMeta.timestamp.name)) throw new Exception("Timestamp is required.")
 
-//  val label = Label.findById(labelWithDir.labelId)
+  //  val label = Label.findById(labelWithDir.labelId)
   lazy val schemaVer = label.schemaVersion
   lazy val ts = propsWithTs.get(LabelMeta.timestamp.name).innerVal.toString().toLong
 
@@ -101,7 +116,11 @@ case class SnapshotEdge(graph: S2GraphLike,
   def allPropsDeleted = S2Edge.allPropsDeleted(propsWithTs)
 
   def toEdge: S2EdgeLike = {
-    S2Edge(graph, srcVertex, tgtVertex, label, dir, op,
+    val e = S2Edge(graph, srcVertex, tgtVertex, label, dir, op,
+      version, propsWithTs, pendingEdgeOpt = pendingEdgeOpt,
+      statusCode = statusCode, lockTs = lockTs, tsInnerValOpt = tsInnerValOpt)
+
+    S2Edge(graph, e.srcForVertex, e.tgtForVertex, label, dir, op,
       version, propsWithTs, pendingEdgeOpt = pendingEdgeOpt,
       statusCode = statusCode, lockTs = lockTs, tsInnerValOpt = tsInnerValOpt)
   }
@@ -137,6 +156,7 @@ case class SnapshotEdge(graph: S2GraphLike,
     propsWithTs.put(key, newProps)
     newProps
   }
+
   override def hashCode(): Int = {
     MurmurHash3.stringHash(srcVertex.innerId + "," + labelWithDir + "," + tgtVertex.innerId)
   }
@@ -187,8 +207,8 @@ case class IndexEdge(graph: S2GraphLike,
                      version: Long,
                      labelIndexSeq: Byte,
                      private val propsWithTs: Props,
-                     tsInnerValOpt: Option[InnerValLike] = None)  {
-//  if (!props.contains(LabelMeta.timeStampSeq)) throw new Exception("Timestamp is required.")
+                     tsInnerValOpt: Option[InnerValLike] = None) {
+  //  if (!props.contains(LabelMeta.timeStampSeq)) throw new Exception("Timestamp is required.")
   //  assert(props.contains(LabelMeta.timeStampSeq))
   lazy val direction = GraphUtil.fromDirection(dir)
   lazy val operation = GraphUtil.fromOp(op)
@@ -222,7 +242,7 @@ case class IndexEdge(graph: S2GraphLike,
           * now we double store target vertex.innerId/srcVertex.innerId for easy development. later fix this to only store id once
           */
         val v = meta match {
-          case LabelMeta.timestamp=> InnerVal.withLong(version, schemaVer)
+          case LabelMeta.timestamp => InnerVal.withLong(version, schemaVer)
           case LabelMeta.to => toEdge.tgtVertex.innerId
           case LabelMeta.from => toEdge.srcVertex.innerId
           case LabelMeta.fromHash => indexOption.map { option =>
@@ -240,7 +260,7 @@ case class IndexEdge(graph: S2GraphLike,
   lazy val ordersKeyMap = orders.map { case (meta, _) => meta.name }.toSet
   lazy val metas = for ((meta, v) <- propsWithTs.asScala if !ordersKeyMap.contains(meta)) yield v.labelMeta -> v.innerVal
 
-//  lazy val propsWithTs = props.map { case (k, v) => k -> InnerValLikeWithTs(v, version) }
+  //  lazy val propsWithTs = props.map { case (k, v) => k -> InnerValLikeWithTs(v, version) }
 
   //TODO:
   //  lazy val kvs = Graph.client.indexedEdgeSerializer(this).toKeyValues.toList
@@ -266,7 +286,7 @@ case class IndexEdge(graph: S2GraphLike,
   }
 
   def property(labelMeta: LabelMeta): InnerValLikeWithTs = {
-//    propsWithTs.get(labelMeta.name).map(_.innerValWithTs).getOrElse(label.metaPropsDefaultMapInner(labelMeta))
+    //    propsWithTs.get(labelMeta.name).map(_.innerValWithTs).getOrElse(label.metaPropsDefaultMapInner(labelMeta))
     if (propsWithTs.containsKey(labelMeta.name)) {
       propsWithTs.get(labelMeta.name).innerValWithTs
     } else {
@@ -292,6 +312,7 @@ case class IndexEdge(graph: S2GraphLike,
     propsWithTs.put(key, newProps)
     newProps
   }
+
   override def hashCode(): Int = {
     MurmurHash3.stringHash(srcVertex.innerId + "," + labelWithDir + "," + tgtVertex.innerId + "," + labelIndexSeq)
   }
@@ -331,7 +352,6 @@ case class S2Edge(override val innerGraph: S2GraphLike,
   //  assert(propsWithTs.contains(LabelMeta.timeStampSeq))
 
 
-
   override def serviceName = innerLabel.serviceName
 
   override def queueKey = Seq(ts.toString, tgtVertex.serviceName).mkString("|")
@@ -346,10 +366,10 @@ case class S2Edge(override val innerGraph: S2GraphLike,
   //  }
 
 
-//  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, propsWithTs).mkString("\t")
-//  }
+  //  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, propsWithTs).mkString("\t")
+  //  }
 
   override def hashCode(): Int = {
     id().hashCode()
@@ -374,8 +394,10 @@ case class S2Edge(override val innerGraph: S2GraphLike,
   }
 
 }
+
 object EdgeId {
   val EdgeIdDelimiter = ","
+
   def fromString(s: String): EdgeId = {
     val js = Json.parse(s)
     s2EdgeIdReads.reads(Json.parse(s)).get
@@ -404,7 +426,6 @@ case class EdgeId(srcVertexId: VertexId,
   }
 
 
-
 }
 
 object EdgeMutate {
@@ -468,7 +489,9 @@ object S2Edge {
   type UpdateFunc = (Option[S2EdgeLike], S2EdgeLike, MergeState)
 
   def EmptyProps = new java.util.HashMap[String, S2Property[_]]
+
   def EmptyState = Map.empty[LabelMeta, InnerValLikeWithTs]
+
   def sameProps(base: Props, other: Props): Boolean = {
     if (base.size != other.size) false
     else {
@@ -494,12 +517,15 @@ object S2Edge {
       ret
     }
   }
+
   def fillPropsWithTs(snapshotEdge: SnapshotEdge, state: State): Unit = {
     state.foreach { case (k, v) => snapshotEdge.property(k.name, v.innerVal.value, v.ts) }
   }
+
   def fillPropsWithTs(indexEdge: IndexEdge, state: State): Unit = {
     state.foreach { case (k, v) => indexEdge.property(k.name, v.innerVal.value, v.ts) }
   }
+
   def fillPropsWithTs(edge: S2EdgeLike, state: State): Unit = {
     state.foreach { case (k, v) => edge.propertyInner(k.name, v.innerVal.value, v.ts) }
   }
@@ -531,9 +557,9 @@ object S2Edge {
     else {
       val lastDeletedAt = props.get(LabelMeta.lastDeletedAt.name).ts
       props.remove(LabelMeta.lastDeletedAt.name)
-//      val propsWithoutLastDeletedAt = props
-//
-//      propsWithoutLastDeletedAt.forall { case (_, v) => v.ts <= lastDeletedAt }
+      //      val propsWithoutLastDeletedAt = props
+      //
+      //      propsWithoutLastDeletedAt.forall { case (_, v) => v.ts <= lastDeletedAt }
       var ret = true
       val iter = props.entrySet().iterator()
       while (iter.hasNext && ret) {
@@ -557,8 +583,8 @@ object S2Edge {
     //            logger.debug(s"oldEdge: ${invertedEdge.map(_.toStringRaw)}")
     //            logger.debug(s"requestEdge: ${requestEdge.toStringRaw}")
     val oldPropsWithTs =
-      if (invertedEdge.isEmpty) Map.empty[LabelMeta, InnerValLikeWithTs]
-      else propsToState(invertedEdge.get.getPropsWithTs())
+    if (invertedEdge.isEmpty) Map.empty[LabelMeta, InnerValLikeWithTs]
+    else propsToState(invertedEdge.get.getPropsWithTs())
 
     val funcs = requestEdges.map { edge =>
       if (edge.getOp() == GraphUtil.operations("insert")) {
@@ -607,7 +633,7 @@ object S2Edge {
 
       //      logger.debug(s"${edgeMutate.toLogString}\n${propsWithTs}")
       //      logger.error(s"$propsWithTs")
-      val newEdge =requestEdge.copyEdgeWithState(propsWithTs)
+      val newEdge = requestEdge.copyEdgeWithState(propsWithTs)
 
       (newEdge, edgeMutate)
     }
@@ -807,8 +833,6 @@ object S2Edge {
     (propsWithTs, true)
   }
 
-//  def fromString(s: String): Option[Edge] = Graph.toEdge(s)
-
   def getServiceColumn(vertex: S2VertexLike, defaultServiceColumn: ServiceColumn) =
     if (vertex.id.column == ServiceColumn.Default) defaultServiceColumn else vertex.id.column
 
@@ -836,28 +860,6 @@ object S2Edge {
     e.innerGraph.elementBuilder.newVertex(VertexId(column, e.tgtVertex.innerId), e.tgtVertex.ts, e.tgtVertex.props, belongLabelIds = belongLabelIds)
   }
 
-  def srcForVertexInner(e: S2EdgeLike): S2VertexLike = {
-    val belongLabelIds = Seq(e.getLabelId())
-    if (e.getDir() == GraphUtil.directions("in")) {
-      val tgtColumn = getServiceColumn(e.tgtVertex, e.innerLabel.tgtColumn)
-      e.innerGraph.elementBuilder.newVertex(VertexId(tgtColumn, e.tgtVertex.innerId), e.tgtVertex.ts, e.tgtVertex.props, belongLabelIds = belongLabelIds)
-    } else {
-      val srcColumn = getServiceColumn(e.srcVertex, e.innerLabel.srcColumn)
-      e.innerGraph.elementBuilder.newVertex(VertexId(srcColumn, e.srcVertex.innerId), e.srcVertex.ts, e.srcVertex.props, belongLabelIds = belongLabelIds)
-    }
-  }
-
-  def tgtForVertexInner(e: S2EdgeLike): S2VertexLike = {
-    val belongLabelIds = Seq(e.getLabelId())
-    if (e.getDir() == GraphUtil.directions("in")) {
-      val srcColumn = getServiceColumn(e.srcVertex, e.innerLabel.srcColumn)
-      e.innerGraph.elementBuilder.newVertex(VertexId(srcColumn, e.srcVertex.innerId), e.srcVertex.ts, e.srcVertex.props, belongLabelIds = belongLabelIds)
-    } else {
-      val tgtColumn = getServiceColumn(e.tgtVertex, e.innerLabel.tgtColumn)
-      e.innerGraph.elementBuilder.newVertex(VertexId(tgtColumn, e.tgtVertex.innerId), e.tgtVertex.ts, e.tgtVertex.props, belongLabelIds = belongLabelIds)
-    }
-  }
-
   def serializePropsWithTs(edge: S2EdgeLike): Array[Byte] =
     HBaseSerializable.propsToKeyValuesWithTs(edge.getPropsWithTs().asScala.map(kv => kv._2.labelMeta.seq -> kv._2.innerValWithTs).toSeq)
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeBuilder.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeBuilder.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeBuilder.scala
index 5e8d094..85321d3 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeBuilder.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeBuilder.scala
@@ -31,10 +31,6 @@ class S2EdgeBuilder(edge: S2EdgeLike) {
 
   def tgtForVertex = S2Edge.tgtForVertex(edge)
 
-  def srcForVertexInner = S2Edge.srcForVertexInner(edge)
-
-  def tgtForVertexInner = S2Edge.tgtForVertexInner(edge)
-
   def duplicateEdge = reverseSrcTgtEdge.reverseDirEdge
 
   def reverseDirEdge = copyEdge(dir = GraphUtil.toggleDir(edge.getDir))

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeLike.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeLike.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeLike.scala
index 3740f28..f2ea4ad 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeLike.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2EdgeLike.scala
@@ -123,10 +123,6 @@ trait S2EdgeLike extends Edge with GraphElement {
 
   def tgtForVertex = builder.tgtForVertex
 
-  def srcForVertexInner = builder.srcForVertexInner
-
-  def tgtForVertexInner = builder.tgtForVertexInner
-
   def duplicateEdge = builder.duplicateEdge
 
   def reverseDirEdge = builder.reverseDirEdge

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/snapshotedge/tall/SnapshotEdgeDeserializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/snapshotedge/tall/SnapshotEdgeDeserializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/snapshotedge/tall/SnapshotEdgeDeserializable.scala
index b7f5ba1..f5c10a7 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/snapshotedge/tall/SnapshotEdgeDeserializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/snapshotedge/tall/SnapshotEdgeDeserializable.scala
@@ -26,6 +26,7 @@ import org.apache.s2graph.core.storage.CanSKeyValue
 import org.apache.s2graph.core.types._
 import org.apache.s2graph.core._
 import org.apache.s2graph.core.storage.serde.Deserializable
+import org.apache.s2graph.core.utils.logger
 
 class SnapshotEdgeDeserializable(graph: S2GraphLike) extends Deserializable[SnapshotEdge] {
   val builder = graph.elementBuilder
@@ -108,7 +109,9 @@ class SnapshotEdgeDeserializable(graph: S2GraphLike) extends Deserializable[Snap
         Option(snapshotEdge)
       }
     } catch {
-      case e: Exception => None
+      case e: Exception =>
+        logger.error("#" * 100, e)
+        None
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
index 4308e2e..94c1e01 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
@@ -20,8 +20,8 @@
 package org.apache.s2graph.graphql.bind
 
 import org.apache.s2graph.core.Management.JsonModel._
-import org.apache.s2graph.core.mysqls.ServiceColumn
-import org.apache.s2graph.core.{S2EdgeLike, S2VertexLike}
+import org.apache.s2graph.core.mysqls.{Label, ServiceColumn}
+import org.apache.s2graph.core.{QueryParam, S2EdgeLike, S2VertexLike}
 import org.apache.s2graph.graphql.repository.GraphRepository
 import org.apache.s2graph.graphql.types.S2Type._
 import sangria.marshalling._
@@ -125,11 +125,25 @@ object Unmarshaller {
     }
   }
 
-  def labelField(c: Context[GraphRepository, Any]): (S2VertexLike, String) = {
+  def labelField(label: Label, c: Context[GraphRepository, Any]): (S2VertexLike, QueryParam) = {
     val vertex = c.value.asInstanceOf[S2VertexLike]
-    val dir = c.arg[String]("direction")
 
-    (vertex, dir)
+    val dir = c.arg[String]("direction")
+    val offset = c.arg[Int]("offset") + 1 // +1 for skip degree edge: currently not support
+    val limit = c.arg[Int]("limit")
+    val whereClauseOpt = c.argOpt[String]("filter")
+    val where = c.ctx.parser.extractWhere(label, whereClauseOpt)
+
+    val qp = QueryParam(
+      labelName = label.label,
+      direction = dir,
+      offset = offset,
+      limit = limit,
+      whereRawOpt = whereClauseOpt,
+      where = where
+    )
+
+    (vertex, qp)
   }
 
   def serviceColumnFieldOnService(column: ServiceColumn, c: Context[GraphRepository, Any]): (Seq[S2VertexLike], Boolean) = {

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/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 626c0e6..078aefd 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
@@ -89,10 +89,8 @@ class GraphRepository(val graph: S2GraphLike) {
     graph.getVertices(vertex)
   }
 
-  def getEdges(vertex: S2VertexLike, label: Label, _dir: String): Future[Seq[S2EdgeLike]] = {
-    val dir = GraphUtil.directions(_dir)
-    val labelWithDir = LabelWithDirection(label.id.get, dir)
-    val step = Step(Seq(QueryParam(labelWithDir).copy(limit = 100, includeDegree = false)))
+  def getEdges(vertex: S2VertexLike, queryParam: QueryParam): Future[Seq[S2EdgeLike]] = {
+    val step = Step(Seq(queryParam))
     val q = Query(Seq(vertex), steps = Vector(step))
 
     graph.getEdges(q).map(_.edgeWithScores.map(_.edge))

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6c72ab8/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
index ca98df2..0fff21b 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
@@ -202,14 +202,31 @@ object S2Type {
       case "both" => Argument("direction", OptionInputType(BothDirectionType), "desc here", defaultValue = "out") :: Nil
     }
 
+    val idxNames = label.indices.map { idx =>
+      EnumValue(idx.name, value = idx.name)
+    }
+
+    val indexEnumType = EnumType(
+      s"Label_index_${label.label}",
+      description = Option("desc here"),
+      values = idxNames
+    )
+
+    val paramArgs = List(
+      Argument("offset", OptionInputType(IntType), "desc here", defaultValue = 0),
+      Argument("limit", OptionInputType(IntType), "desc here", defaultValue = 100),
+      Argument("index", OptionInputType(indexEnumType), "desc here"),
+      Argument("filter", OptionInputType(StringType), "desc here")
+    )
+
     lazy val edgeTypeField: Field[GraphRepository, Any] = Field(
       s"${label.label}",
       ListType(EdgeType),
-      arguments = dirArgs,
+      arguments = dirArgs ++ paramArgs,
       description = Some("fetch edges"),
       resolve = { c =>
-        val (vertex, dir) = Unmarshaller.labelField(c)
-        c.ctx.getEdges(vertex, label, dir)
+        val (vertex, queryParam) = Unmarshaller.labelField(label, c)
+        c.ctx.getEdges(vertex, queryParam)
       }
     )
 


[4/5] incubator-s2graph git commit: remove wraning for intelliJ

Posted by da...@apache.org.
remove wraning for intelliJ


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

Branch: refs/heads/master
Commit: 4c18c38ae072b4f2a2853fc62814779ccf818647
Parents: a3e1e39
Author: daewon <da...@apache.org>
Authored: Fri Apr 6 14:26:09 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Apr 6 14:26:09 2018 +0900

----------------------------------------------------------------------
 .../src/main/scala/org/apache/s2graph/graphql/HttpServer.scala   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/4c18c38a/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
index 26bce34..685e87b 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
@@ -22,9 +22,11 @@ package org.apache.s2graph.graphql
 import akka.actor.ActorSystem
 import akka.http.scaladsl.Http
 import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
 import akka.http.scaladsl.server.Directives._
 import akka.http.scaladsl.server._
 import akka.stream.ActorMaterializer
+import akka.stream.scaladsl.Flow
 import org.slf4j.LoggerFactory
 
 import scala.concurrent.Await
@@ -40,7 +42,7 @@ object Server extends App {
 
   import scala.concurrent.duration._
 
-  val route = (post & path("graphql")) {
+  val route: Flow[HttpRequest, HttpResponse, Any] = (post & path("graphql")) {
     entity(as[spray.json.JsValue])(GraphQLServer.endpoint)
   } ~ {
     getFromResource("assets/graphiql.html")


[3/5] incubator-s2graph git commit: move module

Posted by da...@apache.org.
move module


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

Branch: refs/heads/master
Commit: a3e1e391f3e2554fd7b7bff0befed5ee19cb9199
Parents: 1fe5768
Author: daewon <da...@apache.org>
Authored: Fri Apr 6 14:02:49 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Apr 6 14:05:20 2018 +0900

----------------------------------------------------------------------
 .../s2graph/graphql/bind/Unmarshaller.scala     | 48 ------------
 .../s2graph/graphql/types/FieldResolver.scala   | 77 ++++++++++++++++++++
 .../apache/s2graph/graphql/types/S2Type.scala   | 66 +++++++----------
 3 files changed, 103 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a3e1e391/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
index 94c1e01..807fe48 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/bind/Unmarshaller.scala
@@ -124,52 +124,4 @@ object Unmarshaller {
       partialServiceColumns.toVector
     }
   }
-
-  def labelField(label: Label, c: Context[GraphRepository, Any]): (S2VertexLike, QueryParam) = {
-    val vertex = c.value.asInstanceOf[S2VertexLike]
-
-    val dir = c.arg[String]("direction")
-    val offset = c.arg[Int]("offset") + 1 // +1 for skip degree edge: currently not support
-    val limit = c.arg[Int]("limit")
-    val whereClauseOpt = c.argOpt[String]("filter")
-    val where = c.ctx.parser.extractWhere(label, whereClauseOpt)
-
-    val qp = QueryParam(
-      labelName = label.label,
-      direction = dir,
-      offset = offset,
-      limit = limit,
-      whereRawOpt = whereClauseOpt,
-      where = where
-    )
-
-    (vertex, qp)
-  }
-
-  def serviceColumnFieldOnService(column: ServiceColumn, c: Context[GraphRepository, Any]): (Seq[S2VertexLike], Boolean) = {
-    val ids = c.argOpt[Any]("id").toSeq ++ c.argOpt[List[Any]]("ids").toList.flatten
-    val vertices = ids.map(vid => c.ctx.toS2VertexLike(vid, column))
-
-    val columnFields = column.metasInvMap.keySet
-    val selectedFields = AstHelper.selectedFields(c.astFields)
-
-    val canSkipFetch = selectedFields.forall(f => f == "id" || !columnFields(f))
-
-    (vertices, canSkipFetch)
-  }
-
-  def serviceColumnFieldOnLabel(c: Context[GraphRepository, Any]): (S2VertexLike, Boolean) = {
-    val edge = c.value.asInstanceOf[S2EdgeLike]
-
-    val vertex = edge.tgtForVertex
-    val column = vertex.serviceColumn
-
-    val selectedFields = AstHelper.selectedFields(c.astFields)
-    val columnFields = column.metasInvMap.keySet
-
-    val canSkipFetch = selectedFields.forall(f => f == "id" || !columnFields(f))
-
-    (vertex, canSkipFetch)
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a3e1e391/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/FieldResolver.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/FieldResolver.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/FieldResolver.scala
new file mode 100644
index 0000000..4f092dd
--- /dev/null
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/FieldResolver.scala
@@ -0,0 +1,77 @@
+package org.apache.s2graph.graphql.types
+
+import org.apache.s2graph.core._
+import org.apache.s2graph.core.mysqls._
+import org.apache.s2graph.graphql.bind.AstHelper
+import org.apache.s2graph.graphql.repository.GraphRepository
+import sangria.schema._
+
+object FieldResolver {
+
+  def graphElement[A](name: String, cType: String, c: Context[GraphRepository, Any]): A = {
+    c.value match {
+      case v: S2VertexLike => name match {
+        case "timestamp" => v.ts.asInstanceOf[A]
+        case _ =>
+          val innerVal = v.propertyValue(name).get
+          JSONParser.innerValToAny(innerVal, cType).asInstanceOf[A]
+      }
+      case e: S2EdgeLike => name match {
+        case "timestamp" => e.ts.asInstanceOf[A]
+        case "direction" => e.getDirection().asInstanceOf[A]
+        case _ =>
+          val innerVal = e.propertyValue(name).get.innerVal
+          JSONParser.innerValToAny(innerVal, cType).asInstanceOf[A]
+      }
+      case _ =>
+        throw new RuntimeException(s"Error on resolving field: ${name}, ${cType}, ${c.value.getClass}")
+    }
+  }
+
+  def label(label: Label, c: Context[GraphRepository, Any]): (S2VertexLike, QueryParam) = {
+    val vertex = c.value.asInstanceOf[S2VertexLike]
+
+    val dir = c.arg[String]("direction")
+    val offset = c.arg[Int]("offset") + 1 // +1 for skip degree edge: currently not support
+    val limit = c.arg[Int]("limit")
+    val whereClauseOpt = c.argOpt[String]("filter")
+    val where = c.ctx.parser.extractWhere(label, whereClauseOpt)
+
+    val qp = QueryParam(
+      labelName = label.label,
+      direction = dir,
+      offset = offset,
+      limit = limit,
+      whereRawOpt = whereClauseOpt,
+      where = where
+    )
+
+    (vertex, qp)
+  }
+
+  def serviceColumnOnService(column: ServiceColumn, c: Context[GraphRepository, Any]): (Seq[S2VertexLike], Boolean) = {
+    val ids = c.argOpt[Any]("id").toSeq ++ c.argOpt[List[Any]]("ids").toList.flatten
+    val vertices = ids.map(vid => c.ctx.toS2VertexLike(vid, column))
+
+    val columnFields = column.metasInvMap.keySet
+    val selectedFields = AstHelper.selectedFields(c.astFields)
+
+    val canSkipFetch = selectedFields.forall(f => f == "id" || !columnFields(f))
+
+    (vertices, canSkipFetch)
+  }
+
+  def serviceColumnOnLabel(c: Context[GraphRepository, Any]): (S2VertexLike, Boolean) = {
+    val edge = c.value.asInstanceOf[S2EdgeLike]
+
+    val vertex = edge.tgtForVertex
+    val column = vertex.serviceColumn
+
+    val selectedFields = AstHelper.selectedFields(c.astFields)
+    val columnFields = column.metasInvMap.keySet
+
+    val canSkipFetch = selectedFields.forall(f => f == "id" || !columnFields(f))
+
+    (vertex, canSkipFetch)
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/a3e1e391/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
index 7a46bd1..d458ba4 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
@@ -23,9 +23,11 @@ import scala.concurrent._
 import org.apache.s2graph.core.Management.JsonModel.{Index, Prop}
 import org.apache.s2graph.core._
 import org.apache.s2graph.core.mysqls._
+import org.apache.s2graph.graphql
 import org.apache.s2graph.graphql.repository.GraphRepository
 import sangria.schema._
-import org.apache.s2graph.graphql.bind.{AstHelper, Unmarshaller}
+import org.apache.s2graph.graphql.bind.AstHelper
+import org.apache.s2graph.graphql.repository
 import org.apache.s2graph.graphql.types.StaticTypes._
 
 import scala.language.existentials
@@ -48,37 +50,23 @@ object S2Type {
                                 columnName: String,
                                 props: Seq[Prop] = Nil)
 
-  def makeField[A](name: String, cType: String, tpe: ScalarType[A]): Field[GraphRepository, Any] =
-    Field(name,
-      OptionType(tpe),
-      description = Option("desc here"),
-      resolve = c => c.value match {
-        case v: S2VertexLike => name match {
-          case "timestamp" => v.ts.asInstanceOf[A]
-          case _ =>
-            val innerVal = v.propertyValue(name).get
-            JSONParser.innerValToAny(innerVal, cType).asInstanceOf[A]
-        }
-        case e: S2EdgeLike => name match {
-          case "timestamp" => e.ts.asInstanceOf[A]
-          case "direction" => e.getDirection().asInstanceOf[A]
-          case _ =>
-            val innerVal = e.propertyValue(name).get.innerVal
-            JSONParser.innerValToAny(innerVal, cType).asInstanceOf[A]
-        }
-        case _ =>
-          throw new RuntimeException(s"Error on resolving field: ${name}, ${cType}, ${c.value.getClass}")
-      }
-    )
+  def makeGraphElementField(cName: String, cType: String): Field[GraphRepository, Any] = {
+    def makeField[A](name: String, cType: String, tpe: ScalarType[A]): Field[GraphRepository, Any] =
+      Field(name,
+        OptionType(tpe),
+        description = Option("desc here"),
+        resolve = c => FieldResolver.graphElement[A](name, cType, c)
+      )
 
-  def makePropField(cName: String, cType: String): Field[GraphRepository, Any] = cType match {
-    case "boolean" | "bool" => makeField[Boolean](cName, cType, BooleanType)
-    case "string" | "str" | "s" => makeField[String](cName, cType, StringType)
-    case "int" | "integer" | "i" | "int32" | "integer32" => makeField[Int](cName, cType, IntType)
-    case "long" | "l" | "int64" | "integer64" => makeField[Long](cName, cType, LongType)
-    case "double" | "d" => makeField[Double](cName, cType, FloatType)
-    case "float64" | "float" | "f" | "float32" => makeField[Double](cName, "double", FloatType)
-    case _ => throw new RuntimeException(s"Cannot support data type: ${cType}")
+    cType match {
+      case "boolean" | "bool" => makeField[Boolean](cName, cType, BooleanType)
+      case "string" | "str" | "s" => makeField[String](cName, cType, StringType)
+      case "int" | "integer" | "i" | "int32" | "integer32" => makeField[Int](cName, cType, IntType)
+      case "long" | "l" | "int64" | "integer64" => makeField[Long](cName, cType, LongType)
+      case "double" | "d" => makeField[Double](cName, cType, FloatType)
+      case "float64" | "float" | "f" | "float32" => makeField[Double](cName, "double", FloatType)
+      case _ => throw new RuntimeException(s"Cannot support data type: ${cType}")
+    }
   }
 
   def makeInputFieldsOnService(service: Service): Seq[InputField[Any]] = {
@@ -125,7 +113,7 @@ object S2Type {
     val inLabels = diffLabel.filter(l => column == l.tgtColumn).distinct.toList
     val inOutLabels = sameLabel.filter(l => l.srcColumn == column && l.tgtColumn == column)
 
-    lazy val columnFields = (reservedFields ++ columnMetasKv).map { case (k, v) => makePropField(k, v) }
+    lazy val columnFields = (reservedFields ++ columnMetasKv).map { case (k, v) => makeGraphElementField(k, v) }
 
     lazy val outLabelFields: List[Field[GraphRepository, Any]] = outLabels.map(l => makeLabelField("out", l, allLabels))
     lazy val inLabelFields: List[Field[GraphRepository, Any]] = inLabels.map(l => makeLabelField("in", l, allLabels))
@@ -138,14 +126,14 @@ object S2Type {
   }
 
   def makeServiceField(service: Service, allLabels: List[Label])(implicit repo: GraphRepository): List[Field[GraphRepository, Any]] = {
-    lazy val columnsOnService = service.serviceColumns(false).toList.map { column =>
+    val columnsOnService = service.serviceColumns(false).toList.map { column =>
       lazy val serviceColumnFields = makeServiceColumnFields(column, allLabels)
       lazy val ColumnType = ObjectType(
         s"ServiceColumn_${service.serviceName}_${column.columnName}",
         () => fields[GraphRepository, Any](serviceColumnFields: _*)
       )
 
-      val v = Field(column.columnName,
+      Field(column.columnName,
         ListType(ColumnType),
         arguments = List(
           Argument("id", OptionInputType(toScalarType(column.columnType))),
@@ -154,14 +142,12 @@ object S2Type {
         description = Option("desc here"),
         resolve = c => {
           implicit val ec = c.ctx.ec
-          val (vertices, canSkipFetchVertex) = Unmarshaller.serviceColumnFieldOnService(column, c)
+          val (vertices, canSkipFetchVertex) = graphql.types.FieldResolver.serviceColumnOnService(column, c)
 
           if (canSkipFetchVertex) Future.successful(vertices)
           else c.ctx.getVertices(vertices)
         }
       ): Field[GraphRepository, Any]
-
-      v
     }
 
     columnsOnService
@@ -174,7 +160,7 @@ object S2Type {
     val column = if (dir == "out") label.tgtColumn else label.srcColumn
 
     lazy val labelFields: List[Field[GraphRepository, Any]] =
-      (labelReserved ++ labelProps).map { case (k, v) => makePropField(k, v) }
+      (labelReserved ++ labelProps).map { case (k, v) => makeGraphElementField(k, v) }
 
     lazy val labelPropField = wrapField(s"Label_${label.label}_props", "props", labelFields)
 
@@ -184,7 +170,7 @@ object S2Type {
 
     lazy val serviceColumnField: Field[GraphRepository, Any] = Field(column.columnName, labelColumnType, resolve = c => {
       implicit val ec = c.ctx.ec
-      val (vertex, canSkipFetchVertex) = Unmarshaller.serviceColumnFieldOnLabel(c)
+      val (vertex, canSkipFetchVertex) = graphql.types.FieldResolver.serviceColumnOnLabel(c)
 
       if (canSkipFetchVertex) Future.successful(vertex)
       else c.ctx.getVertices(Seq(vertex)).map(_.head) // fill props
@@ -225,7 +211,7 @@ object S2Type {
       arguments = dirArgs ++ paramArgs,
       description = Some("fetch edges"),
       resolve = { c =>
-        val (vertex, queryParam) = Unmarshaller.labelField(label, c)
+        val (vertex, queryParam) = graphql.types.FieldResolver.label(label, c)
         c.ctx.getEdges(vertex, queryParam)
       }
     )


[5/5] incubator-s2graph git commit: [S2GRAPH-196] Apply Query Parameter to Label Fetch in S2GraphQL

Posted by da...@apache.org.
[S2GRAPH-196] Apply Query Parameter to Label Fetch in S2GraphQL

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

Pull Request:
  Closes #155

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/6d231e29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/6d231e29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/6d231e29

Branch: refs/heads/master
Commit: 6d231e2990076fa8557af0b617f6a3dc68aa264c
Parents: 4c18c38
Author: daewon <da...@apache.org>
Authored: Wed Apr 11 17:02:20 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Wed Apr 11 17:02:20 2018 +0900

----------------------------------------------------------------------
 CHANGES | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/6d231e29/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2a6e465..5213087 100644
--- a/CHANGES
+++ b/CHANGES
@@ -52,6 +52,7 @@ Release Notes - S2Graph - Version 0.2.0
     * [S2GRAPH-191] - Providing request / response logging to GraphQL server and removing println
     * [S2GRAPH-192] - could not find service column when creating the label
     * [S2GRAPH-195] - could not create indices using S2GraphQL
+    * [S2GRAPH-196] - Apply Query Parameter to Label Fetch in S2GraphQL
 
 ** Improvement
     * [S2GRAPH-72] - Support Apache TinkerPop and Gremlin


[2/5] incubator-s2graph git commit: fix broken test case

Posted by da...@apache.org.
fix broken test case


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

Branch: refs/heads/master
Commit: 1fe57680ca957d1563b41b89ea072d85338facad
Parents: d6c72ab
Author: daewon <da...@apache.org>
Authored: Fri Apr 6 13:45:08 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Apr 6 13:45:08 2018 +0900

----------------------------------------------------------------------
 .../src/main/scala/org/apache/s2graph/graphql/HttpServer.scala     | 2 +-
 .../src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala   | 2 +-
 .../src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala     | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1fe57680/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
index 7d3771a..26bce34 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/HttpServer.scala
@@ -40,7 +40,7 @@ object Server extends App {
 
   import scala.concurrent.duration._
 
-  val route: Route = (post & path("graphql")) {
+  val route = (post & path("graphql")) {
     entity(as[spray.json.JsValue])(GraphQLServer.endpoint)
   } ~ {
     getFromResource("assets/graphiql.html")

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1fe57680/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
index 0fff21b..7a46bd1 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
@@ -207,7 +207,7 @@ object S2Type {
     }
 
     val indexEnumType = EnumType(
-      s"Label_index_${label.label}",
+      s"Label_Index_${label.label}",
       description = Option("desc here"),
       values = idxNames
     )

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/1fe57680/s2graphql/src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala b/s2graphql/src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala
index 8b2b3fe..0a309c7 100644
--- a/s2graphql/src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala
+++ b/s2graphql/src/test/scala/org/apache/s2graph/graphql/SchemaTest.scala
@@ -106,6 +106,7 @@ class SchemaTest extends FunSuite with Matchers with BeforeAndAfterAll {
 
             Map("name" -> "Service_kakao"),
 
+            Map("name" -> "Label_Index_friends"),
             Map("name" -> "Label_friends_user"),
             Map("name" -> "Label_friends_user_both"),