From ebd1f8382664b8ce9c16a726f99376266c6faa3e Mon Sep 17 00:00:00 2001 From: rbool Date: Tue, 1 Mar 2016 13:17:27 +0100 Subject: [PATCH 1/2] fix bug on ZIP function when handling a list with only singletons --- .../java/io/warp10/continuum/gts/ZIP.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java b/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java index fe9aee430..8f05883ad 100644 --- a/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java +++ b/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java @@ -49,7 +49,7 @@ public Object apply(WarpScriptStack stack) throws WarpScriptException { // Check the size of the various lists, they are either singletons or of the same size // - int len = -1; + int len = 1; for (Object o: metalist) { if (!(o instanceof List)) { @@ -66,7 +66,7 @@ public Object apply(WarpScriptStack stack) throws WarpScriptException { continue; } - if (-1 == len) { + if (1 == len) { len = size; } else if (size != len) { throw new WarpScriptException(getName() + " operates on lists of lists. All lists which are not singletons must be of the same size."); @@ -77,6 +77,21 @@ public Object apply(WarpScriptStack stack) throws WarpScriptException { List> results = new ArrayList>(); + // in the case the list contains only singletons, we concatenate them together. + if (1 == len) { + List flat = new ArrayList(); + + for (Object l : metalist) { + flat.add(((List) l).get(0)); + } + + results.add(flat); + + stack.push(results); + + return stack; + } + while (i < len) { List l = new ArrayList(); From e571d2a73e8fb146d57865cf6ffe93fb61814679 Mon Sep 17 00:00:00 2001 From: rbool Date: Tue, 1 Mar 2016 14:06:30 +0100 Subject: [PATCH 2/2] fix simplified --- .../main/java/io/warp10/continuum/gts/ZIP.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java b/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java index 8f05883ad..7d89e9adb 100644 --- a/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java +++ b/warp10/src/main/java/io/warp10/continuum/gts/ZIP.java @@ -77,21 +77,6 @@ public Object apply(WarpScriptStack stack) throws WarpScriptException { List> results = new ArrayList>(); - // in the case the list contains only singletons, we concatenate them together. - if (1 == len) { - List flat = new ArrayList(); - - for (Object l : metalist) { - flat.add(((List) l).get(0)); - } - - results.add(flat); - - stack.push(results); - - return stack; - } - while (i < len) { List l = new ArrayList();