com.netflix.astyanax.recipes.uniqueness
Class RowUniquenessConstraint<K,C>

java.lang.Object
  extended by com.netflix.astyanax.recipes.uniqueness.RowUniquenessConstraint<K,C>
Type Parameters:
K -
C -
All Implemented Interfaces:
UniquenessConstraint

public class RowUniquenessConstraint<K,C>
extends Object
implements UniquenessConstraint

Test uniqueness for a single row. This implementation allows for any column type. If the column family uses UTF8Type for the comparator then it is preferable to use ColumnPrefixUniquenessConstraint.

Author:
elandau

Constructor Summary
RowUniquenessConstraint(Keyspace keyspace, ColumnFamily<K,C> columnFamily, K key, com.google.common.base.Supplier<C> uniqueColumnSupplier)
           
 
Method Summary
 void acquire()
          Acquire the row(s) for uniqueness.
 void acquireAndMutate(MutationBatch mutation)
          Acquire the uniqueness constraint and apply the final mutation if the row if found to be unique
 ByteBuffer readData()
          Read the data stored with the unique row.
 String readDataAsString()
           
 void release()
          Release the uniqueness lock for this row.
 RowUniquenessConstraint<K,C> withConsistencyLevel(ConsistencyLevel consistencyLevel)
           
 RowUniquenessConstraint<K,C> withData(ByteBuffer data)
          Specify the data value to add to the column.
 RowUniquenessConstraint<K,C> withData(String data)
           
 RowUniquenessConstraint<K,C> withTtl(Integer ttl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowUniquenessConstraint

public RowUniquenessConstraint(Keyspace keyspace,
                               ColumnFamily<K,C> columnFamily,
                               K key,
                               com.google.common.base.Supplier<C> uniqueColumnSupplier)
Method Detail

withTtl

public RowUniquenessConstraint<K,C> withTtl(Integer ttl)

withConsistencyLevel

public RowUniquenessConstraint<K,C> withConsistencyLevel(ConsistencyLevel consistencyLevel)

withData

public RowUniquenessConstraint<K,C> withData(ByteBuffer data)
Specify the data value to add to the column.

Parameters:
data -
Returns:

withData

public RowUniquenessConstraint<K,C> withData(String data)

acquire

public void acquire()
             throws NotUniqueException,
                    Exception
Description copied from interface: UniquenessConstraint
Acquire the row(s) for uniqueness. Call release() when the uniqueness on the row(s) is no longer needed, such as when deleting the rows.

Specified by:
acquire in interface UniquenessConstraint
Throws:
NotUniqueException
Exception

acquireAndMutate

public void acquireAndMutate(MutationBatch mutation)
                      throws NotUniqueException,
                             Exception
Description copied from interface: UniquenessConstraint
Acquire the uniqueness constraint and apply the final mutation if the row if found to be unique

Specified by:
acquireAndMutate in interface UniquenessConstraint
Throws:
NotUniqueException
Exception

release

public void release()
             throws Exception
Description copied from interface: UniquenessConstraint
Release the uniqueness lock for this row. Only call this when you no longer need the uniqueness lock

Specified by:
release in interface UniquenessConstraint
Throws:
Exception

readData

public ByteBuffer readData()
                    throws Exception
Read the data stored with the unique row. This data is normally a 'foreign' key to another column family.

Returns:
Throws:
Exception

readDataAsString

public String readDataAsString()
                        throws Exception
Throws:
Exception


Copyright © 2012. All Rights Reserved.