summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsylvainhubsch <sylvain.hubsch@gmail.com>2018-02-11 12:05:08 -0800
committerMichael Klishin <mklishin@pivotal.io>2018-02-13 16:19:56 +0300
commit2254c8fa377fb891d7c3c6e2e2e44152eab9fdcf (patch)
treeb4b0caac6d5a15a27c0e25a6e5c3bdad4017e52b
parente6e34651d220f45eb49e66a4017ef15a1e8f6799 (diff)
downloadrabbitmq-server-git-2254c8fa377fb891d7c3c6e2e2e44152eab9fdcf.tar.gz
rabbit_router:match_bindings/2 optimize (uses ets:select directly); improves rabbit_exchange_type_headers, should improves rabbitmq_jms_topic_exchange too
(cherry picked from commit 6ff1fb788a795a08dd98b5c925e44422886691ad)
-rw-r--r--src/rabbit_router.erl17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl
index 1f3017fa07..aaa2f1e170 100644
--- a/src/rabbit_router.erl
+++ b/src/rabbit_router.erl
@@ -36,17 +36,14 @@
%%----------------------------------------------------------------------------
-%% TODO: Maybe this should be handled by a cursor instead.
-%% TODO: This causes a full scan for each entry with the same source
+%% No need to call mnesia:dirty_select/2 (cf. note below), let alone go
+%% through qlc because query is so simple !
match_bindings(SrcName, Match) ->
- Query = qlc:q([DestinationName ||
- #route{binding = Binding = #binding{
- source = SrcName1,
- destination = DestinationName}} <-
- mnesia:table(rabbit_route),
- SrcName == SrcName1,
- Match(Binding)]),
- mnesia:async_dirty(fun qlc:e/1, [Query]).
+ MatchHead = #route{binding = #binding{source = SrcName,
+ _ = '_'}},
+ Routes = ets:select(rabbit_route, [{MatchHead, [], [['$_']]}]),
+ [ Dest || [#route{binding = Binding = #binding{destination = Dest}}] <-
+ Routes, Match(Binding)].
match_routing_key(SrcName, [RoutingKey]) ->
find_routes(#route{binding = #binding{source = SrcName,