test more on IndexProviderTest.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/71d42dc3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/71d42dc3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/71d42dc3 Branch: refs/heads/master Commit: 71d42dc3aa3001b9d511f42b34e35dedd11fbf3f Parents: 1cd00df Author: DO YUNG YOON <[email protected]> Authored: Thu Jul 13 10:13:15 2017 +0900 Committer: DO YUNG YOON <[email protected]> Committed: Thu Jul 13 10:17:36 2017 +0900 ---------------------------------------------------------------------- .../s2graph/core/index/IndexProviderTest.scala | 66 ++++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/71d42dc3/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 f56ac71..b4e5ed2 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 @@ -4,10 +4,11 @@ import org.apache.s2graph.core.Integrate.IntegrateCommon import org.apache.s2graph.core.{Management, S2Vertex} import org.apache.s2graph.core.mysqls._ import org.apache.s2graph.core.types.{InnerVal, InnerValLikeWithTs} - +import scala.collection.JavaConversions._ class IndexProviderTest extends IntegrateCommon { val indexProvider = IndexProvider(config) + val numOfTry = 1 test("test vertex write/query") { import TestUtil._ @@ -28,22 +29,23 @@ class IndexProviderTest extends IntegrateCommon { val vertex = graph.newVertex(vertexId) S2Vertex.fillPropsWithTs(vertex, propsWithTs) - val vertices = Seq(vertex) ++ (0 until 10).map{ ith => - val v = graph.newVertex(vertexId) - S2Vertex.fillPropsWithTs(v, otherPropsWithTs) - v - } + val otherVertex = graph.newVertex(vertexId) + S2Vertex.fillPropsWithTs(otherVertex, otherPropsWithTs) + + val numOfOthers = 10 + val vertices = Seq(vertex) ++ (0 until numOfOthers).map(_ => otherVertex) println(s"[# of vertices]: ${vertices.size}") vertices.foreach(v => println(s"[Vertex]: $v")) indexProvider.mutateVertices(vertices) - import scala.collection.JavaConversions._ - val ids = indexProvider.fetchVertexIds("_timestamp: 1") - ids.head shouldBe vertex.id + (0 until numOfTry).foreach { ith => + var ids = indexProvider.fetchVertexIds("_timestamp: 1") + ids.head shouldBe vertex.id - ids.foreach { id => - println(s"[Id]: $id") + ids.foreach { id => + println(s"[Id]: $id") + } } } test("test edge write/query ") { @@ -64,21 +66,47 @@ class IndexProviderTest extends IntegrateCommon { testLabel.metaPropsInvMap("time") -> InnerValLikeWithTs.withLong(20L, 1L, "v4") ) val edge = graph.newEdge(vertex, vertex, testLabel, 0, propsWithTs = propsWithTs) - val edges = Seq(edge) ++ (0 until 10).map{ ith => - graph.newEdge(otherVertex, otherVertex, testLabel, 0, propsWithTs = otherPropsWithTs) - } + val otherEdge = graph.newEdge(otherVertex, otherVertex, testLabel, 0, propsWithTs = otherPropsWithTs) + val numOfOthers = 10 + val edges = Seq(edge) ++ (0 until numOfOthers).map(_ => otherEdge) println(s"[# of edges]: ${edges.size}") edges.foreach(e => println(s"[Edge]: $e")) indexProvider.mutateEdges(edges) - import scala.collection.JavaConversions._ - val edgeIds = indexProvider.fetchEdgeIds("time: 10 AND _timestamp: 1") - edgeIds.head shouldBe edge.edgeId + // match + (0 until numOfTry).foreach { _ => + + val ids = indexProvider.fetchEdgeIds("time: 10 AND _timestamp: 1") + ids.head shouldBe edge.edgeId - edgeIds.foreach { edgeId => - println(s"[EdgeId]: $edgeId") + ids.foreach { id => + println(s"[Id]: $id") + } } + // match and not + (0 until numOfTry).foreach { _ => + val ids = indexProvider.fetchEdgeIds("time: 20 AND NOT _timestamp: 1") + // ids.size shouldBe 0 + ids.size shouldBe numOfOthers + + ids.foreach { id => + id shouldBe otherEdge.edgeId + println(s"[Id]: $id") + } + } + + // range + (0 until numOfTry).foreach { _ => + val ids = indexProvider.fetchEdgeIds("time: [0 TO 10]") + // ids.size shouldBe 0 + ids.size shouldBe 1 + + ids.foreach { id => + id shouldBe edge.edgeId + println(s"[Id]: $id") + } + } } }
