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

x33g5p2x  于2022-01-26 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(158)

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

Put.getTimestamp介绍

暂无

代码示例

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

protected void addSystemLabel(Region region, Map<String, Integer> labels,
  Map<String, List<Integer>> userAuths) throws IOException {
 if (!labels.containsKey(SYSTEM_LABEL)) {
  byte[] row = Bytes.toBytes(SYSTEM_LABEL_ORDINAL);
  Put p = new Put(row);
  p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
         .setRow(row)
         .setFamily(LABELS_TABLE_FAMILY)
         .setQualifier(LABEL_QUALIFIER)
         .setTimestamp(p.getTimestamp())
         .setType(Type.Put)
         .setValue(Bytes.toBytes(SYSTEM_LABEL))
         .build());
  region.put(p);
  labels.put(SYSTEM_LABEL, SYSTEM_LABEL_ORDINAL);
 }
}

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

@Override
 public Boolean call() throws Exception {
  try (Table t = connection.getTable(tableName)) {
   byte[] value = Bytes.toBytes(Double.toString(ThreadLocalRandom.current().nextDouble()));
   byte[] rk = Bytes.toBytes(ThreadLocalRandom.current().nextLong());
   Put p = new Put(rk);
   p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
       .setRow(rk)
       .setFamily(FAMILY)
       .setQualifier(QUAL)
       .setTimestamp(p.getTimestamp())
       .setType(Type.Put)
       .setValue(value)
       .build());
   t.put(p);
  }
  return true;
 }
}

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

@Override
 public Boolean call() throws Exception {
  // Table implements Closable so we use the try with resource structure here.
  // https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
  try (Table t = connection.getTable(tableName)) {
   byte[] value = Bytes.toBytes(Double.toString(ThreadLocalRandom.current().nextDouble()));
   int rows = 30;
   // Array to put the batch
   ArrayList<Put> puts = new ArrayList<>(rows);
   for (int i = 0; i < 30; i++) {
    byte[] rk = Bytes.toBytes(ThreadLocalRandom.current().nextLong());
    Put p = new Put(rk);
    p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
       .setRow(rk)
       .setFamily(FAMILY)
       .setQualifier(QUAL)
       .setTimestamp(p.getTimestamp())
       .setType(Cell.Type.Put)
       .setValue(value)
       .build());
    puts.add(p);
   }
   // now that we've assembled the batch it's time to push it to hbase.
   t.put(puts);
  }
  return true;
 }
}

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

public static void addReplicationBarrier(Put put, long openSeqNum) throws IOException {
 put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  .setRow(put.getRow())
  .setFamily(HConstants.REPLICATION_BARRIER_FAMILY)
  .setQualifier(HConstants.SEQNUM_QUALIFIER)
  .setTimestamp(put.getTimestamp())
  .setType(Type.Put)
  .setValue(Bytes.toBytes(openSeqNum))
  .build());
}

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

.setFamily(LABELS_TABLE_FAMILY)
.setQualifier(LABEL_QUALIFIER)
.setTimestamp(p.getTimestamp())
.setType(Type.Put)
.setValue(label)

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

private static Put addSequenceNum(Put p, long openSeqNum, int replicaId) throws IOException {
  return p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
       .setRow(p.getRow())
       .setFamily(HConstants.CATALOG_FAMILY)
       .setQualifier(getSeqNumColumn(replicaId))
       .setTimestamp(p.getTimestamp())
       .setType(Type.Put)
       .setValue(Bytes.toBytes(openSeqNum))
       .build());
 }
}

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

private static void addRegionStateToPut(Put put, RegionState.State state) throws IOException {
 put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
   .setRow(put.getRow())
   .setFamily(HConstants.CATALOG_FAMILY)
   .setQualifier(getRegionStateColumn())
   .setTimestamp(put.getTimestamp())
   .setType(Cell.Type.Put)
   .setValue(Bytes.toBytes(state.name()))
   .build());
}

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

.setFamily(LABELS_TABLE_FAMILY)
.setQualifier(user)
.setTimestamp(p.getTimestamp())
.setType(Cell.Type.Put)
.setValue(DUMMY_VALUE)

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

private static void addReplicationParent(Put put, List<RegionInfo> parents) throws IOException {
 byte[] value = getParentsBytes(parents);
 put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
  .setFamily(HConstants.REPLICATION_BARRIER_FAMILY).setQualifier(REPLICATION_PARENT_QUALIFIER)
  .setTimestamp(put.getTimestamp()).setType(Type.Put).setValue(value).build());
}

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

private void addBarrier(RegionInfo region, long... barriers) throws IOException {
 Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
 for (int i = 0; i < barriers.length; i++) {
  put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER,
   put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i]));
 }
 try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
  table.put(put);
 }
}

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

public static Put addRegionInfo(final Put p, final RegionInfo hri)
 throws IOException {
 p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
   .setRow(p.getRow())
   .setFamily(getCatalogFamily())
   .setQualifier(HConstants.REGIONINFO_QUALIFIER)
   .setTimestamp(p.getTimestamp())
   .setType(Type.Put)
   .setValue(RegionInfo.toByteArray(hri))
   .build());
 return p;
}

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

protected CellSetModel buildModelFromPut(Put put) {
 RowModel row = new RowModel(put.getRow());
 long ts = put.getTimestamp();
 for (List<Cell> cells: put.getFamilyCellMap().values()) {
  for (Cell cell: cells) {
   row.addCell(new CellModel(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell),
    ts != HConstants.LATEST_TIMESTAMP ? ts : cell.getTimestamp(),
    CellUtil.cloneValue(cell)));
  }
 }
 CellSetModel model = new CellSetModel();
 model.addRow(row);
 return model;
}

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

public static TPut putFromHBase(Put in) {
 TPut out = new TPut();
 out.setRow(in.getRow());
 if (in.getTimestamp() != HConstants.LATEST_TIMESTAMP) {
  out.setTimestamp(in.getTimestamp());

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

public static Put addLocation(Put p, ServerName sn, long openSeqNum, int replicaId)
  throws IOException {
 CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
 return p.add(builder.clear()
      .setRow(p.getRow())
      .setFamily(getCatalogFamily())
      .setQualifier(getServerColumn(replicaId))
      .setTimestamp(p.getTimestamp())
      .setType(Cell.Type.Put)
      .setValue(Bytes.toBytes(sn.getAddress().toString()))
      .build())
     .add(builder.clear()
      .setRow(p.getRow())
      .setFamily(getCatalogFamily())
      .setQualifier(getStartCodeColumn(replicaId))
      .setTimestamp(p.getTimestamp())
      .setType(Cell.Type.Put)
      .setValue(Bytes.toBytes(sn.getStartcode()))
      .build())
     .add(builder.clear()
      .setRow(p.getRow())
      .setFamily(getCatalogFamily())
      .setQualifier(getSeqNumColumn(replicaId))
      .setTimestamp(p.getTimestamp())
      .setType(Type.Put)
      .setValue(Bytes.toBytes(openSeqNum))
      .build());
}

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

private static Put addEmptyLocation(Put p, int replicaId) throws IOException {
 CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
 return p.add(builder.clear()
       .setRow(p.getRow())
       .setFamily(getCatalogFamily())
       .setQualifier(getServerColumn(replicaId))
       .setTimestamp(p.getTimestamp())
       .setType(Type.Put)
       .build())
     .add(builder.clear()
       .setRow(p.getRow())
       .setFamily(getCatalogFamily())
       .setQualifier(getStartCodeColumn(replicaId))
       .setTimestamp(p.getTimestamp())
       .setType(Cell.Type.Put)
       .build())
     .add(builder.clear()
       .setRow(p.getRow())
       .setFamily(getCatalogFamily())
       .setQualifier(getSeqNumColumn(replicaId))
       .setTimestamp(p.getTimestamp())
       .setType(Cell.Type.Put)
       .build());
}

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

/**
 * Adds split daughters to the Put
 */
public static Put addDaughtersToPut(Put put, RegionInfo splitA, RegionInfo splitB)
  throws IOException {
 if (splitA != null) {
  put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
       .setRow(put.getRow())
       .setFamily(HConstants.CATALOG_FAMILY)
       .setQualifier(HConstants.SPLITA_QUALIFIER)
       .setTimestamp(put.getTimestamp())
       .setType(Type.Put)
       .setValue(RegionInfo.toByteArray(splitA))
       .build());
 }
 if (splitB != null) {
  put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
       .setRow(put.getRow())
       .setFamily(HConstants.CATALOG_FAMILY)
       .setQualifier(HConstants.SPLITB_QUALIFIER)
       .setTimestamp(put.getTimestamp())
       .setType(Type.Put)
       .setValue(RegionInfo.toByteArray(splitB))
       .build());
 }
 return put;
}

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

.setFamily(famAndQf[0])
.setQualifier(famAndQf[1])
.setTimestamp(put.getTimestamp())
.setType(Cell.Type.Put)
.setValue(mput.value != null ? getBytes(mput.value)

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

List<Cell> c = p.get(FAMILY, QUALIFIER);
Assert.assertEquals(0, c.size());
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp());
Assert.assertEquals(1984L, c.get(0).getTimestamp());
Assert.assertArrayEquals(VALUE, CellUtil.cloneValue(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp());
Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
Assert.assertEquals(2013L, c.get(0).getTimestamp());
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp());
Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertArrayEquals(ROW, CellUtil.cloneRow(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimestamp());
Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertArrayEquals(ROW, CellUtil.cloneRow(c.get(0)));
Assert.assertEquals(1970L, p.getTimestamp());
Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));

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

@Override
public OperationStatus[] setAuths(byte[] user, List<byte[]> authLabels) throws IOException {
 assert labelsRegion != null;
 OperationStatus[] finalOpStatus = new OperationStatus[authLabels.size()];
 Put p = new Put(user);
 CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
 for (byte[] auth : authLabels) {
  p.add(builder.clear()
    .setRow(p.getRow())
    .setFamily(LABELS_TABLE_FAMILY)
    .setQualifier(auth)
    .setTimestamp(p.getTimestamp())
    .setType(Cell.Type.Put)
    .setValue(DUMMY_VALUE)
    .build());
 }
 this.labelsRegion.put(p);
 // This is a testing impl and so not doing any caching
 for (int i = 0; i < authLabels.size(); i++) {
  finalOpStatus[i] = new OperationStatus(OperationStatusCode.SUCCESS);
 }
 return finalOpStatus;
}

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

.setFamily(family)
    .setQualifier(qualifier0)
    .setTimestamp(put.getTimestamp())
    .setType(Type.Put)
    .setValue(value0)
assertTrue(cell0.getTimestamp()      == put.getTimestamp());

相关文章