You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemds.apache.org by GitBox <gi...@apache.org> on 2022/10/24 09:14:12 UTC

[GitHub] [systemds] Baunsgaard commented on a diff in pull request #1677: [SYSTEMDS-3413] Add support for row/col aggregation to countDistinct builtin function

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: dev-unsubscribe@systemds.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org