org.apache.hadoop.hbase.regionserver.wal
Class WALEdit
java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.WALEdit
- All Implemented Interfaces:
- HeapSize, org.apache.hadoop.io.Writable
public class WALEdit
- extends Object
- implements org.apache.hadoop.io.Writable, HeapSize
WALEdit: Used in HBase's transaction log (WAL) to represent
the collection of edits (KeyValue objects) corresponding to a
single transaction. The class implements "Writable" interface
for serializing/deserializing a set of KeyValue items.
Previously, if a transaction contains 3 edits to c1, c2, c3 for a row R,
the HLog would have three log entries as follows:
:
:
:
This presents problems because row level atomicity of transactions
was not guaranteed. If we crash after few of the above appends make
it, then recovery will restore a partial transaction.
In the new world, all the edits for a given transaction are written
out as a single record, for example:
:
where, the WALEdit is serialized as:
<-1, # of edits, , , ... >
For example:
<-1, 3, , , >
The -1 marker is just a special way of being backward compatible with
an old HLog which would have contained a single .
The deserializer for WALEdit backward compatibly detects if the record
is an old style KeyValue or the new style WALEdit.
WALEdit
public WALEdit()
setCompressionContext
public void setCompressionContext(org.apache.hadoop.hbase.regionserver.wal.CompressionContext compression)
setCodec(WALEditCodec)
must be called before calling this method.
- Parameters:
compression
- the CompressionContext
for the underlying codec.
setCodec
public void setCodec(WALEditCodec codec)
add
public void add(KeyValue kv)
isEmpty
public boolean isEmpty()
size
public int size()
getKeyValues
public List<KeyValue> getKeyValues()
getFromScope
public Integer getFromScope(byte[] key)
getScopes
@Deprecated
public NavigableMap<byte[],Integer> getScopes()
- Deprecated. use
getFromScope(byte[])
instead
- Returns:
- the underlying replication scope map
setScopes
@Deprecated
public void setScopes(NavigableMap<byte[],Integer> scopes)
- Deprecated. use
putIntoScope(byte[], Integer)
instead. This completely overrides any
existing scopes
- Parameters:
scopes
- set all the replication scope information. Must be non-null
putIntoScope
public void putIntoScope(byte[] key,
Integer value)
hasKeyInScope
public boolean hasKeyInScope(byte[] key)
hasClusterId
public boolean hasClusterId(UUID clusterId)
- Returns:
- true if the cluster with the given clusterId has consumed the change.
addClusterId
public void addClusterId(UUID clusterId)
- Marks that the cluster with the given clusterId has consumed the change.
addClusterIds
public void addClusterIds(List<UUID> clusterIds)
- Marks that the clusters with the given clusterIds have consumed the change.
getClusterIds
public List<UUID> getClusterIds()
- Returns:
- the set of cluster Ids that have consumed the change.
readFields
public void readFields(DataInput in)
throws IOException
- Specified by:
readFields
in interface org.apache.hadoop.io.Writable
- Throws:
IOException
write
public void write(DataOutput out)
throws IOException
- Specified by:
write
in interface org.apache.hadoop.io.Writable
- Throws:
IOException
heapSize
public long heapSize()
- Specified by:
heapSize
in interface HeapSize
- Returns:
- Approximate 'exclusive deep size' of implementing object. Includes
count of payload and hosting object sizings.
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.