java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DoubleRLBE.java [142:196]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    while (val > 0) {
      while (fib[i] > val && i >= 1) {
        i--;
      }
      valfib |= (1 << (i - 1));
      val -= fib[i];
    }
    return valfib;
  }

  /** run length on DiffValue then store length at the first index in Lengrle. */
  private void rleonlengthcode() {
    int i = 0;
    while (i <= writeIndex) {
      int j = i;
      int temprlecal = 0;
      while (LengthCode[j] == LengthCode[i] && j <= writeIndex) {
        j++;
        temprlecal++;
      }
      // store repeat time at the first repeating value's position
      lengRLE[i] = temprlecal;
      i = j;
    }
  }

  /**
   * flush all encoded values in a block to output stream.
   *
   * @param out the output stream to be flushed to
   */
  protected void flushBlock(ByteArrayOutputStream out) {
    if (writeIndex == -1) {
      return;
    }
    // store the number of values
    writewriteIndex(out);
    // calculate length code of delta binary length
    rleonlengthcode();
    for (int i = 0; i <= writeIndex; i++) {
      if (lengRLE[i] > 0) { // flush the adjacent same length delta values
        flushSegment(i, out);
      }
    }
    clearBuffer(out);
    reset();
  }

  /**
   * flush the adjacent same-length delta values.
   *
   * @param i the position of the first delta value
   * @param out output stream
   */
  private void flushSegment(int i, ByteArrayOutputStream out) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/IntRLBE.java [130:184]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    while (val > 0) {
      while (fib[i] > val && i >= 1) {
        i--;
      }
      valfib |= (1 << (i - 1));
      val -= fib[i];
    }
    return valfib;
  }

  /** run length on DiffValue then store length at the first index in Lengrle. */
  private void rleonlengthcode() {
    int i = 0;
    while (i <= writeIndex) {
      int j = i;
      int temprlecal = 0;
      while (LengthCode[j] == LengthCode[i] && j <= writeIndex) {
        j++;
        temprlecal++;
      }
      // store repeat time at the first repeating value's position
      lengRLE[i] = temprlecal;
      i = j;
    }
  }

  /**
   * flush all encoded values in a block to output stream.
   *
   * @param out the output stream to be flushed to
   */
  protected void flushBlock(ByteArrayOutputStream out) {
    if (writeIndex == -1) {
      return;
    }
    // store the number of values
    writewriteIndex(out);
    // calculate length code of delta binary length
    rleonlengthcode();
    for (int i = 0; i <= writeIndex; i++) {
      if (lengRLE[i] > 0) { // flush the adjacent same length delta values
        flushSegment(i, out);
      }
    }
    clearBuffer(out);
    reset();
  }

  /**
   * flush the adjacent same-length delta values.
   *
   * @param i the position of the first delta value
   * @param out output stream
   */
  private void flushSegment(int i, ByteArrayOutputStream out) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



