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.hbql.statement;
22
23 import org.apache.expreval.client.InternalErrorException;
24 import org.apache.hadoop.hbase.hbql.client.ExecutionResults;
25 import org.apache.hadoop.hbase.hbql.client.HBqlException;
26 import org.apache.hadoop.hbase.hbql.impl.HConnectionImpl;
27
28 public abstract class GenericStatement {
29
30 private StatementPredicate predicate = null;
31
32 public GenericStatement() {
33 }
34
35 protected GenericStatement(final StatementPredicate predicate) {
36 this.predicate = predicate;
37 }
38
39 private StatementPredicate getPredicate() {
40 return this.predicate;
41 }
42
43 public ExecutionResults evaluatePredicateAndExecute(final HConnectionImpl conn) throws HBqlException {
44 if (this.getPredicate() == null || this.getPredicate().evaluate(conn)) {
45 return this.execute(conn);
46 }
47 else {
48 final ExecutionResults results = new ExecutionResults("False predicate");
49 results.setPredicate(false);
50 return results;
51 }
52 }
53
54 protected ExecutionResults execute(HConnectionImpl connection) throws HBqlException {
55 throw new InternalErrorException();
56 }
57
58 public void validate() throws HBqlException {
59
60 }
61 }