本文整理了Java中util.HBaseHelper.existsTable()
方法的一些代码示例,展示了HBaseHelper.existsTable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseHelper.existsTable()
方法的具体详情如下:
包路径:util.HBaseHelper
类名称:HBaseHelper
方法名:existsTable
暂无
代码示例来源:origin: larsgeorge/hbase-book
public boolean existsTable(String table)
throws IOException {
return existsTable(TableName.valueOf(table));
}
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
// vv GetTryWithResourcesExample
Configuration conf = HBaseConfiguration.create(); // co GetTryWithResourcesExample-1-CreateConf Create the configuration.
// ^^ GetTryWithResourcesExample
HBaseHelper helper = HBaseHelper.getHelper(conf);
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
}
// vv GetTryWithResourcesExample
try (
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable")); // co GetTryWithResourcesExample-2-NewTable Instantiate a new table reference in "try" block.
) {
Get get = new Get(Bytes.toBytes("row1"));
get.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"));
Result result = table.get(get);
byte[] val = result.getValue(Bytes.toBytes("colfam1"),
Bytes.toBytes("qual1"));
System.out.println("Value: " + Bytes.toString(val));
} // co GetTryWithResourcesExample-3-Close No explicit close needed, Java will handle AutoClosable's.
// ^^ GetTryWithResourcesExample
helper.close();
}
}
代码示例来源:origin: larsgeorge/hbase-book
public void dropTable(TableName table) throws IOException {
if (existsTable(table)) {
if (admin.isTableEnabled(table)) disableTable(table);
admin.deleteTable(table);
}
}
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
// vv GetExample
Configuration conf = HBaseConfiguration.create(); // co GetExample-1-CreateConf Create the configuration.
// ^^ GetExample
HBaseHelper helper = HBaseHelper.getHelper(conf);
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
}
// vv GetExample
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable")); // co GetExample-2-NewTable Instantiate a new table reference.
Get get = new Get(Bytes.toBytes("row1")); // co GetExample-3-NewGet Create get with specific row.
get.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")); // co GetExample-4-AddCol Add a column to the get.
Result result = table.get(get); // co GetExample-5-DoGet Retrieve row with selected columns from HBase.
byte[] val = result.getValue(Bytes.toBytes("colfam1"),
Bytes.toBytes("qual1")); // co GetExample-6-GetValue Get a specific value for the given column.
System.out.println("Value: " + Bytes.toString(val)); // co GetExample-7-Print Print out the value while converting it back.
table.close(); // co GetExample-8-Close Close the table and connection instances to free resources.
connection.close();
// ^^ GetExample
helper.close();
}
}
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
}
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable"));
// vv GetCloneExample
Get get1 = new Get(Bytes.toBytes("row1"));
get1.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"));
Get get2 = new Get(get1);
Result result = table.get(get2);
System.out.println("Result : " + result);
// ^^ GetCloneExample
table.close();
connection.close();
helper.close();
}
}
代码示例来源:origin: larsgeorge/hbase-book
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
代码示例来源:origin: larsgeorge/hbase-book
if (!helper.existsTable("testtable")) {
helper.createTable("testtable", "colfam1");
内容来源于网络,如有侵权,请联系作者删除!