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 2016/12/01 08:30:19 UTC

[09/10] incubator-s2graph git commit: - fix bug on wide.IndexEdgeDeserializable. - bug fix on IndexEdgeTest.

- fix bug on wide.IndexEdgeDeserializable.
- bug fix on IndexEdgeTest.


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

Branch: refs/heads/master
Commit: 0f21ad686afcc4559c26929272e1bf4b0402385c
Parents: a08df11
Author: DO YUNG YOON <st...@apache.org>
Authored: Wed Nov 30 22:26:34 2016 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Wed Nov 30 22:26:34 2016 +0900

----------------------------------------------------------------------
 .../scala/org/apache/s2graph/core/S2Edge.scala  |   4 +-
 .../wide/IndexEdgeDeserializable.scala          |   1 +
 .../core/storage/hbase/IndexEdgeTest.scala      | 205 +++++++++----------
 3 files changed, 105 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0f21ad68/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 5a8408d..2960265 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Edge.scala
@@ -476,7 +476,8 @@ case class S2Edge(innerGraph: S2Graph,
     case e: S2Edge =>
       srcVertex.innerId == e.srcVertex.innerId &&
         tgtVertex.innerId == e.tgtVertex.innerId &&
-        labelWithDir == e.labelWithDir && op == e.op && version == e.version &&
+        labelWithDir == e.labelWithDir && S2Edge.sameProps(propsWithTs, e.propsWithTs) &&
+        op == e.op && version == e.version &&
         pendingEdgeOpt == e.pendingEdgeOpt && lockTs == lockTs && statusCode == statusCode &&
         parentEdges == e.parentEdges && originalEdgeOpt == originalEdgeOpt
     case _ => false
@@ -624,7 +625,6 @@ object S2Edge {
       }
       ret
     }
-//    base.sameElements(other)
   }
   def fillPropsWithTs(snapshotEdge: SnapshotEdge, state: State): Unit = {
     state.foreach { case (k, v) => snapshotEdge.property(k.name, v.innerVal.value, v.ts) }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0f21ad68/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
index 706d8cb..31a1a89 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/storage/serde/indexedge/wide/IndexEdgeDeserializable.scala
@@ -128,6 +128,7 @@ class IndexEdgeDeserializable(graph: S2Graph,
          TargetVertexId(ServiceColumn.Default, vId.innerVal)
        } else tgtVertexIdRaw
 
+     edge.property(LabelMeta.timestamp.name, tsVal, version)
      edge.tgtVertex = graph.newVertex(tgtVertexId, version)
      edge.op = op
      edge.tsInnerValOpt = Option(InnerVal.withLong(tsVal, schemaVer))

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0f21ad68/s2core/src/test/scala/org/apache/s2graph/core/storage/hbase/IndexEdgeTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/storage/hbase/IndexEdgeTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/storage/hbase/IndexEdgeTest.scala
index acbc689..5409d61 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/storage/hbase/IndexEdgeTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/storage/hbase/IndexEdgeTest.scala
@@ -1,103 +1,102 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one
-// * or more contributor license agreements.  See the NOTICE file
-// * distributed with this work for additional information
-// * regarding copyright ownership.  The ASF licenses this file
-// * to you under the Apache License, Version 2.0 (the
-// * "License"); you may not use this file except in compliance
-// * with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing,
-// * software distributed under the License is distributed on an
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// * KIND, either express or implied.  See the License for the
-// * specific language governing permissions and limitations
-// * under the License.
-// */
-//
-//package org.apache.s2graph.core.storage.hbase
-//
-//import org.apache.s2graph.core.mysqls.{Model, Label, LabelIndex, LabelMeta}
-//import org.apache.s2graph.core.types._
-//import org.apache.s2graph.core.{QueryParam, IndexEdge, TestCommonWithModels, Vertex}
-//import org.scalatest.{FunSuite, Matchers}
-//
-//
-//class IndexEdgeTest extends FunSuite with Matchers with TestCommonWithModels {
-//  initTests()
-//
-//  val testLabelMeta = LabelMeta(Option(-1), labelV2.id.get, "test", 1.toByte, "0.0", "double")
-//  /**
-//   * check if storage serializer/deserializer can translate from/to bytes array.
-//   * @param l: label for edge.
-//   * @param ts: timestamp for edge.
-//   * @param to: to VertexId for edge.
-//   * @param props: expected props of edge.
-//   */
-//  def check(l: Label, ts: Long, to: InnerValLike, props: Map[LabelMeta, InnerValLikeWithTs]): Unit = {
-//    val from = InnerVal.withLong(1, l.schemaVersion)
-//    val vertexId = SourceVertexId(HBaseType.DEFAULT_COL_ID, from)
-//    val tgtVertexId = TargetVertexId(HBaseType.DEFAULT_COL_ID, to)
-//    val vertex = Vertex(vertexId, ts)
-//    val tgtVertex = Vertex(tgtVertexId, ts)
-//    val labelWithDir = LabelWithDirection(l.id.get, 0)
-//    val labelOpt = Option(l)
-//    val edge = graph.newEdge(vertex, tgtVertex, l, labelWithDir.dir, 0, ts, props, tsInnerValOpt = Option(InnerVal.withLong(ts, l.schemaVersion)))
-//    val indexEdge = edge.edgesWithIndex.find(_.labelIndexSeq == LabelIndex.DefaultSeq).head
-//    val _indexEdgeOpt = graph.getStorage(l).indexEdgeDeserializer(l.schemaVersion).fromKeyValues(labelOpt,
-//      graph.getStorage(l).indexEdgeSerializer(indexEdge).toKeyValues, l.schemaVersion, None)
-//
-//
-//    _indexEdgeOpt should not be empty
-//    indexEdge should be(_indexEdgeOpt.get)
-//  }
-//
-//
-//  /** note that props have to be properly set up for equals */
-//  test("test serializer/deserializer for index edge.") {
-//    val ts = System.currentTimeMillis()
-//    for {
-//      l <- Seq(label, labelV2, labelV3, labelV4)
-//    } {
-//      val to = InnerVal.withLong(101, l.schemaVersion)
-//      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
-//      val props = Map(LabelMeta.timestamp -> tsInnerValWithTs,
-//        testLabelMeta -> InnerValLikeWithTs.withDouble(2.1, ts, l.schemaVersion))
-//
-//      check(l, ts, to, props)
-//    }
-//  }
-//
-//  test("test serializer/deserializer for degree edge.") {
-//    val ts = System.currentTimeMillis()
-//    for {
-//      l <- Seq(label, labelV2, labelV3, labelV4)
-//    } {
-//      val to = InnerVal.withStr("0", l.schemaVersion)
-//      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
-//      val props = Map(
-//        LabelMeta.degree -> InnerValLikeWithTs.withLong(10, ts, l.schemaVersion),
-//        LabelMeta.timestamp -> tsInnerValWithTs)
-//
-//      check(l, ts, to, props)
-//    }
-//  }
-//
-//  test("test serializer/deserializer for incrementCount index edge.") {
-//    val ts = System.currentTimeMillis()
-//    for {
-//      l <- Seq(label, labelV2, labelV3, labelV4)
-//    } {
-//      val to = InnerVal.withLong(101, l.schemaVersion)
-//      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
-//      val props = Map(LabelMeta.timestamp -> tsInnerValWithTs,
-//        testLabelMeta -> InnerValLikeWithTs.withDouble(2.1, ts, l.schemaVersion),
-//        LabelMeta.count -> InnerValLikeWithTs.withLong(10, ts, l.schemaVersion))
-//
-//
-//      check(l, ts, to, props)
-//    }
-//  }
-//}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.s2graph.core.storage.hbase
+
+import org.apache.s2graph.core.mysqls._
+import org.apache.s2graph.core.types._
+import org.apache.s2graph.core.TestCommonWithModels
+import org.scalatest.{FunSuite, Matchers}
+
+
+class IndexEdgeTest extends FunSuite with Matchers with TestCommonWithModels {
+  initTests()
+
+  val testLabelMeta = LabelMeta(Option(-1), labelV2.id.get, "affinity_score", 1.toByte, "0.0", "double")
+  /**
+   * check if storage serializer/deserializer can translate from/to bytes array.
+   * @param l: label for edge.
+   * @param ts: timestamp for edge.
+   * @param to: to VertexId for edge.
+   * @param props: expected props of edge.
+   */
+  def check(l: Label, ts: Long, to: InnerValLike, props: Map[LabelMeta, InnerValLikeWithTs]): Unit = {
+    val from = InnerVal.withLong(1, l.schemaVersion)
+    val vertexId = SourceVertexId(ServiceColumn.Default, from)
+    val tgtVertexId = TargetVertexId(ServiceColumn.Default, to)
+    val vertex = graph.newVertex(vertexId, ts)
+    val tgtVertex = graph.newVertex(tgtVertexId, ts)
+    val labelWithDir = LabelWithDirection(l.id.get, 0)
+    val labelOpt = Option(l)
+    val edge = graph.newEdge(vertex, tgtVertex, l, labelWithDir.dir, 0, ts, props, tsInnerValOpt = Option(InnerVal.withLong(ts, l.schemaVersion)))
+    val indexEdge = edge.edgesWithIndex.find(_.labelIndexSeq == LabelIndex.DefaultSeq).head
+    val _indexEdgeOpt = graph.getStorage(l).indexEdgeDeserializer(l.schemaVersion).fromKeyValues(labelOpt,
+      graph.getStorage(l).indexEdgeSerializer(indexEdge).toKeyValues, l.schemaVersion, None)
+
+    _indexEdgeOpt should not be empty
+    edge == _indexEdgeOpt.get should be(true)
+  }
+
+
+  /** note that props have to be properly set up for equals */
+  test("test serializer/deserializer for index edge.") {
+    val ts = System.currentTimeMillis()
+    for {
+      l <- Seq(label, labelV2, labelV3, labelV4)
+    } {
+      val to = InnerVal.withLong(101, l.schemaVersion)
+      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
+      val props = Map(LabelMeta.timestamp -> tsInnerValWithTs,
+        testLabelMeta -> InnerValLikeWithTs.withDouble(2.1, ts, l.schemaVersion))
+
+      check(l, ts, to, props)
+    }
+  }
+
+  test("test serializer/deserializer for degree edge.") {
+    val ts = System.currentTimeMillis()
+    for {
+      l <- Seq(label, labelV2, labelV3, labelV4)
+    } {
+      val to = InnerVal.withStr("0", l.schemaVersion)
+      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
+      val props = Map(
+        LabelMeta.degree -> InnerValLikeWithTs.withLong(10, ts, l.schemaVersion),
+        LabelMeta.timestamp -> tsInnerValWithTs)
+
+      check(l, ts, to, props)
+    }
+  }
+
+  test("test serializer/deserializer for incrementCount index edge.") {
+    val ts = System.currentTimeMillis()
+    for {
+      l <- Seq(label, labelV2, labelV3, labelV4)
+    } {
+      val to = InnerVal.withLong(101, l.schemaVersion)
+      val tsInnerValWithTs = InnerValLikeWithTs.withLong(ts, ts, l.schemaVersion)
+      val props = Map(LabelMeta.timestamp -> tsInnerValWithTs,
+        testLabelMeta -> InnerValLikeWithTs.withDouble(2.1, ts, l.schemaVersion),
+        LabelMeta.count -> InnerValLikeWithTs.withLong(10, ts, l.schemaVersion))
+
+
+      check(l, ts, to, props)
+    }
+  }
+}