MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / scanMeta

Method scanMeta

src/HBaseClient.java:2902–2952  ·  view source on GitHub ↗

Later versions of HBase dropped the old RegionClient#getClosestRowBefore(RegionInfo, byte[], byte[], byte[]) method and switched to performing reverse scans. This method will handle the scanning returning either a meta row if found or an empty array if the row/table was not found. TODO - nee

(final RegionClient client, 
                                                 final RegionInfo region, 
                                                 final byte[] table, 
                                                 final byte[] row, 
                                                 final byte[] family)

Source from the content-addressed store, hash-verified

2900 * exist. Or an exception if something goes pear shaped.
2901 */
2902 Deferred<ArrayList<KeyValue>> scanMeta(final RegionClient client,
2903 final RegionInfo region,
2904 final byte[] table,
2905 final byte[] row,
2906 final byte[] family) {
2907 final Scanner scanner = newScanner(table);
2908 scanner.setReversed(true);
2909 scanner.setMaxNumRows(1);
2910 scanner.setStartKey(row);
2911 scanner.setFamily(family);
2912 scanner.setRegionName(region);
2913
2914 final Deferred<ArrayList<KeyValue>> deferred =
2915 new Deferred<ArrayList<KeyValue>>();
2916
2917 class ErrorCB implements Callback<Object, Exception> {
2918 @Override
2919 public Object call(final Exception ex) throws Exception {
2920 scanner.close();
2921 deferred.callback(ex);
2922 return null;
2923 }
2924 @Override
2925 public String toString() {
2926 return "scanMeta.ErrorCB";
2927 }
2928 }
2929
2930 class MetaScanCB implements Callback<Void, ArrayList<ArrayList<KeyValue>>> {
2931 @Override
2932 public Void call(final ArrayList<ArrayList<KeyValue>> rows)
2933 throws Exception {
2934 final ArrayList<KeyValue> row = (rows == null || rows.isEmpty())
2935 ? new ArrayList<KeyValue>(0) : rows.get(0);
2936 scanner.close();
2937 deferred.callback(row);
2938 return null;
2939 }
2940 @Override
2941 public String toString() {
2942 return "scanMeta.MetaScanCB";
2943 }
2944 }
2945
2946 HBaseRpc open_request = scanner.getOpenRequestForReverseScan(row);
2947 open_request.region = region;
2948 open_request.getDeferred().addCallbackDeferring(scanner.opened_scanner)
2949 .addCallbacks(new MetaScanCB(), new ErrorCB());
2950 client.sendRpc(open_request);
2951 return deferred;
2952 }
2953
2954 /**
2955 * Callback executed when a lookup in META completes

Callers 2

locateRegionMethod · 0.95

Calls 9

newScannerMethod · 0.95
setReversedMethod · 0.95
setMaxNumRowsMethod · 0.95
setStartKeyMethod · 0.95
setFamilyMethod · 0.95
setRegionNameMethod · 0.95
getDeferredMethod · 0.95
sendRpcMethod · 0.80