@SuppressWarnings("unchecked")
        @Override
        public void onEvent(final KVEvent event, final long sequence, final boolean endOfBatch) throws Exception {
            this.events.add(event);
            this.cachedBytes += event.kvEntry.length();
            final int size = this.events.size();
            if (!endOfBatch && size < batchingOpts.getBatchSize() && this.cachedBytes < batchingOpts.getMaxWriteBytes()) {
                return;
            }

            if (size == 1) {
                final KVEntry kv = event.kvEntry;
                try {
                    put(kv.getKey(), kv.getValue(), event.future, false);
                } catch (final Throwable t) {
                    exceptionally(t, event.future);
                }
                reset();
            } else {
                final List<KVEntry> entries = Lists.newArrayListWithCapacity(size);
                final CompletableFuture<Boolean>[] futures = new CompletableFuture[size];
                for (int i = 0; i < size; i++) {
                    final KVEvent e = this.events.get(i);
                    entries.add(e.kvEntry);
                    futures[i] = e.future;
                }
                reset();
                try {
                    put(entries).whenComplete((result, throwable) -> {
                        if (throwable == null) {
                            for (int i = 0; i < futures.length; i++) {
                                futures[i].complete(result);
                            }
                            return;
                        }
                        exceptionally(throwable, futures);
                    });
                } catch (final Throwable t) {
                    exceptionally(t, futures);
                }
            }
        }
Returns a heap-allocated iterator over the contents of the
database.
<p>
Caller should close the iterator when it is no longer needed.
The returned iterator should be closed before this db is closed.
<p>
<pre>
    KVIterator it = unsafeLocalIterator();
    try {
        // do something
    } finally {
        it.close();
    }
<pre/>
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java