The difference between the ring buffer and the queue

What is the difference between a circular (circular) buffer and a queue? Both support FIFO, so in what scenarios should I use the ring buffer in the queue and why?

Relevance for Hadoop

In the map phase, a ring buffer is used to store intermediate pairs of key values. What are the reasons for this choice in line?

+4
source share
4 answers

A queue is an abstract data type that supports enqueue and dequeue operations. A ring buffer is one possible implementation of a queue, although it is not the only one (for example, you can implement a queue using a linked list). In other words, a queue is a generic term for a data structure that can support inserting FIFOs and call buffers - this is one of the possible data structures that you could use to implement the queue.

Hope this helps!

+4
source

RingBuffer is an array that is used as a queue

It will support both read and write positions separately. When it reaches the end of the array, it will continue from the beginning of the array.

Using RingBuffer through a queue.

  1. Ring buffers are fast.
  2. , RingBuffer .

.

SE:

Java -

+2

, - , , , . ( FIFO) , .

, - , , , FIFO. "" (, 8 ).

FIFO, , , .

+1

2 , . :

: Fifo:

, , . , . , N -. :

  • FIR, N . N .
  • N , (, , 5 )

FIFO ( ), ( templatetypedef , ). , 2 ; . , ; . , . :

  • One object produces data, and the other must process it, but processing cannot occur on time or at the same time as the data producer. As a queue at the post office.
  • Messages are sent from one system to another. order is important and no one should be lost.
0
source

Source: https://habr.com/ru/post/1536796/


All Articles