org.usergrid.persistence.cassandra
Class SimpleIndexBucketLocatorImpl

java.lang.Object
  extended by org.usergrid.persistence.cassandra.SimpleIndexBucketLocatorImpl
All Implemented Interfaces:
IndexBucketLocator

public class SimpleIndexBucketLocatorImpl
extends Object
implements IndexBucketLocator

Simple implementation that does static hashing across 100 rows. Future implementations should be smarter and create new tokens as required when buckets become too large for an entity property within an application for the given index type.

Author:
tnine

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.usergrid.persistence.IndexBucketLocator
IndexBucketLocator.IndexType
 
Field Summary
static BigInteger MAXIMUM
           
static BigInteger MINIMUM
           
 
Constructor Summary
SimpleIndexBucketLocatorImpl()
          Base constructor that creates a ring of 100 tokens
SimpleIndexBucketLocatorImpl(int size)
          Create a bucket locator with the specified size
 
Method Summary
 String getBucket(UUID applicationId, IndexBucketLocator.IndexType type, UUID entityId, String... components)
          Return the bucket to use for indexing this entity
 List<String> getBuckets(UUID applicationId, IndexBucketLocator.IndexType type, String... components)
          Get all buckets that exist for this application with the given entity type, and property name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM

public static final BigInteger MINIMUM

MAXIMUM

public static final BigInteger MAXIMUM
Constructor Detail

SimpleIndexBucketLocatorImpl

public SimpleIndexBucketLocatorImpl(int size)
Create a bucket locator with the specified size

Parameters:
size -

SimpleIndexBucketLocatorImpl

public SimpleIndexBucketLocatorImpl()
Base constructor that creates a ring of 100 tokens

Method Detail

getBucket

public String getBucket(UUID applicationId,
                        IndexBucketLocator.IndexType type,
                        UUID entityId,
                        String... components)
Description copied from interface: IndexBucketLocator
Return the bucket to use for indexing this entity

Specified by:
getBucket in interface IndexBucketLocator
Parameters:
applicationId - The application id
type - The type of the index. This way indexing on the same property value for different types of indexes does not cause collisions on partitioning and lookups
entityId - The entity id to be indexed
components - The strings and uniquely identify the path to this index. I.E entityType and propName, collection name etc This string must remain the same for all reads and writes
Returns:

getBuckets

public List<String> getBuckets(UUID applicationId,
                               IndexBucketLocator.IndexType type,
                               String... components)
Description copied from interface: IndexBucketLocator
Get all buckets that exist for this application with the given entity type, and property name

Specified by:
getBuckets in interface IndexBucketLocator
Parameters:
applicationId - The application id
type - The type of index
components - The strings and uniquely identify the path to this index. I.E entityType and propName, collection name etc
Returns:
All buckets for this application at the given component path


Copyright © 2013. All Rights Reserved.