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.hadoop.hbase.hbql.client.ExecutionResults;
24 import org.apache.hadoop.hbase.hbql.client.HBqlException;
25 import org.apache.hadoop.hbase.hbql.mapping.EnvVars;
26
27 public class SetStatement extends GenericStatement implements NonConnectionStatement {
28
29 private final String variable, value;
30
31 public SetStatement(final String variable, final String value) {
32 super(null);
33 this.variable = variable;
34 this.value = value;
35 }
36
37 public String getVariable() {
38 return variable;
39 }
40
41 public String getValue() {
42 return value;
43 }
44
45 public ExecutionResults execute() throws HBqlException {
46
47 final String var = this.getVariable();
48
49 if (var == null)
50 throw new HBqlException("Error in SET command");
51
52 if (var.equalsIgnoreCase("packagepath")) {
53 EnvVars.setPackagePath(this.getValue());
54 return new ExecutionResults("PackagePath set to " + this.getValue());
55 }
56
57 throw new HBqlException("Unknown variable: " + var);
58 }
59 }