Baunsgaard commented on code in PR #1677:
URL: https://github.com/apache/systemds/pull/1677#discussion_r1003068071


##########
src/main/java/org/apache/sysds/lops/PartialAggregate.java:
##########
@@ -342,11 +342,20 @@ else if( dir == Direction.Col )
                        }
 
                        case COUNT_DISTINCT: {
-                               if(dir == Direction.RowCol )
-                                       return "uacd";
+                               switch (dir) {
+                                       case RowCol: return "uacd";
+                                       case Row: return "uacdr";
+                                       case Col: return "uacdc";

Review Comment:
   Maybe throw an exception here in the default case and not use the break.
   This would make errors more informative.



##########
src/main/java/org/apache/sysds/lops/PartialAggregate.java:
##########
@@ -355,6 +364,12 @@ else if( dir == Direction.Col )
                                }
                                break;
                        }
+

Review Comment:
   Same just above here , throw exception instead of break.



##########
src/main/java/org/apache/sysds/runtime/instructions/InstructionUtils.java:
##########
@@ -420,7 +413,40 @@ else if ( opcode.equalsIgnoreCase("uacmin") ) {
                        AggregateOperator agg = new 
AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
                        aggun = new AggregateUnaryOperator(agg, 
ReduceRow.getReduceRowFnObject(), numThreads);
                }
-               
+               else if ( opcode.equalsIgnoreCase("uacd") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT)
+                                       .setDirection(Types.Direction.RowCol)
+                                       
.setIndexFunction(ReduceAll.getReduceAllFnObject());
+               }
+               else if ( opcode.equalsIgnoreCase("uacdr") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT)
+                                       .setDirection(Types.Direction.Row)
+                                       
.setIndexFunction(ReduceCol.getReduceColFnObject());
+               }
+               else if ( opcode.equalsIgnoreCase("uacdc") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT)
+                                       .setDirection(Types.Direction.Col)
+                                       
.setIndexFunction(ReduceRow.getReduceRowFnObject());
+               }
+               else if ( opcode.equalsIgnoreCase("uacdap") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT_APPROX)
+                                       .setDirection(Types.Direction.RowCol)
+                                       
.setIndexFunction(ReduceAll.getReduceAllFnObject());
+               }
+               else if ( opcode.equalsIgnoreCase("uacdapr") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT_APPROX)
+                                       .setDirection(Types.Direction.Row)
+                                       
.setIndexFunction(ReduceCol.getReduceColFnObject());
+               }
+               else if ( opcode.equalsIgnoreCase("uacdapc") ) {
+                       aggun = new 
CountDistinctOperator(AggregateUnaryCPInstruction.AUType.COUNT_DISTINCT_APPROX)
+                                       .setDirection(Types.Direction.Col)
+                                       
.setIndexFunction(ReduceRow.getReduceRowFnObject());
+               }
+               else {
+                       throw new IllegalArgumentException("Cannot parse given 
opcode");

Review Comment:
   I think this is what makes the tests fail. since some code rely on us 
returning the aggun as null i believe.



##########
src/main/java/org/apache/sysds/runtime/matrix/operators/AggregateUnaryOperator.java:
##########
@@ -35,7 +35,7 @@ public class AggregateUnaryOperator extends 
MultiThreadedOperator {
        private static final long serialVersionUID = 6690553323120787735L;
 
        public final AggregateOperator aggOp;
-       public final IndexFunction indexFn;
+       public IndexFunction indexFn;

Review Comment:
   if we can please keep it final.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to