org.apache.hadoop.hbase.Cell#getSerializedSize ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.Cell#getSerializedSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: QuotaUtil.java
public static long calculateMutationSize(final Mutation mutation) {
  long size = 0;
  for (Map.Entry<byte[], List<Cell>> entry : mutation.getFamilyCellMap().entrySet()) {
    for (Cell cell : entry.getValue()) {
      size += cell.getSerializedSize();
    }
  }
  return size;
}
 
源代码2 项目: hbase   文件: QuotaUtil.java
public static long calculateResultSize(final Result result) {
  long size = 0;
  for (Cell cell : result.rawCells()) {
    size += cell.getSerializedSize();
  }
  return size;
}
 
源代码3 项目: hbase   文件: QuotaUtil.java
public static long calculateResultSize(final List<Result> results) {
  long size = 0;
  for (Result result: results) {
    for (Cell cell : result.rawCells()) {
      size += cell.getSerializedSize();
    }
  }
  return size;
}
 
源代码4 项目: hbase   文件: HFilePrettyPrinter.java
public void collect(Cell cell) {
  valLen.update(cell.getValueLength());
  if (prevCell != null &&
      CellComparator.getInstance().compareRows(prevCell, cell) != 0) {
    // new row
    collectRow();
  }
  curRowBytes += cell.getSerializedSize();
  curRowKeyLength = KeyValueUtil.keyLength(cell);
  curRowCols++;
  prevCell = cell;
}
 
源代码5 项目: hbase   文件: ConnectionUtils.java
static void validatePut(Put put, int maxKeyValueSize) throws IllegalArgumentException {
  if (put.isEmpty()) {
    throw new IllegalArgumentException("No columns to insert");
  }
  if (maxKeyValueSize > 0) {
    for (List<Cell> list : put.getFamilyCellMap().values()) {
      for (Cell cell : list) {
        if (cell.getSerializedSize() > maxKeyValueSize) {
          throw new IllegalArgumentException("KeyValue size too large");
        }
      }
    }
  }
}
 
源代码6 项目: hbase   文件: Segment.java
/**
 * Get cell length after serialized in {@link KeyValue}
 */
@VisibleForTesting
static int getCellLength(Cell cell) {
  return cell.getSerializedSize();
}
 
源代码7 项目: hbase   文件: TestCellFlatSet.java
private CellChunkMap setUpCellChunkMap(boolean asc) {

    // allocate new chunks and use the data chunk to hold the full data of the cells
    // and the index chunk to hold the cell-representations
    Chunk dataChunk = chunkCreator.getChunk(CompactingMemStore.IndexType.CHUNK_MAP);
    Chunk idxChunk  = chunkCreator.getChunk(CompactingMemStore.IndexType.CHUNK_MAP);
    // the array of index chunks to be used as a basis for CellChunkMap
    Chunk chunkArray[] = new Chunk[8];  // according to test currently written 8 is way enough
    int chunkArrayIdx = 0;
    chunkArray[chunkArrayIdx++] = idxChunk;

    ByteBuffer idxBuffer = idxChunk.getData();  // the buffers of the chunks
    ByteBuffer dataBuffer = dataChunk.getData();
    int dataOffset = ChunkCreator.SIZEOF_CHUNK_HEADER;        // offset inside data buffer
    int idxOffset = ChunkCreator.SIZEOF_CHUNK_HEADER;         // skip the space for chunk ID

    Cell[] cellArray = asc ? ascCells : descCells;

    for (Cell kv: cellArray) {
      // do we have enough space to write the cell data on the data chunk?
      if (dataOffset + kv.getSerializedSize() > chunkCreator.getChunkSize()) {
        // allocate more data chunks if needed
        dataChunk = chunkCreator.getChunk(CompactingMemStore.IndexType.CHUNK_MAP);
        dataBuffer = dataChunk.getData();
        dataOffset = ChunkCreator.SIZEOF_CHUNK_HEADER;
      }
      int dataStartOfset = dataOffset;
      dataOffset = KeyValueUtil.appendTo(kv, dataBuffer, dataOffset, false); // write deep cell data

      // do we have enough space to write the cell-representation on the index chunk?
      if (idxOffset + ClassSize.CELL_CHUNK_MAP_ENTRY > chunkCreator.getChunkSize()) {
        // allocate more index chunks if needed
        idxChunk = chunkCreator.getChunk(CompactingMemStore.IndexType.CHUNK_MAP);
        idxBuffer = idxChunk.getData();
        idxOffset = ChunkCreator.SIZEOF_CHUNK_HEADER;
        chunkArray[chunkArrayIdx++] = idxChunk;
      }
      idxOffset = ByteBufferUtils.putInt(idxBuffer, idxOffset, dataChunk.getId()); // write data chunk id
      idxOffset = ByteBufferUtils.putInt(idxBuffer, idxOffset, dataStartOfset);          // offset
      idxOffset = ByteBufferUtils.putInt(idxBuffer, idxOffset, kv.getSerializedSize()); // length
      idxOffset = ByteBufferUtils.putLong(idxBuffer, idxOffset, kv.getSequenceId());     // seqId
    }

    return new CellChunkMap(CellComparator.getInstance(),chunkArray,0,NUM_OF_CELLS,!asc);
  }
 
源代码8 项目: phoenix   文件: CompatUtil.java
public static int getCellSerializedSize(Cell cell) {
    return cell.getSerializedSize();
}