Details
-
Improvement
-
Status: Done
-
Minor
-
Resolution: Done
-
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
- links to