本文整理了Java中util.HBaseHelper.close()
方法的一些代码示例,展示了HBaseHelper.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HBaseHelper.close()
方法的具体详情如下:
包路径:util.HBaseHelper
类名称:HBaseHelper
方法名:close
暂无
代码示例来源: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 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
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable"));
// vv PutIdenticalExample
Put put = new Put(Bytes.toBytes("row1"));
put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val2"));
put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1")); // co PutIdenticalExample-1-Add Add the same column with a different value. The last value is going to be used.
table.put(put);
Get get = new Get(Bytes.toBytes("row1"));
Result result = table.get(get);
System.out.println("Result: " + result + ", Value: " + Bytes.toString(
result.getValue(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")))); // co PutIdenticalExample-2-Get Perform a get to verify that "val1" was actually stored.
// ^^ PutIdenticalExample
table.close();
connection.close();
helper.close();
}
}
代码示例来源:origin: larsgeorge/hbase-book
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
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
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
@Override
public Void run() throws Exception {
Configuration conf = superuser.getConfiguration();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
System.out.println("Superuser: Adding rows to table...");
helper.fillTable("testtable", 1, 2, 2, "colfam1");
helper.close();
return null;
}
});
代码示例来源:origin: larsgeorge/hbase-book
@Override
public Void run() throws Exception {
Configuration conf = superuser.getConfiguration();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1", "colfam2");
System.out.println("Adding rows to table...");
helper.fillTable("testtable", 1, 100, 100, "colfam1", "colfam2");
helper.close();
return null;
}
});
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create(); // co PutExample-1-CreateConf Create the required configuration.
// ^^ PutExample
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
// vv PutExample
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable")); // co PutExample-2-NewTable Instantiate a new client.
Put put = new Put(Bytes.toBytes("row1")); // co PutExample-3-NewPut Create put with specific row.
put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1")); // co PutExample-4-AddCol1 Add a column, whose name is "colfam1:qual1", to the put.
put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"),
Bytes.toBytes("val2")); // co PutExample-4-AddCol2 Add another column, whose name is "colfam1:qual2", to the put.
table.put(put); // co PutExample-5-DoPut Store row with column into the HBase table.
table.close(); // co PutExample-6-DoPut Close table and connection instances to free resources.
connection.close();
// ^^ PutExample
helper.close();
// vv PutExample
}
}
代码示例来源:origin: larsgeorge/hbase-book
table.close();
connection.close();
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
connection.close();
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
System.out.println("After mutate call...");
helper.dump("testtable", new String[] { "row1" }, null, null);
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
table.close();
connection.close();
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
System.out.println("After delete call...");
helper.dump("testtable", new String[] { "row1" }, null, null);
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
helper.close();
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
// ^^ ScanSlicingExample
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1", "colfam2");
helper.fillTable("testtable", 1, 10, 10, 2, true, "colfam1", "colfam2");
Connection connection = ConnectionFactory.createConnection(conf);
table = connection.getTable(TableName.valueOf("testtable"));
// vv ScanSlicingExample
/*...*/
scan(1, 11, 0, 0, 2, -1, true);
scan(2, 11, 0, 4, 2, -1, true);
scan(3, 5, 0, 0, 2, -1, false);
scan(4, 11, 2, 0, 5, -1, true);
scan(5, 11, -1, -1, -1, 1, false);
scan(6, 11, -1, -1, -1, 10000, false);
/*...*/
// ^^ ScanSlicingExample
table.close();
connection.close();
helper.close();
// vv ScanSlicingExample
}
// ^^ ScanSlicingExample
代码示例来源:origin: larsgeorge/hbase-book
helper.close();
内容来源于网络,如有侵权,请联系作者删除!