c++ - Can protobuf read partially? -
c++ - Can protobuf read partially? -
i want save terrain info file , load parts of it, because it's big store in memory whole. don't know whether protobuf purposes.
for illustration have construction (might invalid gramatically, know simple basics):
message quad { required int32 x = 1; required int32 z = 2; repeated int32 y = 3; }
the x , z values available in programme , using them find right quad object same x , z (in file) obtain y values. however, can't parse file parsefromistream(), because (i think so) loads whole file memory, in case file big.
so, protobuf able load 1 object, send me checking , if object wrong give me sec one?
actually... ask: parsefromistream() loads whole file memory?
this depends on implementation using. have "read sequence" apis. example, assuming stored "repeated quad", protobuf-net be:
int x = ..., y = ...; var found = serializer.deserializeitems<quad>(source) .where(q => q.x ==x && q.y == y);
the point being: yields spooling (not loaded @ once) , short-circuiting sequence.
i don't know c++ api specifically, hope has similar - worst case parse varint headers , prepare length-capped stream.
c++ protocol-buffers
Comments
Post a Comment