For languages that can interface with C/C++, schema-less has a big advantage: you can actually use the C++ implementation to go back and forth from JSON to FlexBuffers in a single function call.. unlike FlatBuffers
Can you tell me which call should I look for? I was looking into flexbuffers.h and couldn't find a function to parse json.
Can someone help me understand the BUILDER_FLAG_SHARE_KEYS implementation? (https://github.com/google/flatbuffers/blob/master/include/flatbuffers/flexbuffers.h#L951)
I am trying to understand how one know, given a set of key positions
key_pool and the new
key if the key is already present in the buffer or not. I think I am missing something here.
678than if the int is store not indirectly the key value pair is (678, 38). If you have
BUILDER_FLAG_SHARE_KEYSturned on than you check if storing "maxim" is necessary or this key is already stored so you can just get the existing position in the buffer. The C++ code is interesting because it adds the string anyways and if the flag is set and the string is already stored, it will put the "cursor" back to where it was before adding "maxim" and return the "old position" of "maxim".
Now I finally understood the C++ implementation.
KeyOffsetCompare holds the buf and its called to check the uniqueness of the element. So it does the comparison by
strcmp the keys in the buffer itself. Clever.
I did the Java implementation very similar to what you did in Swift. A
Map<String, Int> for
key_pool. Then I check if the key exists before writing it. Later I will try to mimic C++ implementation to save some memory