com.netflix.astyanax.thrift
Class AbstractThriftMutationBatchImpl

java.lang.Object
  extended by com.netflix.astyanax.thrift.AbstractThriftMutationBatchImpl
All Implemented Interfaces:
Execution<Void>, MutationBatch

public abstract class AbstractThriftMutationBatchImpl
extends Object
implements MutationBatch

Basic implementation of a mutation batch using the thrift data structures. The thrift mutation data structure is, Map of Keys -> Map of ColumnFamily -> MutationList

Author:
elandau

Field Summary
protected  long timestamp
           
 
Constructor Summary
AbstractThriftMutationBatchImpl(Clock clock)
           
 
Method Summary
<K> void
deleteRow(Collection<ColumnFamily<K,?>> columnFamilies, K rowKey)
          Delete the row for all the specified column families
 void deserialize(ByteBuffer data)
          Re-recreate a mutation batch from a serialized ByteBuffer created by a call to serialize().
 void discardMutations()
          Discard any pending mutations.
 Map<ByteBuffer,Map<String,List<org.apache.cassandra.thrift.Mutation>>> getMutationMap()
           
 int getRowCount()
          Returns the number of rows being mutated
 Map<ByteBuffer,Set<String>> getRowKeys()
          Return a mapping of column families to rows being modified
 boolean isEmpty()
          Checks whether the mutation object contains rows.
 MutationBatch lockCurrentTimestamp()
          Deprecated. 
 void mergeShallow(MutationBatch other)
          Perform a shallow merge of mutations from another batch.
 ByteBuffer serialize()
          Serialize the entire mutation batch into a ByteBuffer.
 MutationBatch setTimeout(long timeout)
          This never really did anything :)
 MutationBatch setTimestamp(long timestamp)
          Set the timestamp for all subsequent operations on this mutation
 String toString()
          Generate a string representation of the mutation with the following syntax Key1: cf1: Mutation count cf2: Mutation count Key2: cf1: Mutation count cf2: Mutation count
<K,C> ColumnListMutation<C>
withRow(ColumnFamily<K,C> columnFamily, K rowKey)
          Mutate a row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.netflix.astyanax.MutationBatch
pinToHost, setConsistencyLevel, usingWriteAheadLog, withRetryPolicy
 
Methods inherited from interface com.netflix.astyanax.Execution
execute, executeAsync
 

Field Detail

timestamp

protected long timestamp
Constructor Detail

AbstractThriftMutationBatchImpl

public AbstractThriftMutationBatchImpl(Clock clock)
Method Detail

withRow

public <K,C> ColumnListMutation<C> withRow(ColumnFamily<K,C> columnFamily,
                                           K rowKey)
Description copied from interface: MutationBatch
Mutate a row. The ColumnFamilyMutation is only valid until execute() or discardMutations is called.

Specified by:
withRow in interface MutationBatch
Returns:

discardMutations

public void discardMutations()
Description copied from interface: MutationBatch
Discard any pending mutations. All previous references returned by row are now invalid.

Specified by:
discardMutations in interface MutationBatch

deleteRow

public <K> void deleteRow(Collection<ColumnFamily<K,?>> columnFamilies,
                          K rowKey)
Description copied from interface: MutationBatch
Delete the row for all the specified column families

Specified by:
deleteRow in interface MutationBatch

isEmpty

public boolean isEmpty()
Checks whether the mutation object contains rows. While the map may contain row keys the row keys may not contain any mutations.

Specified by:
isEmpty in interface MutationBatch
Returns:

toString

public String toString()
Generate a string representation of the mutation with the following syntax Key1: cf1: Mutation count cf2: Mutation count Key2: cf1: Mutation count cf2: Mutation count

Overrides:
toString in class Object

serialize

public ByteBuffer serialize()
                     throws Exception
Description copied from interface: MutationBatch
Serialize the entire mutation batch into a ByteBuffer.

Specified by:
serialize in interface MutationBatch
Returns:
Throws:
Exception

deserialize

public void deserialize(ByteBuffer data)
                 throws Exception
Description copied from interface: MutationBatch
Re-recreate a mutation batch from a serialized ByteBuffer created by a call to serialize(). Serialization of MutationBatches from different implementations is not guaranteed to match.

Specified by:
deserialize in interface MutationBatch
Throws:
Exception

getRowKeys

public Map<ByteBuffer,Set<String>> getRowKeys()
Description copied from interface: MutationBatch
Return a mapping of column families to rows being modified

Specified by:
getRowKeys in interface MutationBatch
Returns:

getMutationMap

public Map<ByteBuffer,Map<String,List<org.apache.cassandra.thrift.Mutation>>> getMutationMap()

mergeShallow

public void mergeShallow(MutationBatch other)
Description copied from interface: MutationBatch
Perform a shallow merge of mutations from another batch.

Specified by:
mergeShallow in interface MutationBatch

getRowCount

public int getRowCount()
Description copied from interface: MutationBatch
Returns the number of rows being mutated

Specified by:
getRowCount in interface MutationBatch
Returns:

setTimeout

public MutationBatch setTimeout(long timeout)
Description copied from interface: MutationBatch
This never really did anything :)

Specified by:
setTimeout in interface MutationBatch

setTimestamp

public MutationBatch setTimestamp(long timestamp)
Description copied from interface: MutationBatch
Set the timestamp for all subsequent operations on this mutation

Specified by:
setTimestamp in interface MutationBatch
Returns:

lockCurrentTimestamp

@Deprecated
public MutationBatch lockCurrentTimestamp()
Deprecated. 

Description copied from interface: MutationBatch
Force all future mutations to have the same timestamp. Make sure to call lockTimestamp before doing any other operations otherwise previously created withRow mutations will use the previous timestamp.

Specified by:
lockCurrentTimestamp in interface MutationBatch
Returns:


Copyright © 2012. All Rights Reserved.