Updated Branches: refs/heads/trunk a3734e54b -> a583123e8
remove unused field RandomPartitioner.DELIMITER_BYTE Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a583123e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a583123e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a583123e Branch: refs/heads/trunk Commit: a583123e8a8c07d5cd1fee06cb1a15af267eeee0 Parents: a3734e5 Author: Dave Brosius <dbros...@apache.org> Authored: Wed May 22 21:55:35 2013 -0400 Committer: Dave Brosius <dbros...@apache.org> Committed: Wed May 22 21:55:35 2013 -0400 ---------------------------------------------------------------------- .../apache/cassandra/dht/RandomPartitioner.java | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/a583123e/src/java/org/apache/cassandra/dht/RandomPartitioner.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/dht/RandomPartitioner.java b/src/java/org/apache/cassandra/dht/RandomPartitioner.java index 15453ba..c9ddccf 100644 --- a/src/java/org/apache/cassandra/dht/RandomPartitioner.java +++ b/src/java/org/apache/cassandra/dht/RandomPartitioner.java @@ -40,8 +40,6 @@ public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken> public static final BigIntegerToken MINIMUM = new BigIntegerToken("-1"); public static final BigInteger MAXIMUM = new BigInteger("2").pow(127); - private static final byte DELIMITER_BYTE = ":".getBytes()[0]; - public DecoratedKey decorateKey(ByteBuffer key) { return new DecoratedKey(getToken(key), key); @@ -128,23 +126,23 @@ public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken> public Map<Token, Float> describeOwnership(List<Token> sortedTokens) { Map<Token, Float> ownerships = new HashMap<Token, Float>(); - Iterator i = sortedTokens.iterator(); + Iterator<Token> i = sortedTokens.iterator(); // 0-case if (!i.hasNext()) { throw new RuntimeException("No nodes present in the cluster. Has this node finished starting up?"); } // 1-case if (sortedTokens.size() == 1) { - ownerships.put((Token)i.next(), new Float(1.0)); + ownerships.put(i.next(), new Float(1.0)); } // n-case else { // NOTE: All divisions must take place in BigDecimals, and all modulo operators must take place in BigIntegers. final BigInteger ri = MAXIMUM; // (used for addition later) final BigDecimal r = new BigDecimal(ri); // The entire range, 2**127 - Token start = (Token)i.next(); BigInteger ti = ((BigIntegerToken)start).token; // The first token and its value + Token start = i.next(); BigInteger ti = ((BigIntegerToken)start).token; // The first token and its value Token t; BigInteger tim1 = ti; // The last token and its value (after loop) while (i.hasNext()) { - t = (Token)i.next(); ti = ((BigIntegerToken)t).token; // The next token and its value + t = i.next(); ti = ((BigIntegerToken)t).token; // The next token and its value float x = new BigDecimal(ti.subtract(tim1).add(ri).mod(ri)).divide(r).floatValue(); // %age = ((T(i) - T(i-1) + R) % R) / R ownerships.put(t, x); // save (T(i) -> %age) tim1 = ti; // -> advance loop