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