This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 0af05d5 Fix float precision test in memtable (#90)
0af05d5 is described below
commit 0af05d530b30f55042ef32c2a15f94f6ef43d710
Author: Xiangdong Huang <[email protected]>
AuthorDate: Fri Mar 8 23:47:14 2019 +0800
Fix float precision test in memtable (#90)
* fix float precision in PrimitiveMemTableTest
---
.../db/engine/memtable/PrimitiveMemTableTest.java | 26 ++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git
a/iotdb/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
b/iotdb/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
index da1eb89..01f43bb 100644
---
a/iotdb/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
+++
b/iotdb/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
@@ -25,14 +25,23 @@ import java.util.Random;
import org.apache.iotdb.db.utils.MathUtils;
import org.apache.iotdb.db.utils.TimeValuePair;
import org.apache.iotdb.db.utils.TsPrimitiveType;
+import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.utils.Binary;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
public class PrimitiveMemTableTest {
+ double delta;
+
+ @Before
+ public void setUp() {
+ delta = Math.pow(0.1, TSFileConfig.floatPrecision);
+ }
+
@Test
public void memSeriesCloneTest() {
TSDataType dataType = TSDataType.INT32;
@@ -105,11 +114,12 @@ public class PrimitiveMemTableTest {
TimeValuePair next = tvPair.next();
Assert.assertEquals(pair.getTimestamp(), next.getTimestamp());
if (dataType == TSDataType.DOUBLE) {
-
Assert.assertEquals(MathUtils.roundWithGivenPrecision(pair.getValue().getDouble()),
- next.getValue().getDouble(), 0.0001);
+ Assert.assertEquals(pair.getValue().getDouble(),
+ MathUtils.roundWithGivenPrecision(next.getValue().getDouble()),
delta);
} else if (dataType == TSDataType.FLOAT) {
-
Assert.assertEquals(MathUtils.roundWithGivenPrecision(pair.getValue().getFloat()),
- next.getValue().getFloat(), 0.0001);
+ float expected = pair.getValue().getFloat();
+ float actual =
MathUtils.roundWithGivenPrecision(next.getValue().getFloat());
+ Assert.assertEquals(expected, actual, delta+ Float.MIN_NORMAL);
} else {
Assert.assertEquals(pair.getValue(), next.getValue());
}
@@ -117,6 +127,14 @@ public class PrimitiveMemTableTest {
}
@Test
+ public void testFloatType() {
+ IMemTable memTable = new PrimitiveMemTable();
+ String deviceId = "d1";
+ int size = 1000000;
+ write(memTable, deviceId, "s1", TSDataType.FLOAT, size);
+ }
+
+ @Test
public void testAllType() {
IMemTable memTable = new PrimitiveMemTable();
int count = 10;