[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user asfgit closed the pull request at: https://github.com/apache/storm/pull/1706 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user HeartSaVioR commented on a diff in the pull request: https://github.com/apache/storm/pull/1706#discussion_r80186596 --- Diff: external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java --- @@ -60,6 +62,25 @@ public static String result(String accumulator) { } + public static class TopN { +public static PriorityQueue init() { + return new PriorityQueue<>(); +} +public static PriorityQueue add(PriorityQueue accumulator, Integer n, Integer val) { + if (accumulator.size() >= n) { --- End diff -- Yes you're right. It'll throw NPE. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user arunmahadevan commented on a diff in the pull request: https://github.com/apache/storm/pull/1706#discussion_r80185268 --- Diff: external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java --- @@ -60,6 +62,25 @@ public static String result(String accumulator) { } + public static class TopN { +public static PriorityQueue init() { + return new PriorityQueue<>(); +} +public static PriorityQueue add(PriorityQueue accumulator, Integer n, Integer val) { + if (accumulator.size() >= n) { --- End diff -- yes, it will throw NPE if n is 0, since it tries to peek from empty queue. will address this. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user HeartSaVioR commented on a diff in the pull request: https://github.com/apache/storm/pull/1706#discussion_r80184767 --- Diff: external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java --- @@ -60,6 +62,25 @@ public static String result(String accumulator) { } + public static class TopN { +public static PriorityQueue init() { + return new PriorityQueue<>(); +} +public static PriorityQueue add(PriorityQueue accumulator, Integer n, Integer val) { + if (accumulator.size() >= n) { --- End diff -- One missed spot is that it should do nothing if n is 0. Now if n is 0, it will behave same as top 1. n should be greater than 0 anyway but we can do some defensive programming. Other then that it looks good. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user arunmahadevan commented on a diff in the pull request: https://github.com/apache/storm/pull/1706#discussion_r80183483 --- Diff: external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java --- @@ -60,6 +62,25 @@ public static String result(String accumulator) { } + public static class TopN { +public static PriorityQueue init() { + return new PriorityQueue<>(); +} +public static PriorityQueue add(PriorityQueue accumulator, Integer n, Integer val) { + if (accumulator.size() >= n) { --- End diff -- Thanks for catching. It should be ```java if (accumulator.size() >= n) { if (val > accumulator.peek()) { accumulator.remove(); accumulator.add(val); } } else { accumulator.add(n); } --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
Github user HeartSaVioR commented on a diff in the pull request: https://github.com/apache/storm/pull/1706#discussion_r80131848 --- Diff: external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java --- @@ -60,6 +62,25 @@ public static String result(String accumulator) { } + public static class TopN { +public static PriorityQueue init() { + return new PriorityQueue<>(); +} +public static PriorityQueue add(PriorityQueue accumulator, Integer n, Integer val) { + if (accumulator.size() >= n) { --- End diff -- Logic need to be changed to add val first, and remove the lowest `if accumulator.size() > n` because val could be lower than lowest value of priority queue. Suppose the input `3, 2, 1`, accumulator will be changed to 3 -> 2, 3 -> 1, 3 (should be 2, 3). We could even do nothing when `(n > 0 && accumulator.size() >= n && accumulator.peek() >= val)`. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] storm pull request #1706: [STORM-2118] A few fixes for storm-sql standalone ...
GitHub user arunmahadevan opened a pull request: https://github.com/apache/storm/pull/1706 [STORM-2118] A few fixes for storm-sql standalone mode 1. Cast the result, accumulator and value types correctly 2. Support aggregate functions with more than one argument You can merge this pull request into a Git repository by running: $ git pull https://github.com/arunmahadevan/storm udf Alternatively you can review and apply these changes as the patch at: https://github.com/apache/storm/pull/1706.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1706 commit 2da36e660dbf3e80db54a209a91d093f520ff7cd Author: Arun Mahadevan Date: 2016-09-15T10:12:25Z [STORM-2118] A few fixes for storm-sql standalone mode 1. Cast the result, accumulator and value types correctly 2. Support aggregate functions with more than one argument --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---