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); } }
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 fromByteArray(ByteBuffer bytes) { return new BytesToken(bytes); }
public BytesToken getToken(ByteBuffer key) { if (key.remaining() == 0) return MINIMUM; return new BytesToken(key); }
public BytesToken getRandomToken() { Random r = new Random(); byte[] buffer = new byte[16]; r.nextBytes(buffer); return new BytesToken(buffer); }
public Token fromString(String string) { if (string.length() % 2 == 1) string = "0" + string; return new BytesToken(Hex.hexToBytes(string)); } };
public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner public static final BytesToken MINIMUM = new BytesToken(ArrayUtils.EMPTY_BYTE_ARRAY);
public BytesToken midpoint(Token lt, Token rt) { BytesToken ltoken = (BytesToken) lt; BytesToken rtoken = (BytesToken) rt; int sigbytes = Math.max(ltoken.token.length, rtoken.token.length); BigInteger left = bigForBytes(ltoken.token, sigbytes); BigInteger right = bigForBytes(rtoken.token, sigbytes); Pair<BigInteger,Boolean> midpair = FBUtilities.midpoint(left, right, 8*sigbytes); return new BytesToken(bytesForBig(midpair.left, sigbytes, midpair.right)); }
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); } }
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); } }
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); } } }