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

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

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

Cell.getFamilyLength介绍

暂无

代码示例

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

public static int compareCommonFamilyPrefix(Cell left, Cell right, int familyCommonPrefix) {
 return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset() + familyCommonPrefix,
   left.getFamilyLength() - familyCommonPrefix, right.getFamilyArray(),
   right.getFamilyOffset() + familyCommonPrefix, right.getFamilyLength() - familyCommonPrefix);
}

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

if ((left.getRowLength() + left.getFamilyLength() + left.getQualifierLength()) != (right
  .getRowLength() + right.getFamilyLength() + right.getQualifierLength())) {
 return false;
int lfoffset = left.getFamilyOffset();
int rfoffset = right.getFamilyOffset();
int lclength = left.getQualifierLength();
int rclength = right.getQualifierLength();
int lfamilylength = left.getFamilyLength();
int rfamilylength = right.getFamilyLength();
int diff = compareFamilies(left.getFamilyArray(), lfoffset, lfamilylength,
  right.getFamilyArray(), rfoffset, rfamilylength);
if (diff != 0) {
 return false;
} else {
 diff = compareColumns(left.getQualifierArray(), left.getQualifierOffset(), lclength,
   right.getQualifierArray(), right.getQualifierOffset(), rclength);
 return diff == 0;

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

/**
 * @param nextIndexed the key of the next entry in the block index (if any)
 * @param currentCell The Cell we're using to calculate the seek key
 * @return result of the compare between the indexed key and the key portion of the passed cell
 */
public int compareKeyForNextColumn(Cell nextIndexed, Cell currentCell) {
 ColumnCount nextColumn = columns.getColumnHint();
 if (nextColumn == null) {
  return PrivateCellUtil.compareKeyBasedOnColHint(rowComparator, nextIndexed, currentCell, 0, 0, null,
   0, 0, HConstants.OLDEST_TIMESTAMP, Type.Minimum.getCode());
 } else {
  return PrivateCellUtil.compareKeyBasedOnColHint(rowComparator, nextIndexed, currentCell,
   currentCell.getFamilyOffset(), currentCell.getFamilyLength(), nextColumn.getBuffer(),
   nextColumn.getOffset(), nextColumn.getLength(), HConstants.LATEST_TIMESTAMP,
   Type.Maximum.getCode());
 }
}

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

buf, keyValue.getFamilyOffset(), keyValue.getFamilyLength(),
buf, keyValue.getQualifierOffset(), keyValue.getQualifierLength(),
keyValue.getTimestamp(), KeyValue.Type.codeToType(keyValue.getTypeByte()),
buf, keyValue.getValueOffset(), keyValue.getValueLength());

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

if (cell.getQualifierLength() == 0
  && (cell.getTypeByte() == Type.DeleteFamily.getCode()
  || cell.getTypeByte() == Type.DeleteFamilyVersion.getCode())) {
curFam.set(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
List<Cell> cols = familyMap1.get(curFam);
for (Cell col : cols) {
 if ((col.getQualifierLength() == 0 && request == OpType.DELETE)
   || CellUtil.matchingQualifier(cell, col)) {
  byte type = col.getTypeByte();

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

public static ByteBuffer getValueAsByteBuffer(Result hbaseRow, byte[] cf, byte[] cq) {
  List<Cell> cells = hbaseRow.listCells();
  if (cells == null || cells.size() == 0) {
    return null;
  } else {
    for (Cell c : cells) {
      if (Bytes.compareTo(cf, 0, cf.length, c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength()) == 0 && //
          Bytes.compareTo(cq, 0, cq.length, c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()) == 0) {
        return ByteBuffer.wrap(c.getValueArray(), c.getValueOffset(), c.getValueLength());
      }
    }
  }
  return null;
}

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

private static int findCommonPrefixInFamilyPart(Cell left, Cell right, int familyCommonPrefix) {
 return Bytes
   .findCommonPrefix(left.getFamilyArray(), right.getFamilyArray(), left.getFamilyLength()
     - familyCommonPrefix, right.getFamilyLength() - familyCommonPrefix,
     left.getFamilyOffset() + familyCommonPrefix, right.getFamilyOffset()
       + familyCommonPrefix);
}

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

Delete delete = new Delete(keyValue.getRowArray(), keyValue.getRowOffset(), keyValue.getRowLength());
KeyValue deleteKeyValue = new KeyValue(buf, keyValue.getRowOffset(), keyValue.getRowLength(),
    buf, keyValue.getFamilyOffset(), keyValue.getFamilyLength(),
    buf, keyValue.getQualifierOffset(), keyValue.getQualifierLength(),
    keyValue.getTimestamp(), KeyValue.Type.Delete,
    ByteUtil.EMPTY_BYTE_ARRAY,0,0);

代码示例来源: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

public static ByteRange fillFamilyRange(Cell cell, ByteRange range) {
 return range.set(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
}

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

public void hashResult(Result result) {
 if (!batchStarted) {
  throw new RuntimeException("Cannot add to batch that has not been started.");
 }
 for (Cell cell : result.rawCells()) {
  int rowLength = cell.getRowLength();
  int familyLength = cell.getFamilyLength();
  int qualifierLength = cell.getQualifierLength();
  int valueLength = cell.getValueLength();
  digest.update(cell.getRowArray(), cell.getRowOffset(), rowLength);
  digest.update(cell.getFamilyArray(), cell.getFamilyOffset(), familyLength);
  digest.update(cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength);
  long ts = cell.getTimestamp();
  for (int i = 8; i > 0; i--) {
   digest.update((byte) ts);
   ts >>>= 8;
  }
  digest.update(cell.getValueArray(), cell.getValueOffset(), valueLength);
  batchSize += rowLength + familyLength + qualifierLength + 8 + valueLength;
 }
}

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

public static boolean matchingFamily(final Cell left, final byte[] buf, final int offset,
  final int length) {
 if (left instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
    ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
    buf, offset, length);
 }
 return Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(), buf,
  offset, length);
}

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

public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
 int lrowlength = left.getRowLength();
 int rrowlength = right.getRowLength();
 int lfamlength = left.getFamilyLength();
 int rfamlength = right.getFamilyLength();
 int lqlength = left.getQualifierLength();
 int rqlength = right.getQualifierLength();
 // match length
 if ((lrowlength + lfamlength + lqlength) !=
   (rrowlength + rfamlength + rqlength)) {
  return false;
 }
 // match row
 if (!Bytes.equals(left.getRowArray(), left.getRowOffset(), lrowlength, right.getRowArray(),
   right.getRowOffset(), rrowlength)) {
  return false;
 }
 //match family
 if (!Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), lfamlength,
   right.getFamilyArray(), right.getFamilyOffset(), rfamlength)) {
  return false;
 }
 //match qualifier
 return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
   lqlength, right.getQualifierArray(), right.getQualifierOffset(),
   rqlength);
}

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

public static void compressFamily(OutputStream out, Cell cell, Dictionary dict)
  throws IOException {
 if (cell instanceof ByteBufferExtendedCell) {
  Dictionary.write(out, ((ByteBufferExtendedCell) cell).getFamilyByteBuffer(),
   ((ByteBufferExtendedCell) cell).getFamilyPosition(), cell.getFamilyLength(), dict);
 } else {
  Dictionary.write(out, cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(),
   dict);
 }
}

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

private void loadRecord(Result r) {
  Cell[] cells = r.rawCells();
  Cell cell = cells[0];
  if (Bytes.compareTo(CF_B, 0, CF_B.length, cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()) != 0 //
      || Bytes.compareTo(COL_B, 0, COL_B.length, cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) != 0)
    throw new IllegalStateException();
  rec.loadCellBlock(0, ByteBuffer.wrap(cell.getRowArray(), cell.getRowOffset() + ID_LEN, cell.getRowLength() - ID_LEN));
  rec.loadCellBlock(1, ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
}

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

/**
 * Compare cell's column family against given comparator
 * @param cell
 * @param comparator
 * @return result comparing cell's column family
 */
public static int compareFamily(Cell cell, ByteArrayComparable comparator) {
 if (cell instanceof ByteBufferExtendedCell) {
  return comparator.compareTo(((ByteBufferExtendedCell) cell).getFamilyByteBuffer(),
   ((ByteBufferExtendedCell) cell).getFamilyPosition(), cell.getFamilyLength());
 }
 return comparator.compareTo(cell.getFamilyArray(), cell.getFamilyOffset(),
  cell.getFamilyLength());
}

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

private int calculateHashForKey(Cell cell) {
 // pre-calculate the 3 hashes made of byte ranges
 int rowHash = Bytes.hashCode(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
 int familyHash = Bytes.hashCode(cell.getFamilyArray(), cell.getFamilyOffset(),
   cell.getFamilyLength());
 int qualifierHash = Bytes.hashCode(cell.getQualifierArray(), cell.getQualifierOffset(),
   cell.getQualifierLength());
 // combine the 6 sub-hashes
 int hash = 31 * rowHash + familyHash;
 hash = 31 * hash + qualifierHash;
 hash = 31 * hash + (int) cell.getTimestamp();
 hash = 31 * hash + cell.getTypeByte();
 return hash;
}

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

/**
 * Compares the cell's family with the given byte[]
 * @param left the cell for which the family has to be compared
 * @param right the byte[] having the family
 * @param roffset the offset of the family
 * @param rlength the length of the family
 * @return greater than 0 if left cell's family is bigger than byte[], lesser than 0 if left
 *         cell's family is lesser than byte[] and 0 otherwise
 */
public final static int compareFamilies(Cell left, byte[] right, int roffset, int rlength) {
 if (left instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
   ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), right, roffset,
   rlength);
 }
 return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
  right, roffset, rlength);
}

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

private static Map<String, Object> toStringMap(Cell cell) {
 Map<String, Object> stringMap = new HashMap<>();
 stringMap.put("row",
   Bytes.toStringBinary(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
 stringMap.put("family", Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),
       cell.getFamilyLength()));
 stringMap.put("qualifier",
   Bytes.toStringBinary(cell.getQualifierArray(), cell.getQualifierOffset(),
     cell.getQualifierLength()));
 stringMap.put("timestamp", cell.getTimestamp());
 stringMap.put("vlen", cell.getValueLength());
 if (cell.getTagsLength() > 0) {
  List<String> tagsString = new ArrayList<>();
  Iterator<Tag> tagsIterator = PrivateCellUtil.tagsIterator(cell);
  while (tagsIterator.hasNext()) {
   Tag tag = tagsIterator.next();
   tagsString
     .add((tag.getType()) + ":" + Bytes.toStringBinary(Tag.cloneValue(tag)));
  }
  stringMap.put("tag", tagsString);
 }
 return stringMap;
}

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

/**
 * Compare the families of left and right cell
 * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
 */
@Override
public final int compareFamilies(Cell left, Cell right) {
 if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
    ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
    ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
    ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());
 }
 if (left instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
    ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
    right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
 }
 if (right instanceof ByteBufferExtendedCell) {
  // Notice how we flip the order of the compare here. We used to negate the return value but
  // see what FindBugs says
  // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
  // It suggest flipping the order to get same effect and 'safer'.
  return ByteBufferUtils.compareTo(
    left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
    ((ByteBufferExtendedCell)right).getFamilyByteBuffer(),
    ((ByteBufferExtendedCell)right).getFamilyPosition(), right.getFamilyLength());
 }
 return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
   right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
}

相关文章