@TestOnly
  public ByteBuffer getRecord(String key) {
    short targetAddr;
    int idx = binarySearchOnKeys(key);
    if (idx >= 0) {
      targetAddr = getOffsetByIndex(idx);
      this.buffer.clear();
      this.buffer.position(targetAddr);
      this.buffer.position(targetAddr + 4 + this.buffer.getInt());
      short len = RecordUtils.getRecordLength(this.buffer);
      this.buffer.limit(this.buffer.position() + len);
      return this.buffer.slice();
    }
    return null;
  }
If buffer position is set to begin of the segment, this methods extract length of it.

@param buffer
@return
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/WrappedSegment.java