Source:
<code>public KinesisBatchPutResult putRecords(final List<DataLoggerBatchPayload> payloadBatch) { final List<List<DataLoggerBatchPayload>> batches = Lists.partition(payloadBatch, MAX_BATCH_RECORDS); int success = 0; List<DataLoggerBatchPayload> failedPutRecords = Lists.newArrayList(); for (List<DataLoggerBatchPayload> batch : batches) { final List<PutRecordsRequestEntry> putRecordsRequestEntries = Lists.newArrayList(); for (final DataLoggerBatchPayload singlePayload : batch) { final ByteBuffer data = ByteBuffer.wrap(singlePayload.payload); final PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry(); putRecordsRequestEntry.setData(data); putRecordsRequestEntry.setPartitionKey(singlePayload.deviceId); putRecordsRequestEntries.add(putRecordsRequestEntry); } <START> PutRecordsRequest putRecordsRequest = new PutRecordsRequest(); <END> putRecordsRequest.setStreamName(streamName); putRecordsRequest.setRecords(putRecordsRequestEntries); PutRecordsResult putRecordsResult = kinesisClient.putRecords(putRecordsRequest); if (putRecordsResult.getFailedRecordCount() == 0) { success += batch.size(); continue; } final List<PutRecordsResultEntry> putRecordsResultEntryList = putRecordsResult.getRecords(); String lastSequenceNumber = ""; for (int i = 0; i < putRecordsResultEntryList.size(); i++) { final PutRecordsResultEntry resultEntry = putRecordsResultEntryList.get(i); if (resultEntry.getErrorCode() == null) { lastSequenceNumber = resultEntry.getSequenceNumber(); success++; continue; } final PutRecordsRequestEntry requestEntry = putRecordsRequest.getRecords().get(i); final ByteBuffer data = requestEntry.getData(); final String partitionKey = requestEntry.getPartitionKey(); final Optional<String> optionalSequenceNumber = putSingleRecord(partitionKey, data, lastSequenceNumber); if (optionalSequenceNumber.isPresent()) { success++; lastSequenceNumber = optionalSequenceNumber.get(); } else { byte[] failedPayload = new byte[data.remaining()]; data.get(failedPayload); failedPutRecords.add(new DataLoggerBatchPayload(partitionKey, failedPayload)); } } } return new KinesisBatchPutResult(success, payloadBatch.size(), failedPutRecords); }</code><technical_language>final</technical_language>

Target:
public KinesisBatchPutResult putRecords(final List<DataLoggerBatchPayload> payloadBatch) { final List<List<DataLoggerBatchPayload>> batches = Lists.partition(payloadBatch, MAX_BATCH_RECORDS); int numSuccesses = 0; final List<Boolean> putSuccesses = Lists.newArrayList(); for (final List<DataLoggerBatchPayload> batch : batches) { final List<PutRecordsRequestEntry> putRecordsRequestEntries = Lists.newArrayList(); for (final DataLoggerBatchPayload singlePayload : batch) { final ByteBuffer data = ByteBuffer.wrap(singlePayload.payload); final PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry(); putRecordsRequestEntry.setData(data); putRecordsRequestEntry.setPartitionKey(singlePayload.deviceId); putRecordsRequestEntries.add(putRecordsRequestEntry); } final PutRecordsRequest putRecordsRequest = new PutRecordsRequest(); putRecordsRequest.setStreamName(streamName); putRecordsRequest.setRecords(putRecordsRequestEntries); final PutRecordsResult putRecordsResult = kinesisClient.putRecords(putRecordsRequest); if (putRecordsResult.getFailedRecordCount() == 0) { numSuccesses += batch.size(); putSuccesses.addAll(new ArrayList<>(Collections.nCopies(batch.size(), true))); } else { final ProcessFailuresResult failuresResult = processFailedPuts(putRecordsResult, putRecordsRequest); numSuccesses += failuresResult.numSuccess; putSuccesses.addAll(failuresResult.putSuccesses); } } return new KinesisBatchPutResult(numSuccesses, payloadBatch.size(), putSuccesses); }