Uploaded image for project: 'S2Graph'
  1. S2Graph
  2. S2GRAPH-122

Change data types of Edge/IndexEdge/SnapshotEdge.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Done
    • Minor
    • Resolution: Done
    • 0.2.0
    • 0.2.0
    • None

    Description

      Currently Edge have following interface.

      case class Edge(srcVertex: Vertex,
                      tgtVertex: Vertex,
                      labelWithDir: LabelWithDirection,
                      op: Byte = GraphUtil.defaultOpByte,
                      version: Long = System.currentTimeMillis(),
                      propsWithTs: Map[Byte, InnerValLikeWithTs],
                      parentEdges: Seq[EdgeWithScore] = Nil,
                      originalEdgeOpt: Option[Edge] = None,
                      pendingEdgeOpt: Option[Edge] = None,
                      statusCode: Byte = 0,
                      lockTs: Option[Long] = None)
      
      case class IndexEdge(srcVertex: Vertex,
                           tgtVertex: Vertex,
                           labelWithDir: LabelWithDirection,
                           op: Byte,
                           version: Long,
                           labelIndexSeq: Byte,
                           props: Map[Byte, InnerValLikeWithTs])
      
      case class SnapshotEdge(srcVertex: Vertex,
                              tgtVertex: Vertex,
                              labelWithDir: LabelWithDirection,
                              op: Byte,
                              version: Long,
                              props: Map[Byte, InnerValLikeWithTs],
                              pendingEdgeOpt: Option[Edge],
                              statusCode: Byte = 0,
                              lockTs: Option[Long]) 
      

      Following is my suggestion.

      1. I think there is no reason to use `LabelWithDirection` which only have labelId and direction. Instead we can actually change it to hold `Label` which contains lots of other meta data(ex: write options which decide this edge need to store reverse direction or not). Because of using `LabelWithDirection`, there are lots of duplicate code to lookup to get `Label` instance from `LabelWithDirection`. Even though we are using local cache, It would be better if we can remove unnecessary lookup cost. I think storing `Label` is also good because we can remove lots of duplicate code which find `Label` instance from LabelWithDirection.

      2. When we deserialize, we first deserialize `SKeyValue` into `IndexEdge`, then call `toEdge` to convert `IndexEdge` to `Edge`. when we convert, there is unnecessary data copy because `IndexEdge` and `Edge` has different data type for props value.

      props.map { case (k, v) => k -> InnerValLikeWithTs(v, version) } 
      

      This will be called per each edge that fetched from storage, so we should avoid unnecessary iteration of properties.

      Attachments

        Issue Links

          Activity

            People

              steamshon Do Yung Yoon
              steamshon Do Yung Yoon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 96h
                  96h
                  Remaining:
                  Remaining Estimate - 96h
                  96h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified