private static void bisectTokeRange ( DeepTokenRange range , final IPartitioner partitioner , final int bisectFactor , final List < DeepTokenRange > accumulator ) { final AbstractType tkValidator = partitioner . getTokenValidator ( ) ; Token leftToken = partitioner . getTokenFactory ( ) . fromByteArray ( tkValidator . decompose ( range . getStartToken ( ) ) ) ; Token rightToken = partitioner . getTokenFactory ( ) . fromByteArray ( tkValidator . decompose ( range . getEndToken ( ) ) ) ; Token midToken = partitioner . midpoint ( leftToken , rightToken ) ; Comparable midpoint = ( Comparable ) tkValidator . compose ( tkValidator . fromString ( midToken . toString ( ) ) ) ; DeepTokenRange left = new DeepTokenRange ( range . getStartToken ( ) , midpoint , range . getReplicas ( ) ) ; DeepTokenRange right = new DeepTokenRange ( midpoint , range . getEndToken ( ) , range . getReplicas ( ) ) ; if ( bisectFactor / 2 <= 1 ) { accumulator . add ( left ) ; accumulator . add ( right ) ; } else { bisectTokeRange ( left , partitioner , bisectFactor / 2 , accumulator ) ; bisectTokeRange ( right , partitioner , bisectFactor / 2 , accumulator ) ; } }
Recursive function that splits a given token range to a given number of token ranges .