From cd8b83ffd6c014de6e8dacf288895081caf2ce1a Mon Sep 17 00:00:00 2001 From: Vlad Ilyushchenko Date: Wed, 29 Apr 2020 17:11:14 +0100 Subject: [PATCH] chore: small fixes for ksum/nsum and added logging (#245) --- core/src/main/c/share/vect.cpp | 5 +- .../java/io/questdb/cairo/TableReader.java | 9 +- .../questdb/griffin/GroupByFunctionTest.java | 96 +++++++++---------- 3 files changed, 59 insertions(+), 51 deletions(-) diff --git a/core/src/main/c/share/vect.cpp b/core/src/main/c/share/vect.cpp index 21d2fa383..504e0dd0c 100644 --- a/core/src/main/c/share/vect.cpp +++ b/core/src/main/c/share/vect.cpp @@ -438,7 +438,7 @@ double SUM_DOUBLE_KAHAN(double *d, int64_t count) { double sum = horizontal_add(sumVec); double c = horizontal_add(cVec); - int nans = horizontal_add(nancount); + int64_t nans = horizontal_add(nancount); for (; d < lim; d++) { double x = *d; if (x == x) { @@ -459,6 +459,7 @@ double SUM_DOUBLE_KAHAN(double *d, int64_t count) { } double SUM_DOUBLE_NEUMAIER(double *d, int64_t count) { +// return sumDoubleNeumaier_Vanilla(d, count); Vec8d inputVec; const int step = 8; const auto *lim = d + count; @@ -483,7 +484,7 @@ double SUM_DOUBLE_NEUMAIER(double *d, int64_t count) { double sum = horizontal_add(sumVec); double c = horizontal_add(cVec); - int nans = horizontal_add(nancount); + int64_t nans = horizontal_add(nancount); for (; d < lim; d++) { double input = *d; if (input == input) { diff --git a/core/src/main/java/io/questdb/cairo/TableReader.java b/core/src/main/java/io/questdb/cairo/TableReader.java index 42b2b0cb2..750070265 100644 --- a/core/src/main/java/io/questdb/cairo/TableReader.java +++ b/core/src/main/java/io/questdb/cairo/TableReader.java @@ -578,6 +578,12 @@ public class TableReader implements Closeable { } } } + LOG.info() + .$("purging memory [prevMinTimestamp=").$ts(prevMinTimestamp) + .$(", minTimestamp=").$ts(minTimestamp) + .$(", partitionCount=").$(partitionCount) + .$(']').$(); + // adjust columns list when leading partitions have been removed if (prevMinTimestamp != minTimestamp) { assert prevMinTimestamp < minTimestamp; @@ -989,7 +995,8 @@ public class TableReader implements Closeable { .$("new transaction [txn=").$(txn) .$(", transientRowCount=").$(transientRowCount) .$(", fixedRowCount=").$(fixedRowCount) - .$(", maxTimestamp=").$(maxTimestamp) + .$(", minTimestamp=").$ts(this.minTimestamp) + .$(", maxTimestamp=").$ts(this.maxTimestamp) .$(", attempts=").$(count) .$(']').$(); return true; diff --git a/core/src/test/java/io/questdb/griffin/GroupByFunctionTest.java b/core/src/test/java/io/questdb/griffin/GroupByFunctionTest.java index 06d91785a..7ac56e282 100644 --- a/core/src/test/java/io/questdb/griffin/GroupByFunctionTest.java +++ b/core/src/test/java/io/questdb/griffin/GroupByFunctionTest.java @@ -73,25 +73,6 @@ public class GroupByFunctionTest extends AbstractGriffinTest { ); } - @Test - public void testKeyedNSumDoubleAllNaN() throws Exception { - assertQuery("s\tnsum\n" + - "aa\tNaN\n" + - "bb\tNaN\n", - "select s, nsum(d) nsum from x", - "create table x as " + - "(" + - "select" + - " rnd_symbol('aa','bb') s," + - " NaN d" + - " from" + - " long_sequence(200)" + - ")", - null, - true - ); - } - @Test public void testKeyedKSumDoubleSomeNaN() throws Exception { assertQuery("s\tksum\n" + @@ -111,25 +92,6 @@ public class GroupByFunctionTest extends AbstractGriffinTest { ); } - @Test - public void testKeyedNSumDoubleSomeNaN() throws Exception { - assertQuery("s\tnsum\n" + - "aa\t37.816973659638755\n" + - "bb\t50.90642211368272\n", - "select s, nsum(d) nsum from x", - "create table x as " + - "(" + - "select" + - " rnd_symbol('aa','bb') s," + - " rnd_double(2) d" + - " from" + - " long_sequence(200)" + - ")", - null, - true - ); - } - @Test public void testKeyedMaxDateAllNaN() throws Exception { assertQuery("s\tmin\n" + @@ -453,6 +415,44 @@ public class GroupByFunctionTest extends AbstractGriffinTest { ); } + @Test + public void testKeyedNSumDoubleAllNaN() throws Exception { + assertQuery("s\tnsum\n" + + "aa\tNaN\n" + + "bb\tNaN\n", + "select s, nsum(d) nsum from x", + "create table x as " + + "(" + + "select" + + " rnd_symbol('aa','bb') s," + + " NaN d" + + " from" + + " long_sequence(200)" + + ")", + null, + true + ); + } + + @Test + public void testKeyedNSumDoubleSomeNaN() throws Exception { + assertQuery("s\tnsum\n" + + "aa\t37.816973659638755\n" + + "bb\t50.90642211368272\n", + "select s, nsum(d) nsum from x", + "create table x as " + + "(" + + "select" + + " rnd_symbol('aa','bb') s," + + " rnd_double(2) d" + + " from" + + " long_sequence(200)" + + ")", + null, + true + ); + } + @Test public void testKeyedSumDoubleAllNaN() throws Exception { assertQuery("s\tsum\n" + @@ -585,16 +585,16 @@ public class GroupByFunctionTest extends AbstractGriffinTest { } @Test - public void testVectorNSumDoubleAllNaN() throws Exception { + public void testVectorKSumOneDouble() throws Exception { assertQuery("sum\n" + - "NaN\n", - "select nsum(d) sum from x", + "416711.27751251\n", + "select round(ksum(d),8) sum from x", "create table x as " + "(" + "select" + - " NaN d" + + " rnd_double(2) d" + " from" + - " long_sequence(200)" + + " long_sequence(1000000)" + ")", null, false @@ -602,16 +602,16 @@ public class GroupByFunctionTest extends AbstractGriffinTest { } @Test - public void testVectorKSumOneDouble() throws Exception { + public void testVectorNSumDoubleAllNaN() throws Exception { assertQuery("sum\n" + - "416711.27751251357\n", - "select ksum(d) sum from x", + "NaN\n", + "select nsum(d) sum from x", "create table x as " + "(" + "select" + - " rnd_double(2) d" + + " NaN d" + " from" + - " long_sequence(1000000)" + + " long_sequence(200)" + ")", null, false -- GitLab