@Override
  public int removeRecord(String key) {
    int idx = binarySearchOnKeys(key);

    // deletion only seeks for name of ICacheMNode
    if (idx < 0) {
      return -1;
    }

    // restore space immediately if the last record removed
    short offset = getOffsetByIndex(idx);
    if (offset == freeAddr) {
      this.buffer.position(offset + 4 + key.getBytes().length);
      short len = RecordUtils.getRecordLength(this.buffer);
      freeAddr += len + 4 + key.getBytes().length;
    }

    // shift offsets forward
    if (idx != recordNum) {
      int shift = recordNum - idx;
      this.buffer.position(SchemaFileConfig.SEG_HEADER_SIZE + idx * 2);
      ShortBuffer lb = this.buffer.asReadOnlyBuffer().asShortBuffer();
      lb.get();
      while (shift != 0) {
        this.buffer.putShort(lb.get());
        shift--;
      }
    }

    recordNum--;
    pairLength -= 2;

    return idx;
  }
<b>Segment Structure:</b>
<li>(25 byte: header)
<li>1 short: length, segment length
<li>1 short: freeAddr, start offset of records
<li>1 short: recordNum, amount of records in this segment
<li>1 short: pairLength, length of key-address in bytes
<li>1 long (8 bytes): prevSegIndex, previous segment index
<li>1 long (8 bytes): nextSegIndex, next segment index
<li>1 bit: delFlag, delete flag
<li>1 bit: aliasFlag, whether alias existed<br>
    (--- checksum, parent record address, max/min record key may be contained further ---)
<li><s>var length: key-address pairs, begin at 25 bytes offset, length of pairLength </s><br>
<li>var length: ORDERED record offset<br>
    ... empty space ...
<li>var length: (record key, record body) * recordNum
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/WrappedSegment.java