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 org.apache.hadoop.hbase.CellComparator; 021import org.apache.hadoop.hbase.ExtendedCell; 022import org.apache.hadoop.hbase.regionserver.ShipperListener; 023import org.apache.yetus.audience.InterfaceAudience; 024 025/** 026 * This interface is used for the tracking and enforcement of Deletes during the course of a Get or 027 * Scan operation. 028 * <p> 029 * This class is utilized through three methods: 030 * <ul> 031 * <li>{@link #add} when encountering a Delete</li> 032 * <li>{@link #isDeleted} when checking if a Put Cell has been deleted</li> 033 * <li>{@link #update} when reaching the end of a StoreFile</li> 034 * </ul> 035 */ 036@InterfaceAudience.Private 037public interface DeleteTracker extends ShipperListener { 038 039 /** 040 * Add the specified cell to the list of deletes to check against for this row operation. 041 * <p> 042 * This is called when a Delete is encountered in a StoreFile. 043 * @param cell - the delete cell 044 */ 045 void add(ExtendedCell cell); 046 047 /** 048 * Check if the specified cell buffer has been deleted by a previously seen delete. 049 * @param cell - current cell to check if deleted by a previously seen delete 050 * @return deleteResult The result tells whether the Cell is deleted and why 051 */ 052 DeleteResult isDeleted(ExtendedCell cell); 053 054 /** Returns true if there are no current delete, false otherwise */ 055 boolean isEmpty(); 056 057 /** 058 * Called at the end of every StoreFile. 059 * <p> 060 * Many optimized implementations of Trackers will require an update at when the end of each 061 * StoreFile is reached. 062 */ 063 void update(); 064 065 /** 066 * Called between rows. 067 * <p> 068 * This clears everything as if a new DeleteTracker was instantiated. 069 */ 070 void reset(); 071 072 /** 073 * Returns codes for delete result. The codes tell the ScanQueryMatcher whether the kv is deleted 074 * and why. Based on the delete result, the ScanQueryMatcher will decide the next operation 075 */ 076 enum DeleteResult { 077 FAMILY_DELETED, // The Cell is deleted by a delete family. 078 FAMILY_VERSION_DELETED, // The Cell is deleted by a delete family version. 079 COLUMN_DELETED, // The Cell is deleted by a delete column. 080 VERSION_DELETED, // The Cell is deleted by a version delete. 081 NOT_DELETED, 082 VERSION_MASKED // The Cell is masked by max number of versions which is considered as 083 // deleted in strong semantics of versions(See MvccTracker) 084 } 085 086 /** 087 * Return the comparator passed to this delete tracker 088 * @return the cell comparator 089 */ 090 CellComparator getCellComparator(); 091 092}