Java Code Examples for org.apache.hadoop.hbase.client.Get#getTimeRange()

The following examples show how to use org.apache.hadoop.hbase.client.Get#getTimeRange() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSerialization.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testGet() throws Exception {
  byte[] row = Bytes.toBytes("row");
  byte[] fam = Bytes.toBytes("fam");
  byte[] qf1 = Bytes.toBytes("qf1");

  long ts = System.currentTimeMillis();
  int maxVersions = 2;

  Get get = new Get(row);
  get.addColumn(fam, qf1);
  get.setTimeRange(ts, ts + 1);
  get.readVersions(maxVersions);

  ClientProtos.Get getProto = ProtobufUtil.toGet(get);
  Get desGet = ProtobufUtil.toGet(getProto);

  assertTrue(Bytes.equals(get.getRow(), desGet.getRow()));
  Set<byte[]> set = null;
  Set<byte[]> desSet = null;

  for (Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()) {
    assertTrue(desGet.getFamilyMap().containsKey(entry.getKey()));
    set = entry.getValue();
    desSet = desGet.getFamilyMap().get(entry.getKey());
    for (byte[] qualifier : set) {
      assertTrue(desSet.contains(qualifier));
    }
  }

  assertEquals(get.getMaxVersions(), desGet.getMaxVersions());
  TimeRange tr = get.getTimeRange();
  TimeRange desTr = desGet.getTimeRange();
  assertEquals(tr.getMax(), desTr.getMax());
  assertEquals(tr.getMin(), desTr.getMin());
}
 
Example 2
Source File: TTable.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
private void throwExceptionIfOpSetsTimerange(Get getOperation) {
    TimeRange tr = getOperation.getTimeRange();
    checkTimerangeIsSetToDefaultValuesOrThrowException(tr);
}