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 */ 018package org.apache.hadoop.hbase.regionserver.querymatcher; 019 020import java.io.IOException; 021 022import org.apache.hadoop.hbase.Cell; 023import org.apache.hadoop.hbase.CellUtil; 024import org.apache.hadoop.hbase.PrivateCellUtil; 025import org.apache.yetus.audience.InterfaceAudience; 026import org.apache.hadoop.hbase.regionserver.ScanInfo; 027 028/** 029 * Query matcher for major compaction. 030 */ 031@InterfaceAudience.Private 032public class MajorCompactionScanQueryMatcher extends DropDeletesCompactionScanQueryMatcher { 033 034 public MajorCompactionScanQueryMatcher(ScanInfo scanInfo, DeleteTracker deletes, 035 ColumnTracker columns, long readPointToUse, long earliestPutTs, long oldestUnexpiredTS, 036 long now) { 037 super(scanInfo, deletes, columns, readPointToUse, earliestPutTs, oldestUnexpiredTS, now); 038 } 039 040 @Override 041 public MatchCode match(Cell cell) throws IOException { 042 MatchCode returnCode = preCheck(cell); 043 if (returnCode != null) { 044 return returnCode; 045 } 046 long timestamp = cell.getTimestamp(); 047 long mvccVersion = cell.getSequenceId(); 048 byte typeByte = cell.getTypeByte(); 049 050 // The delete logic is pretty complicated now. 051 // This is corroborated by the following: 052 // 1. The store might be instructed to keep deleted rows around. 053 // 2. A scan can optionally see past a delete marker now. 054 // 3. If deleted rows are kept, we have to find out when we can 055 // remove the delete markers. 056 // 4. Family delete markers are always first (regardless of their TS) 057 // 5. Delete markers should not be counted as version 058 // 6. Delete markers affect puts of the *same* TS 059 // 7. Delete marker need to be version counted together with puts 060 // they affect 061 // 062 if (PrivateCellUtil.isDelete(typeByte)) { 063 if (mvccVersion > maxReadPointToTrackVersions) { 064 // We can not drop this delete marker yet, and also we should not use this delete marker to 065 // mask any cell yet. 066 return MatchCode.INCLUDE; 067 } 068 trackDelete(cell); 069 returnCode = tryDropDelete(cell); 070 if (returnCode != null) { 071 return returnCode; 072 } 073 } else { 074 returnCode = checkDeleted(deletes, cell); 075 if (returnCode != null) { 076 return returnCode; 077 } 078 } 079 // Skip checking column since we do not remove column during compaction. 080 return columns.checkVersions(cell, timestamp, typeByte, 081 mvccVersion > maxReadPointToTrackVersions); 082 } 083}