use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptor method splitException.
/**
* Marks the entry future with received {@link Throwable}.
*
* <p>In case throwable is {@link MutateRowsException}, then it only sets throwable for the
* entries whose index is mentioned {@link MutateRowsException#getFailedMutations()}.
*/
@Override
public void splitException(Throwable throwable, List<BatchEntry<RowMutationEntry, Void>> entries) {
if (!(throwable instanceof MutateRowsException)) {
for (BatchEntry<RowMutationEntry, Void> entry : entries) {
entry.getResultFuture().setException(throwable);
}
return;
}
List<FailedMutation> failedMutations = ((MutateRowsException) throwable).getFailedMutations();
Map<Integer, Throwable> entryErrors = Maps.newHashMap();
for (FailedMutation failure : failedMutations) {
entryErrors.put(failure.getIndex(), failure.getError());
}
int i = 0;
for (BatchEntry<RowMutationEntry, Void> entry : entries) {
Throwable entryError = entryErrors.get(i++);
if (entryError == null) {
entry.getResultFuture().set(null);
} else {
entry.getResultFuture().setException(entryError);
}
}
}
Aggregations