1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 package org.apache.hadoop.hbase.regionserver; 20 21 import org.apache.hadoop.classification.InterfaceAudience; 22 23 /** 24 * This interface is used for the tracking and enforcement of Deletes 25 * during the course of a Get or Scan operation. 26 * <p> 27 * This class is utilized through three methods: 28 * <ul><li>{@link #add} when encountering a Delete 29 * <li>{@link #isDeleted} when checking if a Put KeyValue has been deleted 30 * <li>{@link #update} when reaching the end of a StoreFile 31 */ 32 @InterfaceAudience.Private 33 public interface DeleteTracker { 34 35 /** 36 * Add the specified KeyValue to the list of deletes to check against for 37 * this row operation. 38 * <p> 39 * This is called when a Delete is encountered in a StoreFile. 40 * @param buffer KeyValue buffer 41 * @param qualifierOffset column qualifier offset 42 * @param qualifierLength column qualifier length 43 * @param timestamp timestamp 44 * @param type delete type as byte 45 */ 46 void add( 47 byte[] buffer, int qualifierOffset, int qualifierLength, long timestamp, byte type 48 ); 49 50 /** 51 * Check if the specified KeyValue buffer has been deleted by a previously 52 * seen delete. 53 * @param buffer KeyValue buffer 54 * @param qualifierOffset column qualifier offset 55 * @param qualifierLength column qualifier length 56 * @param timestamp timestamp 57 * @return deleteResult The result tells whether the KeyValue is deleted and why 58 */ 59 DeleteResult isDeleted( 60 byte[] buffer, int qualifierOffset, int qualifierLength, long timestamp 61 ); 62 63 /** 64 * @return true if there are no current delete, false otherwise 65 */ 66 boolean isEmpty(); 67 68 /** 69 * Called at the end of every StoreFile. 70 * <p> 71 * Many optimized implementations of Trackers will require an update at 72 * when the end of each StoreFile is reached. 73 */ 74 void update(); 75 76 /** 77 * Called between rows. 78 * <p> 79 * This clears everything as if a new DeleteTracker was instantiated. 80 */ 81 void reset(); 82 83 84 /** 85 * Return codes for comparison of two Deletes. 86 * <p> 87 * The codes tell the merging function what to do. 88 * <p> 89 * INCLUDE means add the specified Delete to the merged list. 90 * NEXT means move to the next element in the specified list(s). 91 */ 92 enum DeleteCompare { 93 INCLUDE_OLD_NEXT_OLD, 94 INCLUDE_OLD_NEXT_BOTH, 95 INCLUDE_NEW_NEXT_NEW, 96 INCLUDE_NEW_NEXT_BOTH, 97 NEXT_OLD, 98 NEXT_NEW 99 } 100 101 /** 102 * Returns codes for delete result. 103 * The codes tell the ScanQueryMatcher whether the kv is deleted and why. 104 * Based on the delete result, the ScanQueryMatcher will decide the next 105 * operation 106 */ 107 enum DeleteResult { 108 FAMILY_DELETED, // The KeyValue is deleted by a delete family. 109 FAMILY_VERSION_DELETED, // The KeyValue is deleted by a delete family version. 110 COLUMN_DELETED, // The KeyValue is deleted by a delete column. 111 VERSION_DELETED, // The KeyValue is deleted by a version delete. 112 NOT_DELETED 113 } 114 115 }