HBASE-9196 Remove dead code related to KeyValue
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1513964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d21859e048
commit
88de40d738
|
@ -69,9 +69,6 @@ import com.google.common.primitives.Longs;
|
|||
public class KeyValue implements Cell, HeapSize, Cloneable {
|
||||
static final Log LOG = LogFactory.getLog(KeyValue.class);
|
||||
|
||||
private static final int META_LENGTH =
|
||||
TableName.META_TABLE_NAME.getName().length; // 'hbase.meta' length
|
||||
|
||||
// TODO: Group Key-only comparators and operations into a Key class, just
|
||||
// for neatness sake, if can figure what to call it.
|
||||
|
||||
|
@ -106,18 +103,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
*/
|
||||
public static final KeyComparator META_KEY_COMPARATOR = new MetaKeyComparator();
|
||||
|
||||
/**
|
||||
* A {@link KVComparator} for <code>-ROOT-</code> catalog table
|
||||
* {@link KeyValue}s.
|
||||
*/
|
||||
public static final KVComparator ROOT_COMPARATOR = new RootComparator();
|
||||
|
||||
/**
|
||||
* A {@link KVComparator} for <code>-ROOT-</code> catalog table
|
||||
* {@link KeyValue} keys.
|
||||
*/
|
||||
public static final KeyComparator ROOT_KEY_COMPARATOR = new RootKeyComparator();
|
||||
|
||||
/**
|
||||
* Get the appropriate row comparator for the specified table.
|
||||
*
|
||||
|
@ -128,9 +113,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
* @return The comparator.
|
||||
*/
|
||||
public static KeyComparator getRowComparator(TableName tableName) {
|
||||
if(TableName.ROOT_TABLE_NAME.equals(tableName)) {
|
||||
return ROOT_COMPARATOR.getRawComparator();
|
||||
}
|
||||
if(TableName.META_TABLE_NAME.equals(tableName)) {
|
||||
return META_COMPARATOR.getRawComparator();
|
||||
}
|
||||
|
@ -1782,23 +1764,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link KVComparator} for <code>-ROOT-</code> catalog table
|
||||
* {@link KeyValue}s.
|
||||
*/
|
||||
public static class RootComparator extends MetaComparator {
|
||||
private final KeyComparator rawcomparator = new RootKeyComparator();
|
||||
|
||||
public KeyComparator getRawComparator() {
|
||||
return this.rawcomparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return new RootComparator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link KVComparator} for <code>.META.</code> catalog table
|
||||
* {@link KeyValue}s.
|
||||
|
@ -1840,7 +1805,7 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
right.getKeyLength());
|
||||
if (ret != 0) return ret;
|
||||
// Negate this comparison so later edits show up first
|
||||
return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());
|
||||
return -Longs.compare(left.getMvccVersion(), right.getMvccVersion());
|
||||
}
|
||||
|
||||
public int compareTimestamps(final KeyValue left, final KeyValue right) {
|
||||
|
@ -2000,33 +1965,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
return new KVComparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Comparator that ignores timestamps; useful counting versions.
|
||||
*/
|
||||
public KVComparator getComparatorIgnoringTimestamps() {
|
||||
KVComparator c = null;
|
||||
try {
|
||||
c = (KVComparator)this.clone();
|
||||
c.getRawComparator().ignoreTimestamp = true;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error("Not supported", e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Comparator that ignores key type; useful checking deletes
|
||||
*/
|
||||
public KVComparator getComparatorIgnoringType() {
|
||||
KVComparator c = null;
|
||||
try {
|
||||
c = (KVComparator)this.clone();
|
||||
c.getRawComparator().ignoreType = true;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error("Not supported", e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2393,49 +2331,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
return length + Bytes.SIZEOF_INT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare key portion of a {@link KeyValue} for keys in <code>-ROOT-<code>
|
||||
* table.
|
||||
*/
|
||||
public static class RootKeyComparator extends MetaKeyComparator {
|
||||
public int compareRows(byte [] left, int loffset, int llength,
|
||||
byte [] right, int roffset, int rlength) {
|
||||
// Rows look like this: .META.,ROW_FROM_META,RID
|
||||
// LOG.info("ROOT " + Bytes.toString(left, loffset, llength) +
|
||||
// "---" + Bytes.toString(right, roffset, rlength));
|
||||
int lmetaOffsetPlusDelimiter = loffset + META_LENGTH + 1;
|
||||
int leftFarDelimiter = getDelimiterInReverse(left,
|
||||
lmetaOffsetPlusDelimiter,
|
||||
llength - META_LENGTH - 1, HConstants.DELIMITER);
|
||||
int rmetaOffsetPlusDelimiter = roffset + META_LENGTH + 1;
|
||||
int rightFarDelimiter = getDelimiterInReverse(right,
|
||||
rmetaOffsetPlusDelimiter, rlength - META_LENGTH - 1,
|
||||
HConstants.DELIMITER);
|
||||
if (leftFarDelimiter < 0 && rightFarDelimiter >= 0) {
|
||||
// Nothing between .META. and regionid. Its first key.
|
||||
return -1;
|
||||
} else if (rightFarDelimiter < 0 && leftFarDelimiter >= 0) {
|
||||
return 1;
|
||||
} else if (leftFarDelimiter < 0 && rightFarDelimiter < 0) {
|
||||
return 0;
|
||||
}
|
||||
int result = super.compareRows(left, lmetaOffsetPlusDelimiter,
|
||||
leftFarDelimiter - lmetaOffsetPlusDelimiter,
|
||||
right, rmetaOffsetPlusDelimiter,
|
||||
rightFarDelimiter - rmetaOffsetPlusDelimiter);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
// Compare last part of row, the rowid.
|
||||
leftFarDelimiter++;
|
||||
rightFarDelimiter++;
|
||||
result = compareRowid(left, leftFarDelimiter,
|
||||
llength - (leftFarDelimiter - loffset),
|
||||
right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that compares row component only of a KeyValue.
|
||||
*/
|
||||
|
@ -2532,8 +2427,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
*/
|
||||
public static class KeyComparator
|
||||
implements RawComparator<byte []>, SamePrefixComparator<byte[]> {
|
||||
volatile boolean ignoreTimestamp = false;
|
||||
volatile boolean ignoreType = false;
|
||||
|
||||
public int compare(byte[] left, int loffset, int llength, byte[] right,
|
||||
int roffset, int rlength) {
|
||||
|
@ -2672,7 +2565,6 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
private int compareTimestampAndType(byte[] left, int loffset, int llength,
|
||||
byte[] right, int roffset, int rlength, byte ltype, byte rtype) {
|
||||
int compare;
|
||||
if (!this.ignoreTimestamp) {
|
||||
// Get timestamps.
|
||||
long ltimestamp = Bytes.toLong(left,
|
||||
loffset + (llength - TIMESTAMP_TYPE_SIZE));
|
||||
|
@ -2682,17 +2574,13 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
|
|||
if (compare != 0) {
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.ignoreType) {
|
||||
// Compare types. Let the delete types sort ahead of puts; i.e. types
|
||||
// of higher numbers sort before those of lesser numbers. Maximum (255)
|
||||
// appears ahead of everything, and minimum (0) appears after
|
||||
// everything.
|
||||
return (0xff & rtype) - (0xff & ltype);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int compare(byte[] left, byte[] right) {
|
||||
return compare(left, 0, left.length, right, 0, right.length);
|
||||
|
|
|
@ -167,7 +167,7 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder {
|
|||
public KeyValue getKeyValue() {
|
||||
ByteBuffer kvBuf = getKeyValueBuffer();
|
||||
KeyValue kv = new KeyValue(kvBuf.array(), kvBuf.arrayOffset());
|
||||
kv.setMemstoreTS(current.memstoreTS);
|
||||
kv.setMvccVersion(current.memstoreTS);
|
||||
return kv;
|
||||
}
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ public class RedundantKVGenerator {
|
|||
for (KeyValue kv : keyValues) {
|
||||
totalSize += kv.getLength();
|
||||
if (includesMemstoreTS) {
|
||||
totalSize += WritableUtils.getVIntSize(kv.getMemstoreTS());
|
||||
totalSize += WritableUtils.getVIntSize(kv.getMvccVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class RedundantKVGenerator {
|
|||
for (KeyValue kv : keyValues) {
|
||||
result.put(kv.getBuffer(), kv.getOffset(), kv.getLength());
|
||||
if (includesMemstoreTS) {
|
||||
ByteBufferUtils.writeVLong(result, kv.getMemstoreTS());
|
||||
ByteBufferUtils.writeVLong(result, kv.getMvccVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,28 +128,14 @@ public class TestKeyValue extends TestCase {
|
|||
}
|
||||
|
||||
public void testMoreComparisons() throws Exception {
|
||||
// Root compares
|
||||
long now = System.currentTimeMillis();
|
||||
KeyValue a = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,99999999999999"), now);
|
||||
KeyValue b = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now);
|
||||
KVComparator c = new KeyValue.RootComparator();
|
||||
assertTrue(c.compare(b, a) < 0);
|
||||
KeyValue aa = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now);
|
||||
KeyValue bb = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"),
|
||||
Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1235943454602L,
|
||||
(byte[])null);
|
||||
assertTrue(c.compare(aa, bb) < 0);
|
||||
|
||||
// Meta compares
|
||||
KeyValue aaa = new KeyValue(
|
||||
Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now);
|
||||
KeyValue bbb = new KeyValue(
|
||||
Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now);
|
||||
c = new KeyValue.MetaComparator();
|
||||
KVComparator c = new KeyValue.MetaComparator();
|
||||
assertTrue(c.compare(bbb, aaa) < 0);
|
||||
|
||||
KeyValue aaaa = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,,1236023996656"),
|
||||
|
@ -166,7 +152,6 @@ public class TestKeyValue extends TestCase {
|
|||
assertTrue(c.compare(x, y) < 0);
|
||||
comparisons(new KeyValue.MetaComparator());
|
||||
comparisons(new KeyValue.KVComparator());
|
||||
metacomparisons(new KeyValue.RootComparator());
|
||||
metacomparisons(new KeyValue.MetaComparator());
|
||||
}
|
||||
|
||||
|
@ -217,13 +202,6 @@ public class TestKeyValue extends TestCase {
|
|||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
||||
assertTrue(KeyValue.META_COMPARATOR.compare(rowA, rowB) < 0);
|
||||
|
||||
rowA = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",testtable,www.hbase.org/,1234,4321"),
|
||||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
||||
rowB = new KeyValue(
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",testtable,www.hbase.org/%20,99999,99999"),
|
||||
Bytes.toBytes("fam"), Bytes.toBytes(""), Long.MAX_VALUE, (byte[])null);
|
||||
assertTrue(KeyValue.ROOT_COMPARATOR.compare(rowA, rowB) < 0);
|
||||
}
|
||||
|
||||
private void metacomparisons(final KeyValue.MetaComparator c) {
|
||||
|
@ -296,41 +274,6 @@ public class TestKeyValue extends TestCase {
|
|||
for (KeyValue k: set) {
|
||||
assertTrue(count++ == k.getTimestamp());
|
||||
}
|
||||
// Make up -ROOT- table keys.
|
||||
KeyValue [] rootKeys = {
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",aaaaa,\u0000\u0000,0,2"), fam, qf, 2, nb),
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",aaaaa,\u0001,0,3"), fam, qf, 3, nb),
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",aaaaa,,0,1"), fam, qf, 1, nb),
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",aaaaa,\u1000,0,5"), fam, qf, 5, nb),
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",aaaaa,a,0,4"), fam, qf, 4, nb),
|
||||
new KeyValue(Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,0"), fam, qf, 0, nb),
|
||||
};
|
||||
// This will output the keys incorrectly.
|
||||
set = new TreeSet<KeyValue>(new KeyValue.MetaComparator());
|
||||
// Add to set with bad comparator
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
set.add(rootKeys[i]);
|
||||
}
|
||||
assertion = false;
|
||||
count = 0;
|
||||
try {
|
||||
for (KeyValue k: set) {
|
||||
assertTrue(count++ == k.getTimestamp());
|
||||
}
|
||||
} catch (junit.framework.AssertionFailedError e) {
|
||||
// Expected
|
||||
assertion = true;
|
||||
}
|
||||
// Now with right comparator
|
||||
set = new TreeSet<KeyValue>(new KeyValue.RootComparator());
|
||||
// Add to set with bad comparator
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
set.add(rootKeys[i]);
|
||||
}
|
||||
count = 0;
|
||||
for (KeyValue k: set) {
|
||||
assertTrue(count++ == k.getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
public void testStackedUpKeyValue() {
|
||||
|
@ -559,14 +502,10 @@ public class TestKeyValue extends TestCase {
|
|||
assertTrue(newKeyValue.getTimestamp() == HConstants.LATEST_TIMESTAMP);
|
||||
assertTrue(newKeyValue.getType() == Type.Maximum.getCode());
|
||||
|
||||
//verify root/metaKeyComparator's getShortMidpointKey output
|
||||
final KeyComparator rootKeyComparator = new KeyValue.RootKeyComparator();
|
||||
//verify metaKeyComparator's getShortMidpointKey output
|
||||
final KeyComparator metaKeyComparator = new KeyValue.MetaKeyComparator();
|
||||
kv1 = new KeyValue(Bytes.toBytes("ilovehbase123"), family, qualA, 5, Type.Put);
|
||||
kv2 = new KeyValue(Bytes.toBytes("ilovehbase234"), family, qualA, 0, Type.Put);
|
||||
newKey = rootKeyComparator.getShortMidpointKey(kv1.getKey(), kv2.getKey());
|
||||
assertTrue(rootKeyComparator.compare(kv1.getKey(), newKey) < 0);
|
||||
assertTrue(rootKeyComparator.compare(newKey, kv2.getKey()) == 0);
|
||||
newKey = metaKeyComparator.getShortMidpointKey(kv1.getKey(), kv2.getKey());
|
||||
assertTrue(metaKeyComparator.compare(kv1.getKey(), newKey) < 0);
|
||||
assertTrue(metaKeyComparator.compare(newKey, kv2.getKey()) == 0);
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValue.KeyComparator;
|
||||
import org.apache.hadoop.hbase.KeyValue.MetaKeyComparator;
|
||||
import org.apache.hadoop.hbase.KeyValue.RootKeyComparator;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
import org.apache.hadoop.hbase.codec.prefixtree.decode.DecoderFactory;
|
||||
import org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher;
|
||||
|
@ -198,10 +197,6 @@ public class PrefixTreeCodec implements DataBlockEncoder{
|
|||
throw new IllegalArgumentException("DataBlockEncoding.PREFIX_TREE not compatible with META "
|
||||
+"table");
|
||||
}
|
||||
if(comparator instanceof RootKeyComparator){
|
||||
throw new IllegalArgumentException("DataBlockEncoding.PREFIX_TREE not compatible with ROOT "
|
||||
+"table");
|
||||
}
|
||||
|
||||
return new PrefixTreeSeeker(includesMvccVersion);
|
||||
}
|
||||
|
|
|
@ -612,7 +612,7 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
|||
KEY_VALUE_LEN_SIZE + currKeyLen + currValueLen,
|
||||
currKeyLen);
|
||||
if (this.reader.shouldIncludeMemstoreTS()) {
|
||||
ret.setMemstoreTS(currMemstoreTS);
|
||||
ret.setMvccVersion(currMemstoreTS);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -290,9 +290,9 @@ public class HFileWriterV2 extends AbstractHFileWriter {
|
|||
*/
|
||||
@Override
|
||||
public void append(final KeyValue kv) throws IOException {
|
||||
append(kv.getMemstoreTS(), kv.getBuffer(), kv.getKeyOffset(), kv.getKeyLength(),
|
||||
append(kv.getMvccVersion(), kv.getBuffer(), kv.getKeyOffset(), kv.getKeyLength(),
|
||||
kv.getBuffer(), kv.getValueOffset(), kv.getValueLength());
|
||||
this.maxMemstoreTS = Math.max(this.maxMemstoreTS, kv.getMemstoreTS());
|
||||
this.maxMemstoreTS = Math.max(this.maxMemstoreTS, kv.getMvccVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2623,7 +2623,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
Store store = getStore(family);
|
||||
for (Cell cell: cells) {
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
|
||||
kv.setMemstoreTS(localizedWriteEntry.getWriteNumber());
|
||||
kv.setMvccVersion(localizedWriteEntry.getWriteNumber());
|
||||
size += store.add(kv);
|
||||
}
|
||||
}
|
||||
|
@ -4514,7 +4514,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
writeEntry = mvcc.beginMemstoreInsert();
|
||||
// 6. Apply to memstore
|
||||
for (KeyValue kv : mutations) {
|
||||
kv.setMemstoreTS(writeEntry.getWriteNumber());
|
||||
kv.setMvccVersion(writeEntry.getWriteNumber());
|
||||
byte[] family = kv.getFamily();
|
||||
checkFamily(family);
|
||||
addedSize += stores.get(family).add(kv);
|
||||
|
@ -4730,7 +4730,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
newKV.getBuffer(), newKV.getQualifierOffset(),
|
||||
kv.getQualifierLength());
|
||||
|
||||
newKV.setMemstoreTS(w.getWriteNumber());
|
||||
newKV.setMvccVersion(w.getWriteNumber());
|
||||
kvs.add(newKV);
|
||||
|
||||
// Append update to WAL
|
||||
|
@ -4880,7 +4880,7 @@ public class HRegion implements HeapSize { // , Writable{
|
|||
// Append new incremented KeyValue to list
|
||||
KeyValue newKV =
|
||||
new KeyValue(row, family.getKey(), qualifier, now, Bytes.toBytes(amount));
|
||||
newKV.setMemstoreTS(w.getWriteNumber());
|
||||
newKV.setMvccVersion(w.getWriteNumber());
|
||||
kvs.add(newKV);
|
||||
|
||||
// Prepare WAL updates
|
||||
|
|
|
@ -82,12 +82,6 @@ public class MemStore implements HeapSize {
|
|||
|
||||
final KeyValue.KVComparator comparator;
|
||||
|
||||
// Used comparing versions -- same r/c and ts but different type.
|
||||
final KeyValue.KVComparator comparatorIgnoreType;
|
||||
|
||||
// Used comparing versions -- same r/c and type but different timestamp.
|
||||
final KeyValue.KVComparator comparatorIgnoreTimestamp;
|
||||
|
||||
// Used to track own heapSize
|
||||
final AtomicLong size;
|
||||
|
||||
|
@ -101,8 +95,6 @@ public class MemStore implements HeapSize {
|
|||
volatile MemStoreLAB allocator;
|
||||
volatile MemStoreLAB snapshotAllocator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor. Used for tests.
|
||||
*/
|
||||
|
@ -118,9 +110,6 @@ public class MemStore implements HeapSize {
|
|||
final KeyValue.KVComparator c) {
|
||||
this.conf = conf;
|
||||
this.comparator = c;
|
||||
this.comparatorIgnoreTimestamp =
|
||||
this.comparator.getComparatorIgnoringTimestamps();
|
||||
this.comparatorIgnoreType = this.comparator.getComparatorIgnoringType();
|
||||
this.kvset = new KeyValueSkipListSet(c);
|
||||
this.snapshot = new KeyValueSkipListSet(c);
|
||||
timeRangeTracker = new TimeRangeTracker();
|
||||
|
@ -288,7 +277,7 @@ public class MemStore implements HeapSize {
|
|||
assert alloc != null && alloc.getData() != null;
|
||||
System.arraycopy(kv.getBuffer(), kv.getOffset(), alloc.getData(), alloc.getOffset(), len);
|
||||
KeyValue newKv = new KeyValue(alloc.getData(), alloc.getOffset(), len);
|
||||
newKv.setMemstoreTS(kv.getMemstoreTS());
|
||||
newKv.setMvccVersion(kv.getMvccVersion());
|
||||
return newKv;
|
||||
}
|
||||
|
||||
|
@ -309,12 +298,12 @@ public class MemStore implements HeapSize {
|
|||
// yet started because Store.flush() waits for all rwcc transactions to
|
||||
// commit before starting the flush to disk.
|
||||
KeyValue found = this.snapshot.get(kv);
|
||||
if (found != null && found.getMemstoreTS() == kv.getMemstoreTS()) {
|
||||
if (found != null && found.getMvccVersion() == kv.getMvccVersion()) {
|
||||
this.snapshot.remove(kv);
|
||||
}
|
||||
// If the key is in the memstore, delete it. Update this.size.
|
||||
found = this.kvset.get(kv);
|
||||
if (found != null && found.getMemstoreTS() == kv.getMemstoreTS()) {
|
||||
if (found != null && found.getMvccVersion() == kv.getMvccVersion()) {
|
||||
removeFromKVSet(kv);
|
||||
long s = heapSizeChange(kv, true);
|
||||
this.size.addAndGet(-s);
|
||||
|
@ -623,7 +612,7 @@ public class MemStore implements HeapSize {
|
|||
// check that this is the row and column we are interested in, otherwise bail
|
||||
if (kv.matchingRow(cur) && kv.matchingQualifier(cur)) {
|
||||
// only remove Puts that concurrent scanners cannot possibly see
|
||||
if (cur.getType() == KeyValue.Type.Put.getCode() && cur.getMemstoreTS() <= readpoint) {
|
||||
if (cur.getType() == KeyValue.Type.Put.getCode() && cur.getMvccVersion() <= readpoint) {
|
||||
if (versionsVisible > 1) {
|
||||
// if we get here we have seen at least one version visible to the oldest scanner,
|
||||
// which means we can prove that no scanner will see this version
|
||||
|
@ -785,7 +774,7 @@ public class MemStore implements HeapSize {
|
|||
try {
|
||||
while (it.hasNext()) {
|
||||
v = it.next();
|
||||
if (v.getMemstoreTS() <= readPoint) {
|
||||
if (v.getMvccVersion() <= readPoint) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +958,7 @@ public class MemStore implements HeapSize {
|
|||
}
|
||||
|
||||
public final static long FIXED_OVERHEAD = ClassSize.align(
|
||||
ClassSize.OBJECT + (13 * ClassSize.REFERENCE) + Bytes.SIZEOF_LONG);
|
||||
ClassSize.OBJECT + (11 * ClassSize.REFERENCE) + Bytes.SIZEOF_LONG);
|
||||
|
||||
public final static long DEEP_OVERHEAD = ClassSize.align(FIXED_OVERHEAD +
|
||||
ClassSize.REENTRANT_LOCK + ClassSize.ATOMIC_LONG +
|
||||
|
|
|
@ -316,14 +316,14 @@ public class ScanQueryMatcher {
|
|||
tr.withinTimeRange(timestamp) :
|
||||
tr.withinOrAfterTimeRange(timestamp);
|
||||
if (includeDeleteMarker
|
||||
&& kv.getMemstoreTS() <= maxReadPointToTrackVersions) {
|
||||
&& kv.getMvccVersion() <= maxReadPointToTrackVersions) {
|
||||
this.deletes.add(bytes, offset, qualLength, timestamp, type);
|
||||
}
|
||||
// Can't early out now, because DelFam come before any other keys
|
||||
}
|
||||
if (retainDeletesInOutput
|
||||
|| (!isUserScan && (EnvironmentEdgeManager.currentTimeMillis() - timestamp) <= timeToPurgeDeletes)
|
||||
|| kv.getMemstoreTS() > maxReadPointToTrackVersions) {
|
||||
|| kv.getMvccVersion() > maxReadPointToTrackVersions) {
|
||||
// always include or it is not time yet to check whether it is OK
|
||||
// to purge deltes or not
|
||||
if (!isUserScan) {
|
||||
|
@ -390,7 +390,7 @@ public class ScanQueryMatcher {
|
|||
}
|
||||
|
||||
MatchCode colChecker = columns.checkColumn(bytes, offset, qualLength,
|
||||
timestamp, type, kv.getMemstoreTS() > maxReadPointToTrackVersions);
|
||||
timestamp, type, kv.getMvccVersion() > maxReadPointToTrackVersions);
|
||||
/*
|
||||
* According to current implementation, colChecker can only be
|
||||
* SEEK_NEXT_COL, SEEK_NEXT_ROW, SKIP or INCLUDE. Therefore, always return
|
||||
|
|
|
@ -183,7 +183,7 @@ public class StoreFileScanner implements KeyValueScanner {
|
|||
// readPoint
|
||||
while(enforceMVCC
|
||||
&& cur != null
|
||||
&& (cur.getMemstoreTS() > readPoint)) {
|
||||
&& (cur.getMvccVersion() > readPoint)) {
|
||||
hfs.next();
|
||||
cur = hfs.getKeyValue();
|
||||
}
|
||||
|
@ -199,8 +199,8 @@ public class StoreFileScanner implements KeyValueScanner {
|
|||
// older KV which was not reset to 0 (because it was
|
||||
// not old enough during flush). Make sure that we set it correctly now,
|
||||
// so that the comparision order does not change.
|
||||
if (cur.getMemstoreTS() <= readPoint) {
|
||||
cur.setMemstoreTS(0);
|
||||
if (cur.getMvccVersion() <= readPoint) {
|
||||
cur.setMvccVersion(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -126,11 +126,11 @@ s */
|
|||
// If we know that this KV is going to be included always, then let us
|
||||
// set its memstoreTS to 0. This will help us save space when writing to
|
||||
// disk.
|
||||
if (kv.getMemstoreTS() <= smallestReadPoint) {
|
||||
if (kv.getMvccVersion() <= smallestReadPoint) {
|
||||
// let us not change the original KV. It could be in the memstore
|
||||
// changing its memstoreTS could affect other threads/scanners.
|
||||
kv = kv.shallowCopy();
|
||||
kv.setMemstoreTS(0);
|
||||
kv.setMvccVersion(0);
|
||||
}
|
||||
sink.append(kv);
|
||||
flushed += MemStore.heapSizeChange(kv, true);
|
||||
|
|
|
@ -205,8 +205,8 @@ public abstract class Compactor {
|
|||
hasMore = scanner.next(kvs, compactionKVMax);
|
||||
// output to writer:
|
||||
for (KeyValue kv : kvs) {
|
||||
if (kv.getMemstoreTS() <= smallestReadPoint) {
|
||||
kv.setMemstoreTS(0);
|
||||
if (kv.getMvccVersion() <= smallestReadPoint) {
|
||||
kv.setMvccVersion(0);
|
||||
}
|
||||
writer.append(kv);
|
||||
++progress.currentCompactedKVs;
|
||||
|
|
|
@ -3213,9 +3213,9 @@ public class TestHRegion extends HBaseTestCase {
|
|||
if (Bytes.compareTo(previousKV.getValue(), thisValue) != 0) {
|
||||
LOG.warn("These two KV should have the same value." +
|
||||
" Previous KV:" +
|
||||
previousKV + "(memStoreTS:" + previousKV.getMemstoreTS() + ")" +
|
||||
previousKV + "(memStoreTS:" + previousKV.getMvccVersion() + ")" +
|
||||
", New KV: " +
|
||||
kv + "(memStoreTS:" + kv.getMemstoreTS() + ")"
|
||||
kv + "(memStoreTS:" + kv.getMvccVersion() + ")"
|
||||
);
|
||||
assertEquals(0, Bytes.compareTo(previousKV.getValue(), thisValue));
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ public class TestMemStore extends TestCase {
|
|||
mvcc.beginMemstoreInsert();
|
||||
|
||||
KeyValue kv1 = new KeyValue(row, f, q1, v);
|
||||
kv1.setMemstoreTS(w.getWriteNumber());
|
||||
kv1.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv1);
|
||||
|
||||
MultiVersionConsistencyControl.resetThreadReadPoint(mvcc);
|
||||
|
@ -253,7 +253,7 @@ public class TestMemStore extends TestCase {
|
|||
|
||||
w = mvcc.beginMemstoreInsert();
|
||||
KeyValue kv2 = new KeyValue(row, f, q2, v);
|
||||
kv2.setMemstoreTS(w.getWriteNumber());
|
||||
kv2.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv2);
|
||||
|
||||
MultiVersionConsistencyControl.resetThreadReadPoint(mvcc);
|
||||
|
@ -286,11 +286,11 @@ public class TestMemStore extends TestCase {
|
|||
mvcc.beginMemstoreInsert();
|
||||
|
||||
KeyValue kv11 = new KeyValue(row, f, q1, v1);
|
||||
kv11.setMemstoreTS(w.getWriteNumber());
|
||||
kv11.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv11);
|
||||
|
||||
KeyValue kv12 = new KeyValue(row, f, q2, v1);
|
||||
kv12.setMemstoreTS(w.getWriteNumber());
|
||||
kv12.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv12);
|
||||
mvcc.completeMemstoreInsert(w);
|
||||
|
||||
|
@ -302,11 +302,11 @@ public class TestMemStore extends TestCase {
|
|||
// START INSERT 2: Write both columns val2
|
||||
w = mvcc.beginMemstoreInsert();
|
||||
KeyValue kv21 = new KeyValue(row, f, q1, v2);
|
||||
kv21.setMemstoreTS(w.getWriteNumber());
|
||||
kv21.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv21);
|
||||
|
||||
KeyValue kv22 = new KeyValue(row, f, q2, v2);
|
||||
kv22.setMemstoreTS(w.getWriteNumber());
|
||||
kv22.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv22);
|
||||
|
||||
// BEFORE COMPLETING INSERT 2, SEE FIRST KVS
|
||||
|
@ -341,11 +341,11 @@ public class TestMemStore extends TestCase {
|
|||
mvcc.beginMemstoreInsert();
|
||||
|
||||
KeyValue kv11 = new KeyValue(row, f, q1, v1);
|
||||
kv11.setMemstoreTS(w.getWriteNumber());
|
||||
kv11.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv11);
|
||||
|
||||
KeyValue kv12 = new KeyValue(row, f, q2, v1);
|
||||
kv12.setMemstoreTS(w.getWriteNumber());
|
||||
kv12.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv12);
|
||||
mvcc.completeMemstoreInsert(w);
|
||||
|
||||
|
@ -358,7 +358,7 @@ public class TestMemStore extends TestCase {
|
|||
w = mvcc.beginMemstoreInsert();
|
||||
KeyValue kvDel = new KeyValue(row, f, q2, kv11.getTimestamp(),
|
||||
KeyValue.Type.DeleteColumn);
|
||||
kvDel.setMemstoreTS(w.getWriteNumber());
|
||||
kvDel.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kvDel);
|
||||
|
||||
// BEFORE COMPLETING DELETE, SEE FIRST KVS
|
||||
|
@ -418,7 +418,7 @@ public class TestMemStore extends TestCase {
|
|||
byte[] v = Bytes.toBytes(i);
|
||||
|
||||
KeyValue kv = new KeyValue(row, f, q1, i, v);
|
||||
kv.setMemstoreTS(w.getWriteNumber());
|
||||
kv.setMvccVersion(w.getWriteNumber());
|
||||
memstore.add(kv);
|
||||
mvcc.completeMemstoreInsert(w);
|
||||
|
||||
|
@ -492,38 +492,6 @@ public class TestMemStore extends TestCase {
|
|||
m.kvset.size(), m.kvset.size() == 3);
|
||||
}
|
||||
|
||||
public void testBinary() {
|
||||
MemStore mc = new MemStore(new Configuration(), KeyValue.ROOT_COMPARATOR);
|
||||
final int start = 43;
|
||||
final int end = 46;
|
||||
for (int k = start; k <= end; k++) {
|
||||
byte [] kk = Bytes.toBytes(k);
|
||||
byte [] row =
|
||||
Bytes.toBytes(TableName.META_TABLE_NAME+",table," + Bytes.toString(kk) + ",1," + k);
|
||||
KeyValue key = new KeyValue(row, CONTENTS, BASIC,
|
||||
System.currentTimeMillis(),
|
||||
Bytes.toBytes(CONTENTSTR + k));
|
||||
mc.add(key);
|
||||
System.out.println(key);
|
||||
// key = new KeyValue(row, Bytes.toBytes(ANCHORNUM + k),
|
||||
// System.currentTimeMillis(),
|
||||
// Bytes.toBytes(ANCHORSTR + k));
|
||||
// mc.add(key);
|
||||
// System.out.println(key);
|
||||
}
|
||||
int index = start;
|
||||
for (KeyValue kv: mc.kvset) {
|
||||
System.out.println(kv);
|
||||
byte [] b = kv.getRow();
|
||||
// Hardcoded offsets into String
|
||||
String str = Bytes.toString(b, TableName.META_TABLE_NAME.getName().length+7, 4);
|
||||
byte [] bb = Bytes.toBytes(index);
|
||||
String bbStr = Bytes.toString(bb);
|
||||
assertEquals(str, bbStr);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Get tests
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue