Search in sources :

Example 11 with Put

use of org.apache.hadoop.hbase.client.Put in project hbase by apache.

the class TestHelloHBase method testDeleteRow.

@Test
public void testDeleteRow() throws IOException {
    Admin admin = TEST_UTIL.getAdmin();
    admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
    Table table = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
    table.put(new Put(HelloHBase.MY_ROW_ID).addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME, HelloHBase.MY_FIRST_COLUMN_QUALIFIER, Bytes.toBytes("xyz")));
    HelloHBase.deleteRow(table);
    Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
    assertEquals("#deleteRow failed to delete row.", true, row.isEmpty());
    TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
    admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Get(org.apache.hadoop.hbase.client.Get) Admin(org.apache.hadoop.hbase.client.Admin) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 12 with Put

use of org.apache.hadoop.hbase.client.Put in project hbase by apache.

the class TestBatchCoprocessorEndpoint method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    // set configure to indicate which cp should be loaded
    Configuration conf = util.getConfiguration();
    conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, org.apache.hadoop.hbase.coprocessor.ColumnAggregationEndpoint.class.getName(), ProtobufCoprocessorService.class.getName(), ColumnAggregationEndpointWithErrors.class.getName(), ColumnAggregationEndpointNullResponse.class.getName());
    conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, ProtobufCoprocessorService.class.getName());
    util.startMiniCluster(2);
    Admin admin = util.getAdmin();
    HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
    desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
    admin.createTable(desc, new byte[][] { ROWS[rowSeperator1], ROWS[rowSeperator2] });
    util.waitUntilAllRegionsAssigned(TEST_TABLE);
    admin.close();
    Table table = util.getConnection().getTable(TEST_TABLE);
    for (int i = 0; i < ROWSIZE; i++) {
        Put put = new Put(ROWS[i]);
        put.addColumn(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(i));
        table.put(put);
    }
    table.close();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Configuration(org.apache.hadoop.conf.Configuration) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Admin(org.apache.hadoop.hbase.client.Admin) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) BeforeClass(org.junit.BeforeClass)

Example 13 with Put

use of org.apache.hadoop.hbase.client.Put in project hbase by apache.

the class TestRowProcessorEndpoint method prepareTestData.

public void prepareTestData() throws Exception {
    try {
        util.getAdmin().disableTable(TABLE);
        util.getAdmin().deleteTable(TABLE);
    } catch (Exception e) {
    // ignore table not found
    }
    table = util.createTable(TABLE, FAM);
    {
        Put put = new Put(ROW);
        // B, C are friends of A
        put.addColumn(FAM, A, Bytes.add(B, C));
        // D, E, F are friends of B
        put.addColumn(FAM, B, Bytes.add(D, E, F));
        // G is a friend of C
        put.addColumn(FAM, C, G);
        table.put(put);
        rowSize = put.size();
    }
    Put put = new Put(ROW2);
    put.addColumn(FAM, D, E);
    put.addColumn(FAM, F, G);
    table.put(put);
    row2Size = put.size();
}
Also used : IOException(java.io.IOException) Put(org.apache.hadoop.hbase.client.Put)

Example 14 with Put

use of org.apache.hadoop.hbase.client.Put in project hbase by apache.

the class TestServerCustomProtocol method before.

@Before
public void before() throws Exception {
    final byte[][] SPLIT_KEYS = new byte[][] { ROW_B, ROW_C };
    Table table = util.createTable(TEST_TABLE, TEST_FAMILY, SPLIT_KEYS);
    Put puta = new Put(ROW_A);
    puta.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(puta);
    Put putb = new Put(ROW_B);
    putb.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(putb);
    Put putc = new Put(ROW_C);
    putc.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(putc);
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Put(org.apache.hadoop.hbase.client.Put) Before(org.junit.Before)

Example 15 with Put

use of org.apache.hadoop.hbase.client.Put in project hbase by apache.

the class TestCoprocessorEndpoint method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    // set configure to indicate which cp should be loaded
    Configuration conf = util.getConfiguration();
    conf.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 5000);
    conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, org.apache.hadoop.hbase.coprocessor.ColumnAggregationEndpoint.class.getName(), ProtobufCoprocessorService.class.getName());
    conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, ProtobufCoprocessorService.class.getName());
    util.startMiniCluster(2);
    Admin admin = util.getAdmin();
    HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
    desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
    admin.createTable(desc, new byte[][] { ROWS[rowSeperator1], ROWS[rowSeperator2] });
    util.waitUntilAllRegionsAssigned(TEST_TABLE);
    Table table = util.getConnection().getTable(TEST_TABLE);
    for (int i = 0; i < ROWSIZE; i++) {
        Put put = new Put(ROWS[i]);
        put.addColumn(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(i));
        table.put(put);
    }
    table.close();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Configuration(org.apache.hadoop.conf.Configuration) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Admin(org.apache.hadoop.hbase.client.Admin) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) BeforeClass(org.junit.BeforeClass)

Aggregations

Put (org.apache.hadoop.hbase.client.Put)849 Test (org.junit.Test)414 Table (org.apache.hadoop.hbase.client.Table)237 ArrayList (java.util.ArrayList)216 Result (org.apache.hadoop.hbase.client.Result)183 Scan (org.apache.hadoop.hbase.client.Scan)164 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)149 Delete (org.apache.hadoop.hbase.client.Delete)146 Cell (org.apache.hadoop.hbase.Cell)141 IOException (java.io.IOException)134 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)134 TableName (org.apache.hadoop.hbase.TableName)118 Get (org.apache.hadoop.hbase.client.Get)114 KeyValue (org.apache.hadoop.hbase.KeyValue)98 Configuration (org.apache.hadoop.conf.Configuration)79 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)75 Connection (org.apache.hadoop.hbase.client.Connection)68 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)60 Admin (org.apache.hadoop.hbase.client.Admin)54 Mutation (org.apache.hadoop.hbase.client.Mutation)53