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.select;
22
23 import org.apache.hadoop.hbase.client.Get;
24 import org.apache.hadoop.hbase.client.HTable;
25 import org.apache.hadoop.hbase.client.Result;
26 import org.apache.hadoop.hbase.client.ResultScanner;
27 import org.apache.hadoop.hbase.hbql.client.HBqlException;
28 import org.apache.hadoop.hbase.hbql.mapping.Mapping;
29 import org.apache.hadoop.hbase.hbql.statement.args.WithArgs;
30 import org.apache.hadoop.hbase.hbql.util.Lists;
31
32 import java.io.IOException;
33 import java.util.Iterator;
34 import java.util.List;
35
36 public class GetRequest implements RowRequest {
37
38 final Get getValue;
39
40 public GetRequest(final Get getValue) {
41 this.getValue = getValue;
42 }
43
44 private Get getGetValue() {
45 return this.getValue;
46 }
47
48 public ResultScanner getResultScanner(final Mapping mapping,
49 final WithArgs withArgs,
50 final HTable table) throws HBqlException {
51 try {
52
53 final List<Result> resultList = Lists.newArrayList();
54 final Result result = table.get(this.getGetValue());
55
56 if (result != null && !result.isEmpty())
57 resultList.add(result);
58
59 return new ResultScanner() {
60
61 public Result next() {
62 return null;
63 }
64
65 public Result[] next(final int nbRows) {
66 return null;
67 }
68
69 public Iterator<Result> iterator() {
70 return resultList.iterator();
71 }
72
73 public void close() {
74
75 }
76 };
77 }
78 catch (IOException e) {
79 throw new HBqlException(e);
80 }
81 }
82 }