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 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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. + *
+ * 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. + *
+ * 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. + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 *
* Call CoprocessorEnvironment#complete to skip any subsequent chained coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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. + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 { *
* Call CoprocessorEnvironment#complete to skip any subsequent chained * coprocessors + *
+ * 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 {
* void filterRow(List<KeyValue> kvs) removing all the kvs from
* the passed List
*
+ *
+ * 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
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();
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