/** * The bucket that the xor of the key goes in * Caller must hold read lock * @return null if key is us */ private KBucket<T> getBucket(T key) { int bucket = pickBucket(key); if (bucket < 0) return null; return _buckets.get(bucket); }
getReadLock(); try { int start = pickBucket(key);
/** * The bucket number (NOT the range number) that the xor of the key goes in * Caller must hold read lock * @return 0 to max-1 or -1 for us */ private int pickBucket(T key) { int range = getRange(key); if (range < 0) return -1; int rv = pickBucket(range); if (rv >= 0) { return rv; } _log.error("Key does not fit in any bucket?!\nKey : [" + DataHelper.toHexString(key.getData()) + "]" + "\nUs : " + _us + "\nDelta: [" + DataHelper.toHexString(DataHelper.xor(_us.getData(), key.getData())) + "]", new Exception("???")); _log.error(toString()); throw new IllegalStateException("pickBucket returned " + rv); //return -1; }
int b = pickBucket(r); while (shouldSplit(_buckets.get(b))) { KBucket<T> b0 = _buckets.get(b);