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