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