kani
kani

Reputation: 33

How to retrieve protobuf data rendomly?

I want to store large amount of data in a protobuf format in which include time-stamp parameter. And I want to retrieve the data based on the time-stamp value. Thanks.

Upvotes: 0

Views: 328

Answers (1)

Kenton Varda
Kenton Varda

Reputation: 45171

Protobuf is a sequential-access format. There's no way to jump into the middle of a message looking for data; you have to parse through the whole thing.

Some options:

  • Devise a framing format that allows you to break up your datastore into many small chunks, each of which is a separate protobuf message. This is a fairly large project.
  • Use SQLite or even an actual database.
  • Use a random-access-fieldly format like Cap'n Proto instead. (Disclosure: I'm the author of Cap'n Proto, and also of Protobufs v2 (Google's open source release).)

Upvotes: 1

Related Questions