You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2016/05/02 06:19:32 UTC
hbase git commit: HBASE-15735 Tightening of the CP contract.
Repository: hbase
Updated Branches:
refs/heads/master 15631a76f -> d1130582d
HBASE-15735 Tightening of the CP contract.
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d1130582
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d1130582
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d1130582
Branch: refs/heads/master
Commit: d1130582d54ca78bbd708c39e4fa02e7b89b232e
Parents: 15631a7
Author: anoopsjohn <an...@gmail.com>
Authored: Mon May 2 09:48:51 2016 +0530
Committer: anoopsjohn <an...@gmail.com>
Committed: Mon May 2 09:48:51 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/hbase/ShareableMemory.java | 36 --------
.../hbase/coprocessor/RegionObserver.java | 80 +++++++++++++++++-
.../hadoop/hbase/io/hfile/HFileReaderImpl.java | 87 +++----------------
.../hadoop/hbase/regionserver/HRegion.java | 88 ++++++--------------
.../hbase/regionserver/RSRpcServices.java | 15 +---
.../regionserver/ReversedRegionScannerImpl.java | 5 +-
.../io/hfile/TestScannerFromBucketCache.java | 13 +--
.../hadoop/hbase/io/hfile/TestSeekTo.java | 6 +-
.../TestScannerHeartbeatMessages.java | 19 ++---
9 files changed, 128 insertions(+), 221 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-common/src/main/java/org/apache/hadoop/hbase/ShareableMemory.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ShareableMemory.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ShareableMemory.java
deleted file mode 100644
index f8b9127..0000000
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ShareableMemory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase;
-
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
-
-/**
- * A cell implementing this interface would mean that the memory area backing this cell will refer
- * to a memory area that could be part of a larger common memory area used by the
- * RegionServer. If an exclusive instance is required, use the {@link #cloneToCell()} to have the
- * contents of the cell copied to an exclusive memory area.
- */
-@InterfaceAudience.Private
-public interface ShareableMemory {
- /**
- * Does a deep copy of the contents to a new memory area and
- * returns it in the form of a cell.
- * @return Cell the deep cloned cell
- */
- public Cell cloneToCell();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
index db08b76..cbad200 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionObserver.java
@@ -460,6 +460,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'result' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param get the Get request
* @param result the result to return to the client, modify as necessary
@@ -508,6 +511,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'put' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param put The Put object
* @param edit The WALEdit object that will be written to the wal
@@ -523,6 +529,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'put' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param put The Put object
* @param edit The WALEdit object for the wal
@@ -540,6 +549,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'delete' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param delete The Delete object
* @param edit The WALEdit object for the wal
@@ -573,6 +585,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'delete' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param delete The Delete object
* @param edit The WALEdit object for the wal
@@ -589,6 +604,9 @@ public interface RegionObserver extends Coprocessor {
* for each Mutation at the server. The batch may contain Put/Delete. By setting OperationStatus
* of Mutations ({@link MiniBatchOperationInProgress#setOperationStatus(int, OperationStatus)}),
* {@link RegionObserver} can make Region to skip these Mutations.
+ * <p>
+ * Note: Do not retain references to any Cells in Mutations beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param miniBatchOp batch of Mutations getting applied to region.
* @throws IOException if an error occurred on the coprocessor
@@ -599,6 +617,9 @@ public interface RegionObserver extends Coprocessor {
/**
* This will be called after applying a batch of Mutations on a region. The Mutations are added to
* memstore and WAL.
+ * <p>
+ * Note: Do not retain references to any Cells in Mutations beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param miniBatchOp batch of Mutations applied to region.
* @throws IOException if an error occurred on the coprocessor
@@ -627,7 +648,10 @@ public interface RegionObserver extends Coprocessor {
/**
* Called after the completion of batch put/delete and will be called even if the batch operation
- * fails
+ * fails.
+ * <p>
+ * Note: Do not retain references to any Cells in Mutations beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param ctx
* @param miniBatchOp
* @param success true if batch operation is successful otherwise false.
@@ -643,6 +667,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'put' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -672,6 +699,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'put' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -694,6 +724,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'put' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -718,6 +751,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'delete' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -746,6 +782,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'delete' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -767,6 +806,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'delete' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param row row to check
* @param family column family
@@ -836,6 +878,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'append' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param append Append object
* @return result to return to the client if bypassing default processing
@@ -856,6 +901,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'append' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param append Append object
* @return result to return to the client if bypassing default processing
@@ -869,6 +917,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'append' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param append Append object
* @param result the result returned by increment
@@ -886,6 +937,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'increment' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param increment increment object
* @return result to return to the client if bypassing default processing
@@ -905,6 +959,9 @@ public interface RegionObserver extends Coprocessor {
* Call CoprocessorEnvironment#bypass to skip default actions
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'increment' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
*
* @param c
* the environment provided by the region server
@@ -922,6 +979,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells in 'increment' beyond the life of this invocation.
+ * If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param increment increment object
* @param result the result returned by increment
@@ -939,6 +999,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param scan the Scan specification
* @param s if not null, the base scanner
@@ -963,6 +1026,9 @@ public interface RegionObserver extends Coprocessor {
* coprocessors.
* Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no
* effect in this hook.
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param store the store being scanned
* @param scan the Scan specification
@@ -980,6 +1046,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param scan the Scan specification
* @param s if not null, the base scanner
@@ -997,6 +1066,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param s the scanner
* @param result The result to return to the client if default processing
@@ -1017,6 +1089,9 @@ public interface RegionObserver extends Coprocessor {
* <p>
* Call CoprocessorEnvironment#complete to skip any subsequent chained
* coprocessors
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param s the scanner
* @param result the result to return to the client, can be modified
@@ -1070,6 +1145,9 @@ public interface RegionObserver extends Coprocessor {
* <code>void filterRow(List<KeyValue> kvs)</code> removing all the kvs from
* the passed List</li>
* </ol>
+ * <p>
+ * Note: Do not retain references to any Cells returned by scanner, beyond the life of this
+ * invocation. If need a Cell reference for later use, copy the cell and use that.
* @param c the environment provided by the region server
* @param s the scanner
* @param curRowCell The cell in the current row which got filtered out
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
index 1677448..fc1c04e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
@@ -37,7 +37,6 @@ import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.OffheapKeyValue;
-import org.apache.hadoop.hbase.ShareableMemory;
import org.apache.hadoop.hbase.SizeCachedKeyValue;
import org.apache.hadoop.hbase.SizeCachedNoTagsKeyValue;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
@@ -944,48 +943,23 @@ public class HFileReaderImpl implements HFile.Reader, Configurable {
// TODO : reduce the varieties of KV here. Check if based on a boolean
// we can handle the 'no tags' case.
if (currTagsLen > 0) {
- if (this.curBlock.usesSharedMemory()) {
- ret = new ShareableMemoryKeyValue(blockBuffer.array(), blockBuffer.arrayOffset()
- + blockBuffer.position(), getCellBufSize(), seqId);
- } else {
- ret = new SizeCachedKeyValue(blockBuffer.array(), blockBuffer.arrayOffset()
- + blockBuffer.position(), cellBufSize, seqId);
- }
+ ret = new SizeCachedKeyValue(blockBuffer.array(),
+ blockBuffer.arrayOffset() + blockBuffer.position(), cellBufSize, seqId);
} else {
- if (this.curBlock.usesSharedMemory()) {
- ret = new ShareableMemoryNoTagsKeyValue(blockBuffer.array(), blockBuffer.arrayOffset()
- + blockBuffer.position(), getCellBufSize(), seqId);
- } else {
- ret = new SizeCachedNoTagsKeyValue(blockBuffer.array(), blockBuffer.arrayOffset()
- + blockBuffer.position(), cellBufSize, seqId);
- }
+ ret = new SizeCachedNoTagsKeyValue(blockBuffer.array(),
+ blockBuffer.arrayOffset() + blockBuffer.position(), cellBufSize, seqId);
}
} else {
ByteBuffer buf = blockBuffer.asSubByteBuffer(cellBufSize);
if (buf.isDirect()) {
- if (this.curBlock.usesSharedMemory()) {
- ret = new ShareableMemoryOffheapKeyValue(buf, buf.position(), cellBufSize,
- currTagsLen > 0, seqId);
- } else {
- ret = new OffheapKeyValue(buf, buf.position(), cellBufSize, currTagsLen > 0, seqId);
- }
+ ret = new OffheapKeyValue(buf, buf.position(), cellBufSize, currTagsLen > 0, seqId);
} else {
- if (this.curBlock.usesSharedMemory()) {
- if (currTagsLen > 0) {
- ret = new ShareableMemoryKeyValue(buf.array(), buf.arrayOffset() + buf.position(),
- cellBufSize, seqId);
- } else {
- ret = new ShareableMemoryNoTagsKeyValue(buf.array(),
- buf.arrayOffset() + buf.position(), cellBufSize, seqId);
- }
+ if (currTagsLen > 0) {
+ ret = new SizeCachedKeyValue(buf.array(), buf.arrayOffset() + buf.position(),
+ cellBufSize, seqId);
} else {
- if (currTagsLen > 0) {
- ret = new SizeCachedKeyValue(buf.array(), buf.arrayOffset() + buf.position(),
- cellBufSize, seqId);
- } else {
- ret = new SizeCachedNoTagsKeyValue(buf.array(), buf.arrayOffset() + buf.position(),
- cellBufSize, seqId);
- }
+ ret = new SizeCachedNoTagsKeyValue(buf.array(), buf.arrayOffset() + buf.position(),
+ cellBufSize, seqId);
}
}
}
@@ -1013,47 +987,6 @@ public class HFileReaderImpl implements HFile.Reader, Configurable {
}
}
- private static class ShareableMemoryKeyValue extends SizeCachedKeyValue implements
- ShareableMemory {
- public ShareableMemoryKeyValue(byte[] bytes, int offset, int length, long seqId) {
- super(bytes, offset, length, seqId);
- }
-
- @Override
- public Cell cloneToCell() {
- byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
- return new SizeCachedKeyValue(copy, 0, copy.length, getSequenceId());
- }
- }
-
- private static class ShareableMemoryNoTagsKeyValue extends SizeCachedNoTagsKeyValue implements
- ShareableMemory {
- public ShareableMemoryNoTagsKeyValue(byte[] bytes, int offset, int length, long seqId) {
- super(bytes, offset, length, seqId);
- }
-
- @Override
- public Cell cloneToCell() {
- byte[] copy = Bytes.copy(this.bytes, this.offset, this.length);
- return new SizeCachedNoTagsKeyValue(copy, 0, copy.length, getSequenceId());
- }
- }
-
- private static class ShareableMemoryOffheapKeyValue extends OffheapKeyValue implements
- ShareableMemory {
- public ShareableMemoryOffheapKeyValue(ByteBuffer buf, int offset, int length,
- boolean hasTags, long seqId) {
- super(buf, offset, length, hasTags, seqId);
- }
-
- @Override
- public Cell cloneToCell() {
- byte[] copy = new byte[this.length];
- ByteBufferUtils.copyFromBufferToArray(copy, this.buf, this.offset, 0, this.length);
- return new SizeCachedKeyValue(copy, 0, copy.length, getSequenceId());
- }
- }
-
@Override
public ByteBuffer getValue() {
assertSeeked();
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 1210253..428541f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -35,7 +35,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
@@ -90,7 +89,6 @@ import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
-import org.apache.hadoop.hbase.ShareableMemory;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagRewriteCell;
@@ -2586,22 +2584,12 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
@Override
public RegionScanner getScanner(Scan scan) throws IOException {
- return getScanner(scan, true);
+ return getScanner(scan, null);
}
@Override
public RegionScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners)
throws IOException {
- return getScanner(scan, additionalScanners, true);
- }
-
- public RegionScanner getScanner(Scan scan, boolean copyCellsFromSharedMem) throws IOException {
- RegionScanner scanner = getScanner(scan, null, copyCellsFromSharedMem);
- return scanner;
- }
-
- protected RegionScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners,
- boolean copyCellsFromSharedMem) throws IOException {
startRegionOperation(Operation.SCAN);
try {
// Verify families are all valid
@@ -2615,21 +2603,21 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
checkFamily(family);
}
}
- return instantiateRegionScanner(scan, additionalScanners, copyCellsFromSharedMem);
+ return instantiateRegionScanner(scan, additionalScanners);
} finally {
closeRegionOperation(Operation.SCAN);
}
}
protected RegionScanner instantiateRegionScanner(Scan scan,
- List<KeyValueScanner> additionalScanners, boolean copyCellsFromSharedMem) throws IOException {
+ List<KeyValueScanner> additionalScanners) throws IOException {
if (scan.isReversed()) {
if (scan.getFilter() != null) {
scan.getFilter().setReversed(true);
}
- return new ReversedRegionScannerImpl(scan, additionalScanners, this, copyCellsFromSharedMem);
+ return new ReversedRegionScannerImpl(scan, additionalScanners, this);
}
- return new RegionScannerImpl(scan, additionalScanners, this, copyCellsFromSharedMem);
+ return new RegionScannerImpl(scan, additionalScanners, this);
}
@Override
@@ -5493,7 +5481,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
protected final byte[] stopRow;
protected final HRegion region;
protected final CellComparator comparator;
- protected boolean copyCellsFromSharedMem = false;
private final long readPt;
private final long maxResultSize;
@@ -5505,12 +5492,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
return region.getRegionInfo();
}
- public void setCopyCellsFromSharedMem(boolean copyCells) {
- this.copyCellsFromSharedMem = copyCells;
- }
-
- RegionScannerImpl(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region,
- boolean copyCellsFromSharedMem)
+ RegionScannerImpl(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region)
throws IOException {
this.region = region;
this.maxResultSize = scan.getMaxResultSize();
@@ -5569,7 +5551,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
joinedScanners.add(scanner);
}
}
- this.copyCellsFromSharedMem = copyCellsFromSharedMem;
initializeKVHeap(scanners, joinedScanners, region);
}
@@ -5646,47 +5627,26 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
throw new UnknownScannerException("Scanner was closed");
}
boolean moreValues = false;
- try {
- if (outResults.isEmpty()) {
- // Usually outResults is empty. This is true when next is called
- // to handle scan or get operation.
- moreValues = nextInternal(outResults, scannerContext);
- } else {
- List<Cell> tmpList = new ArrayList<Cell>();
- moreValues = nextInternal(tmpList, scannerContext);
- outResults.addAll(tmpList);
- }
+ if (outResults.isEmpty()) {
+ // Usually outResults is empty. This is true when next is called
+ // to handle scan or get operation.
+ moreValues = nextInternal(outResults, scannerContext);
+ } else {
+ List<Cell> tmpList = new ArrayList<Cell>();
+ moreValues = nextInternal(tmpList, scannerContext);
+ outResults.addAll(tmpList);
+ }
- // If the size limit was reached it means a partial Result is being
- // returned. Returning a
- // partial Result means that we should not reset the filters; filters
- // should only be reset in
- // between rows
- if (!scannerContext.midRowResultFormed()) resetFilters();
+ // If the size limit was reached it means a partial Result is being
+ // returned. Returning a
+ // partial Result means that we should not reset the filters; filters
+ // should only be reset in
+ // between rows
+ if (!scannerContext.midRowResultFormed())
+ resetFilters();
- if (isFilterDoneInternal()) {
- moreValues = false;
- }
-
- // If copyCellsFromSharedMem = true, then we need to copy the cells. Otherwise
- // it is a call coming from the RsRpcServices.scan().
- if (copyCellsFromSharedMem && !outResults.isEmpty()) {
- // Do the copy of the results here.
- ListIterator<Cell> listItr = outResults.listIterator();
- Cell cell = null;
- while (listItr.hasNext()) {
- cell = listItr.next();
- if (cell instanceof ShareableMemory) {
- listItr.set(((ShareableMemory) cell).cloneToCell());
- }
- }
- }
- } finally {
- if (copyCellsFromSharedMem) {
- // In case of copyCellsFromSharedMem==true (where the CPs wrap a scanner) we return
- // the blocks then and there (for wrapped CPs)
- this.shipped();
- }
+ if (isFilterDoneInternal()) {
+ moreValues = false;
}
return moreValues;
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index d15b89b..589c4ed 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -2182,7 +2182,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
RegionScanner scanner = null;
try {
- scanner = region.getScanner(scan, false);
+ scanner = region.getScanner(scan);
scanner.next(results);
} finally {
if (scanner != null) {
@@ -2531,7 +2531,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
boolean moreResults = true;
boolean closeScanner = false;
boolean isSmallScan = false;
- RegionScanner actualRegionScanner = null;
ScanResponse.Builder builder = ScanResponse.newBuilder();
if (request.hasCloseScanner()) {
closeScanner = request.getCloseScanner();
@@ -2576,21 +2575,11 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
scanner = region.getCoprocessorHost().preScannerOpen(scan);
}
if (scanner == null) {
- scanner = ((HRegion)region).getScanner(scan, false);
+ scanner = region.getScanner(scan);
}
- actualRegionScanner = scanner;
if (region.getCoprocessorHost() != null) {
scanner = region.getCoprocessorHost().postScannerOpen(scan, scanner);
}
- if (actualRegionScanner != scanner) {
- // It means the RegionScanner has been wrapped
- if (actualRegionScanner instanceof RegionScannerImpl) {
- // Copy the results when nextRaw is called from the CP so that
- // CP can have a cloned version of the results without bothering
- // about the eviction. Ugly, yes!!!
- ((RegionScannerImpl) actualRegionScanner).setCopyCellsFromSharedMem(true);
- }
- }
scannerId = this.scannerIdGen.incrementAndGet();
scannerName = String.valueOf(scannerId);
rsh = addScanner(scannerName, scanner, region);
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
index ca09cdc..5224b8c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedRegionScannerImpl.java
@@ -41,10 +41,9 @@ class ReversedRegionScannerImpl extends RegionScannerImpl {
* @param region
* @throws IOException
*/
- ReversedRegionScannerImpl(Scan scan,
- List<KeyValueScanner> additionalScanners, HRegion region, boolean copyCellsFromSharedMem)
+ ReversedRegionScannerImpl(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region)
throws IOException {
- region.super(scan, additionalScanners, region, copyCellsFromSharedMem);
+ region.super(scan, additionalScanners, region);
}
@Override
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
index bb6f899..eb3dfa6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.OffheapKeyValue;
-import org.apache.hadoop.hbase.ShareableMemory;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Put;
@@ -121,7 +120,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertFalse(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
// do the scan again and verify. This time it should be from the lru cache
@@ -129,7 +127,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertFalse(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
@@ -161,7 +158,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertFalse(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
// Wait for the bucket cache threads to move the data to offheap
@@ -171,7 +167,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertTrue(actual.get(i) instanceof OffheapKeyValue);
- assertTrue(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
@@ -204,7 +199,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertFalse(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
// Wait for the bucket cache threads to move the data to offheap
@@ -215,7 +209,7 @@ public class TestScannerFromBucketCache {
scan.addFamily(fam1);
scan.setMaxVersions(10);
actual = new ArrayList<Cell>();
- InternalScanner scanner = region.getScanner(scan, false);
+ InternalScanner scanner = region.getScanner(scan);
boolean hasNext = scanner.next(actual);
assertEquals(false, hasNext);
@@ -226,7 +220,6 @@ public class TestScannerFromBucketCache {
// the MBB is copied to form a single cell
assertTrue(actual.get(i) instanceof OffheapKeyValue);
}
- assertTrue(actual.get(i) instanceof ShareableMemory);
}
} catch (InterruptedException e) {
@@ -258,7 +251,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertFalse(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
// do the scan again and verify. This time it should be from the bucket cache in onheap mode
@@ -266,7 +258,6 @@ public class TestScannerFromBucketCache {
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof OffheapKeyValue);
- assertTrue(actual.get(i) instanceof ShareableMemory);
assertTrue(CellUtil.equalsIgnoreMvccVersion(expected.get(i), actual.get(i)));
}
@@ -336,7 +327,7 @@ public class TestScannerFromBucketCache {
scan.addFamily(fam1);
scan.setMaxVersions(MAX_VERSIONS);
List<Cell> actual = new ArrayList<Cell>();
- InternalScanner scanner = region.getScanner(scan, false);
+ InternalScanner scanner = region.getScanner(scan);
boolean hasNext = scanner.next(actual);
assertEquals(false, hasNext);
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
index 6eead71..9ec6dc9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
@@ -41,9 +41,7 @@ import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.OffheapKeyValue;
-import org.apache.hadoop.hbase.ShareableMemory;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagUtil;
import org.apache.hadoop.hbase.ArrayBackedTag;
@@ -110,8 +108,7 @@ public class TestSeekTo {
}
}
}
- static String toRowStr(Cell kv) {
- KeyValue c = KeyValueUtil.ensureKeyValue(kv);
+ static String toRowStr(Cell c) {
return Bytes.toString(c.getRowArray(), c.getRowOffset(), c.getRowLength());
}
@@ -218,7 +215,6 @@ public class TestSeekTo {
// seekBefore d, so the scanner points to c
assertTrue(scanner.seekBefore(toKV("d", tagUsage)));
- assertFalse(scanner.getCell() instanceof ShareableMemory);
assertFalse(scanner.getCell() instanceof OffheapKeyValue);
assertEquals("c", toRowStr(scanner.getCell()));
// reseekTo e and g
http://git-wip-us.apache.org/repos/asf/hbase/blob/d1130582/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java
index 1935c0a..b8eacc7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java
@@ -27,8 +27,6 @@ import java.util.List;
import java.util.concurrent.Callable;
import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -79,7 +77,6 @@ import com.google.protobuf.ServiceException;
*/
@Category(MediumTests.class)
public class TestScannerHeartbeatMessages {
- private static final Log LOG = LogFactory.getLog(TestScannerHeartbeatMessages.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@@ -487,14 +484,14 @@ public class TestScannerHeartbeatMessages {
// Instantiate the custom heartbeat region scanners
@Override
protected RegionScanner instantiateRegionScanner(Scan scan,
- List<KeyValueScanner> additionalScanners, boolean copyCells) throws IOException {
+ List<KeyValueScanner> additionalScanners) throws IOException {
if (scan.isReversed()) {
if (scan.getFilter() != null) {
scan.getFilter().setReversed(true);
}
- return new HeartbeatReversedRegionScanner(scan, additionalScanners, this, copyCells);
+ return new HeartbeatReversedRegionScanner(scan, additionalScanners, this);
}
- return new HeartbeatRegionScanner(scan, additionalScanners, this, copyCells);
+ return new HeartbeatRegionScanner(scan, additionalScanners, this);
}
}
@@ -504,8 +501,8 @@ public class TestScannerHeartbeatMessages {
*/
private static class HeartbeatReversedRegionScanner extends ReversedRegionScannerImpl {
HeartbeatReversedRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners,
- HRegion region, boolean copyCells) throws IOException {
- super(scan, additionalScanners, region, copyCells);
+ HRegion region) throws IOException {
+ super(scan, additionalScanners, region);
}
@Override
@@ -531,9 +528,9 @@ public class TestScannerHeartbeatMessages {
* column family cells
*/
private static class HeartbeatRegionScanner extends RegionScannerImpl {
- HeartbeatRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region,
- boolean copyCells) throws IOException {
- region.super(scan, additionalScanners, region, copyCells);
+ HeartbeatRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region)
+ throws IOException {
+ region.super(scan, additionalScanners, region);
}
@Override