[14/27] hbase git commit: HBASE-19746 Add default impl to Cell#getType
HBASE-19746 Add default impl to Cell#getType Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4bd6ac3e Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4bd6ac3e Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4bd6ac3e Branch: refs/heads/HBASE-19064 Commit: 4bd6ac3e1028c3d9c6c3884b01e875806508ea7a Parents: 3787c60 Author: Chia-Ping TsaiAuthored: Thu Jan 11 15:03:20 2018 -0800 Committer: Michael Stack Committed: Thu Jan 11 15:03:20 2018 -0800 -- .../hadoop/hbase/ByteBufferKeyOnlyKeyValue.java | 4 --- .../main/java/org/apache/hadoop/hbase/Cell.java | 21 +-- .../org/apache/hadoop/hbase/ExtendedCell.java | 11 -- .../org/apache/hadoop/hbase/TestCellUtil.java | 38 ++-- .../org/apache/hadoop/hbase/TestKeyValue.java | 5 --- .../org/apache/hadoop/hbase/fs/HFileSystem.java | 2 +- 6 files changed, 47 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java index db2890f..31f71f9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java @@ -152,10 +152,6 @@ public class ByteBufferKeyOnlyKeyValue extends ByteBufferExtendedCell { return ByteBufferUtils.toByte(this.buf, this.offset + this.length - 1); } - public Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - @Override public void setSequenceId(long seqId) throws IOException { throw new IllegalArgumentException("This is a key only Cell"); http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java index f208625..8cdefff 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java @@ -201,10 +201,19 @@ public interface Cell { int getTagsLength(); /** - * Returns the type of cell in a human readable format using {@link Type} + * Returns the type of cell in a human readable format using {@link Type}. + * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and + * {@link KeyValue.Type#Minimum} * @return The data type this cell: one of Put, Delete, etc */ - Type getType(); + default Type getType() { +byte byteType = getTypeByte(); +Type t = Type.CODE_ARRAY[byteType & 0xff]; +if (t != null) { + return t; +} +throw new UnsupportedOperationException("Invalid type of cell " + byteType); + } /** * The valid types for user to build the cell. Currently, This is subset of {@link KeyValue.Type}. @@ -229,5 +238,13 @@ public interface Cell { public byte getCode() { return this.code; } + +private static final Type[] CODE_ARRAY = new Type[256]; + +static { + for (Type t : Type.values()) { +CODE_ARRAY[t.code & 0xff] = t; + } +} } } http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java index be6d96c..07b0e3f 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java @@ -163,17 +163,6 @@ public interface ExtendedCell extends RawCell, HeapSize, Cloneable { int getTagsLength(); /** - * {@inheritDoc} - * - * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and - * {@link KeyValue.Type#Minimum} - */ - @Override - default Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - - /** * @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc */ byte getTypeByte(); http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
[11/46] hbase git commit: HBASE-19746 Add default impl to Cell#getType
HBASE-19746 Add default impl to Cell#getType Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3e6f80dc Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3e6f80dc Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3e6f80dc Branch: refs/heads/HBASE-19397-branch-2 Commit: 3e6f80dcd5b6630769f310d429f403f1fa8bae23 Parents: 1a11fc9 Author: Chia-Ping TsaiAuthored: Thu Jan 11 15:03:20 2018 -0800 Committer: Michael Stack Committed: Thu Jan 11 15:04:25 2018 -0800 -- .../hadoop/hbase/ByteBufferKeyOnlyKeyValue.java | 4 --- .../main/java/org/apache/hadoop/hbase/Cell.java | 21 +-- .../org/apache/hadoop/hbase/ExtendedCell.java | 11 -- .../org/apache/hadoop/hbase/TestCellUtil.java | 38 ++-- .../org/apache/hadoop/hbase/TestKeyValue.java | 5 --- .../org/apache/hadoop/hbase/fs/HFileSystem.java | 2 +- 6 files changed, 47 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java index db2890f..31f71f9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java @@ -152,10 +152,6 @@ public class ByteBufferKeyOnlyKeyValue extends ByteBufferExtendedCell { return ByteBufferUtils.toByte(this.buf, this.offset + this.length - 1); } - public Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - @Override public void setSequenceId(long seqId) throws IOException { throw new IllegalArgumentException("This is a key only Cell"); http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java index f208625..8cdefff 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java @@ -201,10 +201,19 @@ public interface Cell { int getTagsLength(); /** - * Returns the type of cell in a human readable format using {@link Type} + * Returns the type of cell in a human readable format using {@link Type}. + * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and + * {@link KeyValue.Type#Minimum} * @return The data type this cell: one of Put, Delete, etc */ - Type getType(); + default Type getType() { +byte byteType = getTypeByte(); +Type t = Type.CODE_ARRAY[byteType & 0xff]; +if (t != null) { + return t; +} +throw new UnsupportedOperationException("Invalid type of cell " + byteType); + } /** * The valid types for user to build the cell. Currently, This is subset of {@link KeyValue.Type}. @@ -229,5 +238,13 @@ public interface Cell { public byte getCode() { return this.code; } + +private static final Type[] CODE_ARRAY = new Type[256]; + +static { + for (Type t : Type.values()) { +CODE_ARRAY[t.code & 0xff] = t; + } +} } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java index be6d96c..07b0e3f 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java @@ -163,17 +163,6 @@ public interface ExtendedCell extends RawCell, HeapSize, Cloneable { int getTagsLength(); /** - * {@inheritDoc} - * - * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and - * {@link KeyValue.Type#Minimum} - */ - @Override - default Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - - /** * @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc */ byte getTypeByte(); http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
hbase git commit: HBASE-19746 Add default impl to Cell#getType
Repository: hbase Updated Branches: refs/heads/branch-2 1a11fc92b -> 3e6f80dcd HBASE-19746 Add default impl to Cell#getType Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3e6f80dc Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3e6f80dc Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3e6f80dc Branch: refs/heads/branch-2 Commit: 3e6f80dcd5b6630769f310d429f403f1fa8bae23 Parents: 1a11fc9 Author: Chia-Ping TsaiAuthored: Thu Jan 11 15:03:20 2018 -0800 Committer: Michael Stack Committed: Thu Jan 11 15:04:25 2018 -0800 -- .../hadoop/hbase/ByteBufferKeyOnlyKeyValue.java | 4 --- .../main/java/org/apache/hadoop/hbase/Cell.java | 21 +-- .../org/apache/hadoop/hbase/ExtendedCell.java | 11 -- .../org/apache/hadoop/hbase/TestCellUtil.java | 38 ++-- .../org/apache/hadoop/hbase/TestKeyValue.java | 5 --- .../org/apache/hadoop/hbase/fs/HFileSystem.java | 2 +- 6 files changed, 47 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java index db2890f..31f71f9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java @@ -152,10 +152,6 @@ public class ByteBufferKeyOnlyKeyValue extends ByteBufferExtendedCell { return ByteBufferUtils.toByte(this.buf, this.offset + this.length - 1); } - public Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - @Override public void setSequenceId(long seqId) throws IOException { throw new IllegalArgumentException("This is a key only Cell"); http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java index f208625..8cdefff 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java @@ -201,10 +201,19 @@ public interface Cell { int getTagsLength(); /** - * Returns the type of cell in a human readable format using {@link Type} + * Returns the type of cell in a human readable format using {@link Type}. + * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and + * {@link KeyValue.Type#Minimum} * @return The data type this cell: one of Put, Delete, etc */ - Type getType(); + default Type getType() { +byte byteType = getTypeByte(); +Type t = Type.CODE_ARRAY[byteType & 0xff]; +if (t != null) { + return t; +} +throw new UnsupportedOperationException("Invalid type of cell " + byteType); + } /** * The valid types for user to build the cell. Currently, This is subset of {@link KeyValue.Type}. @@ -229,5 +238,13 @@ public interface Cell { public byte getCode() { return this.code; } + +private static final Type[] CODE_ARRAY = new Type[256]; + +static { + for (Type t : Type.values()) { +CODE_ARRAY[t.code & 0xff] = t; + } +} } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3e6f80dc/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java index be6d96c..07b0e3f 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java @@ -163,17 +163,6 @@ public interface ExtendedCell extends RawCell, HeapSize, Cloneable { int getTagsLength(); /** - * {@inheritDoc} - * - * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and - * {@link KeyValue.Type#Minimum} - */ - @Override - default Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - - /** * @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc */ byte getTypeByte();
hbase git commit: HBASE-19746 Add default impl to Cell#getType
Repository: hbase Updated Branches: refs/heads/master 3787c60cd -> 4bd6ac3e1 HBASE-19746 Add default impl to Cell#getType Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4bd6ac3e Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4bd6ac3e Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4bd6ac3e Branch: refs/heads/master Commit: 4bd6ac3e1028c3d9c6c3884b01e875806508ea7a Parents: 3787c60 Author: Chia-Ping TsaiAuthored: Thu Jan 11 15:03:20 2018 -0800 Committer: Michael Stack Committed: Thu Jan 11 15:03:20 2018 -0800 -- .../hadoop/hbase/ByteBufferKeyOnlyKeyValue.java | 4 --- .../main/java/org/apache/hadoop/hbase/Cell.java | 21 +-- .../org/apache/hadoop/hbase/ExtendedCell.java | 11 -- .../org/apache/hadoop/hbase/TestCellUtil.java | 38 ++-- .../org/apache/hadoop/hbase/TestKeyValue.java | 5 --- .../org/apache/hadoop/hbase/fs/HFileSystem.java | 2 +- 6 files changed, 47 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java index db2890f..31f71f9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyOnlyKeyValue.java @@ -152,10 +152,6 @@ public class ByteBufferKeyOnlyKeyValue extends ByteBufferExtendedCell { return ByteBufferUtils.toByte(this.buf, this.offset + this.length - 1); } - public Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - @Override public void setSequenceId(long seqId) throws IOException { throw new IllegalArgumentException("This is a key only Cell"); http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java index f208625..8cdefff 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java @@ -201,10 +201,19 @@ public interface Cell { int getTagsLength(); /** - * Returns the type of cell in a human readable format using {@link Type} + * Returns the type of cell in a human readable format using {@link Type}. + * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and + * {@link KeyValue.Type#Minimum} * @return The data type this cell: one of Put, Delete, etc */ - Type getType(); + default Type getType() { +byte byteType = getTypeByte(); +Type t = Type.CODE_ARRAY[byteType & 0xff]; +if (t != null) { + return t; +} +throw new UnsupportedOperationException("Invalid type of cell " + byteType); + } /** * The valid types for user to build the cell. Currently, This is subset of {@link KeyValue.Type}. @@ -229,5 +238,13 @@ public interface Cell { public byte getCode() { return this.code; } + +private static final Type[] CODE_ARRAY = new Type[256]; + +static { + for (Type t : Type.values()) { +CODE_ARRAY[t.code & 0xff] = t; + } +} } } http://git-wip-us.apache.org/repos/asf/hbase/blob/4bd6ac3e/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java index be6d96c..07b0e3f 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java @@ -163,17 +163,6 @@ public interface ExtendedCell extends RawCell, HeapSize, Cloneable { int getTagsLength(); /** - * {@inheritDoc} - * - * Note : This does not expose the internal types of Cells like {@link KeyValue.Type#Maximum} and - * {@link KeyValue.Type#Minimum} - */ - @Override - default Type getType() { -return PrivateCellUtil.toType(getTypeByte()); - } - - /** * @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc */ byte getTypeByte();