/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }