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