Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.HTableInterface


    }

    @Override
    public void releaseHTableInterface(HTableInterface table) throws IOException {
        // Wraps the underlying normal htable factory. If the incoming table is a StatsHTable, unwrap it.
        HTableInterface hTableToRelease;
        if(table instanceof StatsHTable) {
            hTableToRelease = ((StatsHTable)table).unwrap();
        } else {
            hTableToRelease = table;
        }
View Full Code Here


        }
    }
   
    @Test
    public void basicGetPutTest() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] key = randomRowKey();
        Put put = new Put(key);
        put.add(cf, key, key);
        hTable.put(put);
        Result result = hTable.get(new Get(key));

        // Make sure the Put made it into the DB and the Get got it back
        Assert.assertNotNull(result);
        Assert.assertArrayEquals(key, result.getColumnLatest(cf, key).getValue());
       
View Full Code Here

        assertMetricsUpdated(OpType.GET, OpType.PUT);
    }
   
    @Test
    public void testExists() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row); // Just put anything, doesn't matter what
        hTable.put(put);
       
        Get get = new Get(row);
        Assert.assertTrue(hTable.exists(get));
       
        assertMetricsUpdated(OpType.EXISTS, OpType.PUT);
    }
View Full Code Here

        assertMetricsUpdated(OpType.EXISTS, OpType.PUT);
    }

    @Test
    public void testBatchNewResultArray() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row); // put whatever, just write something into the row
        hTable.batch(ImmutableList.<Row>of(put));
       
        Get get = new Get(row);
        Assert.assertTrue(hTable.exists(get));
       
        assertMetricsUpdated(OpType.BATCH, OpType.EXISTS);
    }
View Full Code Here

        assertMetricsUpdated(OpType.BATCH, OpType.EXISTS);
    }
   
    @Test
    public void testBatchPassedResultArray() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row); // put whatever, just write something into the row
        hTable.batch(ImmutableList.<Row>of(put));
       
        Object[] results = new Result[1];
        Get get = new Get(row);
        hTable.batch(ImmutableList.<Row>of(get), results);
       
        Assert.assertArrayEquals(row, ((Result)(results[0])).getRow());
        assertMetricsUpdated(OpType.BATCH);
    }
View Full Code Here

        assertMetricsUpdated(OpType.BATCH);
    }

    @Test
    public void testMultiget() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row1 = randomRowKey();
        byte[] row2 = randomRowKey();
       
        Put put1 = new Put(row1);
        put1.add(cf, row1, row1);
        Put put2 = new Put(row2);
        put2.add(cf, row2, row2);
       
        hTable.batch(ImmutableList.<Row>of(put1, put2));
       
        List<Get> gets = ImmutableList.<Get>of(new Get(row1), new Get(row2));
        Result[] results = hTable.get(gets);

        Assert.assertArrayEquals(row1, results[0].getRow());
        Assert.assertArrayEquals(row2, results[1].getRow());
       
        assertMetricsUpdated(OpType.BATCH, OpType.MULTIGET);
View Full Code Here

        assertMetricsUpdated(OpType.BATCH, OpType.MULTIGET);
    }

    @Test
    public void testGetRowOrBefore() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);
       
        @SuppressWarnings("deprecation")
        Result result = hTable.getRowOrBefore(row, cf);
       
        Assert.assertArrayEquals(row, result.getRow());
        assertMetricsUpdated(OpType.PUT, OpType.GET_ROW_OR_BEFORE);
    }
View Full Code Here

        assertMetricsUpdated(OpType.PUT, OpType.GET_ROW_OR_BEFORE);
    }

    @Test
    public void testGetScannerScanOnly() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Assert.assertArrayEquals(row, rs.next().getRow());
        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_NEXT);
       
        rs.close();
View Full Code Here

        rs.close();
    }

    @Test
    public void testResultScannerIterator() throws Exception {
        HTableInterface hTable = getHTable();
        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Assert.assertArrayEquals(row, rs.iterator().next().getRow());
        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_ITERATOR,
                OpType.RESULTITERATOR_NEXT);
       
View Full Code Here

    /**
     * Test that the wrapped ResultScanner.next(int) works, and also ResultScanner.close()
     */
    @Test
    public void testResultScannerIteratorMultiRowAndClose() throws Exception {
        HTableInterface hTable = getHTable();
       
        List<byte[]> rows = getRandomRows(2);

        Put put1 = new Put(rows.get(0));
        Put put2 = new Put(rows.get(1));
        put1.add(cf, rows.get(0), rows.get(0));
        put2.add(cf, rows.get(1), rows.get(1));
        hTable.batch(ImmutableList.<Row>of(put1, put2));

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Result[] results = rs.next(2);
        Assert.assertArrayEquals(rows.get(0), results[0].getRow());
        Assert.assertArrayEquals(rows.get(1), results[1].getRow());

View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.HTableInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.