4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
1053
1053
wl(Cs, Type, delete, Lookup, 1, [{Object,-1}]);
1054
1054
wl([{_Seq, {insert, Object}} | Cs], Type, Del, Lookup, _I, Objs) ->
1056
case lists:keysearch(Object, 1, Objs) of
1056
case lists:keyfind(Object, 1, Objs) of
1058
1058
lists:keyreplace(Object, 1, Objs, {Object,-1});
1059
{value, {_, _C}} when Type =:= bag -> % C =:= 1; C =:= -1
1059
{_, _C} when Type =:= bag -> % C =:= 1; C =:= -1
1061
{value, {_, C}} when C < 0 -> % when Type =:= duplicate_bag
1061
{_, C} when C < 0 -> % when Type =:= duplicate_bag
1062
1062
lists:keyreplace(Object, 1, Objs, {Object,C-1});
1063
{value, {_, C}} -> % when C > 0, Type =:= duplicate_bag
1063
{_, C} -> % when C > 0, Type =:= duplicate_bag
1064
1064
lists:keyreplace(Object, 1, Objs, {Object,C+1});
1065
1065
false when Del =:= delete ->
1066
1066
[{Object, -1} | Objs];
1258
1258
find_key(Head, Pos, NextPos, Size, Term, Key, WLs, L, LU).
1260
1260
find_key(Head, Pos, NextPos, Size, Term, Key, WLs, L, LU) ->
1261
case lists:keysearch(Key, 1, WLs) of
1262
{value, {_, {Delete, LookUp, Objects}} = WL} ->
1261
case lists:keyfind(Key, 1, WLs) of
1262
{_, {Delete, LookUp, Objects}} = WL ->
1263
1263
NWLs = lists:delete(WL, WLs),
1264
1264
{NewObjects, NL, LUK} = eval_object(Size, Term, Delete, LookUp,
1265
1265
Objects, Head, Pos, L, []),
1297
1297
%% All objects in Objects have the key Key.
1298
1298
eval_object(Size, Term, Delete, LookUp, Objects, Head, Pos, L, LU) ->
1299
1299
Type = Head#head.type,
1300
case lists:keysearch(Term, 1, Objects) of
1301
{value, {_Object, N}} when N =:= 0 ->
1300
case lists:keyfind(Term, 1, Objects) of
1301
{_Object, N} when N =:= 0 ->
1302
1302
L1 = [{delete,Pos,Size} | L],
1303
1303
{Objects, L1, LU};
1304
{value, {_Object, N}} when N < 0, Type =:= set ->
1304
{_Object, N} when N < 0, Type =:= set ->
1305
1305
L1 = [{old,Pos} | L],
1306
1306
wl_lookup(LookUp, Objects, Term, L1, LU);
1307
{value, {Object, _N}} when Type =:= bag -> % when N =:= 1; N =:= -1
1307
{Object, _N} when Type =:= bag -> % when N =:= 1; N =:= -1
1308
1308
L1 = [{old,Pos} | L],
1309
1309
Objects1 = lists:keydelete(Object, 1, Objects),
1310
1310
wl_lookup(LookUp, Objects1, Term, L1, LU);
1311
{value, {Object, N}} when N < 0, Type =:= duplicate_bag ->
1311
{Object, N} when N < 0, Type =:= duplicate_bag ->
1312
1312
L1 = [{old,Pos} | L],
1313
1313
Objects1 = lists:keyreplace(Object, 1, Objects, {Object,N+1}),
1314
1314
wl_lookup(LookUp, Objects1, Term, L1, LU);
1315
{value, {_Object, N}} when N > 0, Type =:= duplicate_bag ->
1315
{_Object, N} when N > 0, Type =:= duplicate_bag ->
1316
1316
L1 = [{old,Pos} | L],
1317
1317
wl_lookup(LookUp, Objects, Term, L1, LU);
1318
1318
false when Type =:= set, Delete =:= delete ->
1319
case lists:keysearch(-1, 2, Objects) of
1319
case lists:keyfind(-1, 2, Objects) of
1320
1320
false -> % no inserted object, perhaps deleted objects
1321
1321
L1 = [{delete,Pos,Size} | L],
1323
{value, {Term2,-1}} ->
1324
1324
Bin2 = term_to_binary(Term2),
1325
1325
NSize = byte_size(Bin2),