protected int binarySearchOnKeys(String key) {
    int head = 0;
    int tail = recordNum - 1;
    if (tail < 0
        || key.compareTo(getKeyByIndex(head)) < 0
        || key.compareTo(getKeyByIndex(tail)) > 0) {
      return -1;
    }

    if (key.compareTo(getKeyByIndex(head)) == 0) {
      return head;
    }
    if (key.compareTo(getKeyByIndex(tail)) == 0) {
      return tail;
    }

    int pivot = (head + tail) / 2;
    while (key.compareTo(getKeyByIndex(pivot)) != 0) {
      if (head == tail || pivot == head || pivot == tail) {
        return -1;
      }
      if (key.compareTo(getKeyByIndex(pivot)) < 0) {
        tail = pivot;
      } else if (key.compareTo(getKeyByIndex(pivot)) > 0) {
        head = pivot;
      }
      pivot = (head + tail) / 2;
    }
    return pivot;
  }
@param key
@return -1 if not existed, otherwise correspondent position of target offset
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/WrappedSegment.java