1
-module(broken_dialyzer).
3
-export([do_move_next/1]).
5
-define(ap_indices, 512).
6
-define(dp_indices, 504).
9
-record(apR,{a,c=[],n=[],nc=0,nn=0,nl=[]}).
10
-define(apL(L), [#apR{a=A} || A <- L]).
12
-define(gr, get(my_return_value)).
13
-define(pr(PR), put(my_return_value, PR)).
14
-record(bit,{i,c,n,s}). % index, current, next, state
17
do_move_next({BL,AL}) ->
18
Max = max(length(BL), length(AL)),
19
Max2 = max(length(BL)*2, length(AL)),
20
MoveTo = [A || A <- AL, A#apR.nn < Max, A#apR.nn+A#apR.nc < Max2],
21
MoveFrom = [A || A <- AL,
22
(A#apR.nn > Max) orelse (A#apR.nn+A#apR.nc > Max2)],
23
Unchanged = (AL--MoveTo)--MoveFrom,
24
{BL1,{AL1,{AL2,AL3}}} =
26
fun(B=#bit{i=I,c=C,s=S,n=Next}, {From,{To,FilledUp}})
27
when S==ok;S==lost_replica;S==moved_replica ->
28
case lists:keysearch(Next,#apR.a,From) of
29
{value, F=#apR{n=N1,nn=NN1,nc=NC1}}
30
when (NN1>Max) or (NN1+NC1>Max2) ->
33
{B, {From,{To,FilledUp}}};
35
T=#apR{a=NewNext,n=N2,nn=NN2} =
36
find_next(Next,ShortList),
37
{value, {C,NL_from}} =
38
lists:keysearch(C,1,F#apR.nl),
40
lists:keysearch(C,1,T#apR.nl),
41
NewNL_from = lists:keyreplace(
42
C,1,F#apR.nl,{C,NL_from--[I]}),
43
NewNL_to = lists:keyreplace(
44
C,1,T#apR.nl,{C,[I|NL_to]}),
46
NewT = T#apR{n=[I|N2],nn=NN2+1,
58
F#apR{n=N1--[I],nn=NN1-1,nl=NewNL_from}),
60
(NewT#apR.nn+NewT#apR.nc >= Max2)
61
or (NewT#apR.nn >= Max) ->
62
{lists:keydelete(NewNext,#apR.a,To),
66
NewNext,#apR.a,To,NewT),
71
{B, {From,{To,FilledUp}}}
75
end, {MoveFrom,{MoveTo,[]}},BL),
76
{BL1,Unchanged++AL1++AL2++AL3}.
78
%%% -----------------------------------------------------------------
81
%%% ------------------------------------------------------------------
91
lists:keysearch(Ap,1,ApR#apR.nl),
100
lists:seq(0,?ap_indices))).
102
%%% -----------------------------------------------------------------
105
%%% Calculates max number of indices per AP, given number of indices
106
%%% and number of APs.
107
%%% -----------------------------------------------------------------
116
%%% ==============================================================
117
%%% ADMINISTRATIVE INFORMATION
118
%%% ==============================================================
119
%%% #Copyright (C) 2005
120
%%% by ERICSSON TELECOM AB
121
%%% S - 125 26 STOCKHOLM
122
%%% SWEDEN, tel int + 46 8 719 0000
124
%%% The program may be used and/or copied only with the written
125
%%% permission from ERICSSON TELECOM AB, or in accordance with
126
%%% the terms and conditions stipulated in the agreement/contract
127
%%% under which the program has been supplied.
129
%%% All rights reserved