Skip to content

Commit

Permalink
Workaround for OrientDB Light edges
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelijusb committed Jan 13, 2016
1 parent b2a8e50 commit a22024b
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -73,9 +73,9 @@ trait ReferWrapper[A, Self <: ReferWrapper[A, Self]] { self: Self =>
""".stripMargin
val query = new OCommandSQL(sql.replace("\n", " "))
val parameters = JMap()
persisted.getGraph.command(query).execute[Vertices](parameters).map { row =>
val from = row.getProperty[ODocument]("edgeFrom")
val to = row.getProperty[ODocument]("edgeTo")
persisted.getGraph.command(query).execute[Vertices](parameters).map { row: Vertex =>
val from = getEdge(row, "edgeFrom")
val to = getEdge(row, "edgeTo")
val distance = row.getProperty[Int]("$depth")
cache(to) match {
case Some(cachedTo) => cache(from) match {
Expand All @@ -88,6 +88,13 @@ trait ReferWrapper[A, Self <: ReferWrapper[A, Self]] { self: Self =>
case _ => EmptyDistantRepresentationIterable
}

// Woraround for different light edge configuration
private def getEdge(vertex: Vertex, edge: String): ODocument = try {
vertex.getProperty[ODocument](edge)
} catch {
case e: ClassCastException => vertex.getProperty[OrientVertex](edge).getRecord
}

def derivedRepresentations(implicit cache: R.Cached = R.defaultCache): Iterable[RepresentationWrapper] =
storage.persisted match {
case None => EmptyRepresentationStorageIterable
Expand Down

0 comments on commit a22024b

Please sign in to comment.