{"record":{"id":"f4bbad0ab99747f8","repo":"deeplearning4j/deeplearning4j","slug":"tried-to-combine-incompatible-accu-class-name-f4bbad","errorCode":null,"errorMessage":"Tried to combine() incompatible <accu class name> operator where org.datavec.api.transform.ops.LongWritableOp expected","messagePattern":"Tried to combine\\(\\) incompatible <accu class name> operator where org\\.datavec\\.api\\.transform\\.ops\\.LongWritableOp expected","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"datavec/datavec-api/src/main/java/org/datavec/api/transform/ops/LongWritableOp.java","lineNumber":40,"sourceCode":"\nimport lombok.AllArgsConstructor;\nimport lombok.Data;\nimport lombok.Getter;\nimport org.datavec.api.writable.Writable;\n\n@AllArgsConstructor\n@Data\npublic class LongWritableOp<T> implements IAggregableReduceOp<Writable, T> {\n\n    @Getter\n    private IAggregableReduceOp<Long, T> operation;\n\n    @Override\n    public <W extends IAggregableReduceOp<Writable, T>> void combine(W accu) {\n        if (accu instanceof LongWritableOp)\n            operation.combine(((LongWritableOp) accu).getOperation());\n        else\n            throw new UnsupportedOperationException(\"Tried to combine() incompatible \" + accu.getClass().getName()\n                            + \" operator where \" + this.getClass().getName() + \" expected\");\n    }\n\n    @Override\n    public void accept(Writable writable) {\n        operation.accept(writable.toLong());\n    }\n\n    @Override\n    public T get() {\n        return operation.get();\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":54,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/datavec/datavec-api/src/main/java/org/datavec/api/transform/ops/LongWritableOp.java#L22-L54","documentation":"LongWritableOp.combine() can only merge state with another LongWritableOp accumulator, because the underlying per-column reduce operation expects Long values. When handed a different IAggregableReduceOp implementation (typically from combining reductions over mismatched columns), it throws UnsupportedOperationException naming both classes. This is a programming/alignment bug, not a data problem.","triggerScenarios":"Calling combine(accu) on a LongWritableOp with an accumulator of any other class, e.g. combining reduce results from a String column with those from a Long column, or mixing AggregableReductionUtils outputs across column types (common in distributed/spark aggregation combine phases).","commonSituations":"Custom reduce pipelines where column metadata and the reduce-op list get out of sync; parallel aggregation where reducers are combined positionally but columns were reordered; hand-rolled IAggregableReduceOp implementations passed to an existing reduce.","solutions":["Check that every accumulator you combine was produced for the same column type as the target LongWritableOp (Long/Int columns only).","Inspect the accu class name in the message and trace where that accumulator was created; fix the column-to-op mapping at creation time (see AggregableReductionUtils.reduceColumn).","If you need to combine heterogeneous accumulators, combine them per-column first (each column's ops combined only with matching-type ops), then assemble results."],"exampleFix":"// before: positional combine over mixed columns\nfor (int i = 0; i < ops.size(); i++) ops.get(0).combine(ops.get(i));\n// after: only combine same-typed accumulators\nfor (IAggregableReduceOp<Writable, T> op : ops)\n    if (op.getClass() == ops.get(0).getClass()) ops.get(0).combine(op);","handlingStrategy":"validation","validationCode":"Schema s = transformProcess.getFinalSchema();\n// ensure the column being reduced is Integer/Long before building LongWritableOp-based reducers\nif (!metaData.getColumnType().equals(ColumnType.Integer) && !metaData.getColumnType().equals(ColumnType.Long))\n    throw new IllegalArgumentException(\"Expected Integer/Long column, got \" + metaData.getColumnType());","typeGuard":"if (!(accu instanceof LongWritableOp)) throw new IllegalArgumentException(\"cannot combine \" + accu.getClass().getName());","tryCatchPattern":"try { op.combine(accu); } catch (UnsupportedOperationException e) { log.error(\"Incompatible accumulator: {}\", e.getMessage()); throw e; }","preventionTips":["Keep a 1:1 mapping between column types and reduce-op instances.","Never reorder or interleave accumulator lists between partial reductions.","Unit-test combine() with accumulators produced by the same pipeline configuration."],"tags":["unsupported-operation","type-mismatch","datavec","reduce"],"backgroundTag":"unsupported-operation","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}