deeplearning4j/deeplearning4j · error · UnsupportedOperationException
Tried to combine() incompatible
Error message
Tried to combine() incompatible <accu class name> operator whereAggregableStringPrepend expected
What it means
AggregableStringPrepend.combine() only accepts another AggregableStringPrepend, merging the other's StringBuilder into its own. Any other accumulator class triggers UnsupportedOperationException. It means reducers configured as Prepend were combined with accumulators from a different reducer.
Solutions
- Use the same reducer (Prepend everywhere) for accumulators that will be combined into an AggregableStringPrepend.
- Match the accu class name in the message against your reducer configuration and fix the mismatch at op creation time.
- Note also that Prepend reverses each accepted string internally; verify your expected output order isn't a sign you meant to use Append.
Example fix
// before prependOp.combine(appendOp); // after if (appendOp instanceof AggregableStringPrepend) prependOp.combine(appendOp);
Defensive patterns
Strategy: validation
Validate before calling
if (!(accu instanceof AggregableStringPrepend)) throw new IllegalArgumentException("Prepend reducers can only combine with Prepend reducers, got " + accu.getClass().getName()); Type guard
boolean combinable = accu instanceof AggregableStringPrepend;
Try / catch
try { prependOp.combine(accu); } catch (UnsupportedOperationException e) { throw new IllegalStateException("Reducer type mismatch (Prepend vs " + accu.getClass().getSimpleName() + ")", e); } Prevention
- Pick Append or Prepend once per column and use it consistently.
- Remember Prepend reverses each accepted string; confirm intended semantics before configuring.
- Test end-to-end schema inference (getSchemaAfterStep) on pipelines containing string reducers.
When it happens
Trigger: Calling combine() on an AggregableStringPrepend with e.g. AggregableStringAppend or another reducer's accumulator — typically when merging partial reduce results across partitions/workers.
Common situations: Mixed ReduceOp.Prepend/Append configuration for the same string column across pipeline stages; inconsistent reducer lists between map and reduce sides of a distributed reduction.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Tried to combine() incompatible
- Tried to combine() incompatible
- Tried to combine() incompatible
- Calculating sorted rank on sequences: not yet supported
- Cannot apply SequenceLengthCondition on non-sequence data
AI-assisted analysis of deeplearning4j/deeplearning4j@4c22ac5fe4 (2026-09-07).
Data as JSON: /api/errors/cec9f44478b30119.
Report an issue: GitHub.
Appendix: source
Thrown at datavec/datavec-api/src/main/java/org/datavec/api/transform/ops/StringAggregatorImpls.java:63
@Override
public void accept(String s) {
sb.append(s);
}
@Override
public Writable get() {
return new Text(sb.toString());
}
}
public static class AggregableStringPrepend extends AggregableStringReduce {
@Override
public <W extends IAggregableReduceOp<String, Writable>> void combine(W accu) {
if (accu instanceof AggregableStringPrepend)
sb.append(((AggregableStringPrepend) accu).getSb());
else
throw new UnsupportedOperationException("Tried to combine() incompatible " + accu.getClass().getName()
+ " operator where" + this.getClass().getName() + " expected");
}
@Override
public void accept(String s) {
String rev = new StringBuilder(s).reverse().toString();
sb.append(rev);
}
@Override
public Writable get() {
return new Text(sb.reverse().toString());
}
}
}
View on GitHub (pinned to 4c22ac5fe4)