java - how to define cycles in protobuf? -


say have following mode.proto file:

message entityd {     optional entitye epointer = 1;     optional int32 dfield = 2; }  message entitye {     optional entityd dpointer = 1;     optional int32 efield = 2; } 

this has 2 entities - d , e, allow cross-linking. issue after generating java code above *.proto im unable create cycle:

public static void main(string[] args) throws exception {     model.entityd.builder dbuilder = model.entityd.newbuilder();     model.entitye.builder ebuilder = model.entitye.newbuilder();      dbuilder.setdfield(42);     ebuilder.setefield(7);     dbuilder.setepointer(ebuilder);     ebuilder.setdpointer(dbuilder);      model.entityd d = dbuilder.build();     model.entitye e = ebuilder.build();      system.err.println("same d: "+(d==e.getdpointer()));     system.err.println("same e: "+(e==d.getepointer())); } 

im trying create simple d <--> e cycle. instead this:

same d: false  same e: false 

enter image description here

there is cycle in created model, starting depth.

is issue probuf-generated java code? protobuf officially support cycles in graph ? whats expected result in other protobuf "output" languages? (namely c++)

the protobuf format not include object identity, , there no notion of reference / graph support. basic tree only. beyond implementation specific , not part of specification.

basically, don't that.

this not uncommon: same true of many serializers, including xml , json serializers. , these cases, again, implementations may have support local definition of identity - not guaranteed in general case.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -