1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.filter;
22
23 import org.apache.hadoop.hbase.KeyValue;
24
25 import java.io.DataInput;
26 import java.io.DataOutput;
27 import java.io.IOException;
28 import java.util.List;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 public class SkipFilter extends FilterBase {
49 private boolean filterRow = false;
50 private Filter filter;
51
52 public SkipFilter() {
53 super();
54 }
55
56 public SkipFilter(Filter filter) {
57 this.filter = filter;
58 }
59
60 public Filter getFilter() {
61 return filter;
62 }
63
64 public void reset() {
65 filter.reset();
66 filterRow = false;
67 }
68
69 private void changeFR(boolean value) {
70 filterRow = filterRow || value;
71 }
72
73 public ReturnCode filterKeyValue(KeyValue v) {
74 ReturnCode c = filter.filterKeyValue(v);
75 changeFR(c != ReturnCode.INCLUDE);
76 return c;
77 }
78
79 public boolean filterRow() {
80 return filterRow;
81 }
82
83 public void write(DataOutput out) throws IOException {
84 out.writeUTF(this.filter.getClass().getName());
85 this.filter.write(out);
86 }
87
88 public void readFields(DataInput in) throws IOException {
89 String className = in.readUTF();
90 try {
91 this.filter = (Filter)(Class.forName(className).newInstance());
92 this.filter.readFields(in);
93 } catch (InstantiationException e) {
94 throw new RuntimeException("Failed deserialize.", e);
95 } catch (IllegalAccessException e) {
96 throw new RuntimeException("Failed deserialize.", e);
97 } catch (ClassNotFoundException e) {
98 throw new RuntimeException("Failed deserialize.", e);
99 }
100 }
101 }