@@ -103,15 +103,19 @@ fresh(NumPartitions, SeedNode) ->
103103 Inc = ring_increment (NumPartitions ),
104104 {NumPartitions ,
105105 [{IndexAsInt , SeedNode }
106- || IndexAsInt <- lists :seq (0 , (? RINGTOP ) - 1 - (? RINGTOP rem NumPartitions ), Inc )]}.
106+ || IndexAsInt
107+ <- lists :seq (0 ,
108+ (? RINGTOP ) - 1 - (? RINGTOP ) rem NumPartitions ,
109+ Inc )]}.
107110
108111% % @doc Find the Node that owns the partition identified by IndexAsInt.
109112-spec lookup (IndexAsInt :: index_as_int (),
110113 CHash :: chash ()) -> chash_node ().
111114
112115lookup (IndexAsInt , CHash ) ->
113116 {_NumPartitions , NodeEntries } = CHash ,
114- {IndexAsInt , Node } = proplists :lookup (IndexAsInt , NodeEntries ),
117+ {IndexAsInt , Node } = proplists :lookup (IndexAsInt ,
118+ NodeEntries ),
115119 Node .
116120
117121sha (Bin ) -> crypto :hash (sha , Bin ).
@@ -141,7 +145,8 @@ merge_rings(CHashA, CHashB) ->
141145 {NumPartitions , NodeEntriesB } = CHashB ,
142146 {NumPartitions ,
143147 [{I , random_node (NodeA , NodeB )}
144- || {{I , NodeA }, {I , NodeB }} <- lists :zip (NodeEntriesA , NodeEntriesB )]}.
148+ || {{I , NodeA }, {I , NodeB }}
149+ <- lists :zip (NodeEntriesA , NodeEntriesB )]}.
145150
146151% % @doc Given the integer representation of a chash key,
147152% % return the next ring index integer value.
@@ -166,7 +171,10 @@ nodes(CHash) ->
166171ordered_from (Index , {NumPartitions , NodeEntries }) ->
167172 <<IndexAsInt :160 /integer >> = Index ,
168173 Inc = ring_increment (NumPartitions ),
169- {NodeEntriesA , NodeEntriesB } = lists :split (IndexAsInt div Inc + 1 , NodeEntries ),
174+ {NodeEntriesA , NodeEntriesB } = lists :split (IndexAsInt
175+ div Inc
176+ + 1 ,
177+ NodeEntries ),
170178 NodeEntriesB ++ NodeEntriesA .
171179
172180% % @doc Given an object key, return all NodeEntries in reverse order
@@ -236,9 +244,9 @@ successors(Index, CHash, N) ->
236244update (IndexAsInt , Name , CHash ) ->
237245 {NumPartitions , NodeEntries } = CHash ,
238246 NewNodeEntries = lists :keyreplace (IndexAsInt ,
239- 1 ,
240- NodeEntries ,
241- {IndexAsInt , Name }),
247+ 1 ,
248+ NodeEntries ,
249+ {IndexAsInt , Name }),
242250 {NumPartitions , NewNodeEntries }.
243251
244252% % ====================================================================
@@ -268,9 +276,12 @@ random_node(NodeA, NodeB) ->
268276-ifdef (TEST ).
269277
270278fresh_sizes_test () ->
271- lists :foreach (fun (I ) ->
272- ? assertEqual (I , (length (chash :nodes (chash :fresh (I , the_node )))))
273- end , [1 , 10000 ]).
279+ lists :foreach (fun (I ) ->
280+ ? assertEqual (I ,
281+ (length (chash :nodes (chash :fresh (I ,
282+ the_node )))))
283+ end ,
284+ [1 , 10000 ]).
274285
275286update_test () ->
276287 Node = old@host ,
@@ -281,14 +292,13 @@ update_test() ->
281292 {Index , _ } = lists :nth (N , NodeEntries ),
282293 Index
283294 end ,
284-
285295 {5 ,
286296 [{_ , Node },
287297 {_ , Node },
288298 {_ , Node },
289299 {_ , Node },
290- {_ , Node }]} = CHash ,
291-
300+ {_ , Node }]} =
301+ CHash ,
292302 % Test update...
293303 FirstIndex = GetNthIndex (1 , CHash ),
294304 ThirdIndex = GetNthIndex (3 , CHash ),
0 commit comments