HBASE-18059 remove scanner order related code
This commit is contained in:
parent
6ca8261fc0
commit
556b223744
|
@ -60,18 +60,16 @@ public abstract class AbstractMemStore implements MemStore {
|
||||||
|
|
||||||
public final static long DEEP_OVERHEAD = FIXED_OVERHEAD;
|
public final static long DEEP_OVERHEAD = FIXED_OVERHEAD;
|
||||||
|
|
||||||
public static long addToScanners(List<? extends Segment> segments, long readPt, long order,
|
public static void addToScanners(List<? extends Segment> segments, long readPt,
|
||||||
List<KeyValueScanner> scanners) {
|
List<KeyValueScanner> scanners) {
|
||||||
for (Segment item : segments) {
|
for (Segment item : segments) {
|
||||||
order = addToScanners(item, readPt, order, scanners);
|
addToScanners(item, readPt, scanners);
|
||||||
}
|
}
|
||||||
return order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static long addToScanners(Segment segment, long readPt, long order,
|
protected static void addToScanners(Segment segment, long readPt,
|
||||||
List<KeyValueScanner> scanners) {
|
List<KeyValueScanner> scanners) {
|
||||||
scanners.add(segment.getScanner(readPt, order));
|
scanners.add(segment.getScanner(readPt));
|
||||||
return order - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractMemStore(final Configuration conf, final CellComparator c) {
|
protected AbstractMemStore(final Configuration conf, final CellComparator c) {
|
||||||
|
|
|
@ -354,20 +354,16 @@ public class CompactingMemStore extends AbstractMemStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/*
|
|
||||||
* Scanners are ordered from 0 (oldest) to newest in increasing order.
|
|
||||||
*/
|
|
||||||
public List<KeyValueScanner> getScanners(long readPt) throws IOException {
|
public List<KeyValueScanner> getScanners(long readPt) throws IOException {
|
||||||
MutableSegment activeTmp = active;
|
MutableSegment activeTmp = active;
|
||||||
List<? extends Segment> pipelineList = pipeline.getSegments();
|
List<? extends Segment> pipelineList = pipeline.getSegments();
|
||||||
List<? extends Segment> snapshotList = snapshot.getAllSegments();
|
List<? extends Segment> snapshotList = snapshot.getAllSegments();
|
||||||
long order = 1L + pipelineList.size() + snapshotList.size();
|
long numberOfSegments = 1L + pipelineList.size() + snapshotList.size();
|
||||||
// The list of elements in pipeline + the active element + the snapshot segment
|
// The list of elements in pipeline + the active element + the snapshot segment
|
||||||
// The order is the Segment ordinal
|
List<KeyValueScanner> list = createList((int) numberOfSegments);
|
||||||
List<KeyValueScanner> list = createList((int) order);
|
addToScanners(activeTmp, readPt, list);
|
||||||
order = addToScanners(activeTmp, readPt, order, list);
|
addToScanners(pipelineList, readPt, list);
|
||||||
order = addToScanners(pipelineList, readPt, order, list);
|
addToScanners(snapshotList, readPt, list);
|
||||||
addToScanners(snapshotList, readPt, order, list);
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,19 +120,11 @@ public class CompositeImmutableSegment extends ImmutableSegment {
|
||||||
throw new IllegalStateException("Not supported by CompositeImmutableScanner");
|
throw new IllegalStateException("Not supported by CompositeImmutableScanner");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the scanner for the given read point, and a specific order in a list
|
|
||||||
* @return a scanner for the given read point
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public KeyValueScanner getScanner(long readPoint, long order) {
|
|
||||||
throw new IllegalStateException("Not supported by CompositeImmutableScanner");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<KeyValueScanner> getScanners(long readPoint, long order) {
|
public List<KeyValueScanner> getScanners(long readPoint) {
|
||||||
List<KeyValueScanner> list = new ArrayList<>(segments.size());
|
List<KeyValueScanner> list = new ArrayList<>(segments.size());
|
||||||
AbstractMemStore.addToScanners(segments, readPoint, order, list);
|
AbstractMemStore.addToScanners(segments, readPoint, list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,8 @@ public class DefaultMemStore extends AbstractMemStore {
|
||||||
*/
|
*/
|
||||||
public List<KeyValueScanner> getScanners(long readPt) throws IOException {
|
public List<KeyValueScanner> getScanners(long readPt) throws IOException {
|
||||||
List<KeyValueScanner> list = new ArrayList<>();
|
List<KeyValueScanner> list = new ArrayList<>();
|
||||||
long order = snapshot.getNumOfSegments();
|
addToScanners(active, readPt, list);
|
||||||
order = addToScanners(active, readPt, order, list);
|
addToScanners(snapshot.getAllSegments(), readPt, list);
|
||||||
addToScanners(snapshot.getAllSegments(), readPt, order, list);
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,13 +415,6 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
|
||||||
return this.heap;
|
return this.heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see KeyValueScanner#getScannerOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long getScannerOrder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
KeyValueScanner getCurrentForTesting() {
|
KeyValueScanner getCurrentForTesting() {
|
||||||
|
|
|
@ -73,13 +73,13 @@ public interface KeyValueScanner extends Shipper, Closeable {
|
||||||
boolean reseek(Cell key) throws IOException;
|
boolean reseek(Cell key) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the order of this KeyValueScanner. This is only relevant for StoreFileScanners and
|
* Get the order of this KeyValueScanner. This is only relevant for StoreFileScanners.
|
||||||
* MemStoreScanners (other scanners simply return 0). This is required for comparing multiple
|
* This is required for comparing multiple files to find out which one has the latest
|
||||||
* files to find out which one has the latest data. StoreFileScanners are ordered from 0
|
* data. StoreFileScanners are ordered from 0 (oldest) to newest in increasing order.
|
||||||
* (oldest) to newest in increasing order. MemStoreScanner gets LONG.max since it always
|
|
||||||
* contains freshest data.
|
|
||||||
*/
|
*/
|
||||||
long getScannerOrder();
|
default long getScannerOrder(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the KeyValue scanner.
|
* Close the KeyValue scanner.
|
||||||
|
|
|
@ -56,10 +56,7 @@ public class MemStoreCompactorSegmentsIterator extends MemStoreSegmentsIterator
|
||||||
super(compactionKVMax);
|
super(compactionKVMax);
|
||||||
|
|
||||||
List<KeyValueScanner> scanners = new ArrayList<KeyValueScanner>();
|
List<KeyValueScanner> scanners = new ArrayList<KeyValueScanner>();
|
||||||
// create the list of scanners to traverse over all the data
|
AbstractMemStore.addToScanners(segments, Integer.MAX_VALUE, scanners);
|
||||||
// no dirty reads here as these are immutable segments
|
|
||||||
int order = segments.size();
|
|
||||||
AbstractMemStore.addToScanners(segments, Integer.MAX_VALUE, order, scanners);
|
|
||||||
// build the scanner based on Query Matcher
|
// build the scanner based on Query Matcher
|
||||||
// reinitialize the compacting scanner for each instance of iterator
|
// reinitialize the compacting scanner for each instance of iterator
|
||||||
compactingScanner = createScanner(store, scanners);
|
compactingScanner = createScanner(store, scanners);
|
||||||
|
|
|
@ -47,8 +47,7 @@ public class MemStoreMergerSegmentsIterator extends MemStoreSegmentsIterator {
|
||||||
super(compactionKVMax);
|
super(compactionKVMax);
|
||||||
// create the list of scanners to traverse over all the data
|
// create the list of scanners to traverse over all the data
|
||||||
// no dirty reads here as these are immutable segments
|
// no dirty reads here as these are immutable segments
|
||||||
int order = segments.size();
|
AbstractMemStore.addToScanners(segments, Integer.MAX_VALUE, scanners);
|
||||||
AbstractMemStore.addToScanners(segments, Integer.MAX_VALUE, order, scanners);
|
|
||||||
heap = new KeyValueHeap(scanners, comparator);
|
heap = new KeyValueHeap(scanners, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class MemStoreSnapshot implements Closeable {
|
||||||
this.cellsCount = snapshot.getCellsCount();
|
this.cellsCount = snapshot.getCellsCount();
|
||||||
this.memStoreSize = snapshot.getMemStoreSize();
|
this.memStoreSize = snapshot.getMemStoreSize();
|
||||||
this.timeRangeTracker = snapshot.getTimeRangeTracker();
|
this.timeRangeTracker = snapshot.getTimeRangeTracker();
|
||||||
this.scanners = snapshot.getScanners(Long.MAX_VALUE, Long.MAX_VALUE);
|
this.scanners = snapshot.getScanners(Long.MAX_VALUE);
|
||||||
this.tagsPresent = snapshot.isTagsPresent();
|
this.tagsPresent = snapshot.isTagsPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,16 +118,8 @@ public abstract class Segment {
|
||||||
return new SegmentScanner(this, readPoint);
|
return new SegmentScanner(this, readPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<KeyValueScanner> getScanners(long readPoint) {
|
||||||
* Creates the scanner for the given read point, and a specific order in a list
|
return Collections.singletonList(new SegmentScanner(this, readPoint));
|
||||||
* @return a scanner for the given read point
|
|
||||||
*/
|
|
||||||
public KeyValueScanner getScanner(long readPoint, long order) {
|
|
||||||
return new SegmentScanner(this, readPoint, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<KeyValueScanner> getScanners(long readPoint, long order) {
|
|
||||||
return Collections.singletonList(new SegmentScanner(this, readPoint, order));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,12 +35,6 @@ import org.apache.hadoop.hbase.client.Scan;
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class SegmentScanner implements KeyValueScanner {
|
public class SegmentScanner implements KeyValueScanner {
|
||||||
|
|
||||||
/**
|
|
||||||
* Order of this scanner relative to other scanners. See
|
|
||||||
* {@link KeyValueScanner#getScannerOrder()}.
|
|
||||||
*/
|
|
||||||
private long scannerOrder;
|
|
||||||
private static final long DEFAULT_SCANNER_ORDER = Long.MAX_VALUE;
|
|
||||||
|
|
||||||
// the observed structure
|
// the observed structure
|
||||||
protected final Segment segment;
|
protected final Segment segment;
|
||||||
|
@ -61,15 +55,11 @@ public class SegmentScanner implements KeyValueScanner {
|
||||||
// flag to indicate if this scanner is closed
|
// flag to indicate if this scanner is closed
|
||||||
protected boolean closed = false;
|
protected boolean closed = false;
|
||||||
|
|
||||||
protected SegmentScanner(Segment segment, long readPoint) {
|
|
||||||
this(segment, readPoint, DEFAULT_SCANNER_ORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scannerOrder see {@link KeyValueScanner#getScannerOrder()}.
|
|
||||||
* Scanners are ordered from 0 (oldest) to newest in increasing order.
|
* Scanners are ordered from 0 (oldest) to newest in increasing order.
|
||||||
*/
|
*/
|
||||||
protected SegmentScanner(Segment segment, long readPoint, long scannerOrder) {
|
protected SegmentScanner(Segment segment, long readPoint) {
|
||||||
this.segment = segment;
|
this.segment = segment;
|
||||||
this.readPoint = readPoint;
|
this.readPoint = readPoint;
|
||||||
//increase the reference count so the underlying structure will not be de-allocated
|
//increase the reference count so the underlying structure will not be de-allocated
|
||||||
|
@ -77,7 +67,6 @@ public class SegmentScanner implements KeyValueScanner {
|
||||||
iter = segment.iterator();
|
iter = segment.iterator();
|
||||||
// the initialization of the current is required for working with heap of SegmentScanners
|
// the initialization of the current is required for working with heap of SegmentScanners
|
||||||
updateCurrent();
|
updateCurrent();
|
||||||
this.scannerOrder = scannerOrder;
|
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
// nothing to fetch from this scanner
|
// nothing to fetch from this scanner
|
||||||
close();
|
close();
|
||||||
|
@ -252,13 +241,6 @@ public class SegmentScanner implements KeyValueScanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see KeyValueScanner#getScannerOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long getScannerOrder() {
|
|
||||||
return scannerOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the KeyValue scanner.
|
* Close the KeyValue scanner.
|
||||||
|
|
|
@ -1046,13 +1046,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see KeyValueScanner#getScannerOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long getScannerOrder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seek storefiles in parallel to optimize IO latency as much as possible
|
* Seek storefiles in parallel to optimize IO latency as much as possible
|
||||||
|
|
|
@ -116,13 +116,6 @@ public class CollectionBackedScanner extends NonReversedNonLazyKeyValueScanner {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.apache.hadoop.hbase.regionserver.KeyValueScanner#getScannerOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long getScannerOrder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
Loading…
Reference in New Issue