Java Code Examples for org.apache.hadoop.hbase.KeyValue#TIMESTAMP_SIZE

The following examples show how to use org.apache.hadoop.hbase.KeyValue#TIMESTAMP_SIZE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RowColBloomHashKey.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public byte get(int offset) {
  // For ROW_COL blooms we use bytes
  // <RK length> (2 bytes) , <RK>, 0 (one byte CF length), <CQ>, <TS> (8 btes), <TYPE> ( 1 byte)
  if (offset < Bytes.SIZEOF_SHORT) {
    // assign locally
    int rowlen = rowLength;
    byte b = (byte) rowlen;
    if (offset == 0) {
      rowlen >>= 8;
      b = (byte) rowlen;
    }
    return b;
  }
  int refLen = Bytes.SIZEOF_SHORT + rowLength;
  if (offset < refLen) {
    return PrivateCellUtil.getRowByte(t, offset - Bytes.SIZEOF_SHORT);
  }
  if (offset == refLen) {
    // The fam length should return 0 assuming there is no column family.
    // Because for ROWCOL blooms family is not considered
    return 0;
  }
  refLen += qualLength + Bytes.SIZEOF_BYTE;
  // skip the family len because actual cells may have family also
  if (offset < refLen) {
    return PrivateCellUtil.getQualifierByte(t,
      offset - (Bytes.SIZEOF_SHORT + rowLength + Bytes.SIZEOF_BYTE));
  }
  // TODO : check if ts and type can be removed
  refLen += KeyValue.TIMESTAMP_SIZE;
  if (offset < refLen) {
    return LATEST_TS[offset - (Bytes.SIZEOF_SHORT + rowLength + qualLength + Bytes.SIZEOF_BYTE)];
  }
  return MAX_TYPE;
}
 
Example 2
Source File: FastDiffDeltaEncoder.java    From hbase with Apache License 2.0 5 votes vote down vote up
private int findCommonTimestampPrefix(byte[] curTsBuf, byte[] prevTsBuf) {
  int commonPrefix = 0;
  while (commonPrefix < (KeyValue.TIMESTAMP_SIZE - 1)
      && curTsBuf[commonPrefix] == prevTsBuf[commonPrefix]) {
    commonPrefix++;
  }
  return commonPrefix; // has to be at most 7 bytes
}
 
Example 3
Source File: PrefixKeyDeltaEncoder.java    From hbase with Apache License 2.0 4 votes vote down vote up
private void writeKeyExcludingCommon(Cell cell, int commonPrefix, DataOutputStream out)
    throws IOException {
  short rLen = cell.getRowLength();
  if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
    // Previous and current rows are different. Need to write the differing part followed by
    // cf,q,ts and type
    PrivateCellUtil.writeRowKeyExcludingCommon(cell, rLen, commonPrefix, out);
    byte fLen = cell.getFamilyLength();
    out.writeByte(fLen);
    PrivateCellUtil.writeFamily(out, cell, fLen);
    PrivateCellUtil.writeQualifier(out, cell, cell.getQualifierLength());
    out.writeLong(cell.getTimestamp());
    out.writeByte(cell.getTypeByte());
  } else {
    // The full row key part is common. CF part will be common for sure as we deal with Cells in
    // same family. Just need write the differing part in q, ts and type
    commonPrefix = commonPrefix - (rLen + KeyValue.ROW_LENGTH_SIZE)
        - (cell.getFamilyLength() + KeyValue.FAMILY_LENGTH_SIZE);
    int qLen = cell.getQualifierLength();
    int commonQualPrefix = Math.min(commonPrefix, qLen);
    int qualPartLenToWrite = qLen - commonQualPrefix;
    if (qualPartLenToWrite > 0) {
      PrivateCellUtil.writeQualifierSkippingBytes(out, cell, qLen, commonQualPrefix);
    }
    commonPrefix -= commonQualPrefix;
    // Common part in TS also?
    if (commonPrefix > 0) {
      int commonTimestampPrefix = Math.min(commonPrefix, KeyValue.TIMESTAMP_SIZE);
      if (commonTimestampPrefix < KeyValue.TIMESTAMP_SIZE) {
        byte[] curTsBuf = Bytes.toBytes(cell.getTimestamp());
        out.write(curTsBuf, commonTimestampPrefix, KeyValue.TIMESTAMP_SIZE
            - commonTimestampPrefix);
      }
      commonPrefix -= commonTimestampPrefix;
      if (commonPrefix == 0) {
        out.writeByte(cell.getTypeByte());
      }
    } else {
      out.writeLong(cell.getTimestamp());
      out.writeByte(cell.getTypeByte());
    }
  }
}
 
Example 4
Source File: ClientKeyValue.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getLength() {
  return KEYVALUE_INFRASTRUCTURE_SIZE + KeyValue.ROW_LENGTH_SIZE + row.getLength()
      + KeyValue.FAMILY_LENGTH_SIZE + family.getLength() + qualifier.getLength()
      + KeyValue.TIMESTAMP_SIZE + KeyValue.TYPE_SIZE + value.getLength();
}