java.util.ArrayList; java.util.List; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Delete; org.apache.hadoop.hbase.client.Get; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.client.Row; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ListRow rowList ArrayListRow(); Get get Get(Bytes.toBytes()); get.addColumn(Bytes.toBytes(), Bytes.toBytes()); rowList.add(get); Delete delete Delete(Bytes.toBytes()); rowList.add(delete); Put put Put(Bytes.toBytes()); put.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); rowList.add(put); [] result [rowList.size()]; table.batch(rowList, result); ( ret:result){ System.out.println(ret); } table.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Delete; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Delete delete Delete(Bytes.toBytes()); rettable.checkAndDelete(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(),Bytes.toBytes(), delete); table.close(); System.out.println(ret); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Put put1 Put(Bytes.toBytes()); put1.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); table.checkAndPut(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes(), , put1); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Get; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.filter.ColumnCountGetFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Get get Get(Bytes.toBytes()); ColumnCountGetFilter filter ColumnCountGetFilter(); get.setFilter(filter); Result resulttable.get(get); System.out.println(result); } }
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.ColumnPaginationFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); ColumnPaginationFilter filter ColumnPaginationFilter(, ); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
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.ColumnPrefixFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); ColumnPrefixFilter filter ColumnPrefixFilter(Bytes.toBytes()); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Delete; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Delete delete Delete(Bytes.toBytes()); delete.deleteColumn(Bytes.toBytes(), Bytes.toBytes(),); table.delete(delete); table.close(); } }
java.util.ArrayList; java.util.List; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Delete; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ListDelete deleteList ArrayListDelete(); Delete delete Delete(Bytes.toBytes()); deleteList.add(delete); Delete delete2 Delete(Bytes.toBytes()); delete2.deleteColumn(Bytes.toBytes(), Bytes.toBytes()); deleteList.add(delete2); table.delete(deleteList); table.close(); } }
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.BinaryPrefixComparator; org.apache.hadoop.hbase.filter.ByteArrayComparable; org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; org.apache.hadoop.hbase.filter.DependentColumnFilter; org.apache.hadoop.hbase.util.Bytes; { filter( drop,CompareOp op,ByteArrayComparable comparable) Exception{ Configuration conf HBaseConfiguration.create(); HTable hbasetalbe HTable(conf,); DependentColumnFilter filter ; (comparable){ filter DependentColumnFilter(Bytes.toBytes(), Bytes.toBytes(), drop); }{ filter DependentColumnFilter(Bytes.toBytes(), Bytes.toBytes(), drop,op,comparable); } Scan scan Scan(); scan.setFilter(filter); ResultScanner resultScannerhbasetalbe.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); System.out.println(); System.out.println(); } main([] args) Exception { filter(,,); filter(,,); filter(,CompareOp.EQUAL, BinaryPrefixComparator(Bytes.toBytes())); filter(,CompareOp.EQUAL, BinaryPrefixComparator(Bytes.toBytes())); } }
java.util.ArrayList; java.util.List; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,Bytes.toBytes()); ListPut putList ArrayListPut(); Put put1 Put(Bytes.toBytes()); put1.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); putList.add(put1); Put put2 Put(Bytes.toBytes()); put2.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); putList.add(put2); Put put3 Put(Bytes.toBytes()); putList.add(put3); { table.put(putList); }(Exception e){ e.printStackTrace(); table.flushCommits(); } } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Get; 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.FamilyFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); FamilyFilter familyFilter FamilyFilter(CompareOp.LESS, BinaryComparator(Bytes.toBytes())); scan.setFilter(familyFilter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); Get get Get(Bytes.toBytes()); get.setFilter(familyFilter); Result resulttable.get(get); System.out.println(result); } }
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.FirstKeyOnlyFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); FirstKeyOnlyFilter filter FirstKeyOnlyFilter(); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Get; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable htable HTable(conf,); System.out.println(htable.isAutoFlush()); htable.setAutoFlush(); Put put1 Put(Bytes.toBytes()); put1.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); htable.put(put1); Put put2 Put(Bytes.toBytes()); put2.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); htable.put(put2); Put put3 Put(Bytes.toBytes()); put3.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); htable.put(put3); Get get Get(Bytes.toBytes()); Result resulthtable.get(get); System.out.println(result); htable.flushCommits(); resulthtable.get(get); System.out.println(result); } }
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.util.Bytes; public class GetExample { /** * @param args */ public static void main(String[] args)throws Exception { Configuration conf=HBaseConfiguration.create(); HTable table=new HTable(conf,"testtable"); Get get=new Get(Bytes.toBytes("row1")); get.addColumn(Bytes.toBytes("family1"), Bytes.toBytes("column1")); Result result=table.get(get); byte[] value=result.getValue(Bytes.toBytes("family1"), Bytes.toBytes("column1")); System.out.println(Bytes.toString(value)); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Result resulttable.getRowOrBefore(Bytes.toBytes(), Bytes.toBytes()); System.out.println(Bytes.toString(result.getRow())); Result result2table.getRowOrBefore(Bytes.toBytes(),Bytes.toBytes()); System.out.println(result2); Result result3table.getRowOrBefore(Bytes.toBytes(), Bytes.toBytes()); System.out.println(result3); } }
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.InclusiveStopFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); scan.setStartRow(Bytes.toBytes()); InclusiveStopFilter filter InclusiveStopFilter(Bytes.toBytes()); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
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.KeyOnlyFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); KeyOnlyFilter filter KeyOnlyFilter(); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
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.Get; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ListGet getList ArrayListGet(); Get get1 Get(Bytes.toBytes()); get1.addFamily(Bytes.toBytes()); getList.add(get1); Get get2 Get(Bytes.toBytes()); getList.add(get2); Result[] resultstable.get(getList); (Result result:results){ (result.containsColumn(Bytes.toBytes(), Bytes.toBytes())){ System.out.println(Bytes.toString(result.getRow())); System.out.println(Bytes.toString(result.getValue(Bytes.toBytes(), Bytes.toBytes()))); } (result.containsColumn(Bytes.toBytes(), Bytes.toBytes())){ System.out.println(Bytes.toString(result.getRow())); System.out.println(Bytes.toString(result.getValue(Bytes.toBytes(), Bytes.toBytes()))); } } (Result result:results){ (KeyValue keyValue:result.raw()){ System.out.println(Bytes.toString(keyValue.getRow())); System.out.println(Bytes.toString(keyValue.getValue())); } } } }
java.util.ArrayList; java.util.List; org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf, ); ListPut putList ArrayListPut(); Put put1 Put(Bytes.toBytes()); put1.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); putList.add(put1); Put put2 Put(Bytes.toBytes()); put2.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); putList.add(put2); Put put3 Put(Bytes.toBytes()); put3.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); putList.add(put3); table.put(putList); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.PageFilter; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); PageFilter filter PageFilter(); scan.setFilter(filter); ResultScanner scannertable.getScanner(scan); (Result result:scanner){ System.out.println(result); } scanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.PrefixFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); PrefixFilter filter PrefixFilter(Bytes.toBytes()); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Put; org.apache.hadoop.hbase.util.Bytes; org.codehaus.jackson.sym.BytesToNameCanonicalizer; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable htable HTable(conf, ); Put put Put(Bytes.toBytes()); put.add(Bytes.toBytes(), Bytes.toBytes(), Bytes.toBytes()); put.add(Bytes.toBytes(), Bytes.toBytes(), , Bytes.toBytes()); htable.put(put); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.Get; 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.QualifierFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); QualifierFilter filter QualifierFilter(CompareOp.LESS, BinaryComparator(Bytes.toBytes())); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); Get get Get(Bytes.toBytes()); get.setFilter(filter); Result resulttable.get(get); System.out.println(result); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.RandomRowFilter; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); RandomRowFilter filter RandomRowFilter(); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.RegexStringComparator; org.apache.hadoop.hbase.filter.RowFilter; org.apache.hadoop.hbase.filter.SubstringComparator; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable hbasetalbe HTable(conf, ); Scan scan1 Scan(); RowFilter rowFileter RowFilter(CompareOp.LESS, BinaryComparator(Bytes.toBytes())); scan1.setFilter(rowFileter); ResultScanner resultScannerhbasetalbe.getScanner(scan1); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); Scan scan2 Scan(); RowFilter rowFilter2 RowFilter(CompareOp.EQUAL, RegexStringComparator()); scan2.setFilter(rowFilter2); resultScannerhbasetalbe.getScanner(scan2); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); Scan scan3 Scan(); RowFilter rowFilter3 RowFilter(CompareOp.EQUAL, SubstringComparator()); scan3.setFilter(rowFilter3); resultScannerhbasetalbe.getScanner(scan3); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.client.HTable; org.apache.hadoop.hbase.client.Result; org.apache.hadoop.hbase.client.ResultScanner; org.apache.hadoop.hbase.client.Scan; { scan( cache, batch) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); scan.setCaching(cache); scan.setBatch(batch); ResultScanner resultScantable.getScanner(scan); i; (Result result:resultScan){ i; } System.out.println(i); } main([] args) Exception { scan(,); scan(,); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan1 Scan(); scan1.setStartRow(Bytes.toBytes()); ResultScanner resultScannertable.getScanner(scan1); (Result result:resultScanner){ System.out.println(result); } Scan scan2 Scan(); scan2.addColumn(Bytes.toBytes(), Bytes.toBytes()); resultScannertable.getScanner(scan2); (Result result:resultScanner){ System.out.println(result); } } }
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.CompareFilter.CompareOp; org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter; org.apache.hadoop.hbase.filter.SubstringComparator; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); SingleColumnValueExcludeFilter filter SingleColumnValueExcludeFilter(Bytes.toBytes(), Bytes.toBytes(), CompareOp.EQUAL, SubstringComparator()); filter.setFilterIfMissing(); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
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.CompareFilter.CompareOp; org.apache.hadoop.hbase.filter.SingleColumnValueFilter; org.apache.hadoop.hbase.filter.SubstringComparator; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception { Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); SingleColumnValueFilter filter SingleColumnValueFilter(Bytes.toBytes(), Bytes.toBytes(), CompareOp.EQUAL, SubstringComparator()); filter.setFilterIfMissing(); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.SkipFilter; org.apache.hadoop.hbase.filter.ValueFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); ValueFilter valueFilter ValueFilter(CompareOp.NOT_EQUAL, BinaryComparator(Bytes.toBytes())); Scan scan Scan(); scan.setFilter(valueFilter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); SkipFilter skipFilter SkipFilter(valueFilter); scan.setFilter(skipFilter); resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }
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; { createTable1() Exception{ Configuration conHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(con); HTableDescriptor desc HTableDescriptor(); admin.createTable(desc); admin.close(); } createTable2() Exception{ Configuration conHBaseConfiguration.create(); HBaseAdmin admin HBaseAdmin(con); (admin.tableExists()){ admin.disableTable(); admin.deleteTable(); } HTableDescriptor desc HTableDescriptor(); HColumnDescriptor colDesc HColumnDescriptor(Bytes.toBytes()); desc.addFamily(colDesc); admin.createTable(desc); admin.close(); } main([] args) Exception { createTable2(); } }
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.TimestampsFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); List timeList ArrayList(); timeList.add(); timeList.add(); TimestampsFilter filter TimestampsFilter(timeList); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue kv:result.raw()){ System.out.println(kvBytes.toString(kv.getValue())); } } resultScanner.close(); } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.KeyValue; org.apache.hadoop.hbase.client.Get; 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.CompareFilter.CompareOp; org.apache.hadoop.hbase.filter.RegexStringComparator; org.apache.hadoop.hbase.filter.ValueFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); Scan scan Scan(); ValueFilter filter ValueFilter(CompareOp.EQUAL, RegexStringComparator()); scan.setFilter(filter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ (KeyValue keyValue:result.raw()){ System.out.println(Bytes.toString(keyValue.getValue())); } } resultScanner.close(); System.out.println(); Get get Get(Bytes.toBytes()); get.setFilter(filter); Result resulttable.get(get); (KeyValue kv:result.raw()){ System.out.println(Bytes.toString(kv.getValue())); } } }
org.apache.hadoop.conf.Configuration; org.apache.hadoop.hbase.HBaseConfiguration; 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.RowFilter; org.apache.hadoop.hbase.filter.WhileMatchFilter; org.apache.hadoop.hbase.util.Bytes; { main([] args) Exception{ Configuration confHBaseConfiguration.create(); HTable table HTable(conf,); RowFilter rowFilter RowFilter(CompareOp.EQUAL, BinaryComparator(Bytes.toBytes()) ); Scan scan Scan(); scan.setFilter(rowFilter); ResultScanner resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); System.out.println(); WhileMatchFilter matchFilter WhileMatchFilter(rowFilter); scan.setFilter(matchFilter); resultScannertable.getScanner(scan); (Result result:resultScanner){ System.out.println(result); } resultScanner.close(); } }