HBASE-1938 Make in-memory table scanning faster ; reverted 20110726_1938_MemStore.patch till we figure why it seems to slow tests
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1151653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a02c83a1d7
commit
5148146daf
|
@ -646,15 +646,11 @@ public class MemStore implements HeapSize {
|
||||||
private KeyValue snapshotNextRow = null;
|
private KeyValue snapshotNextRow = null;
|
||||||
|
|
||||||
// iterator based scanning.
|
// iterator based scanning.
|
||||||
private Iterator<KeyValue> kvsetIt;
|
Iterator<KeyValue> kvsetIt;
|
||||||
private Iterator<KeyValue> snapshotIt;
|
Iterator<KeyValue> snapshotIt;
|
||||||
|
|
||||||
// number of iterations in this reseek operation
|
// number of iterations in this reseek operation
|
||||||
private int numIterReseek;
|
int numIterReseek;
|
||||||
|
|
||||||
|
|
||||||
// the pre-calculated KeyValue to be returned by peek() or next()
|
|
||||||
private KeyValue theNext;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some notes...
|
Some notes...
|
||||||
|
@ -680,9 +676,9 @@ public class MemStore implements HeapSize {
|
||||||
//DebugPrint.println(" MS new@" + hashCode());
|
//DebugPrint.println(" MS new@" + hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyValue getNext(Iterator<KeyValue> it, long readPoint) {
|
protected KeyValue getNext(Iterator<KeyValue> it) {
|
||||||
KeyValue ret = null;
|
KeyValue ret = null;
|
||||||
//long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
||||||
//DebugPrint.println( " MS@" + hashCode() + ": threadpoint = " + readPoint);
|
//DebugPrint.println( " MS@" + hashCode() + ": threadpoint = " + readPoint);
|
||||||
|
|
||||||
while (ret == null && it.hasNext()) {
|
while (ret == null && it.hasNext()) {
|
||||||
|
@ -714,11 +710,9 @@ public class MemStore implements HeapSize {
|
||||||
kvsetIt = kvTail.iterator();
|
kvsetIt = kvTail.iterator();
|
||||||
snapshotIt = snapshotTail.iterator();
|
snapshotIt = snapshotTail.iterator();
|
||||||
|
|
||||||
long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
kvsetNextRow = getNext(kvsetIt);
|
||||||
kvsetNextRow = getNext(kvsetIt, readPoint);
|
snapshotNextRow = getNext(snapshotIt);
|
||||||
snapshotNextRow = getNext(snapshotIt, readPoint);
|
|
||||||
|
|
||||||
theNext = getLowest();
|
|
||||||
|
|
||||||
//long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
//long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
||||||
//DebugPrint.println( " MS@" + hashCode() + " kvset seek: " + kvsetNextRow + " with size = " +
|
//DebugPrint.println( " MS@" + hashCode() + " kvset seek: " + kvsetNextRow + " with size = " +
|
||||||
|
@ -726,18 +720,19 @@ public class MemStore implements HeapSize {
|
||||||
//DebugPrint.println( " MS@" + hashCode() + " snapshot seek: " + snapshotNextRow + " with size = " +
|
//DebugPrint.println( " MS@" + hashCode() + " snapshot seek: " + snapshotNextRow + " with size = " +
|
||||||
// snapshot.size() + " threadread = " + readPoint);
|
// snapshot.size() + " threadread = " + readPoint);
|
||||||
|
|
||||||
// has data
|
|
||||||
return (theNext != null);
|
KeyValue lowest = getLowest();
|
||||||
|
|
||||||
|
// has data := (lowest != null)
|
||||||
|
return lowest != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean reseek(KeyValue key) {
|
public boolean reseek(KeyValue key) {
|
||||||
|
|
||||||
numIterReseek = reseekNumKeys;
|
numIterReseek = reseekNumKeys;
|
||||||
while (kvsetNextRow != null &&
|
while (kvsetNextRow != null &&
|
||||||
comparator.compare(kvsetNextRow, key) < 0) {
|
comparator.compare(kvsetNextRow, key) < 0) {
|
||||||
kvsetNextRow = getNext(kvsetIt,
|
kvsetNextRow = getNext(kvsetIt);
|
||||||
ReadWriteConsistencyControl.getThreadReadPoint());
|
|
||||||
// if we scanned enough entries but still not able to find the
|
// if we scanned enough entries but still not able to find the
|
||||||
// kv we are looking for, better cut our costs and do a tree
|
// kv we are looking for, better cut our costs and do a tree
|
||||||
// scan using seek.
|
// scan using seek.
|
||||||
|
@ -748,8 +743,7 @@ public class MemStore implements HeapSize {
|
||||||
|
|
||||||
while (snapshotNextRow != null &&
|
while (snapshotNextRow != null &&
|
||||||
comparator.compare(snapshotNextRow, key) < 0) {
|
comparator.compare(snapshotNextRow, key) < 0) {
|
||||||
snapshotNextRow = getNext(snapshotIt,
|
snapshotNextRow = getNext(snapshotIt);
|
||||||
ReadWriteConsistencyControl.getThreadReadPoint());
|
|
||||||
// if we scanned enough entries but still not able to find the
|
// if we scanned enough entries but still not able to find the
|
||||||
// kv we are looking for, better cut our costs and do a tree
|
// kv we are looking for, better cut our costs and do a tree
|
||||||
// scan using seek.
|
// scan using seek.
|
||||||
|
@ -757,48 +751,38 @@ public class MemStore implements HeapSize {
|
||||||
return seek(key);
|
return seek(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return (kvsetNextRow != null || snapshotNextRow != null);
|
||||||
// Calculate the next value
|
|
||||||
theNext = getLowest();
|
|
||||||
|
|
||||||
return (theNext != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized KeyValue peek() {
|
public synchronized KeyValue peek() {
|
||||||
//DebugPrint.println(" MS@" + hashCode() + " peek = " + getLowest());
|
//DebugPrint.println(" MS@" + hashCode() + " peek = " + getLowest());
|
||||||
return theNext;
|
return getLowest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized KeyValue next() {
|
public synchronized KeyValue next() {
|
||||||
|
KeyValue theNext = getLowest();
|
||||||
|
|
||||||
if (theNext == null) {
|
if (theNext == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValue ret = theNext;
|
|
||||||
|
|
||||||
// Advance one of the iterators
|
// Advance one of the iterators
|
||||||
long readPoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
|
||||||
if (theNext == kvsetNextRow) {
|
if (theNext == kvsetNextRow) {
|
||||||
kvsetNextRow = getNext(kvsetIt, readPoint);
|
kvsetNextRow = getNext(kvsetIt);
|
||||||
} else {
|
} else {
|
||||||
snapshotNextRow = getNext(snapshotIt, readPoint);
|
snapshotNextRow = getNext(snapshotIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the next value
|
//long readpoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
||||||
theNext = getLowest();
|
//DebugPrint.println(" MS@" + hashCode() + " next: " + theNext + " next_next: " +
|
||||||
|
// getLowest() + " threadpoint=" + readpoint);
|
||||||
//readpoint = ReadWriteConsistencyControl.getThreadReadPoint();
|
return theNext;
|
||||||
//DebugPrint.println(" MS@" + hashCode() + " next: " + theNext +
|
|
||||||
// " next_next: " + getLowest() + " threadpoint=" + readpoint);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyValue getLowest() {
|
protected KeyValue getLowest() {
|
||||||
return getLower(kvsetNextRow, snapshotNextRow);
|
return getLower(kvsetNextRow,
|
||||||
|
snapshotNextRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -807,16 +791,15 @@ public class MemStore implements HeapSize {
|
||||||
* comparator.
|
* comparator.
|
||||||
*/
|
*/
|
||||||
protected KeyValue getLower(KeyValue first, KeyValue second) {
|
protected KeyValue getLower(KeyValue first, KeyValue second) {
|
||||||
if (first == null) {
|
if (first == null && second == null) {
|
||||||
return second;
|
return null;
|
||||||
}
|
}
|
||||||
if (second == null) {
|
if (first != null && second != null) {
|
||||||
return first;
|
|
||||||
}
|
|
||||||
|
|
||||||
int compare = comparator.compare(first, second);
|
int compare = comparator.compare(first, second);
|
||||||
return (compare <= 0 ? first : second);
|
return (compare <= 0 ? first : second);
|
||||||
}
|
}
|
||||||
|
return (first != null ? first : second);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
this.kvsetNextRow = null;
|
this.kvsetNextRow = null;
|
||||||
|
|
Loading…
Reference in New Issue