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
.regionserver
;
20 import java
.io
.IOException
;
21 import org
.apache
.hadoop
.hbase
.KeepDeletedCells
;
22 import org
.apache
.hadoop
.hbase
.client
.ImmutableScan
;
23 import org
.apache
.hadoop
.hbase
.client
.Scan
;
24 import org
.apache
.yetus
.audience
.InterfaceAudience
;
27 * Helper class for CP hooks to change max versions and TTL.
29 @InterfaceAudience.Private
30 public class CustomizedScanInfoBuilder
implements ScanOptions
{
32 private final ScanInfo scanInfo
;
34 private Integer maxVersions
;
38 private KeepDeletedCells keepDeletedCells
= null;
40 private Integer minVersions
;
42 private final Scan scan
;
44 public CustomizedScanInfoBuilder(ScanInfo scanInfo
) {
45 this.scanInfo
= scanInfo
;
46 this.scan
= new ImmutableScan(new Scan());
49 public CustomizedScanInfoBuilder(ScanInfo scanInfo
, Scan scan
) {
50 this.scanInfo
= scanInfo
;
51 //copy the scan so no coproc using this ScanOptions can alter the "real" scan
52 this.scan
= new ImmutableScan(scan
);
56 public int getMaxVersions() {
57 return maxVersions
!= null ? maxVersions
.intValue() : scanInfo
.getMaxVersions();
61 public void setMaxVersions(int maxVersions
) {
62 this.maxVersions
= maxVersions
;
66 public long getTTL() {
67 return ttl
!= null ? ttl
.longValue() : scanInfo
.getTtl();
71 public void setTTL(long ttl
) {
75 public ScanInfo
build() {
76 if (maxVersions
== null && ttl
== null && keepDeletedCells
== null) {
79 return scanInfo
.customize(getMaxVersions(), getTTL(), getKeepDeletedCells(), getMinVersions());
83 public String
toString() {
84 return "ScanOptions [maxVersions=" + getMaxVersions() + ", TTL=" + getTTL() +
85 ", KeepDeletedCells=" + getKeepDeletedCells() + ", MinVersions=" + getMinVersions() + "]";
89 public void setKeepDeletedCells(KeepDeletedCells keepDeletedCells
) {
90 this.keepDeletedCells
= keepDeletedCells
;
94 public KeepDeletedCells
getKeepDeletedCells() {
95 return keepDeletedCells
!= null ? keepDeletedCells
: scanInfo
.getKeepDeletedCells();
99 public int getMinVersions() {
100 return minVersions
!= null ? minVersions
: scanInfo
.getMinVersions();
104 public void setMinVersions(int minVersions
) {
105 this.minVersions
= minVersions
;
109 public Scan
getScan() {