shahrs87 commented on a change in pull request #2707: URL: https://github.com/apache/hbase/pull/2707#discussion_r537131395
########## File path: hbase-common/src/main/java/org/apache/hadoop/hbase/TagBuilder.java ########## @@ -0,0 +1,59 @@ +/** + * Copyright The Apache Software Foundation + * + * 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 java.nio.ByteBuffer; +import org.apache.yetus.audience.InterfaceAudience; + +/** + * Builder method to create {@link Tag}. + */ +@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) +public interface TagBuilder { + /** + * Set type of the tag. + * @param tagType type of the tag + * @return {@link TagBuilder} + */ + TagBuilder setTagType(byte tagType); + + /** + * For {@link ArrayBackedTag}, set the value of the tag. + * This method throws {@link UnsupportedOperationException} + * if the tag is backed by {@link ByteBuffer} + * @param tagBytes tag bytes. + * @return {@link TagBuilder} + */ + TagBuilder setTagValue(byte[] tagBytes); Review comment: Thank you for the review. Addressed it in latest commit. ########## File path: hbase-common/src/main/java/org/apache/hadoop/hbase/TagBuilderFactory.java ########## @@ -0,0 +1,105 @@ +/** + * Copyright The Apache Software Foundation + * + * 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 java.nio.ByteBuffer; +import org.apache.yetus.audience.InterfaceAudience; + +/** + * Factory to create Tags. + */ +@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) +public final class TagBuilderFactory { + + public static TagBuilder create(TagBuilderType type) { + switch (type) { Review comment: Thank you for the review. Addressed it in latest commit. ########## File path: hbase-common/src/main/java/org/apache/hadoop/hbase/TagBuilderFactory.java ########## @@ -0,0 +1,105 @@ +/** + * Copyright The Apache Software Foundation + * + * 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 java.nio.ByteBuffer; +import org.apache.yetus.audience.InterfaceAudience; + +/** + * Factory to create Tags. + */ +@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) +public final class TagBuilderFactory { + + public static TagBuilder create(TagBuilderType type) { + switch (type) { + case ARRAY_BACKED: + return new ArrayTagBuilderImpl(); + case BYTE_BUFFER_BACKED: + return new ByteBufferTagBuilderImpl(); + default: + throw new UnsupportedOperationException("The type:" + type + " is unsupported"); + } + } +} + +/** + * Builder implementation to create {@link ArrayBackedTag} + */ +class ArrayTagBuilderImpl implements TagBuilder { + private byte[] tagBytes; + private byte tagType; + + @Override + public TagBuilder setTagType(byte tagType) { + this.tagType = tagType; + return this; + } + + @Override + public TagBuilder setTagValue(byte[] tagBytes) { + this.tagBytes = tagBytes; + return this; + } + + @Override + public TagBuilder setTagByteBuffer(ByteBuffer byteBuffer) { Review comment: Thank you for the review. Addressed it in latest commit. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org