org.apache.hadoop.hbase.client.Get.setTimeRange()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中org.apache.hadoop.hbase.client.Get.setTimeRange()方法的一些代码示例,展示了Get.setTimeRange()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Get.setTimeRange()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Get
类名称:Get
方法名:setTimeRange

Get.setTimeRange介绍

[英]Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
[中]仅获取指定时间戳范围内的列版本,[minStamp,maxStamp)。

代码示例

代码示例来源:origin: apache/hbase

public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?> metaTable,
  TableName tableName) {
 CompletableFuture<Optional<TableState>> future = new CompletableFuture<>();
 Get get = new Get(tableName.getName()).addColumn(getTableFamily(), getStateColumn());
 long time = EnvironmentEdgeManager.currentTime();
 try {
  get.setTimeRange(0, time);
  metaTable.get(get).whenComplete((result, error) -> {
   if (error != null) {
    future.completeExceptionally(error);
    return;
   }
   try {
    future.complete(getTableState(result));
   } catch (IOException e) {
    future.completeExceptionally(e);
   }
  });
 } catch (IOException ioe) {
  future.completeExceptionally(ioe);
 }
 return future;
}

代码示例来源:origin: thinkaurelius/titan

Get g = new Get(key.as(StaticBuffer.ARRAY_FACTORY)).addFamily(columnFamilyBytes).setFilter(getFilter);
try {
  g.setTimeRange(0, Long.MAX_VALUE);
} catch (IOException e) {
  throw new PermanentBackendException(e);

代码示例来源:origin: apache/hbase

/**
 * Uses the TimestampFilter on a Get to request a specified list of
 * versions for the row/column specified by rowIdx & colIdx.
 *
 */
private  Cell[] getNVersions(Table ht, byte[] cf, int rowIdx,
  int colIdx, List<Long> versions)
throws IOException {
 byte row[] = Bytes.toBytes("row:" + rowIdx);
 byte column[] = Bytes.toBytes("column:" + colIdx);
 Get get = new Get(row);
 get.addColumn(cf, column);
 get.setMaxVersions();
 get.setTimeRange(Collections.min(versions), Collections.max(versions)+1);
 Result result = ht.get(get);
 return result.rawCells();
}

代码示例来源:origin: apache/hbase

get.setTimeRange(0, timestamp);
gets.add(get);

代码示例来源:origin: apache/hbase

Get get = new Get(getBytes(row));
 addAttributes(get, attributes);
 get.setTimeRange(0, timestamp);
 Result result = table.get(get);
 return ThriftUtilities.rowResultFromHBase(result);
get.setTimeRange(0, timestamp);
Result result = table.get(get);
return ThriftUtilities.rowResultFromHBase(result);

代码示例来源:origin: apache/hbase

private void getVersionRangeAndVerifyGreaterThan(Table ht, byte [] row,
  byte [] family, byte [] qualifier, long [] stamps, byte [][] values,
  int start, int end)
throws IOException {
 Get get = new Get(row);
 get.addColumn(family, qualifier);
 get.setMaxVersions(Integer.MAX_VALUE);
 get.setTimeRange(stamps[start+1], Long.MAX_VALUE);
 Result result = ht.get(get);
 assertNResult(result, row, family, qualifier, stamps, values, start+1, end);
}

代码示例来源:origin: apache/hbase

private void checkGet(Region region, byte[] row, byte[] fam, byte[] col,
  long time, byte[]... vals) throws IOException {
 Get g = new Get(row);
 g.addColumn(fam, col);
 g.setMaxVersions();
 g.setTimeRange(0L, time);
 Result r = region.get(g);
 checkResult(r, fam, col, vals);
}

代码示例来源:origin: apache/hbase

private void getVersionRangeAndVerify(Table ht, byte [] row, byte [] family,
  byte [] qualifier, long [] stamps, byte [][] values, int start, int end)
throws IOException {
 Get get = new Get(row);
 get.addColumn(family, qualifier);
 get.setMaxVersions(Integer.MAX_VALUE);
 get.setTimeRange(stamps[start], stamps[end]+1);
 Result result = ht.get(get);
 assertNResult(result, row, family, qualifier, stamps, values, start, end);
}

代码示例来源:origin: apache/hbase

get.addColumn(family, qualifier);
get.setTimeRange(0, timestamp);
get.setMaxVersions(numVersions);
Result result = table.get(get);

代码示例来源:origin: apache/hbase

@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get,
  List<Cell> result) throws IOException {
 TableName tableName = c.getEnvironment().getRegion().getTableDescriptor().getTableName();
 Long ttl = this.ttls.get(tableName);
 if (ttl != null) {
  get.setTimeRange(EnvironmentEdgeManager.currentTime() - ttl, get.getTimeRange().getMax());
 }
 Integer version = this.versions.get(tableName);
 if (version != null) {
  get.readVersions(version);
 }
}

代码示例来源:origin: apache/hbase

get.addColumn(family,qf1);
get.setTimeRange(0,15);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()>0);
get.setTimeRange(40,90);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()>0);
get.setTimeRange(10,45);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()>0);
get.setTimeRange(80,145);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()>0);
get.setTimeRange(1,2);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()>0);
get.setTimeRange(90,200);
result = HBaseTestingUtility.getFromStoreFile(store, get);
assertTrue(result.size()==0);

代码示例来源:origin: apache/hbase

/**
 * Do a specific Get on passed <code>columnFamily</code> and column qualifiers.
 * @param mutation Mutation we are doing this Get for.
 * @param store Which column family on row (TODO: Go all Gets in one go)
 * @param coordinates Cells from <code>mutation</code> used as coordinates applied to Get.
 * @return Return list of Cells found.
 */
private List<Cell> get(Mutation mutation, HStore store, List<Cell> coordinates,
  IsolationLevel isolation, TimeRange tr) throws IOException {
 // Sort the cells so that they match the order that they appear in the Get results. Otherwise,
 // we won't be able to find the existing values if the cells are not specified in order by the
 // client since cells are in an array list.
 // TODO: I don't get why we are sorting. St.Ack 20150107
 sort(coordinates, store.getComparator());
 Get get = new Get(mutation.getRow());
 if (isolation != null) {
  get.setIsolationLevel(isolation);
 }
 for (Cell cell: coordinates) {
  get.addColumn(store.getColumnFamilyDescriptor().getName(), CellUtil.cloneQualifier(cell));
 }
 // Increments carry time range. If an Increment instance, put it on the Get.
 if (tr != null) {
  get.setTimeRange(tr.getMin(), tr.getMax());
 }
 return get(get, false);
}

代码示例来源:origin: apache/hbase

get.setTimeRange(rowspec.getStartTime(), rowspec.getEndTime());
get.setMaxVersions(rowspec.getMaxVersions());
if (filter != null) {

代码示例来源:origin: apache/hbase

@Test
public void testTimeRange() throws IOException {
 try (Table t = createTable()) {
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000001, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000002, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000003, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000004, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000005, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000006, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000007, value));
  t.put(new Put(ROW).addColumn(FAMILY, col1, 1000008, value));
  Result r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
  assertEquals(0, r.size());
  TEST_UTIL.getAdmin().flush(t.getName());
  r = t.get(new Get(ROW).setMaxVersions(3).setTimeRange(0, 1000005));
  assertEquals(0, r.size());
 }
}

代码示例来源:origin: apache/hbase

@Test public void testGet() throws Exception{
 byte[] row = "row".getBytes();
 byte[] fam = "fam".getBytes();
 byte[] qf1 = "qf1".getBytes();
 long ts = System.currentTimeMillis();
 int maxVersions = 2;
 Get get = new Get(row);
 get.addColumn(fam, qf1);
 get.setTimeRange(ts, ts+1);
 get.setMaxVersions(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());
}

代码示例来源:origin: apache/hbase

gOne.setTimeRange(0L, ts + 1);
Result rOne = region.get(gOne);
assertFalse(rOne.isEmpty());
g.setTimeRange(0L, ts+1);
Result r = region.get(g);
assertTrue(r.isEmpty());

代码示例来源:origin: apache/hbase

get.setTimeRange(0, maxStamp);
get.setMaxVersions(kvs.length - 1);
result = incommon.get(get);

代码示例来源:origin: apache/hbase

get.setTimeRange(timeRange.getMin(), timeRange.getMax());

代码示例来源:origin: apache/hbase

.setMaxVersions(9999)
.setRowOffsetPerColumnFamily(5)
.setTimeRange(0, 13)
.setAttribute("att_v0", Bytes.toBytes("att_v0"))
.setColumnFamilyTimeRange(Bytes.toBytes("cf"), 0, 123)

代码示例来源:origin: apache/hbase

get.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED);
get.setCheckExistenceOnly(true);
get.setTimeRange(3, 4);
get.setMaxVersions(11);
get.setMaxResultsPerColumnFamily(10);

相关文章