Revision 45749
Added by Claudio Atzori over 7 years ago
ScanFactory.java | ||
---|---|---|
16 | 16 |
import org.apache.hadoop.hbase.util.Base64; |
17 | 17 |
import org.dom4j.Document; |
18 | 18 |
import org.dom4j.Node; |
19 |
import org.springframework.beans.factory.annotation.Value; |
|
19 | 20 |
|
20 | 21 |
public class ScanFactory { |
21 | 22 |
|
22 | 23 |
private static final Log log = LogFactory.getLog(ScanFactory.class); // NOPMD by marko on 11/24/08 5:02 PM |
23 | 24 |
|
24 |
public static String getScan(final ScanProperties scanProperties) throws IOException { |
|
25 |
@Value("${services.hadoop.hbase.maxversions}") |
|
26 |
private int hbaseMaxVersions; |
|
27 |
|
|
28 |
public String getScan(final ScanProperties scanProperties) throws IOException { |
|
25 | 29 |
return convertScanToString(getScanObject(scanProperties)); |
26 | 30 |
} |
27 | 31 |
|
28 |
public static Scan getScanObject(final ScanProperties scanProperties) {
|
|
32 |
public Scan getScanObject(final ScanProperties scanProperties) { |
|
29 | 33 |
final Scan scan = new Scan(); |
30 | 34 |
|
31 | 35 |
scan.setCaching(scanProperties.getCaching()); |
... | ... | |
36 | 40 |
scan.addFamily(family.getBytes()); |
37 | 41 |
} |
38 | 42 |
|
43 |
if (scanProperties.getVersions() > 0) { |
|
44 |
log.info(String.format("scanner to read %s versions from hbase", scanProperties.getVersions())); |
|
45 |
scan.setMaxVersions(scanProperties.getVersions()); |
|
46 |
} |
|
47 |
|
|
39 | 48 |
return scan; |
40 | 49 |
} |
41 | 50 |
|
42 |
public static ScanProperties parseScanProperties(final Document doc, final Map<String, String> bbParams) {
|
|
51 |
public ScanProperties parseScanProperties(final Document doc, final Map<String, String> bbParams) { |
|
43 | 52 |
log.debug("setting job scanner"); |
44 | 53 |
|
45 | 54 |
final ScanProperties scanProperties = new ScanProperties(doc.valueOf("//FILTERS/@operator")); |
... | ... | |
61 | 70 |
if (StringUtils.isNotBlank(qualifier)) { |
62 | 71 |
columnFilter.addFilter(new ColumnPrefixFilter(qualifier.trim().getBytes())); |
63 | 72 |
} |
73 |
String readVersions = node.valueOf("./@readVersions"); |
|
74 |
if (StringUtils.isNotBlank(readVersions) && Boolean.parseBoolean(readVersions)) { |
|
75 |
scanProperties.setVersions(hbaseMaxVersions); |
|
76 |
} |
|
64 | 77 |
|
65 |
log.debug(String.format("scanner family: '%s', qualifier: '%s'", value, qualifier));
|
|
78 |
log.debug(String.format("scanner family: '%s', qualifier: '%s', readVersions: '%s'", value, qualifier, readVersions));
|
|
66 | 79 |
scanProperties.getFamilies().add(value); |
67 | 80 |
} |
68 | 81 |
|
Also available in: Unified diff
scan factory to parse attribute @readVersions