example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.HColumnDescriptor; org.apache.hadoop.hbase.HTableDescriptor; org.apache.hadoop.hbase.client.HBaseAdmin; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.util.Bytes; org.apache.hadoop.hbase.util.Pair; { printRegion( tableName) Exception{ System.out.println(tableName); Configuration confHBaseConfiguration.create(); HTable table HTable(conf,tableName); Pair[][],[][] pairtable.getStartEndKeys(); [][]firstspair.getFirst(); ( i;ifirsts.length;i){ (firsts[i].length){ System.out.println(Bytes.toLong(firsts[i])Bytes.toLong(pair.getSecond()[i])); }{ System.out.println(Bytes.toStringBinary(firsts[i])Bytes.toStringBinary(pair.getSecond()[i])); } } } main([] args) Exception{ Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); HTableDescriptor tabDesc HTableDescriptor(Bytes.toBytes()); HColumnDescriptor colDesc HColumnDescriptor(); tabDesc.addFamily(colDesc); admin.createTable(tabDesc,Bytes.toBytes(),Bytes.toBytes(),); printRegion(); HTableDescriptor tabDesc2 HTableDescriptor(Bytes.toBytes()); HColumnDescriptor colDesc2 HColumnDescriptor(); tabDesc2.addFamily(colDesc2); [][]spilit [][]{ Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes() }; admin.createTable(tabDesc2, spilit); printRegion(); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.HColumnDescriptor; org.apache.hadoop.hbase.HTableDescriptor; org.apache.hadoop.hbase.client.HBaseAdmin; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); HTableDescriptor tableDesc HTableDescriptor(); HColumnDescriptor colDesc HColumnDescriptor(); tableDesc.addFamily(colDesc); admin.createTable(tableDesc); System.out.println(admin.isTableAvailable()); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HBaseAdmin; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); System.out.println(admin.isTableAvailable()); System.out.println(admin.isTableEnabled()); System.out.println(admin.isTableDisabled()); System.out.println(); admin.disableTable(); System.out.println(admin.isTableAvailable()); System.out.println(admin.isTableEnabled()); System.out.println(admin.isTableDisabled()); System.out.println(); admin.deleteTable(); System.out.println(admin.isTableAvailable()); System.out.println(); System.out.println(admin.tableExists()); } }
example; java.util.ArrayList; java.util.List; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.KeyValue; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.client.ResultScanner; org.apache.hadoop.hbase.client.Scan; org.apache.hadoop.hbase.filter.BinaryComparator; org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; org.apache.hadoop.hbase.filter.Filter; org.apache.hadoop.hbase.filter.FilterList; org.apache.hadoop.hbase.filter.FilterList.Operator; org.apache.hadoop.hbase.filter.QualifierFilter; org.apache.hadoop.hbase.filter.RowFilter; org.apache.hadoop.hbase.filter.SubstringComparator; org.apache.hadoop.hbase.filter.ValueFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ListFilter filterList ArrayListFilter(); Filter rowFilter RowFilter(CompareOp.EQUAL, SubstringComparator()); filterList.add(rowFilter); Filter columnFilter QualifierFilter(CompareOp.NOT_EQUAL, SubstringComparator()); filterList.add(columnFilter); Filter valueFilter ValueFilter(CompareOp.LESS, BinaryComparator(Bytes.toBytes())); filterList.add(valueFilter); FilterList filters FilterList(filterList); Scan scan Scan(); scan.setFilter(filters); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); System.out.println(); filters FilterList(Operator.MUST_PASS_ONE,filterList); scan.setFilter(filters); resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ltable.incrementColumnValue(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(), ); System.out.println(l); ltable.incrementColumnValue(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(), ); System.out.println(l); ltable.incrementColumnValue(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(), ); System.out.println(l); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.HTableDescriptor; org.apache.hadoop.hbase.client.HBaseAdmin; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); HTableDescriptor[] descListadmin.listTables(); (HTableDescriptor desc:descList){ System.out.println(Bytes.toString(desc.getName())); } HTableDescriptor descadmin.getTableDescriptor(Bytes.toBytes()); System.out.println(Bytes.toString(desc.getName())); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.HColumnDescriptor; org.apache.hadoop.hbase.HTableDescriptor; org.apache.hadoop.hbase.client.HBaseAdmin; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); HTableDescriptor desc HTableDescriptor(); HColumnDescriptor colDesc HColumnDescriptor(); desc.addFamily(colDesc); admin.createTable(desc); HTableDescriptor desc2admin.getTableDescriptor(Bytes.toBytes()); HColumnDescriptor colDesc2 HColumnDescriptor(); desc2.addFamily(colDesc2); admin.disableTable(); admin.modifyTable(, desc2); admin.enableTable(); HTableDescriptor desc3admin.getTableDescriptor(Bytes.toBytes()); System.out.println(desc2.equals(desc3)); System.out.println(desc3); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.HColumnDescriptor; org.apache.hadoop.hbase.client.HBaseAdmin; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(conf); admin.enableTable(); admin.disableTable(); admin.deleteColumn(, ); admin.enableTable(); System.out.println(admin.getTableDescriptor(Bytes.toBytes())); admin.disableTable(); admin.addColumn(, HColumnDescriptor()); System.out.println(admin.getTableDescriptor(Bytes.toBytes())); } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.KeyValue; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Increment; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Increment increment Increment(Bytes.toBytes()); increment.addColumn(Bytes.toBytes(), Bytes.toBytes(), ); increment.addColumn(Bytes.toBytes(), Bytes.toBytes(), ); increment.addColumn(Bytes.toBytes(), Bytes.toBytes(), ); Result resulttable.increment(increment); (KeyValue kv:result.raw()){ System.out.println(kvBytes.toLong(kv.getValue())); } } }
example; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTableInterface; org.apache.hadoop.hbase.client.HTablePool; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTablePool pool HTablePool(conf,); HTableInterface [] inter HTableInterface[]; ( i;iinter.length;i){ inter[i]pool.getTable(); } ( i;iinter.length;i){ pool.putTable(inter[i]); } pool.closeTablePool(); } }