View Javadoc

1   /**
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
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
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.
17   */
18  
19  package org.apache.hadoop.hbase.regionserver;
20  
21  import org.apache.commons.lang.builder.ToStringBuilder;
22  import org.apache.hadoop.hbase.classification.InterfaceAudience;
23  import org.apache.hadoop.hbase.HColumnDescriptor;
24  import org.apache.hadoop.hbase.KeepDeletedCells;
25  import org.apache.hadoop.hbase.KeyValue.KVComparator;
26  import org.apache.hadoop.hbase.util.Bytes;
27  import org.apache.hadoop.hbase.util.ClassSize;
28  import org.apache.hadoop.conf.Configuration;
29  import org.apache.hadoop.hbase.HConstants;
30  
31  /**
32   * Immutable information for scans over a store.
33   */
34  // Has to be public for PartitionedMobCompactor to access; ditto on tests making use of a few of
35  // the accessors below. Shutdown access. TODO
36  @InterfaceAudience.Private
37  public class ScanInfo {
38    private byte[] family;
39    private int minVersions;
40    private int maxVersions;
41    private long ttl;
42    private KeepDeletedCells keepDeletedCells;
43    private long timeToPurgeDeletes;
44    private KVComparator comparator;
45    private long tableMaxRowSize;
46    private boolean usePread;
47    private long cellsPerTimeoutCheck;
48    private boolean parallelSeekEnabled;
49    private final Configuration conf;
50  
51    public static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT
52        + (2 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_INT)
53        + (4 * Bytes.SIZEOF_LONG) + (3 * Bytes.SIZEOF_BOOLEAN));
54  
55    /**
56     * @param conf
57     * @param family {@link HColumnDescriptor} describing the column family
58     * @param ttl Store's TTL (in ms)
59     * @param timeToPurgeDeletes duration in ms after which a delete marker can
60     *        be purged during a major compaction.
61     * @param comparator The store's comparator
62     */
63    public ScanInfo(final Configuration conf, final HColumnDescriptor family, final long ttl,
64        final long timeToPurgeDeletes, final KVComparator comparator) {
65      this(conf, family.getName(), family.getMinVersions(), family.getMaxVersions(), ttl, family
66          .getKeepDeletedCells(), timeToPurgeDeletes, comparator);
67    }
68  
69    /**
70     * @param conf
71     * @param family Name of this store's column family
72     * @param minVersions Store's MIN_VERSIONS setting
73     * @param maxVersions Store's VERSIONS setting
74     * @param ttl Store's TTL (in ms)
75     * @param timeToPurgeDeletes duration in ms after which a delete marker can
76     *        be purged during a major compaction.
77     * @param keepDeletedCells Store's keepDeletedCells setting
78     * @param comparator The store's comparator
79     */
80    public ScanInfo(final Configuration conf, final byte[] family, final int minVersions,
81        final int maxVersions, final long ttl, final KeepDeletedCells keepDeletedCells,
82        final long timeToPurgeDeletes, final KVComparator comparator) {
83      this.family = family;
84      this.minVersions = minVersions;
85      this.maxVersions = maxVersions;
86      this.ttl = ttl;
87      this.keepDeletedCells = keepDeletedCells;
88      this.timeToPurgeDeletes = timeToPurgeDeletes;
89      this.comparator = comparator;
90      this.tableMaxRowSize =
91        conf.getLong(HConstants.TABLE_MAX_ROWSIZE_KEY, HConstants.TABLE_MAX_ROWSIZE_DEFAULT);
92      this.usePread = conf.getBoolean("hbase.storescanner.use.pread", false);
93      long perHeartbeat =
94        conf.getLong(StoreScanner.HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK,
95          StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK);
96      this.cellsPerTimeoutCheck = perHeartbeat > 0?
97          perHeartbeat: StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK;
98      this.parallelSeekEnabled =
99        conf.getBoolean(StoreScanner.STORESCANNER_PARALLEL_SEEK_ENABLE, false);
100     this.conf = conf;
101   }
102 
103   public Configuration getConfiguration() {
104     return this.conf;
105   }
106 
107   long getTableMaxRowSize() {
108     return this.tableMaxRowSize;
109   }
110 
111   boolean isUsePread() {
112     return this.usePread;
113   }
114 
115   long getCellsPerTimeoutCheck() {
116     return this.cellsPerTimeoutCheck;
117   }
118 
119   boolean isParallelSeekEnabled() {
120     return this.parallelSeekEnabled;
121   }
122 
123   public byte[] getFamily() {
124     return family;
125   }
126 
127   public int getMinVersions() {
128     return minVersions;
129   }
130 
131   public int getMaxVersions() {
132     return maxVersions;
133   }
134 
135   public long getTtl() {
136     return ttl;
137   }
138 
139   public KeepDeletedCells getKeepDeletedCells() {
140     return keepDeletedCells;
141   }
142 
143   public long getTimeToPurgeDeletes() {
144     return timeToPurgeDeletes;
145   }
146 
147   public KVComparator getComparator() {
148     return comparator;
149   }
150 
151   @Override
152   public String toString() {
153     return new ToStringBuilder(this)
154       .append("family", Bytes.toStringBinary(family))
155       .append("minVersions", minVersions)
156       .append("maxVersions", maxVersions)
157       .append("ttl", ttl)
158       .append("keepDeletedCells", keepDeletedCells)
159       .append("timeToPurgeDeletes", timeToPurgeDeletes)
160       .append("tableMaxRowSize", tableMaxRowSize)
161       .append("usePread", usePread)
162       .append("cellsPerTimeoutCheck", cellsPerTimeoutCheck)
163       .append("parallelSeekEnabled", parallelSeekEnabled).toString();
164   }
165 }