I am new to TinkerPop (and graph databases in general) and am trying to replace a (somewhat broken) relational model with a graph. I have come to point where I am struggling to understand how to tackle the problem of collapsing two partitions into one (in fact I would say that I am struggling to understand if that is even something that makes sense).
I tried coming up with an example to illustrate what I would like to do: I am starting with two partitions, but am trying to collapse them together into a single partition.
graph = TinkerFactory.createModern()
g = graph.traversal()
g.V().property('_partition', 'modern')
g.E().property('_partition', 'modern')
socialStrategy = PartitionStrategy.build().partitionKey("_partition").writePartition("social").readPartitions("social").create()
gS = graph.traversal().withStrategies(socialStrategy)
gS.addV('person').property('name', 'marko').property('email', 'marko@markor***.com').as('marko').
addV('person').property('name', 'stephen').property('twitter', '@spmall***').
addE('knows').from('marko')
In this example I am trying to eliminate the "social" partition and end up in the state where:
gremlin> m = g.V().has('name', 'marko').valueMap(true)
==>[_partition:[modern],label:person,name:[marko],id:1,arg:[29],email:[marko@markor***.com]]
gremlin> g.V().has('name', 'stephen').valueMap(true)
==>[_partition:[modern],twitter:[@spmall***],label:person,name:[stephen],id:22]
gremlin> g.V().has('name', 'marko').outE('knows')
==>e[7][1-knows->2]
==>e[8][1-knows->4]
==>e[26][1-knows->22]
I'm not yet comfortable enough with the TinkerPop language to know exactly what a good approach would look like. For example, I'm not sure if this is something I should try to accomplish using multiple traversals; e.g. maybe one to find the vertices that can just have their partition value updated and one to somehow combine the properties of vertices grouped by their "name" from both partitions (which I would be at a loss to actually do). I guess this might be similar to updating the partition value on all nodes in `gS` to the new value and then going back over and cleaning up the "modern" partition?
I'm also aware that partition strategies can have multiple "read" values, so perhaps the right anwser is to just leave the structure of the graph alone and to change how I construct queries to combine the grouped vertex properties (again, I'm not sure exactly what this might look like).
Any pointers or suggestions would be greatly appreciated!
Thanks,
-Jeremy