use of com.google.cloud.bigtable.hbase.filter.TimestampRangeFilter in project java-bigtable-hbase by googleapis.
the class TestTimestampRangeFilterAdapter method timestampFiltersAreAdapted.
@Test
public void timestampFiltersAreAdapted() {
TimestampRangeFilter filter = new TimestampRangeFilter(10L, 20L);
Filters.Filter expectedFilter = filterAdapter.adapt(emptyScanContext, filter);
TimestampRange expectedTimestampFilter = expectedFilter.toProto().getTimestampRangeFilter();
Assert.assertEquals(10000L, expectedTimestampFilter.getStartTimestampMicros());
Assert.assertEquals(20000L, expectedTimestampFilter.getEndTimestampMicros());
}
use of com.google.cloud.bigtable.hbase.filter.TimestampRangeFilter in project java-bigtable-hbase by googleapis.
the class TestFilters method testTimestampRangeFilterWithMaxVal.
/**
* This test case is used to validate TimestampRangeFilter with Integer.MAX_VALUE #1552
*
* @throws IOException
*/
@Test
public void testTimestampRangeFilterWithMaxVal() throws IOException {
// Initialize
long numCols = Integer.MAX_VALUE;
long start = Integer.MAX_VALUE - 2;
String goodValue = "includeThisValue";
Table table = getDefaultTable();
byte[] rowKey = dataHelper.randomData("testRow-TimestampRange-");
Put put = new Put(rowKey);
for (long i = start; i < numCols; ++i) {
put.addColumn(COLUMN_FAMILY, dataHelper.randomData(""), i, Bytes.toBytes(goodValue));
}
table.put(put);
Filter filter = new TimestampRangeFilter(start, Integer.MAX_VALUE);
Get get = new Get(rowKey).setFilter(filter);
Result result = table.get(get);
Cell[] cells = result.rawCells();
Assert.assertEquals("Should have all cells.", 2, cells.length);
long[] timestamps = new long[] { cells[0].getTimestamp(), cells[1].getTimestamp() };
Arrays.sort(timestamps);
Assert.assertArrayEquals(new long[] { start, Integer.MAX_VALUE - 1 }, timestamps);
table.close();
}
use of com.google.cloud.bigtable.hbase.filter.TimestampRangeFilter in project java-bigtable-hbase by googleapis.
the class TestFilters method testTimestampRangeFilter.
@Test
public void testTimestampRangeFilter() throws IOException {
// Initialize
int numCols = 10;
String goodValue = "includeThisValue";
Table table = getDefaultTable();
byte[] rowKey = dataHelper.randomData("testRow-TimestampRange-");
Put put = new Put(rowKey);
for (int i = 0; i < numCols; ++i) {
put.addColumn(COLUMN_FAMILY, dataHelper.randomData(""), i, Bytes.toBytes(goodValue));
}
table.put(put);
// Filter for results
Filter filter = new TimestampRangeFilter(4, 6);
Get get = new Get(rowKey).setFilter(filter);
Result result = table.get(get);
Cell[] cells = result.rawCells();
Assert.assertEquals("Should have three cells, timestamps 4 and 5.", 2, cells.length);
// Since the qualifiers are random, ignore the order of the returned cells.
long[] timestamps = new long[] { cells[0].getTimestamp(), cells[1].getTimestamp() };
Arrays.sort(timestamps);
Assert.assertArrayEquals(new long[] { 4L, 5L }, timestamps);
table.close();
}
Aggregations