本文整理了Java中org.apache.hadoop.hbase.client.Append.setCellVisibility()
方法的一些代码示例,展示了Append.setCellVisibility()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Append.setCellVisibility()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Append
类名称:Append
方法名:setCellVisibility
暂无
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(tableName)) {
Append append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("c"));
append.setCellVisibility(new CellVisibility(PUBLIC));
table.append(append);
Assert.fail("Testcase should fail with AccesDeniedException");
} catch (Throwable t) {
assertTrue(t.getMessage().contains("AccessDeniedException"));
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Test
public void testLabelsWithAppend() throws Throwable {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = TEST_UTIL.createTable(tableName, fam)) {
byte[] row1 = Bytes.toBytes("row1");
byte[] val = Bytes.toBytes("a");
Put put = new Put(row1);
put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, val);
put.setCellVisibility(new CellVisibility(SECRET + " & " + CONFIDENTIAL));
table.put(put);
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(SECRET));
Result result = table.get(get);
assertTrue(result.isEmpty());
Append append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("b"));
table.append(append);
result = table.get(get);
assertTrue(result.isEmpty());
append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("c"));
append.setCellVisibility(new CellVisibility(SECRET));
table.append(append);
result = table.get(get);
assertTrue(!result.isEmpty());
}
}
代码示例来源:origin: apache/hbase
public static Append appendFromThrift(TAppend append) throws IOException {
Append out = new Append(append.getRow());
for (TColumnValue column : append.getColumns()) {
out.addColumn(column.getFamily(), column.getQualifier(), column.getValue());
}
if (append.isSetAttributes()) {
addAttributes(out, append.getAttributes());
}
if (append.isSetDurability()) {
out.setDurability(durabilityFromThrift(append.getDurability()));
}
if(append.getCellVisibility() != null) {
out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
}
if (append.isSetReturnResults()) {
out.setReturnResults(append.isReturnResults());
}
return out;
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Override
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(tableName)) {
Append append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("c"));
append.setCellVisibility(new CellVisibility(PUBLIC));
table.append(append);
Assert.fail("Testcase should fail with AccesDeniedException");
} catch (Throwable t) {
assertTrue(t.getMessage().contains("AccessDeniedException"));
}
return null;
}
};
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testLabelsWithAppend() throws Throwable {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = TEST_UTIL.createTable(tableName, fam);) {
byte[] row1 = Bytes.toBytes("row1");
byte[] val = Bytes.toBytes("a");
Put put = new Put(row1);
put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, val);
put.setCellVisibility(new CellVisibility(SECRET + " & " + CONFIDENTIAL));
table.put(put);
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(SECRET));
Result result = table.get(get);
assertTrue(result.isEmpty());
Append append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("b"));
table.append(append);
result = table.get(get);
assertTrue(result.isEmpty());
append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("c"));
append.setCellVisibility(new CellVisibility(SECRET));
table.append(append);
result = table.get(get);
assertTrue(!result.isEmpty());
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-thrift
public static Append appendFromThrift(TAppend append) throws IOException {
Append out = new Append(append.getRow());
for (TColumnValue column : append.getColumns()) {
out.addColumn(column.getFamily(), column.getQualifier(), column.getValue());
}
if (append.isSetAttributes()) {
addAttributes(out, append.getAttributes());
}
if (append.isSetDurability()) {
out.setDurability(durabilityFromThrift(append.getDurability()));
}
if(append.getCellVisibility() != null) {
out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
}
return out;
}
代码示例来源:origin: org.apache.hbase/hbase-thrift
public static Append appendFromThrift(TAppend append) throws IOException {
Append out = new Append(append.getRow());
for (TColumnValue column : append.getColumns()) {
out.addColumn(column.getFamily(), column.getQualifier(), column.getValue());
}
if (append.isSetAttributes()) {
addAttributes(out, append.getAttributes());
}
if (append.isSetDurability()) {
out.setDurability(durabilityFromThrift(append.getDurability()));
}
if(append.getCellVisibility() != null) {
out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
}
return out;
}
内容来源于网络,如有侵权,请联系作者删除!