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  package org.apache.hadoop.hbase.regionserver;
19  
20  import org.apache.hadoop.hbase.classification.InterfaceAudience;
21  import org.apache.hadoop.hbase.Cell;
22  
23  /**
24   * This interface is used for the tracking and enforcement of Deletes during the course of a Get or
25   * Scan operation.
26   * <p>
27   * This class is utilized through three methods:
28   * <ul>
29   * <li>{@link #add} when encountering a Delete</li>
30   * <li>{@link #isDeleted} when checking if a Put KeyValue has been deleted</li>
31   * <li>{@link #update} when reaching the end of a StoreFile</li>
32   * </ul>
33   */
34  @InterfaceAudience.Private
35  public interface DeleteTracker {
36  
37    /**
38     * Add the specified cell to the list of deletes to check against for this row operation.
39     * <p>
40     * This is called when a Delete is encountered in a StoreFile.
41     * @param cell - the delete cell
42     */
43    void add(Cell cell);
44  
45    /**
46     * Check if the specified cell buffer has been deleted by a previously seen delete.
47     * @param cell - current cell to check if deleted by a previously seen delete
48     * @return deleteResult The result tells whether the KeyValue is deleted and why
49     */
50    DeleteResult isDeleted(Cell cell);
51  
52    /**
53     * @return true if there are no current delete, false otherwise
54     */
55    boolean isEmpty();
56  
57    /**
58     * Called at the end of every StoreFile.
59     * <p>
60     * Many optimized implementations of Trackers will require an update at when the end of each
61     * StoreFile is reached.
62     */
63    void update();
64  
65    /**
66     * Called between rows.
67     * <p>
68     * This clears everything as if a new DeleteTracker was instantiated.
69     */
70    void reset();
71  
72    /**
73     * Return codes for comparison of two Deletes.
74     * <p>
75     * The codes tell the merging function what to do.
76     * <p>
77     * INCLUDE means add the specified Delete to the merged list. NEXT means move to the next element
78     * in the specified list(s).
79     */
80    enum DeleteCompare {
81      INCLUDE_OLD_NEXT_OLD,
82      INCLUDE_OLD_NEXT_BOTH,
83      INCLUDE_NEW_NEXT_NEW,
84      INCLUDE_NEW_NEXT_BOTH,
85      NEXT_OLD,
86      NEXT_NEW
87    }
88  
89    /**
90     * Returns codes for delete result. The codes tell the ScanQueryMatcher whether the kv is deleted
91     * and why. Based on the delete result, the ScanQueryMatcher will decide the next operation
92     */
93    enum DeleteResult {
94      FAMILY_DELETED, // The KeyValue is deleted by a delete family.
95      FAMILY_VERSION_DELETED, // The KeyValue is deleted by a delete family version.
96      COLUMN_DELETED, // The KeyValue is deleted by a delete column.
97      VERSION_DELETED, // The KeyValue is deleted by a version delete.
98      NOT_DELETED
99    }
100 
101 }