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 CassandraShard(CassandraSessionPool.Session session, String keyspace, String table) { this.session = session; this.keyspace = keyspace; this.table = table; this.partitioner = new Murmur3Partitioner(); }
/** * Generate the token of a key. * Note that we need to ensure all generated token are strictly bigger than MINIMUM. * In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't * include MINIMUM but we use such range to select all data whose token is smaller than X. */ public LongToken getToken(ByteBuffer key) { return getToken(key, getHash(key)); }
private LongToken getToken(ByteBuffer key, long[] hash) { if (key.remaining() == 0) return MINIMUM; return new LongToken(normalize(hash[0])); }
public LongToken getRandomToken() { return getRandomToken(ThreadLocalRandom.current()); }
public DecoratedKey decorateKey(ByteBuffer key) { return new BufferDecoratedKey(getToken(key), key); }
/** * Generate the token of a key. * Note that we need to ensure all generated token are strictly bigger than MINIMUM. * In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't * include MINIMUM but we use such range to select all data whose token is smaller than X. */ public LongToken getToken(ByteBuffer key) { return getToken(key, getHash(key)); }
private LongToken getToken(ByteBuffer key, long[] hash) { if (key.remaining() == 0) return MINIMUM; return new LongToken(normalize(hash[0])); }
public LongToken getRandomToken() { return getRandomToken(ThreadLocalRandom.current()); }
/** * Generate the token of a key. * Note that we need to ensure all generated token are strictly bigger than MINIMUM. * In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't * include MINIMUM but we use such range to select all data whose token is smaller than X. */ public LongToken getToken(ByteBuffer key) { return getToken(key, getHash(key)); }
private LongToken getToken(ByteBuffer key, long[] hash) { if (key.remaining() == 0) return MINIMUM; return new LongToken(normalize(hash[0])); }
public LongToken getRandomToken() { return getRandomToken(ThreadLocalRandom.current()); }
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 CassandraShard(CassandraSessionPool.Session session, String keyspace, String table) { this.session = session; this.keyspace = keyspace; this.table = table; this.partitioner = new Murmur3Partitioner(); }
/** * Generate the token of a key. * Note that we need to ensure all generated token are strictly bigger than MINIMUM. * In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't * include MINIMUM but we use such range to select all data whose token is smaller than X. */ public LongToken getToken(ByteBuffer key) { return getToken(key, getHash(key)); }
public LongToken getRandomToken(Random r) { return new LongToken(normalize(r.nextLong())); }
public LongToken getRandomToken() { return getRandomToken(ThreadLocalRandom.current()); }
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 LongToken getToken(ByteBuffer key, long[] hash) { if (key.remaining() == 0) return MINIMUM; return new LongToken(normalize(hash[0])); }