未验证 提交 1d2bb339 编写于 作者: C Cobalt-27 提交者: GitHub

fix(std): fix trailing digits in double conversions (#297) (#2055)

上级 b5a28d8e
......@@ -601,6 +601,10 @@ public final class Numbers {
return 63 - Long.numberOfLeadingZeros(value);
}
/**
* Clinger's fast path:
* https://www.researchgate.net/publication/2295884_How_to_Read_Floating_Point_Numbers_Accurately
*/
public static double parseDouble(CharSequence sequence) throws NumericException {
int lim = sequence.length();
......@@ -634,7 +638,7 @@ public final class Numbers {
int dpe = lim;
int exp = 0;
int dexp = -1; //exponent position
out:
for (; i < lim; i++) {
final int c = sequence.charAt(i);
......@@ -673,14 +677,14 @@ public final class Numbers {
break;
}
}
if ( dp == -1 && dexp == -1 ){
if (dp == -1 && dexp == -1) {
dp = lim;//implicit decimal point
}
if ( dp != -1 ){
int adjust = dp < lim && dpe > dp ? 1 : 0;
exp = exp - (dpe - dp - adjust );
if (dp != -1) {
int adjust = dp < lim && dpe > dp ? 1 : 0;
exp = exp - (dpe - dp - adjust);
}
if (exp > 308) {
......@@ -692,7 +696,7 @@ public final class Numbers {
if (exp > -1) {
return (negative ? -val : val) * pow10d[exp];
} else {
return (negative ? -val : val) * pow10dNeg[-exp];
return (negative ? -val : val) / pow10d[-exp];
}
}
......@@ -728,7 +732,7 @@ public final class Numbers {
int dpe = lim;
int exp = 0;
int dexp = -1; //exponent position
out:
for (int i = p; i < lim; i++) {
int c = sequence.charAt(i);
......@@ -769,13 +773,13 @@ public final class Numbers {
}
}
if ( dp == -1 && dexp == -1 ){
if (dp == -1 && dexp == -1) {
dp = lim;//implicit decimal point
}
if ( dp != -1 ){
if (dp != -1) {
int adjust = dp < lim && dpe > dp ? 1 : 0;
exp = exp - (dpe - dp - adjust );
exp = exp - (dpe - dp - adjust);
}
if (exp > 38) {
......
......@@ -668,7 +668,7 @@ public class LineTcpInsertOtherTypesTest extends BaseLineTcpContextTest {
"value\ttimestamp\n" +
"1.7976931348623157E308\t1970-01-01T00:00:02.000000Z\n" +
"0.425667788123\t1970-01-01T00:00:03.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:04.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:04.000000Z\n" +
"1.7976931348623157E308\t1970-01-01T00:00:05.000000Z\n" +
"1.7976931348623153E308\t1970-01-01T00:00:06.000000Z\n" +
"Infinity\t1970-01-01T00:00:07.000000Z\n" +
......@@ -717,13 +717,13 @@ public class LineTcpInsertOtherTypesTest extends BaseLineTcpContextTest {
assertTypeNoTable("value\ttimestamp\n" +
"1.7976931348623157E308\t1970-01-01T00:00:01.000000Z\n" +
"0.425667788123\t1970-01-01T00:00:02.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:04.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:04.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:05.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:06.000000Z\n" +
"1.35E12\t1970-01-01T00:00:07.000000Z\n" +
"1.35E12\t1970-01-01T00:00:09.000000Z\n" +
"-3.5\t1970-01-01T00:00:10.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:11.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:11.000000Z\n" +
"1.7976931348623153E308\t1970-01-01T00:00:12.000000Z\n" +
"Infinity\t1970-01-01T00:00:13.000000Z\n" +
"-Infinity\t1970-01-01T00:00:14.000000Z\n" +
......@@ -813,7 +813,7 @@ public class LineTcpInsertOtherTypesTest extends BaseLineTcpContextTest {
public void testInsertFloatTableDoesNotExist() throws Exception {
assertTypeNoTable("value\ttimestamp\n" +
"0.425667788123\t1970-01-01T00:00:01.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:02.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:02.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:03.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:04.000000Z\n" +
"1.35E12\t1970-01-01T00:00:05.000000Z\n" +
......
......@@ -427,7 +427,7 @@ public class LineTcpReceiverTest extends AbstractLineTcpReceiverTest {
sendLinger(receiver, lineData, "tableCRASH");
String expected = "tag_n_1\ttag_n_2\ttag_n_3\ttag_n_4\ttag_n_5\ttag_n_6\ttag_n_7\ttag_n_8\ttag_n_9\ttag_n_10\ttag_n_11\ttag_n_12\ttag_n_13\ttag_n_14\ttag_n_15\ttag_n_16\ttag_n_17\tvalue\ttimestamp\n" +
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t42.400000000000006\t2021-04-27T07:40:49.714000Z\n";
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t42.4\t2021-04-27T07:40:49.714000Z\n";
assertTable(expected, "tableCRASH");
});
}
......
......@@ -627,7 +627,7 @@ public class LineUdpInsertOtherTypesTest extends LineUdpInsertTest {
"value\ttimestamp\n" +
"1.7976931348623157E308\t1970-01-01T00:00:02.000000Z\n" +
"0.425667788123\t1970-01-01T00:00:03.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:04.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:04.000000Z\n" +
"1.7976931348623157E308\t1970-01-01T00:00:05.000000Z\n" +
"1.7976931348623153E308\t1970-01-01T00:00:06.000000Z\n" +
"Infinity\t1970-01-01T00:00:07.000000Z\n" +
......@@ -670,13 +670,13 @@ public class LineUdpInsertOtherTypesTest extends LineUdpInsertTest {
assertTypeNoTable("value\ttimestamp\n" +
"1.7976931348623157E308\t1970-01-01T00:00:01.000000Z\n" +
"0.425667788123\t1970-01-01T00:00:02.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:04.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:04.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:05.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:06.000000Z\n" +
"1.35E12\t1970-01-01T00:00:07.000000Z\n" +
"1.35E12\t1970-01-01T00:00:09.000000Z\n" +
"-3.5\t1970-01-01T00:00:10.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:11.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:11.000000Z\n" +
"1.7976931348623153E308\t1970-01-01T00:00:12.000000Z\n" +
"Infinity\t1970-01-01T00:00:13.000000Z\n" +
"-Infinity\t1970-01-01T00:00:14.000000Z\n" +
......@@ -754,7 +754,7 @@ public class LineUdpInsertOtherTypesTest extends LineUdpInsertTest {
public void testInsertFloatTableDoesNotExist() throws Exception {
assertTypeNoTable("value\ttimestamp\n" +
"0.425667788123\t1970-01-01T00:00:01.000000Z\n" +
"3.1415926535897936\t1970-01-01T00:00:02.000000Z\n" +
"3.141592653589793\t1970-01-01T00:00:02.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:03.000000Z\n" +
"1.35E-12\t1970-01-01T00:00:04.000000Z\n" +
"1.35E12\t1970-01-01T00:00:05.000000Z\n" +
......
......@@ -60,8 +60,8 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
private void testAddColumnInteger(short colType, String nullValue) throws Exception {
final String expected = "tag\ttag2\tfield\tf4\tfield2\tfx\ttimestamp\tf5\n" +
"abc\txyz\t100\t9.034\tstr\ttrue\t1970-01-01T00:01:40.000000Z\t" + nullValue + "\n" +
"woopsie\tdaisy\t127\t3.0889100000000003\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t" + nullValue + "\n" +
"444\td555\t110\t1.4000000000000001\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t55\n" +
"woopsie\tdaisy\t127\t3.08891\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t" + nullValue + "\n" +
"444\td555\t110\t1.4\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t55\n" +
"666\t777\t40\t1.1\tcomment\\ X\tfalse\t1970-01-01T00:01:40.000000Z\t" + nullValue + "\n";
final String lines = "tab,tag=abc,tag2=xyz field=100i,f4=9.034,field2=\"str\",fx=true 100000000000\n" +
......@@ -94,8 +94,8 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
public void testAddColumnDefaultDouble() throws Exception {
testAddColumnFloat(ColumnType.DOUBLE, "tag\ttag2\tfield\tf4\tfield2\tfx\ttimestamp\tf5\n" +
"abc\txyz\t100\t9.034\tstr\ttrue\t1970-01-01T00:01:40.000000Z\tNaN\n" +
"woopsie\tdaisy\t127\t3.0889100000000003\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\tNaN\n" +
"444\td555\t110\t1.4000000000000001\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t55.0\n" +
"woopsie\tdaisy\t127\t3.08891\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\tNaN\n" +
"444\td555\t110\t1.4\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\t55.0\n" +
"666\t777\t40\t1.1\tcomment\\ X\tfalse\t1970-01-01T00:01:40.000000Z\tNaN\n");
}
......@@ -287,7 +287,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\t15\ttrue\tstring1\t1970-01-01T00:25:00.000000Z\t\n" +
"\tNaN\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -309,7 +309,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\t15\ttrue\tstring1\t1970-01-01T00:25:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -353,7 +353,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\t15\ttrue\tstring1\t1970-01-01T00:25:00.000000Z\t\n" +
"\t1.3\tNaN\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -375,7 +375,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\tNaN\ttrue\tstring1\t1970-01-01T00:25:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -397,7 +397,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\tNaN\ttrue\tstring1\t1970-01-01T00:25:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -418,7 +418,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym2\tdouble\tint\tbool\tstr\ttimestamp\tsym1\n" +
"\t1.3\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t9.4\t6\tfalse\tstring3\t1970-01-01T00:25:00.000000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -439,7 +439,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym2\tdouble\tint\tbool\tstr\ttimestamp\tsym1\n" +
"xyz\t1.6\t15\ttrue\tstring1\t1970-01-01T00:00:01.234000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t1970-01-01T00:25:00.000000Z\tabc\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t1970-01-01T00:25:00.000000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t1970-01-01T00:28:20.000000Z\n" +
......@@ -547,7 +547,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
public void testCreateAndAppend() throws Exception {
final String expected = "tag\ttag2\tfield\tf4\tfield2\tfx\ttimestamp\n" +
"abc\txyz\t10000\t9.034\tstr\ttrue\t1970-01-01T00:01:40.000000Z\n" +
"woopsie\tdaisy\t2000\t3.0889100000000003\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\n";
"woopsie\tdaisy\t2000\t3.08891\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\n";
final String lines = "tab,tag=abc,tag2=xyz field=10000i,f4=9.034,field2=\"str\",fx=true 100000000000\n" +
"tab,tag=woopsie,tag2=daisy field=2000i,f4=3.08891,field2=\"comment\",fx=true 100000000000\n";
......@@ -562,7 +562,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\t15\ttrue\tstring1\t2017-10-03T10:00:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t2017-10-03T10:00:00.010000Z\tabc\n" +
"\t0.9\t6\tfalse\tstring3\t2017-10-03T10:00:00.030000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.050000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.050000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.020000Z\n" +
......@@ -620,7 +620,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
"xyz\t1.6\t15\ttrue\tstring1\t2017-10-03T10:00:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t2017-10-03T10:00:00.010000Z\tabc\n" +
"\tNaN\t6\tfalse\tstring3\t2017-10-03T10:00:00.030000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.050000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.050000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.020000Z\n" +
......@@ -641,7 +641,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym2\tdouble\tint\tbool\tstr\ttimestamp\tsym1\n" +
"xyz\t1.6\t15\ttrue\tstring1\t2017-10-03T10:00:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t2017-10-03T10:00:00.010000Z\tabc\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.020000Z\n" +
......@@ -662,7 +662,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym2\tdouble\tint\tbool\tstr\ttimestamp\tsym1\n" +
"xyz\t1.6\t15\ttrue\tstring1\t2017-10-03T10:00:00.000000Z\t\n" +
"\t1.3\t11\tfalse\tstring2\t2017-10-03T10:00:00.010000Z\tabc\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.020000Z\n" +
......@@ -683,7 +683,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym2\tdouble\tint\tbool\tstr\ttimestamp\tsym1\n" +
"xyz\t1.6\t15\ttrue\tstring1\t2017-10-03T10:00:00.000000Z\t\n" +
"\t9.4\t6\tfalse\tstring3\t2017-10-03T10:00:00.020000Z\trow3\n" +
"\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
"\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\trow4\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.010000Z\n" +
......@@ -704,7 +704,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
final String expected1 = "sym1\tdouble\tint\tbool\tstr\ttimestamp\n" +
"abc\t1.3\t11\tfalse\tstring2\t2017-10-03T10:00:00.000000Z\n" +
"row3\t9.4\t6\tfalse\tstring3\t2017-10-03T10:00:00.020000Z\n" +
"row4\t0.30000000000000004\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\n";
"row4\t0.3\t91\ttrue\tstring4\t2017-10-03T10:00:00.040000Z\n";
final String expected2 = "asym1\tasym2\tadouble\ttimestamp\n" +
"55\tbox\t5.9\t2017-10-03T10:00:00.010000Z\n" +
......@@ -724,7 +724,7 @@ public class LineUdpParserImplTest extends AbstractCairoTest {
public void testAddTag() throws Exception {
final String expected = "tag\ttag3\tfield\tf4\tfield2\tfx\ttimestamp\ttag2\n" +
"abc\txyz\t10000\t9.034\tstr\ttrue\t1970-01-01T00:01:40.000000Z\t\n" +
"woopsie\t\t2000\t3.0889100000000003\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\tdaisy\n";
"woopsie\t\t2000\t3.08891\tcomment\ttrue\t1970-01-01T00:01:40.000000Z\tdaisy\n";
final String lines = "tab,tag=abc,tag3=xyz field=10000i,f4=9.034,field2=\"str\",fx=true 100000000000\n" +
"tab,tag=woopsie,tag2=daisy field=2000i,f4=3.08891,field2=\"comment\",fx=true 100000000000\n";
assertThat(expected, lines, "tab");
......
......@@ -226,16 +226,16 @@ public class LinuxLineUdpProtoReceiverTest extends AbstractCairoTest {
private void assertReceive(LineUdpReceiverConfiguration receiverCfg, ReceiverFactory factory) throws Exception {
TestUtils.assertMemoryLeak(() -> {
final String expected = "colour\tshape\tsize\ttimestamp\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4000000000000004\t1970-01-01T00:01:40.000000Z\n";
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n" +
"blue\tx square\t3.4\t1970-01-01T00:01:40.000000Z\n";
try (CairoEngine engine = new CairoEngine(configuration)) {
try (AbstractLineProtoUdpReceiver receiver = factory.create(receiverCfg, engine, null, false, null, null, metrics)) {
......
......@@ -5158,7 +5158,7 @@ create table tab as (
">50000000675f5f6173796e6370675f73746d745f315f5f000a20202020202020202020202073656c656374202a2066726f6d202774616232272077686572652061203e2024310a2020202020202020202020204c494d4954203130300a20202020202020200000004400000018535f5f6173796e6370675f73746d745f315f5f004800000004\n" +
"<3100000004740000000a0001000002bd540000001a00016100000000000001000002bd0008ffffffff0000\n" +
">420000002e005f5f6173796e6370675f73746d745f315f5f00000100010001000000083fd999999999999a00010001450000000900000000005300000004\n" +
"<320000000444000000120001000000083fe6666666666667430000000d53454c4543542031005a0000000549\n" +
"<320000000444000000120001000000083fe6666666666666430000000d53454c4543542031005a0000000549\n" +
">5800000004\n";
assertHexScript(
getFragmentedSendFacade(),
......@@ -6957,7 +6957,7 @@ create table tab as (
try (ResultSet rs = ps.executeQuery()) {
assertResultSet(
"device_id[VARCHAR],column_name[VARCHAR],value[DOUBLE],timestamp[TIMESTAMP]\n" +
"d1,c1,101.30000000000001,1970-01-01 00:00:00.000002\n",
"d1,c1,101.3,1970-01-01 00:00:00.000002\n",
sink,
rs
);
......@@ -6988,10 +6988,10 @@ create table tab as (
try (ResultSet rs = ps.executeQuery()) {
assertResultSet(
"device_id[VARCHAR],column_name[VARCHAR],value[DOUBLE],timestamp[TIMESTAMP]\n" +
"d2,c1,201.20000000000002,1970-01-01 00:00:00.000001\n" +
"d2,c1,201.2,1970-01-01 00:00:00.000001\n" +
"d1,c1,101.2,1970-01-01 00:00:00.000001\n" +
"d2,c1,201.3,1970-01-01 00:00:00.000002\n" +
"d1,c1,101.30000000000001,1970-01-01 00:00:00.000002\n",
"d1,c1,101.3,1970-01-01 00:00:00.000002\n",
sink,
rs
);
......@@ -7007,7 +7007,7 @@ create table tab as (
assertResultSet(
"device_id[VARCHAR],column_name[VARCHAR],value[DOUBLE],timestamp[TIMESTAMP]\n" +
"d1,c1,101.2,1970-01-01 00:00:00.000001\n" +
"d1,c1,101.30000000000001,1970-01-01 00:00:00.000002\n",
"d1,c1,101.3,1970-01-01 00:00:00.000002\n",
sink,
rs
);
......
......@@ -552,12 +552,12 @@ public class TextLoaderTest extends AbstractGriffinTest {
assertNoLeak(textLoader -> {
final String expected = "f0\tf1\tf2\tf3\tf4\tf5\tf6\n" +
"123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\ttrue\tLorem ipsum dolor sit amet.\t122\n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.3420000000000005\tfalse\tLorem ipsum \n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.342\tfalse\tLorem ipsum \n" +
"\n" +
"dolor \"sit\" amet.\t546756\n" +
"125\tabc\t2015-01-20T21:00:00.000Z\t9.334\tfalse\tLorem ipsum \"dolor\" sit amet.\t23\n" +
"126\tabc\t2015-01-20T21:00:00.000Z\t1.345\ttrue\tLorem, ipsum, dolor sit amet.\t434\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.5332100000000002\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.53321\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"128\tabc\t2015-01-20T21:00:00.000Z\t2.456\ttrue\tLorem ipsum dolor sit amet.\t122\n";
String csv = "123,abc,2015-01-20T21:00:00.000Z,3.1415,TRUE,Lorem ipsum dolor sit amet.,122\r\n" +
......@@ -589,12 +589,12 @@ public class TextLoaderTest extends AbstractGriffinTest {
assertNoLeak(textLoader -> {
final String expected = "f0\tf1\tf2\tf3\tf4\tf5\tf6\n" +
"123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\ttrue\tLorem ipsum dolor sit amet.\t122\n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.3420000000000005\tfalse\tLorem ipsum \n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.342\tfalse\tLorem ipsum \n" +
"\n" +
"dolor \"sit\" amet.\t546756\n" +
"125\tabc\t2015-01-20T21:00:00.000Z\t9.334\tfalse\tLorem ipsum \"dolor\" sit amet.\t23\n" +
"126\tabc\t2015-01-20T21:00:00.000Z\t1.345\ttrue\tLorem, ipsum, dolor sit amet.\t434\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.5332100000000002\ttrue\tLorem ipsum dolor sit amet.\t112\n";
"127\tabc\t2015-01-20T21:00:00.000Z\t1.53321\ttrue\tLorem ipsum dolor sit amet.\t112\n";
String csv = "123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\tTRUE\tLorem ipsum dolor sit amet.\t122\n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.342\tFALSE\t\"Lorem ipsum \n" +
......@@ -1178,29 +1178,29 @@ public class TextLoaderTest extends AbstractGriffinTest {
engine,
textLoader -> {
String expected = "s\n" +
"0.5035558920000001\n" +
"0.5370835850000001\n" +
"0.503555892\n" +
"0.537083585\n" +
"0.518392756\n" +
"0.898078974\n" +
"0.153959029\n" +
"0.368878817\n" +
"0.7685725170000001\n" +
"0.768572517\n" +
"0.409412157\n" +
"0.959138401\n" +
"0.49868191100000003\n" +
"0.498681911\n" +
"0.466161354\n" +
"0.6500869570000001\n" +
"0.650086957\n" +
"0.201807867\n" +
"0.699247724\n" +
"0.8836387710000001\n" +
"0.883638771\n" +
"0.855572368\n" +
"0.7143630950000001\n" +
"0.14668836100000002\n" +
"0.714363095\n" +
"0.146688361\n" +
"0.507968298\n" +
"0.064159752\n" +
"0.19579689800000002\n" +
"0.7118503740000001\n" +
"0.24136422300000002\n";
"0.195796898\n" +
"0.711850374\n" +
"0.241364223\n";
String csv = "s\n" +
......@@ -1450,20 +1450,20 @@ public class TextLoaderTest extends AbstractGriffinTest {
public void testLoadRowsWithExtraColumns() throws Exception {
assertNoLeak(textLoader -> {
final String expected = "VendorID\tlpep_pickup_datetime\tLpep_dropoff_datetime\tStore_and_fwd_flag\tRateCodeID\tPickup_longitude\tPickup_latitude\tDropoff_longitude\tDropoff_latitude\tPassenger_count\tTrip_distance\tFare_amount\tExtra\tMTA_tax\tTip_amount\tTolls_amount\tEhail_fee\tTotal_amount\tPayment_type\tTrip_type\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T19:18:34.000Z\tN\t1\t0\t0\t-73.87202453613283\t40.678714752197266\t6\t7.0200000000000005\t28.5\t0.0\t0.5\t0.0\t0\t\t29.0\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T13:10:37.000Z\tN\t1\t0\t0\t-73.91783905029298\t40.75776672363282\t1\t5.43\t23.5\t0.0\t0.5\t5.88\t0\t\t29.88\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T19:18:34.000Z\tN\t1\t0\t0\t-73.87202453613281\t40.678714752197266\t6\t7.02\t28.5\t0.0\t0.5\t0.0\t0\t\t29.0\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T13:10:37.000Z\tN\t1\t0\t0\t-73.91783905029298\t40.75776672363281\t1\t5.43\t23.5\t0.0\t0.5\t5.88\t0\t\t29.88\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T14:36:16.000Z\tN\t1\t0\t0\t-73.88289642333984\t40.87045669555664\t1\t0.84\t5.0\t0.0\t0.5\t0.0\t0\t\t5.5\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T02:51:03.000Z\tN\t1\t0\t0\t0.0\t0.0\t1\t8.98\t26.5\t0.5\t0.5\t5.4\t0\t\t32.9\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T03:13:09.000Z\tN\t1\t0\t0\t0.0\t0.0\t1\t0.91\t5.5\t0.5\t0.5\t0.0\t0\t\t6.5\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T14:12:18.000Z\tN\t1\t0\t0\t0.0\t0.0\t1\t2.88\t13.0\t0.0\t0.5\t2.6\t0\t\t16.1\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T19:37:31.000Z\tN\t1\t0\t0\t0.0\t0.0\t1\t2.04\t9.0\t0.0\t0.5\t0.0\t0\t\t9.5\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T08:05:26.000Z\tN\t1\t0\t0\t-73.86398315429689\t40.89520645141602\t1\t7.61\t22.5\t0.0\t0.5\t0.0\t0\t\t23.0\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T08:05:26.000Z\tN\t1\t0\t0\t-73.86398315429688\t40.895206451416016\t1\t7.61\t22.5\t0.0\t0.5\t0.0\t0\t\t23.0\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T17:02:26.000Z\tN\t1\t0\t0\t0.0\t0.0\t1\t3.37\t14.0\t0.0\t0.5\t7.5\t0\t\t22.0\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T10:45:08.000Z\tN\t1\t0\t0\t-73.98382568359375\t40.67216491699219\t5\t2.98\t11.0\t0.0\t0.5\t0.0\t0\t\t11.5\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T19:23:12.000Z\tN\t1\t0\t0\t-73.89750671386719\t40.856563568115234\t1\t6.1000000000000005\t21.0\t0.0\t0.5\t4.2\t0\t\t25.700000000000003\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T20:30:34.000Z\tN\t1\t0\t0\t-73.83473205566408\t40.769981384277344\t1\t4.03\t13.5\t0.5\t0.5\t0.0\t0\t\t14.5\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T02:11:02.000Z\tN\t1\t0\t0\t-73.9626922607422\t40.80527877807618\t1\t11.02\t36.5\t0.5\t0.5\t9.25\t0\t\t46.75\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T01:12:02.000Z\tN\t1\t0\t0\t-73.81257629394531\t40.72515869140625\t1\t2.98\t11.0\t0.5\t0.5\t2.3000000000000003\t0\t\t14.3\t1\t1\n";
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T19:23:12.000Z\tN\t1\t0\t0\t-73.89750671386719\t40.856563568115234\t1\t6.1\t21.0\t0.0\t0.5\t4.2\t0\t\t25.7\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T20:30:34.000Z\tN\t1\t0\t0\t-73.83473205566406\t40.769981384277344\t1\t4.03\t13.5\t0.5\t0.5\t0.0\t0\t\t14.5\t2\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T02:11:02.000Z\tN\t1\t0\t0\t-73.96269226074219\t40.80527877807618\t1\t11.02\t36.5\t0.5\t0.5\t9.25\t0\t\t46.75\t1\t1\n" +
"2\t2014-03-01T00:00:00.000Z\t2014-03-01T01:12:02.000Z\tN\t1\t0\t0\t-73.81257629394531\t40.72515869140625\t1\t2.98\t11.0\t0.5\t0.5\t2.3\t0\t\t14.3\t1\t1\n";
String csv = "VendorID,lpep_pickup_datetime,Lpep_dropoff_datetime,Store_and_fwd_flag,RateCodeID,Pickup_longitude,Pickup_latitude,Dropoff_longitude,Dropoff_latitude,Passenger_count,Trip_distance,Fare_amount,Extra,MTA_tax,Tip_amount,Tolls_amount,Ehail_fee,Total_amount,Payment_type,Trip_type\n" +
"\n" +
......@@ -2094,12 +2094,12 @@ public class TextLoaderTest extends AbstractGriffinTest {
assertNoLeak(textLoader -> {
final String expected = "f0\tf1\tf2\tf3\tf4\tf5\tf6\n" +
"123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\ttrue\tLorem ipsum dolor sit amet.\t122\n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.3420000000000005\tfalse\tLorem ipsum \n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.342\tfalse\tLorem ipsum \n" +
"\n" +
"dolor \"sit\" amet.\t546756\n" +
"125\tabc\t2015-01-20T21:00:00.000Z\t9.334\tfalse\tLorem ipsum \"dolor\" sit amet.\t23\n" +
"126\tabc\t2015-01-20T21:00:00.000Z\t1.345\ttrue\tLorem, ipsum, dolor sit amet.\t434\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.5332100000000002\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.53321\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"128\tabc\t2015-01-20T21:00:00.000Z\t2.456\ttrue\tLorem ipsum dolor sit amet.\t122\n";
String csv = "123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\tTRUE\tLorem ipsum dolor sit amet.\t122\n" +
......@@ -2131,12 +2131,12 @@ public class TextLoaderTest extends AbstractGriffinTest {
assertNoLeak(textLoader -> {
final String expected = "f0\tf1\tf2\tf3\tf4\tf5\tf6\n" +
"123\tabc\t2015-01-20T21:00:00.000Z\t3.1415\ttrue\tLorem ipsum dolor sit amet.\t122\n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.3420000000000005\tfalse\tLorem ipsum \n" +
"124\tabc\t2015-01-20T21:00:00.000Z\t7.342\tfalse\tLorem ipsum \n" +
"\n" +
"dolor \"sit\" amet.\t546756\n" +
"125\tabc\t2015-01-20T21:00:00.000Z\t9.334\tfalse\tLorem ipsum \"dolor\" sit amet.\t23\n" +
"126\tabc\t2015-01-20T21:00:00.000Z\t1.345\ttrue\tLorem, ipsum, dolor sit amet.\t434\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.5332100000000002\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"127\tabc\t2015-01-20T21:00:00.000Z\t1.53321\ttrue\tLorem ipsum dolor sit amet.\t112\n" +
"128\tabc\t2015-01-20T21:00:00.000Z\t2.456\ttrue\tLorem ipsum dolor sit amet.\t122\n";
String csv = "123|abc|2015-01-20T21:00:00.000Z|3.1415|TRUE|Lorem ipsum dolor sit amet.|122\n" +
......
......@@ -96,7 +96,7 @@ public class CopyTest extends AbstractGriffinTest {
"CMP2\t7\t6103\t6.36347207706422\t2015-01-24T19:15:09.000Z\t2015-01-24T19:15:09.000Z\t2015-01-24T00:00:00.000Z\t6047\tfalse\t84767095\n" +
"CMP1\t7\t1313\t7.38160170149058\t2015-01-25T19:15:09.000Z\t2015-01-25T19:15:09.000Z\t2015-01-25T00:00:00.000Z\t3837\ttrue\t13178079\n" +
"CMP1\t1\t9952\t5.43148486176506\t2015-01-26T19:15:09.000Z\t2015-01-26T19:15:09.000Z\t2015-01-26T00:00:00.000Z\t5578\tfalse\t61000112\n" +
"CMP2\t2\t5589\t3.8917106972076003\t2015-01-27T19:15:09.000Z\t\t2015-01-27T00:00:00.000Z\t4153\ttrue\t43900701\n" +
"CMP2\t2\t5589\t3.8917106972076\t2015-01-27T19:15:09.000Z\t\t2015-01-27T00:00:00.000Z\t4153\ttrue\t43900701\n" +
"CMP1\t3\t9438\t3.90446535777301\t2015-01-28T19:15:09.000Z\t2015-01-28T19:15:09.000Z\t2015-01-28T00:00:00.000Z\t6363\tfalse\t88289909\n" +
"CMP2\t8\t8000\t2.27636352181435\t2015-01-29T19:15:09.000Z\t2015-01-29T19:15:09.000Z\t2015-01-29T00:00:00.000Z\t323\ttrue\t14925407\n" +
"CMP1\t2\t1581\t9.01423481060192\t2015-01-30T19:15:09.000Z\t2015-01-30T19:15:09.000Z\t2015-01-30T00:00:00.000Z\t9138\tfalse\t68225213\n" +
......@@ -127,7 +127,7 @@ public class CopyTest extends AbstractGriffinTest {
"CMP2\t3\t9117\t6.16650991374627\t2015-02-24T19:15:09.000Z\t2015-02-24T19:15:09.000Z\t2015-02-24T00:00:00.000Z\t3588\ttrue\t4354364\n" +
"CMP1\t6\t2745\t6.12624417291954\t2015-02-25T19:15:09.000Z\t2015-02-25T19:15:09.000Z\t2015-02-25T00:00:00.000Z\t6149\tfalse\t71925383\n" +
"CMP2\t2\t986\t4.00966874323785\t2015-02-26T19:15:09.000Z\t2015-02-26T19:15:09.000Z\t2015-02-26T00:00:00.000Z\t4099\ttrue\t53416732\n" +
"CMP1\t7\t8510\t0.8291012421250341\t2015-02-27T19:15:09.000Z\t2015-02-27T19:15:09.000Z\t2015-02-27T00:00:00.000Z\t6459\tfalse\t17817647\n" +
"CMP1\t7\t8510\t0.829101242125034\t2015-02-27T19:15:09.000Z\t2015-02-27T19:15:09.000Z\t2015-02-27T00:00:00.000Z\t6459\tfalse\t17817647\n" +
"CMP2\t6\t2368\t4.37540231039748\t2015-02-28T19:15:09.000Z\t2015-02-28T19:15:09.000Z\t2015-02-28T00:00:00.000Z\t7812\ttrue\t99185079\n" +
"CMP1\t6\t1758\t8.40889546554536\t2015-03-01T19:15:09.000Z\t2015-03-01T19:15:09.000Z\t2015-03-01T00:00:00.000Z\t7485\tfalse\t46226610\n" +
"CMP2\t4\t4049\t1.08890570467338\t2015-03-02T19:15:09.000Z\t2015-03-02T19:15:09.000Z\t2015-03-02T00:00:00.000Z\t4412\ttrue\t54936589\n" +
......@@ -143,10 +143,10 @@ public class CopyTest extends AbstractGriffinTest {
"CMP2\t1\t1731\t6.87037272611633\t2015-03-12T19:15:09.000Z\t2015-03-12T19:15:09.000Z\t2015-03-12T00:00:00.000Z\t7299\ttrue\t61351111\n" +
"CMP1\t7\t6530\t9.17741159442812\t2015-03-13T19:15:09.000Z\t2015-03-13T19:15:09.000Z\t2015-03-13T00:00:00.000Z\t4186\tfalse\t68200832\n" +
"CMP2\t6\t441\t9.87805142300203\t2015-03-14T19:15:09.000Z\t2015-03-14T19:15:09.000Z\t2015-03-14T00:00:00.000Z\t6256\ttrue\t25615453\n" +
"CMP1\t8\t6476\t0.6236567208543421\t2015-03-15T19:15:09.000Z\t2015-03-15T19:15:09.000Z\t2015-03-15T00:00:00.000Z\t8916\tfalse\t11378657\n" +
"CMP1\t8\t6476\t0.623656720854342\t2015-03-15T19:15:09.000Z\t2015-03-15T19:15:09.000Z\t2015-03-15T00:00:00.000Z\t8916\tfalse\t11378657\n" +
"CMP2\t3\t9245\t4.85969736473635\t2015-03-16T19:15:09.000Z\t2015-03-16T19:15:09.000Z\t2015-03-16T00:00:00.000Z\t5364\ttrue\t72902099\n" +
"CMP1\t5\t135\t0.71932214545086\t2015-03-17T19:15:09.000Z\t2015-03-17T19:15:09.000Z\t2015-03-17T00:00:00.000Z\t6172\tfalse\t94911256\n" +
"CMP2\t6\t5662\t0.9344037040136751\t2015-03-18T19:15:09.000Z\t2015-03-18T19:15:09.000Z\t2015-03-18T00:00:00.000Z\t3228\ttrue\t71957668\n" +
"CMP2\t6\t5662\t0.934403704013675\t2015-03-18T19:15:09.000Z\t2015-03-18T19:15:09.000Z\t2015-03-18T00:00:00.000Z\t3228\ttrue\t71957668\n" +
"CMP1\t7\t8820\t2.26465462474152\t2015-03-19T19:15:09.000Z\t2015-03-19T19:15:09.000Z\t2015-03-19T00:00:00.000Z\t5414\tfalse\t37676934\n" +
"CMP2\t1\t1673\t1.13900111755356\t2015-03-20T19:15:09.000Z\t2015-03-20T19:15:09.000Z\t2015-03-20T00:00:00.000Z\t792\ttrue\t45159973\n" +
"CMP1\t6\t8704\t7.43929118616506\t2015-03-21T19:15:09.000Z\t2015-03-21T19:15:09.000Z\t2015-03-21T00:00:00.000Z\t4887\tfalse\t27305661\n" +
......@@ -175,12 +175,12 @@ public class CopyTest extends AbstractGriffinTest {
"CMP2\t6\t4692\t2.76645212434232\t2015-04-13T19:15:09.000Z\t2015-04-13T19:15:09.000Z\t2015-04-13T00:00:00.000Z\t4201\ttrue\t28465709\n" +
"CMP1\t7\t7116\t6.58135131234303\t2015-04-14T19:15:09.000Z\t2015-04-14T19:15:09.000Z\t2015-04-14T00:00:00.000Z\t3892\tfalse\t48420564\n" +
"CMP2\t3\t2457\t5.60338953277096\t2015-04-15T19:15:09.000Z\t2015-04-15T19:15:09.000Z\t2015-04-15T00:00:00.000Z\t7053\ttrue\t33039439\n" +
"CMP1\t8\t9975\t0.16938636312261202\t2015-04-16T19:15:09.000Z\t2015-04-16T19:15:09.000Z\t2015-04-16T00:00:00.000Z\t6874\tfalse\t6451182\n" +
"CMP1\t8\t9975\t0.169386363122612\t2015-04-16T19:15:09.000Z\t2015-04-16T19:15:09.000Z\t2015-04-16T00:00:00.000Z\t6874\tfalse\t6451182\n" +
"CMP2\t5\t4952\t0.968641364015639\t2015-04-17T19:15:09.000Z\t2015-04-17T19:15:09.000Z\t2015-04-17T00:00:00.000Z\t1680\ttrue\t77366482\n" +
"CMP1\t6\t2024\t1.11267756437883\t2015-04-18T19:15:09.000Z\t2015-04-18T19:15:09.000Z\t2015-04-18T00:00:00.000Z\t3883\tfalse\t65946538\n" +
"CMP2\t2\t7689\t6.29668754525483\t2015-04-19T19:15:09.000Z\t2015-04-19T19:15:09.000Z\t2015-04-19T00:00:00.000Z\t254\ttrue\t15272074\n" +
"CMP1\t1\t9916\t0.24603431345894902\t2015-04-20T19:15:09.000Z\t2015-04-20T19:15:09.000Z\t2015-04-20T00:00:00.000Z\t7768\tfalse\t24934386\n" +
"CMP2\t8\t2034\t7.2211763379164005\t2015-04-21T19:15:09.000Z\t2015-04-21T19:15:09.000Z\t2015-04-21T00:00:00.000Z\t8514\ttrue\t26112211\n" +
"CMP1\t1\t9916\t0.246034313458949\t2015-04-20T19:15:09.000Z\t2015-04-20T19:15:09.000Z\t2015-04-20T00:00:00.000Z\t7768\tfalse\t24934386\n" +
"CMP2\t8\t2034\t7.2211763379164\t2015-04-21T19:15:09.000Z\t2015-04-21T19:15:09.000Z\t2015-04-21T00:00:00.000Z\t8514\ttrue\t26112211\n" +
"CMP1\t8\t673\t4.48250063927844\t2015-04-22T19:15:09.000Z\t2015-04-22T19:15:09.000Z\t2015-04-22T00:00:00.000Z\t2455\tfalse\t51949360\n" +
"CMP2\t3\t6513\t4.39972517313436\t2015-04-23T19:15:09.000Z\t2015-04-23T19:15:09.000Z\t2015-04-23T00:00:00.000Z\t7307\ttrue\t74090772\n" +
"CMP1\t2\t8509\t7.21647302387282\t2015-04-24T19:15:09.000Z\t2015-04-24T19:15:09.000Z\t2015-04-24T00:00:00.000Z\t1784\tfalse\t43610015\n" +
......@@ -195,7 +195,7 @@ public class CopyTest extends AbstractGriffinTest {
"CMP2\tNaN\t2848\t5.32819046406075\t2015-05-03T19:15:09.000Z\t2015-05-03T19:15:09.000Z\t2015-05-03T00:00:00.000Z\t7628\ttrue\t36732064\n" +
"CMP1\tNaN\t2776\t5.30948682921007\t2015-05-04T19:15:09.000Z\t2015-05-04T19:15:09.000Z\t2015-05-04T00:00:00.000Z\t5917\tfalse\t59635623\n" +
"CMP2\t8\t5256\t8.02117716753855\t2015-05-05T19:15:09.000Z\t2015-05-05T19:15:09.000Z\t2015-05-05T00:00:00.000Z\t4088\ttrue\t50247928\n" +
"CMP1\t7\t9250\t0.8500805334188041\t2015-05-06T19:15:09.000Z\t2015-05-06T19:15:09.000Z\t2015-05-06T00:00:00.000Z\t519\tfalse\t61373305\n" +
"CMP1\t7\t9250\t0.850080533418804\t2015-05-06T19:15:09.000Z\t2015-05-06T19:15:09.000Z\t2015-05-06T00:00:00.000Z\t519\tfalse\t61373305\n" +
"CMP2\t2\t6675\t7.95846320921555\t2015-05-07T19:15:09.000Z\t2015-05-07T19:15:09.000Z\t2015-05-07T00:00:00.000Z\t7530\ttrue\t49634855\n" +
"CMP1\t5\t8367\t9.34185237856582\t2015-05-08T19:15:09.000Z\t2015-05-08T19:15:09.000Z\t2015-05-08T00:00:00.000Z\t9714\tfalse\t91106929\n" +
"CMP2\t4\t370\t7.84945336403325\t2015-05-09T19:15:09.000Z\t2015-05-09T19:15:09.000Z\t2015-05-09T00:00:00.000Z\t8590\ttrue\t89638043\n" +
......
......@@ -36,7 +36,7 @@ public class PowerTest extends AbstractGriffinTest {
"select power(10.2, 3)",
sink,
"power\n" +
"1061.2080000000003\n"
"1061.2079999999999\n"
));
}
......
......@@ -4261,7 +4261,7 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
") timestamp(t)",
"a\tb\tk\n" +
"54.55175324785665\tHYRX\t1970-02-02T07:00:00.000000Z\n" +
"88.10000000000001\tXYZ\t1971-01-01T00:00:00.000000Z\n",
"88.1\tXYZ\t1971-01-01T00:00:00.000000Z\n",
true,
true,
true
......@@ -7038,12 +7038,12 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
// "d2\tc1\t201.10000000000002\t2021-10-05T11:31:35.878000Z\n" +
// "d1\tc2\t102.10000000000001\t2021-10-05T11:31:35.878000Z\n" +
// "d1\tc1\t101.10000000000001\t2021-10-05T11:31:35.878000Z\n" +
// "d2\tc1\t201.20000000000002\t2021-10-05T12:31:35.878000Z\n" +
// "d2\tc1\t201.2\t2021-10-05T12:31:35.878000Z\n" +
// "d1\tc2\t102.2\t2021-10-05T12:31:35.878000Z\n" +
// "d1\tc1\t101.2\t2021-10-05T12:31:35.878000Z\n" +
// "d2\tc1\t201.3\t2021-10-05T13:31:35.878000Z\n" +
// "d1\tc2\t102.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
// "d1\tc1\t101.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
// "d1\tc1\t101.3\t2021-10-05T13:31:35.878000Z\n" +
// "d2\tc1\t201.4\t2021-10-05T14:31:35.878000Z\n" +
// "d1\tc2\t102.4\t2021-10-05T14:31:35.878000Z\n" +
// "d1\tc1\t101.4\t2021-10-05T14:31:35.878000Z\n" +
......@@ -7057,8 +7057,8 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
// "d2\tc1\t201.10000000000002\t2021-10-05T11:31:35.878000Z\n" +
// "d1\tc1\t101.2\t2021-10-05T12:31:35.878000Z\n" +
// "d1\tc2\t102.2\t2021-10-05T12:31:35.878000Z\n" +
// "d2\tc1\t201.20000000000002\t2021-10-05T12:31:35.878000Z\n" +
// "d1\tc1\t101.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
// "d2\tc1\t201.2\t2021-10-05T12:31:35.878000Z\n" +
// "d1\tc1\t101.3\t2021-10-05T13:31:35.878000Z\n" +
// "d1\tc2\t102.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
// "d2\tc1\t201.3\t2021-10-05T13:31:35.878000Z\n" +
// "d1\tc1\t101.4\t2021-10-05T14:31:35.878000Z\n" +
......@@ -7102,8 +7102,8 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
"d2\tc1\t201.10000000000002\t2021-10-05T11:31:35.878000Z\n" +
"d1\tc1\t101.2\t2021-10-05T12:31:35.878000Z\n" +
"d1\tc2\t102.2\t2021-10-05T12:31:35.878000Z\n" +
"d2\tc1\t201.20000000000002\t2021-10-05T12:31:35.878000Z\n" +
"d1\tc1\t101.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
"d2\tc1\t201.2\t2021-10-05T12:31:35.878000Z\n" +
"d1\tc1\t101.3\t2021-10-05T13:31:35.878000Z\n" +
"d1\tc2\t102.30000000000001\t2021-10-05T13:31:35.878000Z\n" +
"d2\tc1\t201.3\t2021-10-05T13:31:35.878000Z\n" +
"d1\tc1\t101.4\t2021-10-05T14:31:35.878000Z\n" +
......
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2022 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package io.questdb.griffin;
import io.questdb.std.Rnd;
import io.questdb.test.tools.TestUtils;
import org.junit.Assert;
import org.junit.Test;
public class TrailingDigitsTest extends AbstractGriffinTest {
/**
* Test if output contains trailing digits with a simple test case.
*/
@Test
public void simpleDoubleConversionTest() throws Exception {
assertMemoryLeak(
() -> {
TestUtils.printSql(
compiler,
sqlExecutionContext,
"select * from (select 111.1111111 as val)",
sink
);
TestUtils.assertEquals("val\n111.1111111\n", sink);
}
);
}
/**
* Generate multiple test cases to test if trailing digits exists.
*/
@Test
public void testDoubleConversion() throws SqlException {
int cases = 1000;
for (int digits = 11; digits <= 14; digits++)
Assert.assertEquals(passCount(cases, digits), cases);
}
/**
* Check trailing digits for the conversion of input with given digits.
* @param cases the number of generated cases
* @param digits the digits count of generated input, should be greater than 5
*/
private int passCount(int cases, int digits) throws SqlException {
Assert.assertTrue(digits>5);
int pass = 0;
char[] s = new char[digits];
Rnd rnd = new Rnd();
for (int t = 0; t < cases; t++) {
for (int i = 0; i < s.length; i++) {
s[i] = (char) (rnd.nextPositiveInt() % 9 + '1');
}
int dp = rnd.nextPositiveInt() % (5) + 1;
s[dp] = '.';
String numStr = new String(s);
String expected = "val\n" + numStr + "\n";
TestUtils.printSql(
compiler,
sqlExecutionContext,
"select * from (select " + numStr + " as val)",
sink
);
if (((CharSequence)sink).equals(expected)) {
pass++;
}
}
return pass;
}
}
......@@ -79,7 +79,7 @@ public class TruncateUncachedSymbolTest extends AbstractGriffinTest {
"positions",
sink,
"time\tuuid\tlatitude\tlongitude\thash1\thash2\thash3\thash4\thash5\thash6\thash1i\thash2i\thash3i\thash4i\thash5i\thash6i\n" +
"2020-01-08T17:55:42.000000Z\t123e4567-e89b-12d3-a456-426614174000\t54.180326799999996\t7.8889438\tu\tu1\tu1t\tu1ts\tu1ts5\tu1ts5x\t1\t2\t3\t4\t5\t6\n"
"2020-01-08T17:55:42.000000Z\t123e4567-e89b-12d3-a456-426614174000\t54.1803268\t7.8889438\tu\tu1\tu1t\tu1ts\tu1ts5\tu1ts5x\t1\t2\t3\t4\t5\t6\n"
);
compiler.compile("truncate table positions", sqlExecutionContext);
......
......@@ -4635,9 +4635,9 @@ public class CastTest extends AbstractGriffinTest {
"a\n" +
"1234.556\n" +
"NaN\n" +
"988.2230000000001\n" +
"988.223\n" +
"NaN\n" +
"988.2230000000001\n" +
"988.223\n" +
"NaN\n" +
"NaN\n" +
"NaN\n" +
......@@ -4647,7 +4647,7 @@ public class CastTest extends AbstractGriffinTest {
"1234.556\n" +
"NaN\n" +
"NaN\n" +
"988.2230000000001\n",
"988.223\n",
true,
true,
true
......@@ -4969,9 +4969,9 @@ public class CastTest extends AbstractGriffinTest {
"a\n" +
"1234.556\n" +
"NaN\n" +
"988.2230000000001\n" +
"988.223\n" +
"NaN\n" +
"988.2230000000001\n" +
"988.223\n" +
"NaN\n" +
"NaN\n" +
"NaN\n" +
......@@ -4981,7 +4981,7 @@ public class CastTest extends AbstractGriffinTest {
"1234.556\n" +
"NaN\n" +
"NaN\n" +
"988.2230000000001\n",
"988.223\n",
true,
true,
true
......
......@@ -75,7 +75,7 @@ public class SumDoubleVecGroupByFunctionFactoryTest extends AbstractGriffinTest
null,
"insert into tab select 0.9822 from long_sequence(1)",
"sum\n" +
"0.9822000000000001\n",
"0.9822\n",
false,
true,
true
......
......@@ -57,7 +57,7 @@ public class NegFunctionFactoryTest extends AbstractGriffinTest {
@Test
public void testNegDouble() throws Exception {
assertNeg("select -x, typeOf(-x) from (select 5.6 x)", "-5.6000000000000005\tDOUBLE\n");
assertNeg("select -x, typeOf(-x) from (select 5.6 x)", "-5.6\tDOUBLE\n");
}
@Test
......
......@@ -146,7 +146,7 @@ public class RoundHalfEvenDoubleFunctionFactoryConstTest extends AbstractGriffin
public void testOKPosScale17() throws SqlException {
assertQuery(
"round_half_even\n" +
"14.777800000000003\n",
"14.777800000000001\n",
"select round_half_even(14.7778, 15) from long_sequence(1)",
null,
true,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册