Re: EdgeId and RelationId using VertexWritable


"ra...@gmail.com" <rafi1...@...>
 

Thanks Marc

I understood the encoding part of the edge_id components. I have few more doubts.
If we look at the example [1zf-388-b2t-368][4184-lives->4112] 
1zf = LongEncoding.encode(2571L) ... RelationId
388 = LongEncoding.encode(4184L) ... Outgoing vertex ID
368 =  LongEncoding.encode(4112L) Incoming vertex ID
b2t = ? ( unknown) ...  From the Relation Identifier , i saw the fourth part is the typeID but what is this and how is it being derived is still unclear to me.

Since I dont have the type ID with me , it seems that the typecasting to RelationIdentifier would not be possible.

Thanks

Rafi

On Wednesday, August 26, 2020 at 12:35:54 AM UTC+5:30 HadoopMarc wrote:
Ok, the form [1zf-388-b2t-368][4184-lives->4112] derives from:

https://github.com/apache/tinkerpop/blob/3.4.7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java

return E + L_BRACKET + edge.id() + R_BRACKET + L_BRACKET + edge.outVertex().id() + DASH + edge.label() + ARROW + edge.inVertex().id() + R_BRACKET;

You can also check in the console:

gremlin> import org.janusgraph.util.encoding.LongEncoding
gremlin> LongEncoding.encode(2571L)
==>1zf
gremlin> LongEncoding.encode(4184L)
==>388
gremlin> LongEncoding.encode(4112L)
==>368

I guess you have to typecast the edge.id() result to the JanusGraph RelationIdentifier somehow to get the canonical form you want. My scala is a bit rusty, so I leave that to you.

Btw, it can hardly be a coincidence that someone else had the same problem in a current thread!

Marc

Op dinsdag 25 augustus 2020 om 12:50:44 UTC+2 schreef ra...@...:
Hi Everyone,

I am using the VertexWritable class of Janusgraph to fetch the data via Spark as below:
-------------------------------------------------------------------------
val rdd0: RDD[(NullWritable, VertexWritable)] = spark.sparkContext.newAPIHadoopRDD(hadoopConfiguration, classOf[CqlInputFormat], classOf[NullWritable], classOf[VertexWritable])

val rdd1: RDD[VertexWritable] = rdd0.map { case (x, y) => y.asInstanceOf[VertexWritable] }
------------------------------------------------------------------

When I use rdd1.map(x => x.edges(Direction.IN)), I get the tinkerpop Edge and the edge.id() returns the relation ID (e[2571][4184-lives->4112]). How do I get the edge Id ==>e[1zf-388-b2t-368][4184-lives->4112]?

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.