@Override public BigIntegerToken getToken(ByteBuffer key) { ByteBuffer extractedToken = extractSolandraToken(key); if(extractedToken == null) return super.getToken(key); //the token is pre-processed try { return new BigIntegerToken(ByteBufferUtil.string(extractedToken)); } catch (CharacterCodingException e) { throw new RuntimeException(e); } }
private static Token getMinimumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return ((RandomPartitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof Murmur3Partitioner) { return ((Murmur3Partitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof ByteOrderedPartitioner) { //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys) return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.zeroByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } }
public BigIntegerToken getToken(ByteBuffer key) { if (key.remaining() == 0) return MINIMUM; return new BigIntegerToken(hashToBigInteger(key)); }
public Token split(Token ltoken, Token rtoken, double ratioToLeft) { BigDecimal left = ltoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)ltoken).token), right = rtoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)rtoken).token), ratio = BigDecimal.valueOf(ratioToLeft); BigInteger newToken; if (left.compareTo(right) < 0) { newToken = right.subtract(left).multiply(ratio).add(left).toBigInteger(); } else { // wrapping case // L + ((R - min) + (max - L)) * ratio BigDecimal max = new BigDecimal(MAXIMUM); newToken = max.add(right).subtract(left).multiply(ratio).add(left).toBigInteger().mod(MAXIMUM); } assert isValidToken(newToken) : "Invalid tokens from split"; return new BigIntegerToken(newToken); }
public BigIntegerToken getToken(ByteBuffer key) { if (key.remaining() == 0) return MINIMUM; return new BigIntegerToken(hashToBigInteger(key)); }
public Token split(Token ltoken, Token rtoken, double ratioToLeft) { BigDecimal left = ltoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)ltoken).token), right = rtoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)rtoken).token), ratio = BigDecimal.valueOf(ratioToLeft); BigInteger newToken; if (left.compareTo(right) < 0) { newToken = right.subtract(left).multiply(ratio).add(left).toBigInteger(); } else { // wrapping case // L + ((R - min) + (max - L)) * ratio BigDecimal max = new BigDecimal(MAXIMUM); newToken = max.add(right).subtract(left).multiply(ratio).add(left).toBigInteger().mod(MAXIMUM); } assert isValidToken(newToken) : "Invalid tokens from split"; return new BigIntegerToken(newToken); }
@Override public org.apache.cassandra.db.DecoratedKey<BigIntegerToken> decorateKey(ByteBuffer key) { ByteBuffer extractedToken = extractSolandraToken(key); //non-solandra key passes through if(extractedToken == null) return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(super.getToken(key), key); //the token is pre-processed try { return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(new BigIntegerToken(ByteBufferUtil.string(extractedToken)), key); } catch (CharacterCodingException e) { throw new RuntimeException(e); } }
public BigIntegerToken getToken(ByteBuffer key) { if (key.remaining() == 0) return MINIMUM; return new BigIntegerToken(hashToBigInteger(key)); }
public Token split(Token ltoken, Token rtoken, double ratioToLeft) { BigDecimal left = ltoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)ltoken).token), right = rtoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)rtoken).token), ratio = BigDecimal.valueOf(ratioToLeft); BigInteger newToken; if (left.compareTo(right) < 0) { newToken = right.subtract(left).multiply(ratio).add(left).toBigInteger(); } else { // wrapping case // L + ((R - min) + (max - L)) * ratio BigDecimal max = new BigDecimal(MAXIMUM); newToken = max.add(right).subtract(left).multiply(ratio).add(left).toBigInteger().mod(MAXIMUM); } assert isValidToken(newToken) : "Invalid tokens from split"; return new BigIntegerToken(newToken); }
private static Token getMinimumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return ((RandomPartitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof Murmur3Partitioner) { return ((Murmur3Partitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof ByteOrderedPartitioner) { //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys) return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.zeroByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } }
public DecoratedKey decorateKey(ByteBuffer key) { return new CachedHashDecoratedKey(getToken(key), key); }
public BigIntegerToken getRandomToken() { BigInteger token = hashToBigInteger(GuidGenerator.guidAsBytes()); if ( token.signum() == -1 ) token = token.multiply(BigInteger.valueOf(-1L)); return new BigIntegerToken(token); }
public Token split(Token ltoken, Token rtoken, double ratioToLeft) { BigDecimal left = ltoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)ltoken).token), right = rtoken.equals(MINIMUM) ? BigDecimal.ZERO : new BigDecimal(((BigIntegerToken)rtoken).token), ratio = BigDecimal.valueOf(ratioToLeft); BigInteger newToken; if (left.compareTo(right) < 0) { newToken = right.subtract(left).multiply(ratio).add(left).toBigInteger(); } else { // wrapping case // L + ((R - min) + (max - L)) * ratio BigDecimal max = new BigDecimal(MAXIMUM); newToken = max.add(right).subtract(left).multiply(ratio).add(left).toBigInteger().mod(MAXIMUM); } assert isValidToken(newToken) : "Invalid tokens from split"; return new BigIntegerToken(newToken); }
private static Token getMinimumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return ((RandomPartitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof Murmur3Partitioner) { return ((Murmur3Partitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof ByteOrderedPartitioner) { //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys) return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.zeroByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } }
public DecoratedKey decorateKey(ByteBuffer key) { return new CachedHashDecoratedKey(getToken(key), key); }
public BigIntegerToken getRandomToken() { BigInteger token = hashToBigInteger(GuidGenerator.guidAsBytes()); if ( token.signum() == -1 ) token = token.multiply(BigInteger.valueOf(-1L)); return new BigIntegerToken(token); }
public DecoratedKey decorateKey(ByteBuffer key) { return new CachedHashDecoratedKey(getToken(key), key); }
public BigIntegerToken getRandomToken(Random random) { BigInteger token = hashToBigInteger(GuidGenerator.guidAsBytes(random, "host/127.0.0.1", 0)); if ( token.signum() == -1 ) token = token.multiply(BigInteger.valueOf(-1L)); return new BigIntegerToken(token); }
public DecoratedKey decorateKey(ByteBuffer key) { return new BufferDecoratedKey(getToken(key), key); }
public BigIntegerToken getRandomToken(Random random) { BigInteger token = hashToBigInteger(GuidGenerator.guidAsBytes(random, "host/127.0.0.1", 0)); if ( token.signum() == -1 ) token = token.multiply(BigInteger.valueOf(-1L)); return new BigIntegerToken(token); }