org.apache.hadoop.hbase.Cell.getSequenceId()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(175)

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

Cell.getSequenceId介绍

[英]A region-specific unique monotonically increasing sequence ID given to each Cell. It always exists for cells in the memstore but is not retained forever. It will be kept for HConstants#KEEP_SEQID_PERIOD days, but generally becomes irrelevant after the cell's row is no longer involved in any operations that require strict consistency.
[中]给每个细胞的一个特定于区域的唯一单调递增序列ID。它始终存在于memstore中的单元格中,但不会永远保留。它将在HConstants#KEEP _SEQUID(保留#ID)期间保留数天,但通常在单元格行不再参与任何需要严格一致性的操作后变得不相关。

代码示例

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

@Override
public long getSequenceId() {
 return this.cell.getSequenceId();
}

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

@Override
public long getSequenceId() {
 return cell.getSequenceId();
}

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

/**
 * Look at the next Cell in this scanner, but do not iterate the scanner
 * @return the currently observed Cell
 */
@Override
public Cell peek() {          // sanity check, the current should be always valid
 if (closed) {
  return null;
 }
 if (current!=null && current.getSequenceId() > readPoint) {
  throw new RuntimeException("current is invalid: read point is "+readPoint+", " +
    "while current sequence id is " +current.getSequenceId());
 }
 return current;
}

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

CellWrapper(Cell cell) {
 assert !(cell instanceof ExtendedCell);
 this.cell = cell;
 this.sequenceId = cell.getSequenceId();
 this.timestamp = cell.getTimestamp();
}

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

public void addVersionDelete(Cell cell) {
 SortedSet<Long> set = deletesMap.get(cell.getTimestamp());
 if (set == null) {
  set = new TreeSet<>();
  deletesMap.put(cell.getTimestamp(), set);
 }
 set.add(cell.getSequenceId());
 // The init set should be the puts whose mvcc is smaller than this Delete. Because
 // there may be some Puts masked by them. The Puts whose mvcc is larger than this Delete can
 // not be copied to this node because we may delete one version and the oldest put may not be
 // masked.
 SortedSet<Long> nextValue = mvccCountingMap.ceilingEntry(cell.getSequenceId()).getValue();
 SortedSet<Long> thisValue = new TreeSet<>(nextValue.headSet(cell.getSequenceId()));
 mvccCountingMap.put(cell.getSequenceId(), thisValue);
}

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

@Override
public void addVersionDelete(Cell cell) {
 SortedMap<Long, TagInfo> set = deletesMap.get(cell.getTimestamp());
 if (set == null) {
  set = new TreeMap<>();
  deletesMap.put(cell.getTimestamp(), set);
 }
 set.put(cell.getSequenceId(), new TagInfo(cell));
 // The init set should be the puts whose mvcc is smaller than this Delete. Because
 // there may be some Puts masked by them. The Puts whose mvcc is larger than this Delete can
 // not be copied to this node because we may delete one version and the oldest put may not be
 // masked.
 SortedSet<Long> nextValue = mvccCountingMap.ceilingEntry(cell.getSequenceId()).getValue();
 SortedSet<Long> thisValue = new TreeSet<>(nextValue.headSet(cell.getSequenceId()));
 mvccCountingMap.put(cell.getSequenceId(), thisValue);
}

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

@Override
public int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
 int diff = compareRows(a, b);
 if (diff != 0) {
  return diff;
 }
 diff = compareWithoutRow(a, b);
 if (diff != 0) {
  return diff;
 }
 // Negate following comparisons so later edits show up first mvccVersion: later sorts first
 return ignoreSequenceid? diff: Longs.compare(b.getSequenceId(), a.getSequenceId());
}

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

@Override
public int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
 int diff = 0;
 // "Peel off" the most common path.
 if (a instanceof ByteBufferKeyValue && b instanceof ByteBufferKeyValue) {
  diff = BBKVComparator.compare((ByteBufferKeyValue)a, (ByteBufferKeyValue)b, ignoreSequenceid);
  if (diff != 0) {
   return diff;
  }
 } else {
  diff = compareRows(a, b);
  if (diff != 0) {
   return diff;
  }
  diff = compareWithoutRow(a, b);
  if (diff != 0) {
   return diff;
  }
 }
 // Negate following comparisons so later edits show up first mvccVersion: later sorts first
 return ignoreSequenceid? diff: Long.compare(b.getSequenceId(), a.getSequenceId());
}

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

@Override
public void add(Cell cell) {
 prepare(cell);
 byte type = cell.getTypeByte();
 switch (Type.codeToType(type)) {
 // By the order of seen. We put null cq at first.
 case DeleteFamily: // Delete all versions of all columns of the specified family
  delFamMap.put(cell.getSequenceId(),
    new DeleteVersionsNode(cell.getTimestamp(), cell.getSequenceId()));
  break;
 case DeleteFamilyVersion: // Delete all columns of the specified family and specified version
  delFamMap.ceilingEntry(cell.getSequenceId()).getValue().addVersionDelete(cell);
  break;
 // These two kinds of markers are mix with Puts.
 case DeleteColumn: // Delete all versions of the specified column
  delColMap.put(cell.getSequenceId(),
    new DeleteVersionsNode(cell.getTimestamp(), cell.getSequenceId()));
  break;
 case Delete: // Delete the specified version of the specified column.
  delColMap.ceilingEntry(cell.getSequenceId()).getValue().addVersionDelete(cell);
  break;
 default:
  throw new AssertionError("Unknown delete marker type for " + cell);
 }
}

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

/**************** copy the cell to create a new keyvalue *********************/
public static KeyValue copyToNewKeyValue(final Cell cell) {
 byte[] bytes = copyToNewByteArray(cell);
 KeyValue kvCell = new KeyValue(bytes, 0, bytes.length);
 kvCell.setSequenceId(cell.getSequenceId());
 return kvCell;
}

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

@Override
public void add(Cell cell) {
 prepare(cell);
 byte type = cell.getTypeByte();
 switch (KeyValue.Type.codeToType(type)) {
 // By the order of seen. We put null cq at first.
 case DeleteFamily: // Delete all versions of all columns of the specified family
  delFamMap.put(cell.getSequenceId(),
    new VisibilityDeleteVersionsNode(cell.getTimestamp(), cell.getSequenceId(),
      new TagInfo(cell)));
  break;
 case DeleteFamilyVersion: // Delete all columns of the specified family and specified version
  delFamMap.ceilingEntry(cell.getSequenceId()).getValue().addVersionDelete(cell);
  break;
 // These two kinds of markers are mix with Puts.
 case DeleteColumn: // Delete all versions of the specified column
  delColMap.put(cell.getSequenceId(),
    new VisibilityDeleteVersionsNode(cell.getTimestamp(), cell.getSequenceId(),
      new TagInfo(cell)));
  break;
 case Delete: // Delete the specified version of the specified column.
  delColMap.ceilingEntry(cell.getSequenceId()).getValue().addVersionDelete(cell);
  break;
 default:
  throw new AssertionError("Unknown delete marker type for " + cell);
 }
}

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

/**
 * Copies the key to a new KeyValue
 * @param cell
 * @return the KeyValue that consists only the key part of the incoming cell
 */
public static KeyValue toNewKeyCell(final Cell cell) {
 byte[] bytes = new byte[keyLength(cell)];
 appendKeyTo(cell, bytes, 0);
 KeyValue kv = new KeyValue.KeyOnlyKeyValue(bytes, 0, bytes.length);
 // Set the seq id. The new key cell could be used in comparisons so it
 // is important that it uses the seqid also. If not the comparsion would fail
 kv.setSequenceId(cell.getSequenceId());
 return kv;
}

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

/**
 * Clone the passed cell by copying its data into the passed buf and create a cell with a chunkid
 * out of it
 * @see #copyBBECToChunkCell(ByteBufferExtendedCell, ByteBuffer, int, int)
 */
private static Cell copyToChunkCell(Cell cell, ByteBuffer buf, int offset, int len) {
 int tagsLen = cell.getTagsLength();
 if (cell instanceof ExtendedCell) {
  ((ExtendedCell) cell).write(buf, offset);
 } else {
  // Normally all Cell impls within Server will be of type ExtendedCell. Just considering the
  // other case also. The data fragments within Cell is copied into buf as in KeyValue
  // serialization format only.
  KeyValueUtil.appendTo(cell, buf, offset, true);
 }
 return createChunkCell(buf, offset, len, tagsLen, cell.getSequenceId());
}

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

public int write(Cell cell) throws IOException {
 // We write tags seperately because though there is no tag in KV
 // if the hfilecontext says include tags we need the tags length to be
 // written
 int size = KeyValueUtil.oswrite(cell, out, false);
 // Write the additional tag into the stream
 if (encodingCtx.getHFileContext().isIncludesTags()) {
  int tagsLength = cell.getTagsLength();
  out.writeShort(tagsLength);
  if (tagsLength > 0) {
   PrivateCellUtil.writeTags(out, cell, tagsLength);
  }
  size += tagsLength + KeyValue.TAGS_LENGTH_SIZE;
 }
 if (encodingCtx.getHFileContext().isIncludesMvcc()) {
  WritableUtils.writeVLong(out, cell.getSequenceId());
  size += WritableUtils.getVIntSize(cell.getSequenceId());
 }
 return size;
}

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

/**
 * @param cell
 * @return The Key portion of the passed <code>cell</code> as a String.
 */
public static String getCellKeyAsString(Cell cell) {
 StringBuilder sb = new StringBuilder(Bytes.toStringBinary(
  cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
 sb.append('/');
 sb.append(cell.getFamilyLength() == 0? "":
  Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()));
 // KeyValue only added ':' if family is non-null.  Do same.
 if (cell.getFamilyLength() > 0) sb.append(':');
 sb.append(cell.getQualifierLength() == 0? "":
  Bytes.toStringBinary(cell.getQualifierArray(), cell.getQualifierOffset(),
   cell.getQualifierLength()));
 sb.append('/');
 sb.append(KeyValue.humanReadableTimestamp(cell.getTimestamp()));
 sb.append('/');
 sb.append(Type.codeToType(cell.getTypeByte()));
 if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {
  sb.append("/vlen=");
  sb.append(cell.getValueLength());
 }
 sb.append("/seqid=");
 sb.append(cell.getSequenceId());
 return sb.toString();
}

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

protected boolean skipKVsNewerThanReadpoint() throws IOException {
 // We want to ignore all key-values that are newer than our current
 // readPoint
 Cell startKV = cur;
 while(enforceMVCC
   && cur != null
   && (cur.getSequenceId() > readPt)) {
  boolean hasNext = hfs.next();
  setCurrentCell(hfs.getCell());
  if (hasNext && this.stopSkippingKVsIfNextRow
    && getComparator().compareRows(cur, startKV) > 0) {
   return false;
  }
 }
 if (cur == null) {
  return false;
 }
 return true;
}

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

@Override
public void write(Cell cell) throws IOException {
 checkFlushed();
 // Row
 write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
 // Column family
 write(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
 // Qualifier
 write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
 // Version
 this.out.write(Bytes.toBytes(cell.getTimestamp()));
 // Type
 this.out.write(cell.getTypeByte());
 // Value
 write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
 // MvccVersion
 this.out.write(Bytes.toBytes(cell.getSequenceId()));
}

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

@Override
public void write(Cell cell) throws IOException {
 checkFlushed();
 // Row
 write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
 // Column family
 write(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
 // Qualifier
 write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
 // Version
 this.out.write(Bytes.toBytes(cell.getTimestamp()));
 // Type
 this.out.write(cell.getTypeByte());
 // Value
 write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
 // Tags
 write(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
 // MvccVersion
 this.out.write(Bytes.toBytes(cell.getSequenceId()));
}

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

@Override
 public MatchCode match(Cell cell) throws IOException {
  MatchCode returnCode = preCheck(cell);
  if (returnCode != null) {
   return returnCode;
  }
  long mvccVersion = cell.getSequenceId();
  byte typeByte = cell.getTypeByte();
  if (PrivateCellUtil.isDelete(typeByte)) {
   if (mvccVersion > maxReadPointToTrackVersions) {
    // we should not use this delete marker to mask any cell yet.
    return MatchCode.INCLUDE;
   }
   trackDelete(cell);
   return MatchCode.INCLUDE;
  }
  returnCode = checkDeleted(deletes, cell);
  if (returnCode != null) {
   return returnCode;
  }
  // Skip checking column since we do not remove column during compaction.
  return columns.checkVersions(cell, cell.getTimestamp(), typeByte,
   mvccVersion > maxReadPointToTrackVersions);
 }
}

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

public KeyValue(Cell c) {
 this(c.getRowArray(), c.getRowOffset(), c.getRowLength(),
   c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength(),
   c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength(),
   c.getTimestamp(), Type.codeToType(c.getTypeByte()), c.getValueArray(), c.getValueOffset(),
   c.getValueLength(), c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
 this.seqId = c.getSequenceId();
}

相关文章