]> granicus.if.org Git - ejabberd/commitdiff
Refactor pubsub's get_last_items
authorChristophe Romain <christophe.romain@process-one.net>
Thu, 30 Mar 2017 12:26:30 +0000 (14:26 +0200)
committerChristophe Romain <christophe.romain@process-one.net>
Thu, 30 Mar 2017 12:26:30 +0000 (14:26 +0200)
17 files changed:
include/pubsub.hrl
src/gen_pubsub_node.erl
src/mod_pubsub.erl
src/node_buddy.erl
src/node_club.erl
src/node_dag.erl
src/node_dispatch.erl
src/node_flat.erl
src/node_flat_sql.erl
src/node_hometree.erl
src/node_mb.erl
src/node_mix.erl
src/node_mix_sql.erl
src/node_online.erl
src/node_pep.erl
src/node_private.erl
src/node_public.erl

index b2bc05c99bd512d8899e9318fb21f72805ef387e..86cdb515d5bc9d01d4d856adc421335b3fdb4b1c 100644 (file)
 -record(pubsub_state,
 {
     stateid               ,% :: {jlib:ljid(), mod_pubsub:nodeIdx()},
+    nodeidx               ,% :: mod_pubsub:nodeIdx(),
     items         = []    ,% :: [mod_pubsub:itemId(),...],
     affiliation   = 'none',% :: mod_pubsub:affiliation(),
     subscriptions = []    % :: [{mod_pubsub:subscription(), mod_pubsub:subId()}]
 -record(pubsub_item,
 {
     itemid                           ,% :: {mod_pubsub:itemId(), mod_pubsub:nodeIdx()},
+    nodeidx                          ,% :: mod_pubsub:nodeIdx(),
     creation     = {unknown, unknown},% :: {erlang:timestamp(), jlib:ljid()},
     modification = {unknown, unknown},% :: {erlang:timestamp(), jlib:ljid()},
     payload      = []                % :: mod_pubsub:payload()
index 477fafc46fcd327dfbccf32cdc77658511131a38..4f516bd58d8153cdaa52ad0bd0fe525dfa7e97d6 100644 (file)
 -callback get_items(nodeIdx(), jid(), undefined | rsm_set()) ->
     {result, {[pubsubItem()], undefined | rsm_set()}}.
 
+-callback get_last_items(nodeIdx(), jid(), undefined | rsm_set()) ->
+    {result, {[pubsubItem()], undefined | rsm_set()}}.
+
 -callback get_item(NodeIdx :: nodeIdx(),
        ItemId :: itemId(),
        JID :: jid(),
index 6218af227b7071774e22c1a905d1f35557615e2b..e9d9769a5649e81666ac2f282fcfe1fbc761e93c 100644 (file)
 -type(pubsubState() ::
     #pubsub_state{
        stateid       :: {Entity::ljid(), Nidx::mod_pubsub:nodeIdx()},
+       nodeidx       :: Nidx::mod_pubsub:nodeIdx(),
        items         :: [ItemId::mod_pubsub:itemId()],
        affiliation   :: Affs::mod_pubsub:affiliation(),
        subscriptions :: [{Sub::mod_pubsub:subscription(), SubId::mod_pubsub:subId()}]
 -type(pubsubItem() ::
     #pubsub_item{
        itemid       :: {ItemId::mod_pubsub:itemId(), Nidx::mod_pubsub:nodeIdx()},
+       nodeidx      :: Nidx::mod_pubsub:nodeIdx(),
        creation     :: {erlang:timestamp(), ljid()},
        modification :: {erlang:timestamp(), ljid()},
        payload      :: mod_pubsub:payload()
@@ -2165,48 +2167,21 @@ get_allowed_items_call(Host, Nidx, From, Type, Options, Owners, RSM) ->
     {PS, RG} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
     node_call(Host, Type, get_items, [Nidx, From, AccessModel, PS, RG, undefined, RSM]).
 
-get_last_item(Host, Type, Nidx, LJID) ->
-    case get_cached_item(Host, Nidx) of
-       undefined -> get_last_item(Host, Type, Nidx, LJID, gen_mod:db_type(serverhost(Host), ?MODULE));
-       LastItem -> LastItem
-    end.
-get_last_item(Host, Type, Nidx, LJID, mnesia) ->
-    case node_action(Host, Type, get_items, [Nidx, LJID, undefined]) of
-       {result, {[LastItem|_], _}} -> LastItem;
-       _ -> undefined
-    end;
-get_last_item(Host, Type, Nidx, LJID, sql) ->
-    case node_action(Host, Type, get_last_items, [Nidx, LJID, 1]) of
-       {result, [LastItem]} -> LastItem;
-       _ -> undefined
-    end;
-get_last_item(_Host, _Type, _Nidx, _LJID, _) ->
-    undefined.
-
-get_last_items(Host, Type, Nidx, LJID, Number) ->
-    get_last_items(Host, Type, Nidx, LJID, Number, gen_mod:db_type(serverhost(Host), ?MODULE)).
-get_last_items(Host, Type, Nidx, LJID, Number, mnesia) ->
-    case node_action(Host, Type, get_items, [Nidx, LJID, undefined]) of
-       {result, {Items, _}} -> lists:sublist(Items, Number);
-       _ -> []
-    end;
-get_last_items(Host, Type, Nidx, LJID, Number, sql) ->
-    case node_action(Host, Type, get_last_items, [Nidx, LJID, Number]) of
+get_last_items(Host, Type, Nidx, LJID, Count) ->
+    case node_action(Host, Type, get_last_items, [Nidx, LJID, Count]) of
        {result, Items} -> Items;
        _ -> []
-    end;
-get_last_items(_Host, _Type, _Nidx, _LJID, _Number, _) ->
-    [].
+    end.
 
 %% @doc <p>Resend the items of a node to the user.</p>
 %% @todo use cache-last-item feature
 send_items(Host, Node, Nidx, Type, Options, LJID, last) ->
-    case get_last_item(Host, Type, Nidx, LJID) of
-       undefined ->
-           ok;
-       LastItem ->
+    case get_last_items(Host, Type, Nidx, LJID, 1) of
+       [LastItem] ->
            Stanza = items_event_stanza(Node, Options, [LastItem]),
-           dispatch_items(Host, LJID, Node, Stanza)
+           dispatch_items(Host, LJID, Node, Stanza);
+       _ ->
+           ok
     end;
 send_items(Host, Node, Nidx, Type, Options, LJID, Number) when Number > 0 ->
     Stanza = items_event_stanza(Node, Options, get_last_items(Host, Type, Nidx, Number, LJID)),
@@ -2566,28 +2541,21 @@ get_subscriptions(Host, Node, JID) ->
            Error
     end.
 
-get_subscriptions_for_send_last(Host, PType, mnesia, JID, LJID, BJID) ->
+get_subscriptions_for_send_last(Host, PType, sql, JID, LJID, BJID) ->
+    {result, Subs} = node_action(Host, PType,
+           get_entity_subscriptions_for_send_last,
+           [Host, JID]),
+    [{Node, Sub, SubId, SubJID}
+       || {Node, Sub, SubId, SubJID} <- Subs,
+           Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID)];
+get_subscriptions_for_send_last(Host, PType, _, JID, LJID, BJID) ->
     {result, Subs} = node_action(Host, PType,
            get_entity_subscriptions,
            [Host, JID]),
     [{Node, Sub, SubId, SubJID}
        || {Node, Sub, SubId, SubJID} <- Subs,
            Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID),
-           match_option(Node, send_last_published_item, on_sub_and_presence)];
-get_subscriptions_for_send_last(Host, PType, sql, JID, LJID, BJID) ->
-    case catch node_action(Host, PType,
-           get_entity_subscriptions_for_send_last,
-           [Host, JID])
-    of
-       {result, Subs} ->
-           [{Node, Sub, SubId, SubJID}
-               || {Node, Sub, SubId, SubJID} <- Subs,
-                   Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID)];
-       _ ->
-           []
-    end;
-get_subscriptions_for_send_last(_Host, _PType, _, _JID, _LJID, _BJID) ->
-    [].
+           match_option(Node, send_last_published_item, on_sub_and_presence)].
 
 -spec set_subscriptions(host(), binary(), jid(), [ps_subscription()]) ->
                               {result, undefined} | {error, stanza_error()}.
@@ -3202,28 +3170,18 @@ filter_node_options(Options, BaseOptions) ->
 
 -spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].
 node_owners_action(Host, Type, Nidx, []) ->
-    case gen_mod:db_type(serverhost(Host), ?MODULE) of
-       sql ->
-           case node_action(Host, Type, get_node_affiliations, [Nidx]) of
-               {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
-               _ -> []
-           end;
-       _ ->
-           []
+    case node_action(Host, Type, get_node_affiliations, [Nidx]) of
+       {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
+       _ -> []
     end;
 node_owners_action(_Host, _Type, _Nidx, Owners) ->
     Owners.
 
 -spec node_owners_call(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].
 node_owners_call(Host, Type, Nidx, []) ->
-    case gen_mod:db_type(serverhost(Host), ?MODULE) of
-       sql ->
-           case node_call(Host, Type, get_node_affiliations, [Nidx]) of
-               {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
-               _ -> []
-           end;
-       _ ->
-           []
+    case node_call(Host, Type, get_node_affiliations, [Nidx]) of
+       {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner];
+       _ -> []
     end;
 node_owners_call(_Host, _Type, _Nidx, Owners) ->
     Owners.
@@ -3468,23 +3426,15 @@ tree(Host) ->
        Tree -> Tree
     end.
 
--spec tree(host(), binary() | atom()) -> atom().
+-spec tree(host(), binary()) -> atom().
 tree(_Host, <<"virtual">>) ->
     nodetree_virtual;   % special case, virtual does not use any backend
 tree(Host, Name) ->
-    case gen_mod:db_type(serverhost(Host), ?MODULE) of
-       mnesia -> aux:binary_to_atom(<<"nodetree_", Name/binary>>);
-       sql -> aux:binary_to_atom(<<"nodetree_", Name/binary, "_sql">>);
-       _ -> Name
-    end.
+    submodule(Host, <<"nodetree_", Name/binary>>).
 
--spec plugin(host(), binary() | atom()) -> atom().
+-spec plugin(host(), binary()) -> atom().
 plugin(Host, Name) ->
-    case gen_mod:db_type(serverhost(Host), ?MODULE) of
-       mnesia -> aux:binary_to_atom(<<"node_", Name/binary>>);
-       sql -> aux:binary_to_atom(<<"node_", Name/binary, "_sql">>);
-       _ -> Name
-    end.
+    submodule(Host, <<"node_", Name/binary>>).
 
 -spec plugins(host()) -> [binary()].
 plugins(Host) ->
@@ -3494,14 +3444,16 @@ plugins(Host) ->
        Plugins -> Plugins
     end.
 
--spec subscription_plugin(host()) -> pubsub_subscription |
-                                    pubsub_subscription_sql |
-                                    none.
+-spec subscription_plugin(host()) -> atom().
 subscription_plugin(Host) ->
+    submodule(Host, <<"pubsub_subscription">>).
+
+-spec submodule(host(), binary()) -> atom().
+submodule(Host, Name) ->
     case gen_mod:db_type(serverhost(Host), ?MODULE) of
-       mnesia -> pubsub_subscription;
-       sql -> pubsub_subscription_sql;
-       _ -> none
+       mnesia -> aux:binary_to_atom(Name);
+       Type -> aux:binary_to_atom(<<Name/binary, "_",
+                   (jlib:atom_to_binary(Type))/binary>>)
     end.
 
 -spec config(binary(), any()) -> any().
@@ -3614,9 +3566,14 @@ tree_action(Host, Function, Args) ->
                    {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)}
            end;
        Other ->
-           ?ERROR_MSG("unsupported backend: ~p~n", [Other]),
-           ErrTxt = <<"Database failure">>,
-           {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)}
+           case catch Fun() of
+               {'EXIT', _} ->
+                   ?ERROR_MSG("unsupported backend: ~p~n", [Other]),
+                   ErrTxt = <<"Database failure">>,
+                   {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)};
+               Result ->
+                   Result
+           end
     end.
 
 %% @doc <p>node plugin call.</p>
@@ -3684,7 +3641,7 @@ transaction_retry(Host, ServerHost, Fun, Trans, DBType, Count) ->
            end,
            catch ejabberd_sql:SqlFun(ServerHost, Fun);
        _ ->
-           {unsupported, DBType}
+           catch Fun()
     end,
     case Res of
        {result, Result} ->
index a01332b675339ef3deef1c4a3c896fa75dc77efd..6f126518c37cf3a579097b40802a93e7313ad64b 100644 (file)
@@ -39,6 +39,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -157,6 +158,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index 54ee5d7632387edbbbfe68474523729220ce4d55..2f674760d9adf88229bff05dacffda7b5d5803fa 100644 (file)
@@ -39,6 +39,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index c81b2bc80598b16fc354d262152824c651e0a047..9829c27cbe35d5cc0fc0fa638ac25c391ad3c14d 100644 (file)
@@ -40,6 +40,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -144,6 +145,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_hometree:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_hometree:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_hometree:get_item(Nidx, ItemId).
 
index bde20e7727e633785530284098cb57dd52e5819d..92a655b8b60475563717e7f8dddf8a4d00522357 100644 (file)
@@ -46,6 +46,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -170,6 +171,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_hometree:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_hometree:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_hometree:get_item(Nidx, ItemId).
 
index 90785842896c3d0847a28ac492b85052fc84ef19..3989e0d943600fef5c25ca874f370c6822fe4791 100644 (file)
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
-    path_to_node/1, can_fetch_item/2, is_subscribed/1]).
+    path_to_node/1, can_fetch_item/2, is_subscribed/1, transform/1]).
 
 init(_Host, _ServerHost, _Opts) ->
     %pubsub_subscription:init(Host, ServerHost, Opts),
     ejabberd_mnesia:create(?MODULE, pubsub_state,
-       [{disc_copies, [node()]},
+       [{disc_copies, [node()]}, {index, [nodeidx]},
            {type, ordered_set},
            {attributes, record_info(fields, pubsub_state)}]),
     ejabberd_mnesia:create(?MODULE, pubsub_item,
-       [{disc_only_copies, [node()]},
+       [{disc_only_copies, [node()]}, {index, [nodeidx]},
            {attributes, record_info(fields, pubsub_item)}]),
     ejabberd_mnesia:create(?MODULE, pubsub_orphan,
        [{disc_copies, [node()]},
@@ -131,7 +132,7 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
 create_node(Nidx, Owner) ->
     OwnerKey = jid:tolower(jid:remove_resource(Owner)),
     set_state(#pubsub_state{stateid = {OwnerKey, Nidx},
-           affiliation = owner}),
+           nodeidx = Nidx, affiliation = owner}),
     {result, {default, broadcast}}.
 
 delete_node(Nodes) ->
@@ -382,6 +383,7 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload,
                                payload = Payload};
                        _ ->
                            #pubsub_item{itemid = {ItemId, Nidx},
+                               nodeidx = Nidx,
                                creation = {Now, GenKey},
                                modification = PubId,
                                payload = Payload}
@@ -681,8 +683,7 @@ get_nodes_helper(NodeTree, #pubsub_state{stateid = {_, N}, subscriptions = Subs}
 %% ```get_states(Nidx) ->
 %%           node_default:get_states(Nidx).'''</p>
 get_states(Nidx) ->
-    States = case catch mnesia:match_object(
-           #pubsub_state{stateid = {'_', Nidx}, _ = '_'}) of
+    States = case catch mnesia:index_read(pubsub_state, Nidx, #pubsub_state.nodeidx) of
        List when is_list(List) -> List;
        _ -> []
     end,
@@ -693,7 +694,7 @@ get_state(Nidx, Key) ->
     StateId = {Key, Nidx},
     case catch mnesia:read({pubsub_state, StateId}) of
        [State] when is_record(State, pubsub_state) -> State;
-       _ -> #pubsub_state{stateid = StateId}
+       _ -> #pubsub_state{stateid = StateId, nodeidx = Nidx}
     end.
 
 %% @doc <p>Write a state into database.</p>
@@ -725,7 +726,7 @@ del_state(#pubsub_state{stateid = {Key, Nidx}, items = Items}) ->
 %% <p>PubSub plugins can store the items where they wants (for example in a
 %% relational database), or they can even decide not to persist any items.</p>
 get_items(Nidx, _From, _RSM) ->
-    Items = mnesia:match_object(#pubsub_item{itemid = {'_', Nidx}, _ = '_'}),
+    Items = mnesia:index_read(pubsub_item, Nidx, #pubsub_item.nodeidx),
     {result, {lists:reverse(lists:keysort(#pubsub_item.modification, Items)), undefined}}.
 
 get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) ->
@@ -764,6 +765,12 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
            get_items(Nidx, JID, RSM)
     end.
 
+get_last_items(Nidx, From, Count) when Count > 0 ->
+    {result, {Items, _}} = get_items(Nidx, From, undefined),
+    {result, lists:sublist(Items, Count)};
+get_last_items(_Nidx, _From, _Count) ->
+    {result, []}.
+
 %% @doc <p>Returns an item (one item list), given its reference.</p>
 
 get_item(Nidx, ItemId) ->
@@ -868,3 +875,10 @@ first_in_list(Pred, [H | T]) ->
        true -> {value, H};
        _ -> first_in_list(Pred, T)
     end.
+
+transform({pubsub_state, {Id, Nidx}, Is, A, Ss}) ->
+    {pubsub_state, {Id, Nidx}, Nidx, Is, A, Ss};
+transform({pubsub_item, {Id, Nidx}, C, M, P}) ->
+    {pubsub_item, {Id, Nidx}, Nidx, C, M, P};
+transform(Rec) ->
+    Rec.
index e133a8e73331f7288b2c4eae378571fb4a997ef2..8127d2619a343f7203ce8f914a88bee08ac77911 100644 (file)
@@ -615,10 +615,11 @@ get_state_without_itemids(Nidx, JID) ->
                "where nodeid=%(Nidx)d and jid=%(J)s")) of
        {selected, [{SJID, Aff, Subs}]} ->
            #pubsub_state{stateid = {decode_jid(SJID), Nidx},
+                         nodeidx = Nidx,
                          affiliation = decode_affiliation(Aff),
                          subscriptions = decode_subscriptions(Subs)};
        _ ->
-           #pubsub_state{stateid = {JID, Nidx}}
+           #pubsub_state{stateid = {JID, Nidx}, nodeidx = Nidx}
     end.
 
 set_state(State) ->
index 1255c3d5f9bc90f09404e2846abb4323b47db99e..ddefa30cf849c2c3f4b8b1b792cd08405198ac05 100644 (file)
@@ -39,6 +39,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -154,6 +155,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index 04370f61fd6636362c551eaf6f84eb6c867d68b9..132060319cc2507ec9dd046cc8028bb13c91767f 100644 (file)
@@ -53,6 +53,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -171,6 +172,9 @@ get_items(Nidx, From, RSM) ->
 get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
     node_pep:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_pep:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_pep:get_item(Nidx, ItemId).
 
index 485782a9cfefe81877f66095db2ce086e13a8c20..2d394aaa62aeb819da3c3fb17c543106464c10a2 100644 (file)
@@ -37,6 +37,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -161,6 +162,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index de7319fa7a19c6cb94c9c1494910254bc2d865fe..5ba2cd21d7e5f5d11664c45b05de513e8563addc 100644 (file)
@@ -37,6 +37,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1, get_entity_subscriptions_for_send_last/2]).
 
@@ -161,6 +162,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat_sql:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat_sql:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat_sql:get_item(Nidx, ItemId).
 
index 56357a6521cbfe35105719165a81f96739062372..39b08d992356790620509407abc35c53ee4881f8 100644 (file)
@@ -40,6 +40,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index c79df4e15985706a1d01c1ee75bc26fda89b2a6b..6dd7a68c4d98826bcb63e2b83862039a99985ea4 100644 (file)
@@ -43,6 +43,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1, depends/3]).
 
@@ -228,6 +229,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index 6cf50bfc28ee4493550266e53fcbae1f6c9f7df9..9738d3b86a963f8c713ac6ea2a02924bd67bf6e3 100644 (file)
@@ -39,6 +39,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).
 
index 84e71590e82df5c7e9716ba0299012b265020667..bfa45230dc297a504629dc98b6e89a8b45d4ba56 100644 (file)
@@ -39,6 +39,7 @@
     get_subscriptions/2, set_subscriptions/4,
     get_pending_nodes/2, get_states/1, get_state/2,
     set_state/1, get_items/7, get_items/3, get_item/7,
+    get_last_items/3,
     get_item/2, set_item/1, get_item_name/3, node_to_path/1,
     path_to_node/1]).
 
@@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM)
     node_flat:get_items(Nidx, JID, AccessModel,
        PresenceSubscription, RosterGroup, SubId, RSM).
 
+get_last_items(Nidx, From, Count) ->
+    node_flat:get_last_items(Nidx, From, Count).
+
 get_item(Nidx, ItemId) ->
     node_flat:get_item(Nidx, ItemId).