Java Code Examples for org.apache.hadoop.hbase.client.Put.getTimeStamp()

The following are Jave code examples for showing how to use getTimeStamp() of the org.apache.hadoop.hbase.client.Put class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ditb   File: LMDIndexWriter.java   Source Code and License Vote up 6 votes
/**
 * parse put, add index put into mdRecordList
 */
private void processPut(List<KeyValue> mdRecordList, Put put) throws IOException {
  if (put == null) return;
  byte[] rawRowkey = put.getRow();
  int[] arr = new int[dimensions];
  int i = 0;
  for (Map.Entry<byte[], TreeSet<byte[]>> entry : tableRelation.getIndexFamilyMap().entrySet()) {
    for (byte[] qualifier : entry.getValue()) {
      arr[i] = Bytes.toInt(put.get(entry.getKey(), qualifier).get(0).getValue());
      ++i;
    }
  }
  byte[] mdKey = MDUtils.bitwiseZip(arr, dimensions);
  KeyValue keyValue =
      new KeyValue(mdKey, LMDIndexConstants.FAMILY, rawRowkey, put.getTimeStamp(), Type.Put,
          LMDIndexConstants.VALUE);
  mdRecordList.add(keyValue);
}
 
Example 2
Project: ditb   File: RemoteHTable.java   Source Code and License Vote up 5 votes
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;
}
 
Example 3
Project: ditb   File: TestProtobufUtil.java   Source Code and License Vote up 4 votes
/**
 * Test Put Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testPut() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.PUT);
  mutateBuilder.setTimestamp(111111);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
  qualifierBuilder.setTimestamp(222222);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Put put = ProtobufUtil.toPut(proto);

  // put value always use the default timestamp if no
  // value level timestamp specified,
  // add the timestamp to the original mutate
  long timestamp = put.getTimeStamp();
  for (ColumnValue.Builder column:
      mutateBuilder.getColumnValueBuilderList()) {
    for (QualifierValue.Builder qualifier:
        column.getQualifierValueBuilderList()) {
      if (!qualifier.hasTimestamp()) {
        qualifier.setTimestamp(timestamp);
      }
    }
  }
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(MutationType.PUT, put));
}