2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
;
20 import java
.util
.List
;
22 import org
.apache
.commons
.lang3
.ArrayUtils
;
23 import org
.apache
.yetus
.audience
.InterfaceAudience
;
25 @InterfaceAudience.Private
26 public abstract class ExtendedCellBuilderImpl
implements ExtendedCellBuilder
{
27 protected byte[] row
= null;
28 protected int rOffset
= 0;
29 protected int rLength
= 0;
30 protected byte[] family
= null;
31 protected int fOffset
= 0;
32 protected int fLength
= 0;
33 protected byte[] qualifier
= null;
34 protected int qOffset
= 0;
35 protected int qLength
= 0;
36 protected long timestamp
= HConstants
.LATEST_TIMESTAMP
;
37 protected KeyValue
.Type type
= null;
38 protected byte[] value
= null;
39 protected int vOffset
= 0;
40 protected int vLength
= 0;
41 protected long seqId
= 0;
42 protected byte[] tags
= null;
43 protected int tagsOffset
= 0;
44 protected int tagsLength
= 0;
47 public ExtendedCellBuilder
setRow(final byte[] row
) {
48 return setRow(row
, 0, ArrayUtils
.getLength(row
));
52 public ExtendedCellBuilder
setRow(final byte[] row
, int rOffset
, int rLength
) {
54 this.rOffset
= rOffset
;
55 this.rLength
= rLength
;
60 public ExtendedCellBuilder
setFamily(final byte[] family
) {
61 return setFamily(family
, 0, ArrayUtils
.getLength(family
));
65 public ExtendedCellBuilder
setFamily(final byte[] family
, int fOffset
, int fLength
) {
67 this.fOffset
= fOffset
;
68 this.fLength
= fLength
;
73 public ExtendedCellBuilder
setQualifier(final byte[] qualifier
) {
74 return setQualifier(qualifier
, 0, ArrayUtils
.getLength(qualifier
));
78 public ExtendedCellBuilder
setQualifier(final byte[] qualifier
, int qOffset
, int qLength
) {
79 this.qualifier
= qualifier
;
80 this.qOffset
= qOffset
;
81 this.qLength
= qLength
;
86 public ExtendedCellBuilder
setTimestamp(final long timestamp
) {
87 this.timestamp
= timestamp
;
92 public ExtendedCellBuilder
setType(final Cell
.Type type
) {
93 this.type
= PrivateCellUtil
.toTypeByte(type
);
98 public ExtendedCellBuilder
setType(final byte type
) {
99 this.type
= KeyValue
.Type
.codeToType(type
);
104 public ExtendedCellBuilder
setValue(final byte[] value
) {
105 return setValue(value
, 0, ArrayUtils
.getLength(value
));
109 public ExtendedCellBuilder
setValue(final byte[] value
, int vOffset
, int vLength
) {
111 this.vOffset
= vOffset
;
112 this.vLength
= vLength
;
117 public ExtendedCellBuilder
setTags(final byte[] tags
) {
118 return setTags(tags
, 0, ArrayUtils
.getLength(tags
));
122 public ExtendedCellBuilder
setTags(final byte[] tags
, int tagsOffset
, int tagsLength
) {
124 this.tagsOffset
= tagsOffset
;
125 this.tagsLength
= tagsLength
;
130 public ExtendedCellBuilder
setTags(List
<Tag
> tags
) {
131 byte[] tagBytes
= TagUtil
.fromList(tags
);
132 return setTags(tagBytes
);
136 public ExtendedCellBuilder
setSequenceId(final long seqId
) {
141 private void checkBeforeBuild() {
143 throw new IllegalArgumentException("The type can't be NULL");
147 protected abstract ExtendedCell
innerBuild();
150 public ExtendedCell
build() {
156 public ExtendedCellBuilder
clear() {
166 timestamp
= HConstants
.LATEST_TIMESTAMP
;