@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); } }
@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); } }
private static Token getMaximumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return new BigIntegerToken(RandomPartitioner.MAXIMUM); } else if (partitioner instanceof Murmur3Partitioner) { return new LongToken(Murmur3Partitioner.MAXIMUM); } 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.oneByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } } }
public Token fromString(String string) { return new BigIntegerToken(new BigInteger(string)); } };
public BigIntegerToken getToken(ByteBuffer key) { if (key.remaining() == 0) return MINIMUM; return new BigIntegerToken(FBUtilities.hashToBigInteger(key)); }
public Token midpoint(Token ltoken, Token rtoken) { // the symbolic MINIMUM token should act as ZERO: the empty bit array BigInteger left = ltoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)ltoken).token; BigInteger right = rtoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)rtoken).token; Pair<BigInteger,Boolean> midpair = FBUtilities.midpoint(left, right, 127); // discard the remainder return new BigIntegerToken(midpair.left); }
public Token fromByteArray(ByteBuffer bytes) { return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes))); }
public BigIntegerToken getRandomToken() { BigInteger token = FBUtilities.hashToBigInteger(GuidGenerator.guidAsBytes()); if ( token.signum() == -1 ) token = token.multiply(BigInteger.valueOf(-1L)); return new BigIntegerToken(token); }
private static Token getMaximumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return new BigIntegerToken(RandomPartitioner.MAXIMUM); } else if (partitioner instanceof Murmur3Partitioner) { return new LongToken(Murmur3Partitioner.MAXIMUM); } 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.oneByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } } }
private static Token getMaximumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return new BigIntegerToken(RandomPartitioner.MAXIMUM); } else if (partitioner instanceof Murmur3Partitioner) { return new LongToken(Murmur3Partitioner.MAXIMUM); } 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.oneByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } } }