diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java index 870d872..27c4efa 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java @@ -350,31 +350,4 @@ public class ByteBufferKeyValue extends ByteBufferCell implements ExtendedCell { hash = 31 * hash + cell.getTypeByte(); return hash; } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsPosition(); - int pos = offset; - int tagLen; - while (pos < offset + length) { - ByteBuffer tagsBuffer = getTagsByteBuffer(); - tagLen = ByteBufferUtils.readAsInt(tagsBuffer, pos, TAG_LENGTH_SIZE); - if (ByteBufferUtils.toByte(tagsBuffer, pos + TAG_LENGTH_SIZE) == type) { - return Optional.ofNullable(new ByteBufferTag(tagsBuffer, pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java index a25bd19..03c3c5e 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java @@ -304,30 +304,4 @@ public class IndividualBytesFieldCell implements ExtendedCell { public String toString() { return CellUtil.toString(this, true); } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); - if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java index 6a79c88..a6c5eb5 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java @@ -2555,30 +2555,4 @@ public class KeyValue implements ExtendedCell { kv.setSequenceId(this.getSequenceId()); return kv; } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); - if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java index e52ed84..18b2b68 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java @@ -314,32 +314,6 @@ public final class PrivateCellUtil { Cell clonedBaseCell = ((ExtendedCell) this.cell).deepClone(); return new TagRewriteCell(clonedBaseCell, this.tags); } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); - if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } static class TagRewriteByteBufferCell extends ByteBufferCell implements ExtendedCell { @@ -573,33 +547,6 @@ public final class PrivateCellUtil { public int getTagsPosition() { return 0; } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsPosition(); - int pos = offset; - int tagLen; - while (pos < offset + length) { - ByteBuffer tagsBuffer = getTagsByteBuffer(); - tagLen = ByteBufferUtils.readAsInt(tagsBuffer, pos, TAG_LENGTH_SIZE); - if (ByteBufferUtils.toByte(tagsBuffer, pos + TAG_LENGTH_SIZE) == type) { - return Optional.ofNullable(new ByteBufferTag(tagsBuffer, pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } static class ValueAndTagRewriteCell extends TagRewriteCell { @@ -1424,32 +1371,6 @@ public final class PrivateCellUtil { public int getTagsLength() { return 0; } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); - if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } /** @@ -1603,33 +1524,6 @@ public final class PrivateCellUtil { public int getValuePosition() { return 0; } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsPosition(); - int pos = offset; - int tagLen; - while (pos < offset + length) { - ByteBuffer tagsBuffer = getTagsByteBuffer(); - tagLen = ByteBufferUtils.readAsInt(tagsBuffer, pos, TAG_LENGTH_SIZE); - if (ByteBufferUtils.toByte(tagsBuffer, pos + TAG_LENGTH_SIZE) == type) { - return Optional.ofNullable(new ByteBufferTag(tagsBuffer, pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } private static class FirstOnRowCell extends EmptyCell { diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/RawCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/RawCell.java index 4cda7d5..b2ddc92 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/RawCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/RawCell.java @@ -41,14 +41,18 @@ public interface RawCell extends Cell { * Creates a list of tags in the current cell * @return a list of tags */ - List getTags(); + default List getTags() { + return PrivateCellUtil.getTags(this); + } /** * Returns the specific tag of the given type * @param type the type of the tag * @return the specific tag if available or null */ - Optional getTag(byte type); + default Optional getTag(byte type) { + return PrivateCellUtil.getTag(this, type); + } /** * Check the length of tags. If it is invalid, throw IllegalArgumentException diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java index f4d3c40..1b8ac4c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java @@ -482,32 +482,6 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder { // This is not used in actual flow. Throwing UnsupportedOperationException throw new UnsupportedOperationException(); } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, Tag.TAG_LENGTH_SIZE); - if (getTagsArray()[pos + Tag.TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + Tag.TAG_LENGTH_SIZE)); - } - pos += Tag.TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } } protected static class OffheapDecodedCell extends ByteBufferCell implements ExtendedCell { @@ -753,35 +727,6 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder { // This is not used in actual flow. Throwing UnsupportedOperationException throw new UnsupportedOperationException(); } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsPosition(); - int pos = offset; - int tagLen; - while (pos < offset + length) { - ByteBuffer tagsBuffer = getTagsByteBuffer(); - tagLen = ByteBufferUtils.readAsInt(tagsBuffer, pos, Tag.TAG_LENGTH_SIZE); - if (ByteBufferUtils.toByte(tagsBuffer, pos + Tag.TAG_LENGTH_SIZE) == type) { - return Optional - .ofNullable(new ByteBufferTag(tagsBuffer, pos, tagLen + Tag.TAG_LENGTH_SIZE)); - } - pos += Tag.TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } - } protected abstract static class BufferedEncodedSeeker diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceCell.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceCell.java index ae47e7a..5307f97 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceCell.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceCell.java @@ -276,30 +276,4 @@ public class MapReduceCell extends ByteBufferCell implements ExtendedCell { throw new RuntimeException(e); } } - - @Override - public Optional getTag(byte type) { - int length = getTagsLength(); - int offset = getTagsOffset(); - int pos = offset; - while (pos < offset + length) { - int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); - if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { - return Optional - .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); - } - pos += TAG_LENGTH_SIZE + tagLen; - } - return Optional.ofNullable(null); - } - - @Override - public List getTags() { - List tags = new ArrayList<>(); - Iterator tagsItr = PrivateCellUtil.tagsIterator(this); - while (tagsItr.hasNext()) { - tags.add(tagsItr.next()); - } - return tags; - } }