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

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(148)

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

Increment.setTimeRange介绍

[英]Sets the TimeRange to be used on the Get for this increment.

This is useful for when you have counters that only last for specific periods of time (ie. counters that are partitioned by time). By setting the range of valid times for this increment, you can potentially gain some performance with a more optimal Get operation. Be careful adding the time range to this class as you will update the old cell if the time range doesn't include the latest cells.

This range is used as [minStamp, maxStamp).
[中]设置此增量的Get上要使用的时间范围。
当您的计数器只持续特定时间段(即按时间分区的计数器)时,这非常有用。通过设置此增量的有效时间范围,您可以通过更优化的Get操作获得一些性能。请小心将时间范围添加到此类中,因为如果时间范围不包括最新的单元格,您将更新旧单元格。
此范围用作[minStamp,maxStamp]。

代码示例

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

@Test
public void testIncrementCopyConstructor() throws IOException {
 Increment origin = new Increment(Bytes.toBytes("ROW-01"));
 origin.setPriority(100);
 byte[] family = Bytes.toBytes("CF-01");
 origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  .setRow(origin.getRow())
  .setFamily(family)
  .setQualifier(Bytes.toBytes("q"))
  .setType(Cell.Type.Put)
  .setValue(Bytes.toBytes(100))
  .build());
 origin.addColumn(family, Bytes.toBytes("q0"), 4);
 origin.setTimeRange(100, 1000);
 Increment clone = new Increment(origin);
 assertEquals(origin, clone);
 origin.addColumn(family, Bytes.toBytes("q1"), 3);
 //They should have different cell lists
 assertNotEquals(origin.getCellList(family), clone.getCellList(family));
}

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

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

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

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = toTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

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

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
   try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
    Increment inc = new Increment(TEST_ROW1);
    inc.setTimeRange(0, 123);
    inc.addColumn(TEST_FAMILY1, TEST_Q1, 2L);
    t.increment(inc);
    t.incrementColumnValue(TEST_ROW1, TEST_FAMILY1, TEST_Q2, 1L);
   }
  }
  return null;
 }
});

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

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
   try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
    Increment inc = new Increment(row);
    inc.setTimeRange(0, 127);
    inc.addColumn(TEST_FAMILY1, q1, 2L);
    t.increment(inc);
    fail(user.getShortName() + " cannot do the increment.");
   } catch (Exception e) {
   }
  }
  return null;
 }
});

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

TimeRange range10 = new TimeRange(1, time+10);
hTableInterface.increment(new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 10L)
  .setTimeRange(range10.getMin(), range10.getMax()));
checkRowValue(ROW_A, Bytes.toBytes(11L));
assertEquals(MyObserver.tr10.getMin(), range10.getMin());
List<Row> actions =
  Arrays.asList(new Row[] { new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 2L)
    .setTimeRange(range2.getMin(), range2.getMax()),
    new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 2L)
    .setTimeRange(range2.getMin(), range2.getMax()) });
Object[] results3 = new Object[actions.size()];
Object[] results1 = results3;

代码示例来源:origin: forcedotcom/phoenix

public Increment newIncrement(long timestamp) {
  Increment inc = new Increment(SchemaUtil.getSequenceKey(key.getTenantId(), key.getSchemaName(), key.getSequenceName()));
  // It doesn't matter what we set the amount too - we always use the values we get
  // from the Get we do to prevent any race conditions. All columns that get added
  // are returned with their current value
  try {
    inc.setTimeRange(MetaDataProtocol.MIN_TABLE_TIMESTAMP, timestamp);
  } catch (IOException e) {
    throw new RuntimeException(e); // Impossible
  }
  for (KeyValue kv : SEQUENCE_KV_COLUMNS) {
    // We don't care about the amount, as we'll add what gets looked up on the server-side
    inc.addColumn(kv.getFamily(), kv.getQualifier(), AMOUNT);
  }
  return inc;
}

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

inc.setTimeRange(MetaDataProtocol.MIN_TABLE_TIMESTAMP, timestamp);
  inc.setAttribute(SequenceRegionObserver.NUM_TO_ALLOCATE, Bytes.toBytes(numToAllocate));
} catch (IOException e) {

代码示例来源:origin: org.apache.hbase/hbase-client

@Test
public void testIncrementCopyConstructor() throws IOException {
 Increment origin = new Increment(Bytes.toBytes("ROW-01"));
 origin.setPriority(100);
 byte[] family = Bytes.toBytes("CF-01");
 origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  .setRow(origin.getRow())
  .setFamily(family)
  .setQualifier(Bytes.toBytes("q"))
  .setType(Cell.Type.Put)
  .setValue(Bytes.toBytes(100))
  .build());
 origin.addColumn(family, Bytes.toBytes("q0"), 4);
 origin.setTimeRange(100, 1000);
 Increment clone = new Increment(origin);
 assertEquals(origin, clone);
 origin.addColumn(family, Bytes.toBytes("q1"), 3);
 //They should have different cell lists
 assertNotEquals(origin.getCellList(family), clone.getCellList(family));
}

代码示例来源:origin: org.apache.hbase/hbase-client

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = toTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

代码示例来源:origin: org.apache.hbase/hbase-client

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

代码示例来源:origin: org.apache.phoenix/phoenix-core

inc.setTimeRange(MetaDataProtocol.MIN_TABLE_TIMESTAMP, timestamp);
  inc.setAttribute(SequenceRegionObserver.NUM_TO_ALLOCATE, Bytes.toBytes(numToAllocate));
} catch (IOException e) {

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

inc.setTimeRange(MetaDataProtocol.MIN_TABLE_TIMESTAMP, timestamp);
  inc.setAttribute(SequenceRegionObserver.NUM_TO_ALLOCATE, Bytes.toBytes(numToAllocate));
} catch (IOException e) {

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = toTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
 * Convert a protocol buffer Mutate to an Increment
 *
 * @param proto the protocol buffer Mutate to convert
 * @return the converted client Increment
 * @throws IOException
 */
public static Increment toIncrement(final MutationProto proto, final CellScanner cellScanner)
    throws IOException {
 MutationType type = proto.getMutateType();
 assert type == MutationType.INCREMENT : type.name();
 Increment increment = toDelta((Bytes row) -> new Increment(row.get(), row.getOffset(), row.getLength()),
     Increment::add, proto, cellScanner);
 if (proto.hasTimeRange()) {
  TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  increment.setTimeRange(timeRange.getMin(), timeRange.getMax());
 }
 return increment;
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
   try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
    Increment inc = new Increment(TEST_ROW1);
    inc.setTimeRange(0, 123);
    inc.addColumn(TEST_FAMILY1, TEST_Q1, 2L);
    t.increment(inc);
    t.incrementColumnValue(TEST_ROW1, TEST_FAMILY1, TEST_Q2, 1L);
   }
  }
  return null;
 }
});

代码示例来源:origin: org.apache.hbase/hbase-server

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
   try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
    Increment inc = new Increment(row);
    inc.setTimeRange(0, 127);
    inc.addColumn(TEST_FAMILY1, q1, 2L);
    t.increment(inc);
    fail(user.getShortName() + " cannot do the increment.");
   } catch (Exception e) {
   }
  }
  return null;
 }
});

代码示例来源:origin: org.apache.hbase/hbase-server

TimeRange range10 = new TimeRange(1, time+10);
hTableInterface.increment(new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 10L)
  .setTimeRange(range10.getMin(), range10.getMax()));
checkRowValue(ROW_A, Bytes.toBytes(11L));
assertEquals(MyObserver.tr10.getMin(), range10.getMin());
List<Row> actions =
  Arrays.asList(new Row[] { new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 2L)
    .setTimeRange(range2.getMin(), range2.getMax()),
    new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 2L)
    .setTimeRange(range2.getMin(), range2.getMax()) });
Object[] results3 = new Object[actions.size()];
Object[] results1 = results3;

代码示例来源:origin: harbby/presto-connectors

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

相关文章