HBase使用標(biāo)簽讀取單元格

2018-05-04 13:42 更新

使用標(biāo)簽讀取單元格

當(dāng)您發(fā)出掃描或獲取時(shí),HBase會使用您的一組默認(rèn)授權(quán)來過濾掉您無權(quán)訪問的單元格。超級用戶(superuser)可以通過使用set_auths HBase Shell命令或VisibilityClient.setAuths()方法為給定用戶設(shè)置默認(rèn)授權(quán)集。

如果您使用API??,則可以在掃描或獲取期間通過在HBase Shell中傳遞AUTHORIZATIONS選項(xiàng)或在Scan.setAuthorizations()方法中指定不同的授權(quán)。此授權(quán)將與您的默認(rèn)設(shè)置一起作為附加過濾器。它會進(jìn)一步過濾你的結(jié)果,而不是給你額外的授權(quán)。

HBase Shell

hbase> get_auths 'myUser'
hbase> scan 'table1', AUTHORIZATIONS => ['private']

例子:Java API

...
public Void run() throws Exception {
  String[] auths1 = { SECRET, CONFIDENTIAL };
  GetAuthsResponse authsResponse = null;
  try {
    VisibilityClient.setAuths(conf, auths1, user);
    try {
      authsResponse = VisibilityClient.getAuths(conf, user);
    } catch (Throwable e) {
      fail("Should not have failed");
    }
  } catch (Throwable e) {
  }
  List<String> authsList = new ArrayList<String>();
  for (ByteString authBS : authsResponse.getAuthList()) {
    authsList.add(Bytes.toString(authBS.toByteArray()));
  }
  assertEquals(2, authsList.size());
  assertTrue(authsList.contains(SECRET));
  assertTrue(authsList.contains(CONFIDENTIAL));
  return null;
}
...
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號