Search in sources :

Example 81 with ColumnFamilyDescriptor

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

the class TestMinVersions method testFilters.

/**
 * Verify that basic filters still behave correctly with
 * minimum versions enabled.
 */
@Test
public void testFilters() throws Exception {
    final byte[] c1 = COLUMNS[1];
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(2).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
    ColumnFamilyDescriptor cfd2 = ColumnFamilyDescriptorBuilder.newBuilder(c1).setMinVersions(2).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
    List<ColumnFamilyDescriptor> cfdList = new ArrayList();
    cfdList.add(cfd);
    cfdList.add(cfd2);
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamilies(cfdList).build();
    HRegion region = hbu.createLocalHRegion(htd, null, null);
    // 2s in the past
    long ts = EnvironmentEdgeManager.currentTime() - 2000;
    try {
        Put p = new Put(T1, ts - 3);
        p.addColumn(c0, c0, T0);
        p.addColumn(c1, c1, T0);
        region.put(p);
        p = new Put(T1, ts - 2);
        p.addColumn(c0, c0, T1);
        p.addColumn(c1, c1, T1);
        region.put(p);
        p = new Put(T1, ts - 1);
        p.addColumn(c0, c0, T2);
        p.addColumn(c1, c1, T2);
        region.put(p);
        p = new Put(T1, ts);
        p.addColumn(c0, c0, T3);
        p.addColumn(c1, c1, T3);
        region.put(p);
        List<Long> tss = new ArrayList<>();
        tss.add(ts - 1);
        tss.add(ts - 2);
        // Sholud only get T2, versions is 2, so T1 is gone from user view.
        Get g = new Get(T1);
        g.addColumn(c1, c1);
        g.setFilter(new TimestampsFilter(tss));
        g.readAllVersions();
        Result r = region.get(g);
        checkResult(r, c1, T2);
        // Sholud only get T2, versions is 2, so T1 is gone from user view.
        g = new Get(T1);
        g.addColumn(c0, c0);
        g.setFilter(new TimestampsFilter(tss));
        g.readAllVersions();
        r = region.get(g);
        checkResult(r, c0, T2);
        // now flush/compact
        region.flush(true);
        region.compact(true);
        // After flush/compact, the result should be consistent with previous result
        g = new Get(T1);
        g.addColumn(c1, c1);
        g.setFilter(new TimestampsFilter(tss));
        g.readAllVersions();
        r = region.get(g);
        checkResult(r, c1, T2);
        // After flush/compact, the result should be consistent with previous result
        g = new Get(T1);
        g.addColumn(c0, c0);
        g.setFilter(new TimestampsFilter(tss));
        g.readAllVersions();
        r = region.get(g);
        checkResult(r, c0, T2);
    } finally {
        HBaseTestingUtil.closeRegionAndWAL(region);
    }
}
Also used : ArrayList(java.util.ArrayList) TimestampsFilter(org.apache.hadoop.hbase.filter.TimestampsFilter) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Get(org.apache.hadoop.hbase.client.Get) Test(org.junit.Test)

Example 82 with ColumnFamilyDescriptor

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

the class TestMinVersions method testMemStore.

/**
 * Make sure the memstor behaves correctly with minimum versions
 */
@Test
public void testMemStore() throws Exception {
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(2).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(cfd).build();
    HRegion region = hbu.createLocalHRegion(htd, null, null);
    // 2s in the past
    long ts = EnvironmentEdgeManager.currentTime() - 2000;
    try {
        // 2nd version
        Put p = new Put(T1, ts - 2);
        p.addColumn(c0, c0, T2);
        region.put(p);
        // 3rd version
        p = new Put(T1, ts - 1);
        p.addColumn(c0, c0, T3);
        region.put(p);
        // 4th version
        p = new Put(T1, ts);
        p.addColumn(c0, c0, T4);
        region.put(p);
        // now flush/compact
        region.flush(true);
        region.compact(true);
        // now put the first version (backdated)
        p = new Put(T1, ts - 3);
        p.addColumn(c0, c0, T1);
        region.put(p);
        // now the latest change is in the memstore,
        // but it is not the latest version
        Result r = region.get(new Get(T1));
        checkResult(r, c0, T4);
        Get g = new Get(T1);
        g.readAllVersions();
        // this'll use ScanWildcardColumnTracker
        r = region.get(g);
        checkResult(r, c0, T4, T3);
        g = new Get(T1);
        g.readAllVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T4, T3);
        p = new Put(T1, ts + 1);
        p.addColumn(c0, c0, T5);
        region.put(p);
        // now the latest version is in the memstore
        g = new Get(T1);
        g.readAllVersions();
        // this'll use ScanWildcardColumnTracker
        r = region.get(g);
        checkResult(r, c0, T5, T4);
        g = new Get(T1);
        g.readAllVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T5, T4);
    } finally {
        HBaseTestingUtil.closeRegionAndWAL(region);
    }
}
Also used : Get(org.apache.hadoop.hbase.client.Get) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 83 with ColumnFamilyDescriptor

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

the class TestMinVersions method testStoreMemStore.

/**
 * Test mixed memstore and storefile scanning
 * with minimum versions.
 */
@Test
public void testStoreMemStore() throws Exception {
    // keep 3 versions minimum
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(3).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(cfd).build();
    HRegion region = hbu.createLocalHRegion(htd, null, null);
    // 2s in the past
    long ts = EnvironmentEdgeManager.currentTime() - 2000;
    try {
        Put p = new Put(T1, ts - 1);
        p.addColumn(c0, c0, T2);
        region.put(p);
        p = new Put(T1, ts - 3);
        p.addColumn(c0, c0, T0);
        region.put(p);
        // now flush/compact
        region.flush(true);
        region.compact(true);
        p = new Put(T1, ts);
        p.addColumn(c0, c0, T3);
        region.put(p);
        p = new Put(T1, ts - 2);
        p.addColumn(c0, c0, T1);
        region.put(p);
        p = new Put(T1, ts - 3);
        p.addColumn(c0, c0, T0);
        region.put(p);
        // newest version in the memstore
        // the 2nd oldest in the store file
        // and the 3rd, 4th oldest also in the memstore
        Get g = new Get(T1);
        g.readAllVersions();
        // this'll use ScanWildcardColumnTracker
        Result r = region.get(g);
        checkResult(r, c0, T3, T2, T1);
        g = new Get(T1);
        g.readAllVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3, T2, T1);
    } finally {
        HBaseTestingUtil.closeRegionAndWAL(region);
    }
}
Also used : Get(org.apache.hadoop.hbase.client.Get) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 84 with ColumnFamilyDescriptor

use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor 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 {
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(3).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(cfd).build();
    HRegion 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.readAllVersions();
        // this'll use ScanWildcardColumnTracker
        Result r = region.get(g);
        checkResult(r, c0, T3);
        g = new Get(T1);
        g.readAllVersions();
        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.readAllVersions();
        // this'll use ScanWildcardColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3);
        g = new Get(T1);
        g.readAllVersions();
        g.addColumn(c0, c0);
        // this'll use ExplicitColumnTracker
        r = region.get(g);
        checkResult(r, c0, T3);
    } finally {
        HBaseTestingUtil.closeRegionAndWAL(region);
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Get(org.apache.hadoop.hbase.client.Get) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 85 with ColumnFamilyDescriptor

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

the class TestMinVersions method testMinVersionsWithKeepDeletedCellsTTL.

@Test
public void testMinVersionsWithKeepDeletedCellsTTL() throws Exception {
    int ttl = 4;
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setVersionsWithTimeToLive(ttl, 2).build();
    verifyVersionedCellKeyValues(ttl, cfd);
    cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(2).setMaxVersions(Integer.MAX_VALUE).setTimeToLive(ttl).setKeepDeletedCells(KeepDeletedCells.TTL).build();
    verifyVersionedCellKeyValues(ttl, cfd);
}
Also used : ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Test(org.junit.Test)

Aggregations

ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)199 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)95 Test (org.junit.Test)92 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)78 IOException (java.io.IOException)44 TableName (org.apache.hadoop.hbase.TableName)44 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)42 Path (org.apache.hadoop.fs.Path)41 Admin (org.apache.hadoop.hbase.client.Admin)36 Configuration (org.apache.hadoop.conf.Configuration)34 ArrayList (java.util.ArrayList)32 Put (org.apache.hadoop.hbase.client.Put)32 FileSystem (org.apache.hadoop.fs.FileSystem)28 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)24 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)22 Get (org.apache.hadoop.hbase.client.Get)20 Result (org.apache.hadoop.hbase.client.Result)19 ColumnFamilyDescriptorBuilder (org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder)17 Scan (org.apache.hadoop.hbase.client.Scan)17 Table (org.apache.hadoop.hbase.client.Table)17