flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [2/3] flink git commit: [FLINK-2487] [ml] In cosine distance, check that datapoints are of same cardinality
Date Sun, 16 Aug 2015 17:44:36 GMT
[FLINK-2487] [ml] In cosine distance, check that datapoints are of same cardinality

This closes #1021


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/0a7cc023
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/0a7cc023
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/0a7cc023

Branch: refs/heads/master
Commit: 0a7cc02354abc985b92704729a8c12a856056398
Parents: 3c1b5f0
Author: Rucongzhang <zhangrucong@huawei.com>
Authored: Sat Aug 15 17:25:25 2015 +0800
Committer: Stephan Ewen <sewen@apache.org>
Committed: Sun Aug 16 18:25:59 2015 +0200

----------------------------------------------------------------------
 .../streaming/api/windowing/deltafunction/CosineDistance.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/0a7cc023/flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/windowing/deltafunction/CosineDistance.java
----------------------------------------------------------------------
diff --git a/flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/windowing/deltafunction/CosineDistance.java
b/flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/windowing/deltafunction/CosineDistance.java
index 15aaf51..77486d0 100644
--- a/flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/windowing/deltafunction/CosineDistance.java
+++ b/flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/windowing/deltafunction/CosineDistance.java
@@ -52,6 +52,11 @@ public class CosineDistance<DATA> extends ExtractionAwareDeltaFunction<DATA,
dou
 			return 0;
 		}
 
+		if (oldDataPoint.length != newDataPoint.length) {
+			throw new IllegalArgumentException(
+					"The size of two input arrays are not same, can not compute cosine distance");
+		}
+
 		double sum1 = 0;
 		double sum2 = 0;
 		for (int i = 0; i < oldDataPoint.length; i++) {


Mime
View raw message