diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-05-19 17:58:25 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-05-19 17:58:25 +0100 |
| commit | 69bc3e33a6840e66ef539441d6845024d30d0260 (patch) | |
| tree | 9d38c2ae5069bf3be84a63ac8e7c2e07a248aff8 | |
| parent | d7b87754b8b7ec01e8d4586f754bb6a5636b9a50 (diff) | |
| download | rabbitmq-server-git-69bc3e33a6840e66ef539441d6845024d30d0260.tar.gz | |
more efficient 'bounds' function
This no longer touches the file system. It's still O(n * log n) in the
number of segments though.
| -rw-r--r-- | src/rabbit_queue_index.erl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index e02483ef93..93dce89e05 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -314,17 +314,19 @@ next_segment_boundary(SeqId) -> {Seg, _RelSeq} = seq_id_to_seg_and_rel_seq_id(SeqId), reconstruct_seq_id(Seg + 1, 0). -bounds(State) -> - SegNums = all_segment_nums(State), +bounds(State = #qistate { segments = Segments }) -> + %% This is not particularly efficient, but only gets invoked on + %% queue initialisation and termination. + SegNums = lists:sort(segment_fetch_keys(Segments)), %% Don't bother trying to figure out the lowest seq_id, merely the %% seq_id of the start of the lowest segment. That seq_id may not %% actually exist, but that's fine. The important thing is that %% the segment exists and the seq_id reported is on a segment %% boundary. - + %% %% We also don't really care about the max seq_id. Just start the %% next segment: it makes life much easier. - + %% %% SegNums is sorted, ascending. {LowSeqId, NextSeqId} = case SegNums of |
