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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations