HBASE-2496 Less ArrayList churn on the scan path
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@939030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c50c92879
commit
369056d691
@ -537,6 +537,7 @@ Release 0.21.0 - Unreleased
|
|||||||
(Todd Lipcon via Stack)
|
(Todd Lipcon via Stack)
|
||||||
HBASE-2393 ThriftServer instantiates a new HTable per request
|
HBASE-2393 ThriftServer instantiates a new HTable per request
|
||||||
(Bogdan DRAGU via Stack)
|
(Bogdan DRAGU via Stack)
|
||||||
|
HBASE-2496 Less ArrayList churn on the scan path
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
HBASE-1961 HBase EC2 scripts
|
HBASE-1961 HBase EC2 scripts
|
||||||
|
@ -25,9 +25,9 @@ package org.apache.hadoop.hbase.regionserver;
|
|||||||
* NOT thread-safe because it is not used in a multi-threaded context, yet.
|
* NOT thread-safe because it is not used in a multi-threaded context, yet.
|
||||||
*/
|
*/
|
||||||
public class ColumnCount {
|
public class ColumnCount {
|
||||||
private byte [] bytes;
|
private final byte [] bytes;
|
||||||
private int offset;
|
private final int offset;
|
||||||
private int length;
|
private final int length;
|
||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +97,15 @@ public class ColumnCount {
|
|||||||
public int increment() {
|
public int increment() {
|
||||||
return ++count;
|
return ++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current count to a new count
|
||||||
|
* @param count new count to set
|
||||||
|
*/
|
||||||
|
public void setCount(int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if needed to fetch more versions
|
* Check to see if needed to fetch more versions
|
||||||
|
@ -46,11 +46,11 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||||||
*/
|
*/
|
||||||
public class ExplicitColumnTracker implements ColumnTracker {
|
public class ExplicitColumnTracker implements ColumnTracker {
|
||||||
|
|
||||||
private int maxVersions;
|
private final int maxVersions;
|
||||||
private List<ColumnCount> columns;
|
private final List<ColumnCount> columns;
|
||||||
|
private final List<ColumnCount> columnsToReuse;
|
||||||
private int index;
|
private int index;
|
||||||
private ColumnCount column;
|
private ColumnCount column;
|
||||||
private NavigableSet<byte[]> origColumns;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
@ -59,7 +59,11 @@ public class ExplicitColumnTracker implements ColumnTracker {
|
|||||||
*/
|
*/
|
||||||
public ExplicitColumnTracker(NavigableSet<byte[]> columns, int maxVersions) {
|
public ExplicitColumnTracker(NavigableSet<byte[]> columns, int maxVersions) {
|
||||||
this.maxVersions = maxVersions;
|
this.maxVersions = maxVersions;
|
||||||
this.origColumns = columns;
|
this.columns = new ArrayList<ColumnCount>(columns.size());
|
||||||
|
this.columnsToReuse = new ArrayList<ColumnCount>(columns.size());
|
||||||
|
for(byte [] column : columns) {
|
||||||
|
this.columnsToReuse.add(new ColumnCount(column,maxVersions));
|
||||||
|
}
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,15 +151,16 @@ public class ExplicitColumnTracker implements ColumnTracker {
|
|||||||
|
|
||||||
// Called between every row.
|
// Called between every row.
|
||||||
public void reset() {
|
public void reset() {
|
||||||
buildColumnList(this.origColumns);
|
buildColumnList();
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.column = this.columns.get(this.index);
|
this.column = this.columns.get(this.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildColumnList(NavigableSet<byte[]> columns) {
|
private void buildColumnList() {
|
||||||
this.columns = new ArrayList<ColumnCount>(columns.size());
|
this.columns.clear();
|
||||||
for(byte [] column : columns) {
|
this.columns.addAll(this.columnsToReuse);
|
||||||
this.columns.add(new ColumnCount(column,maxVersions));
|
for(ColumnCount col : this.columns) {
|
||||||
|
col.setCount(this.maxVersions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1815,12 +1815,12 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
this.leases.renewLease(scannerName);
|
this.leases.renewLease(scannerName);
|
||||||
List<Result> results = new ArrayList<Result>();
|
List<Result> results = new ArrayList<Result>(nbRows);
|
||||||
long currentScanResultSize = 0;
|
long currentScanResultSize = 0;
|
||||||
|
List<KeyValue> values = new ArrayList<KeyValue>();
|
||||||
for (int i = 0; i < nbRows && currentScanResultSize < maxScannerResultSize; i++) {
|
for (int i = 0; i < nbRows && currentScanResultSize < maxScannerResultSize; i++) {
|
||||||
requestCount.incrementAndGet();
|
requestCount.incrementAndGet();
|
||||||
// Collect values to be returned here
|
// Collect values to be returned here
|
||||||
List<KeyValue> values = new ArrayList<KeyValue>();
|
|
||||||
boolean moreRows = s.next(values);
|
boolean moreRows = s.next(values);
|
||||||
if (!values.isEmpty()) {
|
if (!values.isEmpty()) {
|
||||||
for (KeyValue kv : values) {
|
for (KeyValue kv : values) {
|
||||||
@ -1831,6 +1831,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
|||||||
if (!moreRows) {
|
if (!moreRows) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
values.clear();
|
||||||
}
|
}
|
||||||
// Below is an ugly hack where we cast the InternalScanner to be a
|
// Below is an ugly hack where we cast the InternalScanner to be a
|
||||||
// HRegion.RegionScanner. The alternative is to change InternalScanner
|
// HRegion.RegionScanner. The alternative is to change InternalScanner
|
||||||
|
Loading…
x
Reference in New Issue
Block a user