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</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
39 * this row operation.
40 * <p>
41 * This is called when a Delete is encountered in a StoreFile.
42 * @param cell - the delete cell
43 */
44 void add(Cell cell);
45
46 /**
47 * Check if the specified cell buffer has been deleted by a previously
48 * seen delete.
49 * @param cell - current cell to check if deleted by a previously seen delete
50 * @return deleteResult The result tells whether the KeyValue is deleted and why
51 */
52 DeleteResult isDeleted(Cell cell);
53
54 /**
55 * @return true if there are no current delete, false otherwise
56 */
57 boolean isEmpty();
58
59 /**
60 * Called at the end of every StoreFile.
61 * <p>
62 * Many optimized implementations of Trackers will require an update at
63 * when the end of each StoreFile is reached.
64 */
65 void update();
66
67 /**
68 * Called between rows.
69 * <p>
70 * This clears everything as if a new DeleteTracker was instantiated.
71 */
72 void reset();
73
74
75 /**
76 * Return codes for comparison of two Deletes.
77 * <p>
78 * The codes tell the merging function what to do.
79 * <p>
80 * INCLUDE means add the specified Delete to the merged list.
81 * NEXT means move to the next element in the specified list(s).
82 */
83 enum DeleteCompare {
84 INCLUDE_OLD_NEXT_OLD,
85 INCLUDE_OLD_NEXT_BOTH,
86 INCLUDE_NEW_NEXT_NEW,
87 INCLUDE_NEW_NEXT_BOTH,
88 NEXT_OLD,
89 NEXT_NEW
90 }
91
92 /**
93 * Returns codes for delete result.
94 * The codes tell the ScanQueryMatcher whether the kv is deleted and why.
95 * Based on the delete result, the ScanQueryMatcher will decide the next
96 * operation
97 */
98 enum DeleteResult {
99 FAMILY_DELETED, // The KeyValue is deleted by a delete family.
100 FAMILY_VERSION_DELETED, // The KeyValue is deleted by a delete family version.
101 COLUMN_DELETED, // The KeyValue is deleted by a delete column.
102 VERSION_DELETED, // The KeyValue is deleted by a version delete.
103 NOT_DELETED
104 }
105
106 }