001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.hbase.regionserver; 020 021import org.apache.hadoop.conf.Configuration; 022import org.apache.hadoop.hbase.CellComparator; 023import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; 024import org.apache.hadoop.hbase.HConstants; 025import org.apache.hadoop.hbase.KeepDeletedCells; 026import org.apache.hadoop.hbase.util.Bytes; 027import org.apache.hadoop.hbase.util.ClassSize; 028import org.apache.yetus.audience.InterfaceAudience; 029 030/** 031 * Immutable information for scans over a store. 032 */ 033// Has to be public for PartitionedMobCompactor to access; ditto on tests making use of a few of 034// the accessors below. Shutdown access. TODO 035@InterfaceAudience.Private 036public class ScanInfo { 037 private byte[] family; 038 private int minVersions; 039 private int maxVersions; 040 private long ttl; 041 private KeepDeletedCells keepDeletedCells; 042 private long timeToPurgeDeletes; 043 private CellComparator comparator; 044 private long tableMaxRowSize; 045 private boolean usePread; 046 private long cellsPerTimeoutCheck; 047 private boolean parallelSeekEnabled; 048 private final long preadMaxBytes; 049 private final boolean newVersionBehavior; 050 051 public static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT 052 + (2 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_INT) 053 + (4 * Bytes.SIZEOF_LONG) + (4 * Bytes.SIZEOF_BOOLEAN)); 054 055 /** 056 * @param conf 057 * @param family {@link ColumnFamilyDescriptor} describing the column family 058 * @param ttl Store's TTL (in ms) 059 * @param timeToPurgeDeletes duration in ms after which a delete marker can be purged during a 060 * major compaction. 061 * @param comparator The store's comparator 062 */ 063 public ScanInfo(Configuration conf, ColumnFamilyDescriptor family, long ttl, 064 long timeToPurgeDeletes, CellComparator comparator) { 065 this(conf, family.getName(), family.getMinVersions(), family.getMaxVersions(), ttl, 066 family.getKeepDeletedCells(), family.getBlocksize(), timeToPurgeDeletes, comparator, 067 family.isNewVersionBehavior()); 068 } 069 070 private static long getCellsPerTimeoutCheck(Configuration conf) { 071 long perHeartbeat = conf.getLong(StoreScanner.HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK, 072 StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK); 073 return perHeartbeat > 0 ? perHeartbeat 074 : StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK; 075 } 076 077 /** 078 * @param conf 079 * @param family Name of this store's column family 080 * @param minVersions Store's MIN_VERSIONS setting 081 * @param maxVersions Store's VERSIONS setting 082 * @param ttl Store's TTL (in ms) 083 * @param blockSize Store's block size 084 * @param timeToPurgeDeletes duration in ms after which a delete marker can 085 * be purged during a major compaction. 086 * @param keepDeletedCells Store's keepDeletedCells setting 087 * @param comparator The store's comparator 088 */ 089 public ScanInfo(Configuration conf, byte[] family, int minVersions, int maxVersions, long ttl, 090 KeepDeletedCells keepDeletedCells, long blockSize, long timeToPurgeDeletes, 091 CellComparator comparator, boolean newVersionBehavior) { 092 this(family, minVersions, maxVersions, ttl, keepDeletedCells, timeToPurgeDeletes, comparator, 093 conf.getLong(HConstants.TABLE_MAX_ROWSIZE_KEY, HConstants.TABLE_MAX_ROWSIZE_DEFAULT), 094 conf.getBoolean("hbase.storescanner.use.pread", false), getCellsPerTimeoutCheck(conf), 095 conf.getBoolean(StoreScanner.STORESCANNER_PARALLEL_SEEK_ENABLE, false), 096 conf.getLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, 4 * blockSize), newVersionBehavior); 097 } 098 099 private ScanInfo(byte[] family, int minVersions, int maxVersions, long ttl, 100 KeepDeletedCells keepDeletedCells, long timeToPurgeDeletes, CellComparator comparator, 101 long tableMaxRowSize, boolean usePread, long cellsPerTimeoutCheck, 102 boolean parallelSeekEnabled, long preadMaxBytes, boolean newVersionBehavior) { 103 this.family = family; 104 this.minVersions = minVersions; 105 this.maxVersions = maxVersions; 106 this.ttl = ttl; 107 this.keepDeletedCells = keepDeletedCells; 108 this.timeToPurgeDeletes = timeToPurgeDeletes; 109 this.comparator = comparator; 110 this.tableMaxRowSize = tableMaxRowSize; 111 this.usePread = usePread; 112 this.cellsPerTimeoutCheck = cellsPerTimeoutCheck; 113 this.parallelSeekEnabled = parallelSeekEnabled; 114 this.preadMaxBytes = preadMaxBytes; 115 this.newVersionBehavior = newVersionBehavior; 116 } 117 118 long getTableMaxRowSize() { 119 return this.tableMaxRowSize; 120 } 121 122 boolean isUsePread() { 123 return this.usePread; 124 } 125 126 long getCellsPerTimeoutCheck() { 127 return this.cellsPerTimeoutCheck; 128 } 129 130 boolean isParallelSeekEnabled() { 131 return this.parallelSeekEnabled; 132 } 133 134 public byte[] getFamily() { 135 return family; 136 } 137 138 public int getMinVersions() { 139 return minVersions; 140 } 141 142 public int getMaxVersions() { 143 return maxVersions; 144 } 145 146 public long getTtl() { 147 return ttl; 148 } 149 150 public KeepDeletedCells getKeepDeletedCells() { 151 return keepDeletedCells; 152 } 153 154 public long getTimeToPurgeDeletes() { 155 return timeToPurgeDeletes; 156 } 157 158 public CellComparator getComparator() { 159 return comparator; 160 } 161 162 long getPreadMaxBytes() { 163 return preadMaxBytes; 164 } 165 166 public boolean isNewVersionBehavior() { 167 return newVersionBehavior; 168 } 169 170 /** 171 * Used for CP users for customizing max versions, ttl and keepDeletedCells. 172 */ 173 ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells) { 174 return customize(maxVersions, ttl, keepDeletedCells, minVersions); 175 } 176 177 ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells, 178 int minVersions) { 179 return new ScanInfo(family, minVersions, maxVersions, ttl, keepDeletedCells, timeToPurgeDeletes, 180 comparator, tableMaxRowSize, usePread, cellsPerTimeoutCheck, parallelSeekEnabled, 181 preadMaxBytes, newVersionBehavior); 182 } 183}