Random access in python

31 views
Skip to first unread message

Qibin Zhou

unread,
Feb 21, 2020, 10:51:56 PM2/21/20
to Cap'n Proto
Hi,

I want to create a multi-message file and randomly access individual messages in python. Is there any way to do it in pycapnp? Thank you very much!

Best,

Qibin

Jacob Alexander

unread,
Feb 22, 2020, 12:25:34 AM2/22/20
to Cap'n Proto
I'm not entirely sure I get your question. To clarify, do you mean storing multiple Cap'n'proto messages inside of a file and accessing them? Or are you trying to send a file with multiple messages over RPC?

I believe it should be possible to store multiple messages inside of a file. Though I'm not quite sure what you mean by random, you'll need some sort of way to index the files, unless you are ok with sequentially parsing each of them.

-Jacob Alexander

Kenton Varda

unread,
Feb 22, 2020, 11:19:27 AM2/22/20
to Qibin Zhou, Cap'n Proto
Hi Qibin,

Cap'n Proto supports random access within a message. One way you could do what you want is to create your file as a single large message containing a List, instead of multiple messages.

If you need to use multiple messages (say, because you write them in a streaming way), then it's up to you to create some sort of index that allows you to seek to a particular message in constant time. Cap'n Proto itself doesn't define any such indexing mechanism.

-Kenton

Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you should delete this message. You are hereby notified that any disclosure, copying, distribution or taking action in relation to the contents of this information is strictly prohibited and may be unlawful.

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/bee76a9f-0bb5-4f92-84e8-cd598c8a7bed%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages