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 compressionContext)
add
public void add(KeyValue kv)
isEmpty
public boolean isEmpty()
size
public int size()
getKeyValues
public List<KeyValue> getKeyValues()
getScopes
public NavigableMap<byte[],Integer> getScopes()
setScopes
public void setScopes(NavigableMap<byte[],Integer> scopes)
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 © 2013 The Apache Software Foundation. All Rights Reserved.