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

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(160)

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

Append.setTimeRange介绍

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

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 append, 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

  1. @Test
  2. public void testAppendCopyConstructor() throws IOException {
  3. Append origin = new Append(Bytes.toBytes("ROW-01"));
  4. origin.setPriority(100);
  5. byte[] family = Bytes.toBytes("CF-01");
  6. origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  7. .setRow(origin.getRow())
  8. .setFamily(family)
  9. .setQualifier(Bytes.toBytes("q"))
  10. .setType(Type.Put)
  11. .setValue(Bytes.toBytes(100))
  12. .build());
  13. origin.addColumn(family, Bytes.toBytes("q0"), Bytes.toBytes("value"));
  14. origin.setTimeRange(100, 1000);
  15. Append clone = new Append(origin);
  16. assertEquals(origin, clone);
  17. origin.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes("value"));
  18. //They should have different cell lists
  19. assertNotEquals(origin.getCellList(family), clone.getCellList(family));
  20. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = toTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. TimeRange range10 = new TimeRange(1, time + 10);
  2. Result r = table.append(new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("b"))
  3. .setTimeRange(range10.getMin(), range10.getMax()));
  4. checkRowValue(table, ROW, Bytes.toBytes("ab"));
  5. assertEquals(MyObserver.tr10.getMin(), range10.getMin());
  6. Arrays.asList(new Row[] {
  7. new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("c"))
  8. .setTimeRange(range2.getMin(), range2.getMax()),
  9. new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("c"))
  10. .setTimeRange(range2.getMin(), range2.getMax()) });
  11. Object[] results1 = new Object[actions.size()];
  12. table.batch(actions, results1);

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

  1. @Test
  2. public void testAppendCopyConstructor() throws IOException {
  3. Append origin = new Append(Bytes.toBytes("ROW-01"));
  4. origin.setPriority(100);
  5. byte[] family = Bytes.toBytes("CF-01");
  6. origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  7. .setRow(origin.getRow())
  8. .setFamily(family)
  9. .setQualifier(Bytes.toBytes("q"))
  10. .setType(Type.Put)
  11. .setValue(Bytes.toBytes(100))
  12. .build());
  13. origin.addColumn(family, Bytes.toBytes("q0"), Bytes.toBytes("value"));
  14. origin.setTimeRange(100, 1000);
  15. Append clone = new Append(origin);
  16. assertEquals(origin, clone);
  17. origin.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes("value"));
  18. //They should have different cell lists
  19. assertNotEquals(origin.getCellList(family), clone.getCellList(family));
  20. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = toTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = toTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. /**
  2. * Convert a protocol buffer Mutate to an Append
  3. * @param cellScanner
  4. * @param proto the protocol buffer Mutate to convert
  5. * @return the converted client Append
  6. * @throws IOException
  7. */
  8. public static Append toAppend(final MutationProto proto, final CellScanner cellScanner)
  9. throws IOException {
  10. MutationType type = proto.getMutateType();
  11. assert type == MutationType.APPEND : type.name();
  12. Append append = toDelta((Bytes row) -> new Append(row.get(), row.getOffset(), row.getLength()),
  13. Append::add, proto, cellScanner);
  14. if (proto.hasTimeRange()) {
  15. TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
  16. append.setTimeRange(timeRange.getMin(), timeRange.getMax());
  17. }
  18. return append;
  19. }

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

  1. TimeRange range10 = new TimeRange(1, time + 10);
  2. Result r = table.append(new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("b"))
  3. .setTimeRange(range10.getMin(), range10.getMax()));
  4. checkRowValue(table, ROW, Bytes.toBytes("ab"));
  5. assertEquals(MyObserver.tr10.getMin(), range10.getMin());
  6. Arrays.asList(new Row[] {
  7. new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("c"))
  8. .setTimeRange(range2.getMin(), range2.getMax()),
  9. new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("c"))
  10. .setTimeRange(range2.getMin(), range2.getMax()) });
  11. Object[] results1 = new Object[actions.size()];
  12. table.batch(actions, results1);

相关文章