HBASE-1643 ScanDeleteTracker takes comparator but it unused
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@793084 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
60e69c6982
commit
f10f85f0ff
|
@ -462,6 +462,7 @@ Release 0.20.0 - Unreleased
|
||||||
Scan (Jon Gray via Nitay)
|
Scan (Jon Gray via Nitay)
|
||||||
HBASE-1640 Allow passing arguments to jruby script run when run by bin/hbase shell
|
HBASE-1640 Allow passing arguments to jruby script run when run by bin/hbase shell
|
||||||
HBASE-698 HLog recovery is not performed after master failure
|
HBASE-698 HLog recovery is not performed after master failure
|
||||||
|
HBASE-1643 ScanDeleteTracker takes comparator but it unused
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
HBASE-1412 Change values for delete column and column family in KeyValue
|
HBASE-1412 Change values for delete column and column family in KeyValue
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class GetDeleteTracker implements DeleteTracker {
|
||||||
int qualifierLength, long timestamp) {
|
int qualifierLength, long timestamp) {
|
||||||
|
|
||||||
// Check against DeleteFamily
|
// Check against DeleteFamily
|
||||||
if(timestamp <= familyStamp) {
|
if (timestamp <= familyStamp) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class KeyValueHeap implements KeyValueScanner, InternalScanner {
|
||||||
this.comparator = new KVScannerComparator(comparator);
|
this.comparator = new KVScannerComparator(comparator);
|
||||||
this.heap = new PriorityQueue<KeyValueScanner>(scanners.length,
|
this.heap = new PriorityQueue<KeyValueScanner>(scanners.length,
|
||||||
this.comparator);
|
this.comparator);
|
||||||
for(KeyValueScanner scanner : scanners) {
|
for (KeyValueScanner scanner : scanners) {
|
||||||
if(scanner.peek() != null) {
|
if (scanner.peek() != null) {
|
||||||
this.heap.add(scanner);
|
this.heap.add(scanner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class KeyValueHeap implements KeyValueScanner, InternalScanner {
|
||||||
InternalScanner currentAsInternal = (InternalScanner)this.current;
|
InternalScanner currentAsInternal = (InternalScanner)this.current;
|
||||||
currentAsInternal.next(result);
|
currentAsInternal.next(result);
|
||||||
KeyValue pee = this.current.peek();
|
KeyValue pee = this.current.peek();
|
||||||
if(pee == null) {
|
if (pee == null) {
|
||||||
this.current.close();
|
this.current.close();
|
||||||
} else {
|
} else {
|
||||||
this.heap.add(this.current);
|
this.heap.add(this.current);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class MinorCompactingStoreScanner implements KeyValueScanner, InternalSca
|
||||||
MinorCompactingStoreScanner(Store store,
|
MinorCompactingStoreScanner(Store store,
|
||||||
KeyValueScanner [] scanners) {
|
KeyValueScanner [] scanners) {
|
||||||
comparator = store.comparator;
|
comparator = store.comparator;
|
||||||
deleteTracker = new ScanDeleteTracker(store.comparator.getRawComparator());
|
deleteTracker = new ScanDeleteTracker();
|
||||||
KeyValue firstKv = KeyValue.createFirstOnRow(HConstants.EMPTY_START_ROW);
|
KeyValue firstKv = KeyValue.createFirstOnRow(HConstants.EMPTY_START_ROW);
|
||||||
for (KeyValueScanner scanner : scanners ) {
|
for (KeyValueScanner scanner : scanners ) {
|
||||||
scanner.seek(firstKv);
|
scanner.seek(firstKv);
|
||||||
|
@ -53,7 +53,7 @@ public class MinorCompactingStoreScanner implements KeyValueScanner, InternalSca
|
||||||
MinorCompactingStoreScanner(String cfName, KeyValue.KVComparator comparator,
|
MinorCompactingStoreScanner(String cfName, KeyValue.KVComparator comparator,
|
||||||
KeyValueScanner [] scanners) {
|
KeyValueScanner [] scanners) {
|
||||||
this.comparator = comparator;
|
this.comparator = comparator;
|
||||||
deleteTracker = new ScanDeleteTracker(comparator.getRawComparator());
|
deleteTracker = new ScanDeleteTracker();
|
||||||
|
|
||||||
KeyValue firstKv = KeyValue.createFirstOnRow(HConstants.EMPTY_START_ROW);
|
KeyValue firstKv = KeyValue.createFirstOnRow(HConstants.EMPTY_START_ROW);
|
||||||
for (KeyValueScanner scanner : scanners ) {
|
for (KeyValueScanner scanner : scanners ) {
|
||||||
|
|
|
@ -47,14 +47,11 @@ public class ScanDeleteTracker implements DeleteTracker {
|
||||||
private byte deleteType = 0;
|
private byte deleteType = 0;
|
||||||
private long deleteTimestamp = 0L;
|
private long deleteTimestamp = 0L;
|
||||||
|
|
||||||
private KeyValue.KeyComparator comparator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ScanDeleteTracker
|
* Constructor for ScanDeleteTracker
|
||||||
* @param comparator
|
|
||||||
*/
|
*/
|
||||||
public ScanDeleteTracker(KeyValue.KeyComparator comparator) {
|
public ScanDeleteTracker() {
|
||||||
this.comparator = comparator;
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,15 +68,15 @@ public class ScanDeleteTracker implements DeleteTracker {
|
||||||
@Override
|
@Override
|
||||||
public void add(byte[] buffer, int qualifierOffset, int qualifierLength,
|
public void add(byte[] buffer, int qualifierOffset, int qualifierLength,
|
||||||
long timestamp, byte type) {
|
long timestamp, byte type) {
|
||||||
if(timestamp > familyStamp) {
|
if (timestamp > familyStamp) {
|
||||||
if(type == KeyValue.Type.DeleteFamily.getCode()) {
|
if (type == KeyValue.Type.DeleteFamily.getCode()) {
|
||||||
familyStamp = timestamp;
|
familyStamp = timestamp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(deleteBuffer != null && type < deleteType) {
|
if (deleteBuffer != null && type < deleteType) {
|
||||||
// same column, so ignore less specific delete
|
// same column, so ignore less specific delete
|
||||||
if(Bytes.compareTo(deleteBuffer, deleteOffset, deleteLength,
|
if (Bytes.compareTo(deleteBuffer, deleteOffset, deleteLength,
|
||||||
buffer, qualifierOffset, qualifierLength) == 0){
|
buffer, qualifierOffset, qualifierLength) == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -107,17 +104,16 @@ public class ScanDeleteTracker implements DeleteTracker {
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeleted(byte [] buffer, int qualifierOffset,
|
public boolean isDeleted(byte [] buffer, int qualifierOffset,
|
||||||
int qualifierLength, long timestamp) {
|
int qualifierLength, long timestamp) {
|
||||||
if(timestamp < familyStamp) {
|
if (timestamp < familyStamp) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(deleteBuffer != null) {
|
if (deleteBuffer != null) {
|
||||||
// TODO ryan use a specific comparator
|
|
||||||
int ret = Bytes.compareTo(deleteBuffer, deleteOffset, deleteLength,
|
int ret = Bytes.compareTo(deleteBuffer, deleteOffset, deleteLength,
|
||||||
buffer, qualifierOffset, qualifierLength);
|
buffer, qualifierOffset, qualifierLength);
|
||||||
|
|
||||||
if(ret == 0) {
|
if (ret == 0) {
|
||||||
if(deleteType == KeyValue.Type.DeleteColumn.getCode()) {
|
if (deleteType == KeyValue.Type.DeleteColumn.getCode()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Delete (aka DeleteVersion)
|
// Delete (aka DeleteVersion)
|
||||||
|
@ -158,5 +154,4 @@ public class ScanDeleteTracker implements DeleteTracker {
|
||||||
public void update() {
|
public void update() {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -24,7 +24,6 @@ import java.util.NavigableSet;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.filter.Filter;
|
|
||||||
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
||||||
import org.apache.hadoop.hbase.filter.Filter.ReturnCode;
|
import org.apache.hadoop.hbase.filter.Filter.ReturnCode;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -54,15 +53,14 @@ public class ScanQueryMatcher extends QueryMatcher {
|
||||||
this.tr = scan.getTimeRange();
|
this.tr = scan.getTimeRange();
|
||||||
this.oldestStamp = System.currentTimeMillis() - ttl;
|
this.oldestStamp = System.currentTimeMillis() - ttl;
|
||||||
this.rowComparator = rowComparator;
|
this.rowComparator = rowComparator;
|
||||||
// shouldn't this be ScanDeleteTracker?
|
this.deletes = new ScanDeleteTracker();
|
||||||
this.deletes = new ScanDeleteTracker(rowComparator);
|
|
||||||
this.startKey = KeyValue.createFirstOnRow(scan.getStartRow());
|
this.startKey = KeyValue.createFirstOnRow(scan.getStartRow());
|
||||||
this.stopKey = KeyValue.createFirstOnRow(scan.getStopRow());
|
this.stopKey = KeyValue.createFirstOnRow(scan.getStopRow());
|
||||||
this.filter = scan.getFilter();
|
this.filter = scan.getFilter();
|
||||||
this.oldFilter = scan.getOldFilter();
|
this.oldFilter = scan.getOldFilter();
|
||||||
|
|
||||||
// Single branch to deal with two types of reads (columns vs all in family)
|
// Single branch to deal with two types of reads (columns vs all in family)
|
||||||
if(columns == null || columns.size() == 0) {
|
if (columns == null || columns.size() == 0) {
|
||||||
// use a specialized scan for wildcard column tracker.
|
// use a specialized scan for wildcard column tracker.
|
||||||
this.columns = new ScanWildcardColumnTracker(maxVersions);
|
this.columns = new ScanWildcardColumnTracker(maxVersions);
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,7 +164,8 @@ public class ScanQueryMatcher extends QueryMatcher {
|
||||||
return MatchCode.SKIP;
|
return MatchCode.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deletes.isDeleted(bytes, offset, qualLength, timestamp)) {
|
if (!this.deletes.isEmpty() &&
|
||||||
|
deletes.isDeleted(bytes, offset, qualLength, timestamp)) {
|
||||||
return MatchCode.SKIP;
|
return MatchCode.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
||||||
|
|
||||||
// Combine all seeked scanners with a heap
|
// Combine all seeked scanners with a heap
|
||||||
heap = new KeyValueHeap(
|
heap = new KeyValueHeap(
|
||||||
scanners.toArray(new KeyValueScanner[scanners.size()]), store.comparator);
|
scanners.toArray(new KeyValueScanner[scanners.size()]), store.comparator);
|
||||||
|
|
||||||
this.store.addChangedReaderObserver(this);
|
this.store.addChangedReaderObserver(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue