Difference between a ring buffer and a queue
data-structures, hadoop, hadoop2
Solution
A RingBuffer is an array, which is used as Queue
It will maintain both Read & Write positions separately. When it reach end of Array, it will continue from beginning of Array.
Uses of RingBuffer over Queue.
- Ring Buffers are fast.
- When you have hard cut-off for how much data to be stored, RingBuffer is useful.
Have a look at this article by Jakob Jenkov for more details.
Have a look at related SE question :
Java - Ring Buffer
Problem
What is the difference between the ring (circular) buffer and a queue? Both support FIFO so in what scenarios I should use ring buffer over a queue and why? Relevance to Hadoop The map phase uses ring buffer to store intermediate key value pairs. What are the reasons for this choice over a queue?