How to boost::serialize S2PointIndex #342
Replies: 5 comments
-
It looks like we don't have an Encode() method on that one, so I think the
answer is yes. Fortunately it's pretty simple under the hood.
…On Tue, Oct 31, 2023 at 3:47 PM GoroYeh-HRI ***@***.***> wrote:
Hi,
If I want to use boost::serialize() to store class S2PointIndex as binary
stream,
how do I do it?
Do I need to implement my own serialization function for S2PointIndex ?
Thanks.
—
Reply to this email directly, view it on GitHub
<#332>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGEMKT7NZFWQI5R7IH34DDYCFWWJAVCNFSM6AAAAAA6YMF2FGVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE3TCMZUHA2DEMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi @smcallis , thanks for your reply. I'm currently tracing class Could you provide more details on how to implement serialize() function for this class? |
Beta Was this translation helpful? Give feedback.
-
S2Point and S2CellId already have Encode/Init methods so they can serialize themselves for you. s2internal::BTreeMultimap is just absl::btree_multimap. I'd probably just iterate that container and store pairs of (S2CellId, [list of data]), then read that back into a new absl::btree_multimap when decoding. That might not be the absolute most efficient encoding space-wise but it is simple. I'd worry more about the fact that PointIndex takes a template parameter for the data, so you'll have to serialize the data type too. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your reply! I noticed the BTreeMultimap is instantiated like this: Did you mean I'll need to serialize |
Beta Was this translation helpful? Give feedback.
-
You'll have to write code to hook S2Point and S2CellId into boost::serialize, but you can probably do that using their existing Encode/Init methods. I don't think you'll need to worry about storing the map params, that's a runtime detail different from storing the data in a serialized form. |
Beta Was this translation helpful? Give feedback.
-
Hi,
If I want to use
boost::serialize()
to store classS2PointIndex
as binary stream,how do I do it?
Do I need to implement my own serialization function for
S2PointIndex
?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions