@Override
    public void batchGetAndPut(final KVStateOutputList kvStates) {
        if (kvStates.isSingletonList()) {
            final KVState kvState = kvStates.getSingletonElement();
            final KVOperation op = kvState.getOp();
            getAndPut(op.getKey(), op.getValue(), kvState.getDone());
            return;
        }
        final Timer.Context timeCtx = getTimeContext("BATCH_GET_PUT");
        final Lock readLock = this.readWriteLock.readLock();
        readLock.lock();
        try {
            Partitions.manyToOne(kvStates, MAX_BATCH_WRITE_SIZE, (Function<List<KVState>, Void>) segment -> {
                try (final WriteBatch batch = new WriteBatch()) {
                    final List<byte[]> keys = Lists.newArrayListWithCapacity(segment.size());
                    for (final KVState kvState : segment) {
                        final KVOperation op = kvState.getOp();
                        final byte[] key = op.getKey();
                        keys.add(key);
                        batch.put(key, op.getValue());
                    }
                    // first, get prev values
                    final Map<byte[], byte[]> prevValMap = multiGetAsMap(keys);
                    this.db.write(this.writeOptions, batch);
                    for (final KVState kvState : segment) {
                        setSuccess(kvState.getDone(), prevValMap.get(kvState.getOp().getKey()));
                    }
                } catch (final Exception e) {
                    LOG.error("Failed to [BATCH_GET_PUT], [size = {}] {}.", segment.size(),
                        StackTraceUtil.stackTrace(e));
                    setCriticalError(Lists.transform(kvStates, KVState::getDone), "Fail to [BATCH_GET_PUT]", e);
                }
                return null;
            });
        } finally {
            readLock.unlock();
            timeCtx.stop();
        }
    }
Local KV store based on RocksDB

@author dennis
@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java