Search in sources :

Example 96 with Delete

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

the class TestMinVersions method testDelete.

/**
   * Make sure the Deletes behave as expected with minimum versions
   */
@Test
public void testDelete() throws Exception {
    HTableDescriptor htd = hbu.createTableDescriptor(name.getMethodName(), 3, 1000, 1, KeepDeletedCells.FALSE);
    Region region = hbu.createLocalHRegion(htd, null, null);
    // 2s in the past
    long ts = EnvironmentEdgeManager.currentTime() - 2000;
    try {
        Put p = new Put(T1, ts - 2);
        p.addColumn(c0, c0, T1);
        region.put(p);
        p = new Put(T1, ts - 1);
        p.addColumn(c0, c0, T2);
        region.put(p);
        p = new Put(T1, ts);
        p.addColumn(c0, c0, T3);
        region.put(p);
        Delete d = new Delete(T1, ts - 1);
        region.delete(d);
        Get g = new Get(T1);
        g.setMaxVersions();
        // this'll use ScanWildcardColumnTracker
        Result r = region.get(g);
        checkResult(r, c0, T3);
        g = new Get(T1);
        g.setMaxVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3);
        // now flush/compact
        region.flush(true);
        region.compact(true);
        // try again
        g = new Get(T1);
        g.setMaxVersions();
        // this'll use ScanWildcardColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3);
        g = new Get(T1);
        g.setMaxVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3);
    } finally {
        HBaseTestingUtility.closeRegionAndWAL(region);
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Get(org.apache.hadoop.hbase.client.Get) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 97 with Delete

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

the class TestMinorCompaction method testMinorCompactionWithDeleteVersion2.

@Test
public void testMinorCompactionWithDeleteVersion2() throws Exception {
    Delete deleteVersion = new Delete(secondRowBytes);
    deleteVersion.addColumn(fam2, col2, 1);
    /*
     * the table has 4 versions: 0, 1, 2, and 3.
     * We delete 1.
     * Should have 3 remaining.
     */
    testMinorCompactionWithDelete(deleteVersion, 3);
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Test(org.junit.Test)

Example 98 with Delete

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

the class TestMinorCompaction method testMinorCompactionWithDeleteColumn2.

@Test
public void testMinorCompactionWithDeleteColumn2() throws Exception {
    Delete dc = new Delete(secondRowBytes);
    dc.addColumn(fam2, col2);
    /* compactionThreshold is 3. The table has 4 versions: 0, 1, 2, and 3.
     * we only delete the latest version. One might expect to see only
     * versions 1 and 2. HBase differs, and gives us 0, 1 and 2.
     * This is okay as well. Since there was no compaction done before the
     * delete, version 0 seems to stay on.
     */
    testMinorCompactionWithDelete(dc, 3);
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Test(org.junit.Test)

Example 99 with Delete

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

the class TestMinorCompaction method testMinorCompactionWithDeleteColumn1.

@Test
public void testMinorCompactionWithDeleteColumn1() throws Exception {
    Delete dc = new Delete(secondRowBytes);
    /* delete all timestamps in the column */
    dc.addColumns(fam2, col2);
    testMinorCompactionWithDelete(dc);
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Test(org.junit.Test)

Example 100 with Delete

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

the class TestMinorCompaction method testMinorCompactionWithDeleteVersion1.

@Test
public void testMinorCompactionWithDeleteVersion1() throws Exception {
    Delete deleteVersion = new Delete(secondRowBytes);
    deleteVersion.addColumns(fam2, col2, 2);
    /* compactionThreshold is 3. The table has 4 versions: 0, 1, 2, and 3.
     * We delete versions 0 ... 2. So, we still have one remaining.
     */
    testMinorCompactionWithDelete(deleteVersion, 1);
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Test(org.junit.Test)

Aggregations

Delete (org.apache.hadoop.hbase.client.Delete)291 Put (org.apache.hadoop.hbase.client.Put)146 Test (org.junit.Test)142 Result (org.apache.hadoop.hbase.client.Result)101 Table (org.apache.hadoop.hbase.client.Table)99 Scan (org.apache.hadoop.hbase.client.Scan)93 IOException (java.io.IOException)85 Cell (org.apache.hadoop.hbase.Cell)74 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)70 TableName (org.apache.hadoop.hbase.TableName)65 Connection (org.apache.hadoop.hbase.client.Connection)55 ArrayList (java.util.ArrayList)52 InterruptedIOException (java.io.InterruptedIOException)45 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)44 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)42 Get (org.apache.hadoop.hbase.client.Get)41 CellScanner (org.apache.hadoop.hbase.CellScanner)32 Mutation (org.apache.hadoop.hbase.client.Mutation)32 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)27 Admin (org.apache.hadoop.hbase.client.Admin)20