[
https://issues.apache.org/jira/browse/S2GRAPH-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16241588#comment-16241588
]
DOYUNG YOON commented on S2GRAPH-170:
-------------------------------------
So far, I have removed SelfType on `S2EdgeLike/S2VertexLike` class(not yet
started with S2GraphLike). works can be found on
[here|https://github.com/SteamShon/incubator-s2graph/commits/S2GRAPH-170].
In summary following is how our interface looks like so far.
h4. S2VertexLike
{noformat}
trait S2VertexLike extends Vertex with GraphElement {
val graph: S2Graph
val id: VertexId
val ts: Long
val props: Props
val op: Byte
val belongLabelIds: Seq[Int]
val innerId = id.innerId
val innerIdVal = innerId.value
val builder = new S2VertexBuilder(this)
def label(): String = serviceColumn.columnName
def schemaVer = serviceColumn.schemaVersion
def serviceColumn = ServiceColumn.findById(id.colId)
def columnName = serviceColumn.columnName
lazy val service = Service.findById(serviceColumn.serviceId)
lazy val (hbaseZkAddr, hbaseTableName) = (service.cluster, service.hTableName)
def defaultProps: util.HashMap[String, S2VertexProperty[_]]
def toLogString(): String
def vertices(direction: Direction, edgeLabels: String*): util.Iterator[Vertex]
def edges(direction: Direction, labelNames: String*): util.Iterator[Edge]
def propertyInner[V](cardinality: Cardinality, key: String, value: V,
objects: AnyRef*): VertexProperty[V]
def property[V](cardinality: Cardinality, key: String, value: V, objects:
AnyRef*): VertexProperty[V]
def addEdge(labelName: String, vertex: Vertex, kvs: AnyRef*): Edge
def property[V](key: String): VertexProperty[V]
def properties[V](keys: String*): util.Iterator[VertexProperty[V]]
def remove(): Unit
}
{noformat}
h4. S2EdgeLike
{noformat}
trait S2EdgeLike extends Edge with GraphElement {
/* immutable variable */
val innerGraph: S2Graph
val srcVertex: S2VertexLike
var tgtVertex: S2VertexLike
val innerLabel: Label
val dir: Int
/* mutable variable */
var op: Byte
var version: Long
var tsInnerValOpt: Option[InnerValLike]
val propsWithTs: Props = S2Edge.EmptyProps
/* only internal usage variables */
val parentEdges: Seq[EdgeWithScore] = Nil
val originalEdgeOpt: Option[S2EdgeLike] = None
val pendingEdgeOpt: Option[S2EdgeLike] = None
val statusCode: Byte = 0
val lockTs: Option[Long] = None
lazy val ts: Long
private lazy val operation: String
private lazy val direction: String
private lazy val tsInnerVal: Any
/* getter/setter */
def graph(): Graph
lazy val edgeId: EdgeId
def id(): AnyRef
def label(): String
def getLabelId(): Int
def getDirection(): String
def getOperation(): String
def getTsInnerValValue(): Any
def isDirected(): Boolean
def getTs(): Long = ts
def getOriginalEdgeOpt(): Option[S2EdgeLike]
def getParentEdges(): Seq[EdgeWithScore]
def getPendingEdgeOpt(): Option[S2EdgeLike]
def getPropsWithTs(): Props
def getLockTs(): Option[Long]
def getStatusCode(): Byte
def getDir(): Int
def setTgtVertex(v: S2VertexLike): Unit
def getOp(): Byte
def setOp(newOp: Byte): Unit
def getVersion(): Long
def setVersion(newVersion: Long): Unit
def getTsInnerValOpt(): Option[InnerValLike]
def setTsInnerValOpt(newTsInnerValOpt: Option[InnerValLike]): Unit
/* conversion helper used internal */
def toSnapshotEdge: SnapshotEdge
def toIndexEdge(labelIndexSeq: Byte): IndexEdge
/* property related helper */
def updatePropsWithTs(others: Props = S2Edge.EmptyProps): Props
def propertyValue(key: String): Option[InnerValLikeWithTs]
def propertyValueInner(labelMeta: LabelMeta): InnerValLikeWithTs
def propertyValues(keys: Seq[String] = Nil): Map[LabelMeta,
InnerValLikeWithTs]
def propertyValuesInner(labelMetas: Seq[LabelMeta] = Nil): Map[LabelMeta,
InnerValLikeWithTs]
/* copy helper */
def checkProperty(key: String): Boolean
def copyEdgeWithState(state: State): S2EdgeLike
def copyOp(newOp: Byte): S2EdgeLike
def copyVersion(newVersion: Long): S2EdgeLike
def copyParentEdges(parents: Seq[EdgeWithScore]): S2EdgeLike
def copyOriginalEdgeOpt(newOriginalEdgeOpt: Option[S2EdgeLike]): S2EdgeLike
def copyStatusCode(newStatusCode: Byte): S2EdgeLike
def copyLockTs(newLockTs: Option[Long]): S2EdgeLike
def copyTs(newTs: Long): S2EdgeLike
def updateTgtVertex(id: InnerValLike): S2EdgeLike
/* tinkerpop Edge interface */
def vertices(direction: Direction): util.Iterator[structure.Vertex]
def properties[V](keys: String*): util.Iterator[Property[V]]
def property[V](key: String): Property[V]
def property[V](key: String, value: V): Property[V]
def propertyInner[V](key: String, value: V, ts: Long): Property[V]
def remove(): Unit
/* GraphElement interface */
def toLogString: String
}
{noformat}
There are many methods and variables that we can provide default
implementation, for example, edgeId and all getter/setter etc.
Even though SelfType can be removed, I hope more thought goes on what will be
exposed on S2VertexLike/S2EdgeLike.
Please keep in mind that above is just an example so please give more thought.
> Create Interface for S2Edge/S2Vertex/S2Graph.
> ---------------------------------------------
>
> Key: S2GRAPH-170
> URL: https://issues.apache.org/jira/browse/S2GRAPH-170
> Project: S2Graph
> Issue Type: Improvement
> Affects Versions: 0.2.1
> Reporter: DOYUNG YOON
> Fix For: 0.2.1
>
> Original Estimate: 504h
> Remaining Estimate: 504h
>
> h2. Problem Statement
> S2Graph’s entire code base is dependent on S2Edge/S2Vertex/S2Graph class.
> Even though lots of code touch theses two class, there is no interface
> defined currently. This means lots of code is interact with these class in
> different way all by their own way, and this make extremely hard to make any
> change on these two classes.
> For example, I was working on S2GRAPH-80 to provide java client, and there
> are too many places to be changed since all theses places use concrete
> implementation class S2Edge/S2Vertex/S2Graph, not the interfaces. Not just
> for S2GRAPH-80, but any other issues that need to change theses classes would
> benefit by communicating through interface.
> h2. Suggestion
> Define interface and change code base to communicate through theses
> interfaces.
> # Create interface S2Edge/S2Vertex/S2Graph that implement Tinkerpop’s
> Edge/Vertex/Graph interface
> # Extract tinkerpop interface related implementations
> # Change caller of S2Edge/S2Vertex/S2Graph to call interface rather than
> concrete implementation.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)