Class Mutation
- All Implemented Interfaces:
org.apache.hadoop.io.Writable
- Direct Known Subclasses:
ConditionalMutation
Convenience methods which takes columns and value as CharSequence (String implements CharSequence) are provided. CharSequence is converted to UTF-8 by constructing a new Text object.
When always passing in the same data as a CharSequence/String, it's probably more efficient to call the Text put methods. This way the data is only encoded once and only one Text object is created.
All of the put methods append data to the mutation; they do not overwrite anything that was previously put. The mutation holds a list of all columns/values that were put into it.
The putDelete() methods do not remove something that was previously added to the mutation; rather, they indicate that Accumulo should insert a delete marker for that row column. A delete marker effectively hides entries for that row column with a timestamp earlier than the marker's. (The hidden data is eventually removed during Accumulo garbage collection.)
This class has many overloaded put
and putDelete
methods. These were added to
support different subset of fields and types. The functionality of all of these put
methods and more is provided by the new fluent at()
method added in 2.0.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Provides methods for setting the column family of a Mutation.static interface
Provides methods for setting the value of a Mutation.static interface
Provides methods for setting the column qualifier of a Mutation.static enum
Formats available for serializing Mutations.static interface
Provides methods for setting the timestamp of a Mutation.static interface
Provides methods for setting the column visibility of a Mutation. -
Constructor Summary
ConstructorDescriptionMutation()
Creates a new mutation.Mutation
(byte[] row) Creates a new mutation.Mutation
(byte[] row, int initialBufferSize) Creates a new mutation.Mutation
(byte[] row, int start, int length) Creates a new mutation.Mutation
(byte[] row, int start, int length, int initialBufferSize) Creates a new mutation.Mutation
(CharSequence row) Creates a new mutation.Mutation
(CharSequence row, int initialBufferSize) Creates a new mutation.Creates a new mutation by copying another.Mutation
(org.apache.accumulo.core.dataImpl.thrift.TMutation tmutation) Creates a new mutation from a Thrift mutation.Mutation
(org.apache.hadoop.io.Text row) Creates a new mutation.Mutation
(org.apache.hadoop.io.Text row, int initialBufferSize) Creates a new mutation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReplicationSource
(String peer) Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code.at()
Fluent API for putting or deleting to a Mutation that makes it easy use different types (i.e byte[], CharSequence, etc) when specifying the family, qualifier, value, etc.protected void
droppingOldTimestamp
(long ts) boolean
boolean
Checks if this mutation equals another.long
Gets an estimate of the amount of memory used by this mutation.Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code.byte[]
getRow()
Gets the row ID for this mutation.protected Mutation.SERIALIZED_FORMAT
Gets the serialization format used to (de)serialize this mutation.Gets the modifications and deletions in this mutation.int
hashCode()
protected ColumnUpdate
newColumnUpdate
(byte[] cf, byte[] cq, byte[] cv, boolean hasts, long ts, boolean deleted, byte[] val) long
numBytes()
Gets the total number of bytes in this mutation.Creates a multi-lined, human-readable String for this mutation.void
put
(byte[] columnFamily, byte[] columnQualifier, byte[] value) Puts a modification in this mutation.void
put
(byte[] columnFamily, byte[] columnQualifier, long timestamp, byte[] value) Puts a modification in this mutation.void
put
(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, byte[] value) Puts a modification in this mutation.void
put
(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, long timestamp, byte[] value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, long timestamp, CharSequence value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, long timestamp, Value value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, CharSequence value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, Value value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp, CharSequence value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp, Value value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, CharSequence value) Puts a modification in this mutation.void
put
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, Value value) Puts a modification in this mutation.void
put
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, long timestamp, Value value) Puts a modification in this mutation.void
Puts a modification in this mutation.void
put
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, long timestamp, Value value) Puts a modification in this mutation.void
put
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, Value value) Puts a modification in this mutation.void
putDelete
(byte[] columnFamily, byte[] columnQualifier) Puts a deletion in this mutation.void
putDelete
(byte[] columnFamily, byte[] columnQualifier, long timestamp) Puts a deletion in this mutation.void
putDelete
(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation.void
putDelete
(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation.void
putDelete
(CharSequence columnFamily, CharSequence columnQualifier) Puts a deletion in this mutation.void
putDelete
(CharSequence columnFamily, CharSequence columnQualifier, long timestamp) Puts a deletion in this mutation.void
putDelete
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation.void
putDelete
(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation.void
putDelete
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier) Puts a deletion in this mutation.void
putDelete
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, long timestamp) Puts a deletion in this mutation.void
putDelete
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation.void
putDelete
(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation.void
readFields
(DataInput in) void
setReplicationSources
(Set<String> sources) Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code.int
size()
Gets the number of modifications / deletions in this mutation.org.apache.accumulo.core.dataImpl.thrift.TMutation
toThrift()
Creates aTMutation
object containing this Mutation's data.void
write
(DataOutput out)
-
Constructor Details
-
Mutation
public Mutation(byte[] row) Creates a new mutation. A defensive copy is made.- Parameters:
row
- row ID- Since:
- 1.5.0
-
Mutation
public Mutation(byte[] row, int initialBufferSize) Creates a new mutation. A defensive copy is made.- Parameters:
row
- row IDinitialBufferSize
- the initial size, in bytes, of the internal buffer for serializing- Since:
- 1.7.0
-
Mutation
public Mutation(byte[] row, int start, int length) Creates a new mutation. A defensive copy is made.- Parameters:
row
- byte array containing row IDstart
- starting index of row ID in byte arraylength
- length of row ID in byte array- Throws:
IndexOutOfBoundsException
- if start or length is invalid- Since:
- 1.5.0
-
Mutation
public Mutation(byte[] row, int start, int length, int initialBufferSize) Creates a new mutation. A defensive copy is made.- Parameters:
row
- byte array containing row IDstart
- starting index of row ID in byte arraylength
- length of row ID in byte arrayinitialBufferSize
- the initial size, in bytes, of the internal buffer for serializing- Throws:
IndexOutOfBoundsException
- if start or length is invalid- Since:
- 1.7.0
-
Mutation
public Mutation(org.apache.hadoop.io.Text row) Creates a new mutation. A defensive copy is made.- Parameters:
row
- row ID
-
Mutation
public Mutation(org.apache.hadoop.io.Text row, int initialBufferSize) Creates a new mutation. A defensive copy is made.- Parameters:
row
- row IDinitialBufferSize
- the initial size, in bytes, of the internal buffer for serializing- Since:
- 1.7.0
-
Mutation
Creates a new mutation.- Parameters:
row
- row ID
-
Mutation
Creates a new mutation.- Parameters:
row
- row IDinitialBufferSize
- the initial size, in bytes, of the internal buffer for serializing- Since:
- 1.7.0
-
Mutation
public Mutation()Creates a new mutation. -
Mutation
public Mutation(org.apache.accumulo.core.dataImpl.thrift.TMutation tmutation) Creates a new mutation from a Thrift mutation.- Parameters:
tmutation
- Thrift mutation
-
Mutation
Creates a new mutation by copying another.- Parameters:
m
- mutation to copy
-
-
Method Details
-
getRow
public byte[] getRow()Gets the row ID for this mutation. Not a defensive copy.- Returns:
- row ID
-
put
public void put(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, Value value) Puts a modification in this mutation. Column visibility is empty; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiervalue
- cell value- See Also:
-
put
public void put(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, Value value) Puts a modification in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilityvalue
- cell value- See Also:
-
put
public void put(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, long timestamp, Value value) Puts a modification in this mutation. Column visibility is empty. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestampvalue
- cell value- See Also:
-
put
public void put(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, long timestamp, Value value) Puts a modification in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestampvalue
- cell value- See Also:
-
putDelete
public void putDelete(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier) Puts a deletion in this mutation. Matches empty column visibility; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifier- See Also:
-
putDelete
public void putDelete(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibility- See Also:
-
putDelete
public void putDelete(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, long timestamp) Puts a deletion in this mutation. Matches empty column visibility. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestamp- See Also:
-
putDelete
public void putDelete(org.apache.hadoop.io.Text columnFamily, org.apache.hadoop.io.Text columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestamp- See Also:
-
put
Puts a modification in this mutation. Column visibility is empty; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifier- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, Value value) Puts a modification in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilityvalue
- cell value- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, long timestamp, Value value) Puts a modification in this mutation. Column visibility is empty. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestampvalue
- cell value- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp, Value value) Puts a modification in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestampvalue
- cell value- See Also:
-
putDelete
Puts a deletion in this mutation. Matches empty column visibility; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifier- See Also:
-
putDelete
public void putDelete(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation. Timestamp is not set. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibility- See Also:
-
putDelete
Puts a deletion in this mutation. Matches empty column visibility. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestamp- See Also:
-
putDelete
public void putDelete(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestamp- See Also:
-
put
Puts a modification in this mutation. Column visibility is empty; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiervalue
- cell value- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, CharSequence value) Puts a modification in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilityvalue
- cell value- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, long timestamp, CharSequence value) Puts a modification in this mutation. Column visibility is empty. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestampvalue
- cell value- See Also:
-
put
public void put(CharSequence columnFamily, CharSequence columnQualifier, ColumnVisibility columnVisibility, long timestamp, CharSequence value) Puts a modification in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestampvalue
- cell value- See Also:
-
put
public void put(byte[] columnFamily, byte[] columnQualifier, byte[] value) Puts a modification in this mutation. Column visibility is empty; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiervalue
- cell value- Since:
- 1.5.0
- See Also:
-
put
public void put(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, byte[] value) Puts a modification in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilityvalue
- cell value- Since:
- 1.5.0
- See Also:
-
put
public void put(byte[] columnFamily, byte[] columnQualifier, long timestamp, byte[] value) Puts a modification in this mutation. Column visibility is empty. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestampvalue
- cell value- Since:
- 1.5.0
- See Also:
-
put
public void put(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, long timestamp, byte[] value) Puts a modification in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestampvalue
- cell value- Since:
- 1.5.0
- See Also:
-
putDelete
public void putDelete(byte[] columnFamily, byte[] columnQualifier) Puts a deletion in this mutation. Matches empty column visibility; timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifier- Since:
- 1.5.0
- See Also:
-
putDelete
public void putDelete(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility) Puts a deletion in this mutation. Timestamp is not set. All parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibility- Since:
- 1.5.0
- See Also:
-
putDelete
public void putDelete(byte[] columnFamily, byte[] columnQualifier, long timestamp) Puts a deletion in this mutation. Matches empty column visibility. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiertimestamp
- timestamp- Since:
- 1.5.0
- See Also:
-
putDelete
public void putDelete(byte[] columnFamily, byte[] columnQualifier, ColumnVisibility columnVisibility, long timestamp) Puts a deletion in this mutation. All appropriate parameters are defensively copied.- Parameters:
columnFamily
- column familycolumnQualifier
- column qualifiercolumnVisibility
- column visibilitytimestamp
- timestamp- Since:
- 1.5.0
- See Also:
-
at
Fluent API for putting or deleting to a Mutation that makes it easy use different types (i.e byte[], CharSequence, etc) when specifying the family, qualifier, value, etc.Methods are optional but must follow this order: family, qualifier, visibility, timestamp.
The put and delete methods end the chain and add the modification to the Mutation.
The following is an example if using
at()
to put and delete. Notice how the example mixesString
andbyte[]
.Mutation m = new Mutation("row0017"); m.at().family("001").qualifier(new byte[] {0,1}).put("v99"); m.at().family("002").qualifier(new byte[] {0,1}).delete();
- Returns:
- a new FamilyOptions object, starting the method chain
- Since:
- 2.0.0
-
getUpdates
Gets the modifications and deletions in this mutation. After calling this method, further modifications to this mutation are ignored. Changes made to the returned updates do not affect this mutation.- Returns:
- list of modifications and deletions
-
newColumnUpdate
protected ColumnUpdate newColumnUpdate(byte[] cf, byte[] cq, byte[] cv, boolean hasts, long ts, boolean deleted, byte[] val) -
numBytes
public long numBytes()Gets the total number of bytes in this mutation.- Returns:
- length of mutation in bytes
-
estimatedMemoryUsed
public long estimatedMemoryUsed()Gets an estimate of the amount of memory used by this mutation. The estimate includes data sizes and object overhead.- Returns:
- memory usage estimate
-
size
public int size()Gets the number of modifications / deletions in this mutation.- Returns:
- the number of modifications / deletions
-
addReplicationSource
Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code. It is being marked as deprecated in 2.1.1 in order to correct that oversight, and will be removed in 3.0.0 with the rest of the code pertaining to this feature.Add a new element to the set of peers which this Mutation originated from- Parameters:
peer
- the peer to add- Since:
- 1.7.0
-
setReplicationSources
Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code. It is being marked as deprecated in 2.1.1 in order to correct that oversight, and will be removed in 3.0.0 with the rest of the code pertaining to this feature.Set the replication peers which this Mutation originated from- Parameters:
sources
- Set of peer names which have processed this update- Since:
- 1.7.0
-
getReplicationSources
Deprecated.The feature pertaining to this method was deprecated in 2.1.0, but this method was overlooked when annotating the code. It is being marked as deprecated in 2.1.1 in order to correct that oversight, and will be removed in 3.0.0 with the rest of the code pertaining to this feature.Return the replication sources for this Mutation- Returns:
- An unmodifiable view of the replication sources
-
readFields
- Specified by:
readFields
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
droppingOldTimestamp
protected void droppingOldTimestamp(long ts) -
write
- Specified by:
write
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
equals
Checks if this mutation equals another. Two mutations are equal if they target the same row and have the same modifications and deletions, in order. This method may be removed in a future API revision in favor ofequals(Object)
. See ACCUMULO-1627 for more information.- Parameters:
m
- mutation to compare- Returns:
- true if this mutation equals the other, false otherwise
-
toThrift
public org.apache.accumulo.core.dataImpl.thrift.TMutation toThrift()Creates aTMutation
object containing this Mutation's data. Note that this method will move the Mutation into a "serialized" state that will prevent users from adding more data via Mutation#put().- Returns:
- a thrift form of this Mutation
-
getSerializedFormat
Gets the serialization format used to (de)serialize this mutation.- Returns:
- serialization format
-
prettyPrint
Creates a multi-lined, human-readable String for this mutation. This method creates many intermediate Strings and should not be used for large volumes of Mutations.- Returns:
- A multi-lined, human-readable String for this mutation.
- Since:
- 2.1.0
-