java - Disruptor how to use his ring buffer to read a file? -


i looking use dirsuptor ring buffer parse file. not see how set range of value ring buffer.

in example below seem. loop each item assign buffer. me, assign directly x items.

when fileinputstream.read( byte[] bytes ), put these bytes ring buffer.

usually buffer twice bigger bytes read. read page while computing 1 ( eg bytes array length == buffer / 2 ):

executorservice exec = executors.newcachedthreadpool(); // preallocate ringbuffer 1024 valueevents disruptor<valueevent> disruptor = new disruptor<valueevent>(valueevent.event_factory, 1024, exec);  // build dependency graph ringbuffer<valueevent> ringbuffer = disruptor.start();  (long = 10; < 2000; i++) {     string uuid = uuid.randomuuid().tostring();     // 2 phase commit. grab 1 of 1024 slots     long seq = ringbuffer.next();     valueevent valueevent = ringbuffer.get(seq);     valueevent.setvalue(uuid);     ringbuffer.publish(seq); } 

thanks

since version 3.0.0 of disruptor has supported batch publication.

there variety of publishevents methods on ringbuffer depending on how wish transform events.

given sample code suspect want @ this version, , supply array of uuids. there multiple versions depending on how many arguments wish pass translator.

the alternative version capture uuid in eventtranslator self.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -