0

How to create a blank node as a resource object in Jena when assigning yourself the banknode identifier ?

NodeFactory.createBlankNode(UUIDs.random().toString)

I want to make that a resource so i can add it in a statement.

I tried the following but i am not sure that i am doing the right thing.

ResourceFactory.createResource(NodeFactory.createBlankNode(UUIDs.random().toString).getBlankNodeLabel)

Can anyone advise me here ?

MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
  • Nope that question does not answer how to set the identifier of the blanknode yourself. – MaatDeamon Sep 21 '18 at 09:48
  • You don't need to set the blank node internal identifier to add statements. Just use the Java object from ResourceFactory.createResource(). – AndyS Sep 21 '18 at 10:42
  • But that is the point I need to do it for my use case. I am working on spark and doing a lot of transformation and use massive paralllization across nodes and within nodes and each data frame row is one entity that may contain blank node. This run the risk of blank node collision as each element/row of a data frame is its own document. If I can set those across myself with the right library with real uuid version one that will help. I am using datasax uuid implementation – MaatDeamon Sep 21 '18 at 10:52
  • You can use the parameter `org.apache.jena.shared.impl.JenaParameters#disableBNodeUIDGeneration` (jena 3.8.0) to switch to AtomicInteger counter instead of UUID or reflection to generate patched instance of `org.apache.jena.graph.BlankNodeId` – ssz Sep 22 '18 at 20:57
  • Also, just an remark about UUID collisions: https://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid if I were in your place, I would first calculate the probability of collisions in your application – ssz Sep 23 '18 at 10:52

0 Answers0