简体   繁体   English

多次读取记事字节并同时作为流读取

[英]Read Chronicle Bytes multiple times and concurrently as stream

I am using Chronicle Bytes version 1.7.22. 我正在使用Chronicle Bytes版本1.7.22。 I would like to use Bytes for off-heap caching and persistence of large media (eg images, videos). 我想将字节用于大型媒体(例如图像,视频)的堆外缓存和持久性。 Currently I am creating the Bytes as follows: 目前,我正在创建字节,如下所示:

Bytes.elasticByteBuffer();

OR (for persistence) 或(用于持久性)

MappedBytes.mappedBytes(file, 64);

I have used Bytes.outputStream() to write the media content and used Bytes.inputStream() to read the media content. 我已经使用Bytes.outputStream()写入媒体内容,并使用Bytes.inputStream()读取媒体内容。 However, I can only read the InputStream once. 但是,我只能读取一次InputStream。 It does not seem to support reset. 它似乎不支持重置。 How can I read the media content multiple times and concurrently without allocation of extra memory? 如何在不分配额外内存的情况下多次读取媒体内容?

I would suggest you upgrade to the latest 1.9.x version though thus wont fix you problem as such it will fix many bugs. 我建议您升级到最新的1.9.x版本,尽管这样不会解决您的问题,因为它将解决许多错误。

Bytes is intended to be single threaded however with care the underlying bytes can be shared. 字节旨在用于单线程,但是请注意可以共享基础字节。 You need to create a BytesStore whuch has the shared data and wrap thus with a Bytes eg NativeBytes so you can have a thread local pointer to that data. 您需要创建一个拥有共享数据的BytesStore,然后使用Bytes进行包装,例如NativeBytes,以便您可以拥有一个指向该数据的线程本地指针。

If you need to share how long the data is you must store that in the underlying bytes using a thread safe operation. 如果需要共享数据多长时间,则必须使用线程安全操作将其存储在基础字节中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM