diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-06-17 10:33:00 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-06-17 10:33:00 +0100 |
commit | 79c78f47e0dba7170a888fa47e8f558e29f13fee (patch) | |
tree | 5933024b72e7c582365bdc5b7706f998e57f79f7 /src/rabbit_queue_index.erl | |
parent | 0d6873ff8b5a3e297113dc1125bb53c8f2ac1a67 (diff) | |
download | rabbitmq-server-79c78f47e0dba7170a888fa47e8f558e29f13fee.tar.gz |
get rid of vq:read_one_index_segment
The purpose of the function was to keep reading until either some
data was found or the end was reached. However, both call sites
contain loops already that effectively do the same, making the
function redundant.
There is also a small tweak to the qi:read API - it now returns the
"next seq id to read". Previously it was returning 'undefined' when
the requested (exclusive) End was inside the same segment as the
Start, so now we simply return that End in that case.
Diffstat (limited to 'src/rabbit_queue_index.erl')
-rw-r--r-- | src/rabbit_queue_index.erl | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 5f94cf9d..d062c4fd 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -196,8 +196,7 @@ -spec(sync/2 :: ([seq_id()], qistate()) -> qistate()). -spec(flush/1 :: (qistate()) -> qistate()). -spec(read/3 :: (seq_id(), seq_id(), qistate()) -> - {[{guid(), seq_id(), boolean(), boolean()}], - seq_id() | 'undefined', qistate()}). + {[{guid(), seq_id(), boolean(), boolean()}], seq_id(), qistate()}). -spec(next_segment_boundary/1 :: (seq_id()) -> seq_id()). -spec(bounds/1 :: (qistate()) -> {non_neg_integer(), non_neg_integer(), qistate()}). @@ -282,17 +281,17 @@ flush(State = #qistate { dirty_count = 0 }) -> State; flush(State) -> flush_journal(State). read(StartEnd, StartEnd, State) -> - {[], undefined, State}; + {[], StartEnd, State}; read(Start, End, State = #qistate { segments = Segments, dir = Dir }) when Start =< End -> %% Start is inclusive, End is exclusive. {StartSeg, StartRelSeq} = seq_id_to_seg_and_rel_seq_id(Start), {EndSeg, EndRelSeq} = seq_id_to_seg_and_rel_seq_id(End), Start1 = reconstruct_seq_id(StartSeg + 1, 0), - Again = case End =< Start1 of - true -> undefined; - false -> Start1 - end, + Next = case End =< Start1 of + true -> End; + false -> Start1 + end, MaxRelSeq = case StartSeg =:= EndSeg of true -> EndRelSeq; false -> ?SEGMENT_ENTRY_COUNT @@ -307,7 +306,7 @@ read(Start, End, State = #qistate { segments = Segments, Acc end, [], Segment), Segments1 = segment_store(Segment, Segments), - {Messages, Again, State #qistate { segments = Segments1 }}. + {Messages, Next, State #qistate { segments = Segments1 }}. next_segment_boundary(SeqId) -> {Seg, _RelSeq} = seq_id_to_seg_and_rel_seq_id(SeqId), |