Refine search
public static void main(String[] args) throws IOException { foo(6, 5); foo(5, 2); foo(3, 0); Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum", "hbase_host"); conf.set("zookeeper.znode.parent", "/hbase-unsecure"); HTable table = new HTable(conf, "test1"); Put put = new Put(Bytes.toBytes("row1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"), Bytes.toBytes("val2")); table.put(put); table.close(); } }
@Test public void testBasicOperation() throws Exception { TableName tn = TableName.valueOf(name.getMethodName()); // create table Connection conn = TEST_UTIL.getConnection(); Admin admin = conn.getAdmin(); HTable table = (HTable) conn.getTable(tn); try { ColumnFamilyDescriptorBuilder cfDescBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family); TableDescriptorBuilder tableDescBuilder = TableDescriptorBuilder.newBuilder(tn).setColumnFamily(cfDescBuilder.build()); admin.createTable(tableDescBuilder.build()); // test simple get and put Put put = new Put(row); put.addColumn(family, qualifier, value); table.put(put); Get get = new Get(row); Result result = table.get(get); LOG.debug("Result: " + Bytes.toString(result.getValue(family, qualifier))); Assert.assertArrayEquals(value, result.getValue(family, qualifier)); } finally { admin.close(); table.close(); } }
@Ignore("Configuration issue - valid test, just needs fixing") @Test public void testWaitsOnIndexRegionToReload() throws Exception { HBaseTestingUtility util = new HBaseTestingUtility(); HTable primary = new HTable(conf, testTable.getTableName()); primary.put(p); primary.flushCommits(); HTable index = new HTable(conf, getIndexTableName()); ResultScanner scanner = index.getScanner(s); int count = 0; index.close(); primary.close(); util.shutdownMiniCluster();
public static void main(String[] args) throws IOException { foo(6, 5); foo(5, 2); foo(3, 0); Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum", "hbase_host"); conf.set("zookeeper.znode.parent", "/hbase-unsecure"); HTable table = new HTable(conf, "test1"); Put put = new Put(Bytes.toBytes("row1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"), Bytes.toBytes("val2")); table.put(put); table.close(); } }
@Test public void testNonForwardQuery() throws Exception { executeString("CREATE TABLE hbase_mapped_table1 (rk text, col1 text, col2 text, col3 int) " + try (HBaseAdmin hAdmin = new HBaseAdmin(testingCluster.getHBaseUtil().getConf())) { hAdmin.tableExists("hbase_table1"); htable = new HTable(testingCluster.getHBaseUtil().getConf(), "hbase_table1"); org.apache.hadoop.hbase.util.Pair<byte[][], byte[][]> keys = htable.getStartEndKeys(); assertEquals(5, keys.getFirst().length); htable.close();
public static void main(String[] args) throws IOException, Exception{ Configuration conf = HBaseConfiguration.create(); conf.set("hbase.master", "localhost:60000"); conf.set("hbase.zookeeper.quorum","localhost"); conf.set("hbase.zookeeper.property.clientPort", "2181"); HTable table = new HTable(conf, "mytable"); Get g = new Get(Bytes.toBytes("row1")); Result result = table.get(g); byte[]value=result.getValue(Bytes.toBytes("Columnfam1"),Bytes.toBytes("column"); String R = Bytes.toString(value); System.out.println(R); table.close(); }
@Test public void testJoin() throws Exception { executeString("CREATE TABLE hbase_mapped_table (rk text, col1 text, col2 text, col3 int8) " + try { hAdmin.tableExists("hbase_table"); htable = new HTable(testingCluster.getHBaseUtil().getConf(), "hbase_table"); org.apache.hadoop.hbase.util.Pair<byte[][], byte[][]> keys = htable.getStartEndKeys(); assertEquals(5, keys.getFirst().length); hAdmin.close(); if (htable != null) { htable.close();
public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); HTable table = new HTable(conf, "my-table"); Put put = new Put(Bytes.toBytes("row1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("value1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"), Bytes.toBytes("value2")); put.add(Bytes.toBytes("colfam2"), Bytes.toBytes("qual1"), Bytes.toBytes("value3")); table.put(put); table.flushCommits(); table.close(); } }
@Test public void testIndexPredication() throws Exception { String sql = hAdmin.tableExists("hbase_table"); HTable htable = new HTable(testingCluster.getHBaseUtil().getConf(), "hbase_table"); try { org.apache.hadoop.hbase.util.Pair<byte[][], byte[][]> keys = htable.getStartEndKeys(); } finally { executeString("DROP TABLE hbase_mapped_table PURGE").close(); htable.close(); hAdmin.close();
public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); HTable table = new HTable(conf, "my-table"); Put put = new Put(Bytes.toBytes("row1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("value1-a")); put.add(Bytes.toBytes("colfam3"), Bytes.toBytes("qual1"), Bytes.toBytes("value4")); table.put(put); table.flushCommits(); table.close(); } }
insertIntoTable(conn, table1, fam3Name, 3, NB_ROWS_FAM3).close(); insertIntoTable(conn, table1, mobName, 3, NB_ROWS_FAM3).close(); HBaseAdmin admin = null; admin = (HBaseAdmin) conn.getAdmin(); insertIntoTable(conn, table1, mobName, 3, NB_ROWS_MOB); LOG.debug("written " + NB_ROWS_MOB + " rows to " + table1 + " to Mob enabled CF"); t1.close(); Assert.assertEquals(HBaseTestingUtility.countRows(t1), NB_ROWS_IN_BATCH + ADD_ROWS + NB_ROWS_MOB); t2.close(); LOG.debug("written " + 5 + " rows to " + table2); t3.close(); hTable.close(); hTable.close(); LOG.debug("mob has " + countMobName + " rows"); Assert.assertEquals(countMobName, NB_ROWS_MOB); hTable.close(); hTable.close(); admin.close();