message TreeNodeChanged {
oneof key {
sometype path_to_node1 = 1;
sometype path_to_node2 = 2;
...
}
}
intLit = decimalLit | octalLit | hexLit
decimalLit = ( "1" … "9" ) { decimalDigit }
octalLit = "0" { octalDigit }
hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit } decimalDigit = "0" … "9" hexDigit = "0" … "9" | "A" … "F" | "a" … "f"
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
Hey there,This might a stupid question, but i haven't found anything certain in the docs/specs about that:Our main goal is actually to keep compatibility while syncing a tree.The protocol is actually just one giant oneof containing all possible paths for the tree:message TreeNodeChanged {oneof key {sometype path_to_node1 = 1;sometype path_to_node2 = 2;...}}and thats already working.The problem is however that we don't only want forward backward compability between server and client, but also sideways:e.g. person A introduced message index 2 and also did person B, both meaning totally different things, but it should be recognized and ignored(/or maybe even accepted?! if we find a way to do this)
So the idea of my mate was to make the field number a hash of the path_to_node!Candidates are e.g. a 32bit FNV-hash or maybe an adapted CRC32. This would both mean field numbers in a pretty high area.Maybe we're going the totally wrong way here but following this path leads to the following issues:1) what is the maximum value of the protobuf field numbers?
In the proto language specification it simply says its of type "intLit" and intLit is:intLit = decimalLit | octalLit | hexLit decimalLit = ( "1" … "9" ) { decimalDigit } octalLit = "0" { octalDigit } hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit }So this means only decimal and hexadecimal values are actually allowed doesnt it?
Then however given:decimalDigit = "0" … "9" hexDigit = "0" … "9" | "A" … "F" | "a" … "f"Means it has different limits for hex and int notation, is that correct?I mean:the max value for decimalLit is one billion-1 : "999 999 999"according to this specs, which fits fine in a 32bit integer (with 30bits set)but for base 16 its allowed length is 16! which would be awesome cause thatwould mean an allowed integer size of 64bit.So which one is true? Both?which leads to issue 2:1) are there issues with high field numbersAnd are they even tested at all?
I've red elsewhere that "we have used field numbers in the range 50000-99999. This range is reserved for internal use within individual organizations"which would suggest that even values above 50 000 are uncommen ..Furthermore some people mentioned high values would suffer from beeing less performant, but: in how far is that relevant? Only because the index number consumes slightly more memory?Well: Maybe we totally ask the wrong questions here and theres a much simpler logic already introduced or invented to better make protobuf message version independent, if yes we would be happy to hear them!Thanks in advance and for reading all this stuff :)
https://developers.google.com/protocol-buffers/docs/encoding#structureProtobuf messages are associative arrays of key value pairs, where the key is a union of the field number encoded as a varint and the value wire type (union operator being a left shift of the field number by 3 bits). Because the field number is variable width, it's theoretical size is unbounded but is likely implementation dependent as some programming languages super arbitrarily large numbers, and other implementations might use fixed width types to represent the field for convenience.
On Sun, Jun 19, 2016 at 7:56 AM, a_teammate <mad...@web.de> wrote:
The problem is however that we don't only want forward backward compability between server and client, but also sideways:e.g. person A introduced message index 2 and also did person B, both meaning totally different things, but it should be recognized and ignored(/or maybe even accepted?! if we find a way to do this)
If person A already added a field with field number 2, how can person B add another one with the same field number? Do you have multiple copies of the .proto files and they are not synced?
If you are trying to prevent collisions between two people modifying the key space, I recommend making separate embedded messages so there is no chance of collision. CRC-ing field numbers is just too heavy weight for what it is you're trying to do in my opinion.
Regarding performance, varint encoding/decoding time is O(n) in the byte length of the result. Whether this is important depends on your application of course, but you're really better off understanding how the encoding works so you can do a quick back of the envelope guess to see if it matters, followed by actually benchmarking if performance is really that important to you.
On Sun, Jun 19, 2016 at 7:56 AM, a_teammate <mad...@web.de> wrote:
1) what is the maximum value of the protobuf field numbers?
The range of valid field numbers is 1 to 2^29 - 1:
Some field numbers in this range are reserved so you will need to account for those as well.
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
> Separate embedded messages would involve switches for the code generation (official build vs modded build) but could be doable, and maybe it is even a bit cleaner.> The CRC thing would have meant an uniform solution, but maybe namespacing the modded messages isn't the worst idea.I'd be really surprised if a CRC ended up being more performant than a single branch to see if the mod message exists if I'm understanding your situation correctly.