code: private List<Write> getWritesToExecute() {
          // Calculate how much estimated space there is in the current ledger.
          final long maxTotalSize = this.config.getBkLedgerMaxSize() - getWriteLedger().ledger.getLength();
  
          // Get the writes to execute from the queue.
          List<Write> toExecute = this.writes.getWritesToExecute(maxTotalSize);
  
          // Check to see if any writes executed on closed ledgers, in which case they either need to be failed (if deemed
          // appropriate, or retried).
          if (handleClosedLedgers(toExecute)) {
              // If any changes were made to the Writes in the list, re-do the search to get a more accurate list of Writes
              // to execute (since some may have changed Ledgers, more writes may not be eligible for execution).
              toExecute = this.writes.getWritesToExecute(maxTotalSize);
          }
  
          return toExecute;
      }
docs: Collects an ordered list of Writes to execute to BookKeeper.
  
  @return The list of Writes to execute.