This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new 97401d3e Fix encoder and decoder construction of RLBE (#162)
97401d3e is described below
commit 97401d3e21979daed9b999f56d79a0bc2235c2db
Author: Jiang Tian <[email protected]>
AuthorDate: Mon Jul 8 12:24:30 2024 +0800
Fix encoder and decoder construction of RLBE (#162)
---
.../java/org/apache/tsfile/encoding/decoder/Decoder.java | 3 ++-
.../apache/tsfile/encoding/encoder/TSEncodingBuilder.java | 5 ++---
.../apache/tsfile/encoding/decoder/RLBEDecoderTest.java | 14 +++++++++-----
pom.xml | 10 +++++-----
4 files changed, 18 insertions(+), 14 deletions(-)
diff --git
a/java/tsfile/src/main/java/org/apache/tsfile/encoding/decoder/Decoder.java
b/java/tsfile/src/main/java/org/apache/tsfile/encoding/decoder/Decoder.java
index be83a285..36c3d826 100644
--- a/java/tsfile/src/main/java/org/apache/tsfile/encoding/decoder/Decoder.java
+++ b/java/tsfile/src/main/java/org/apache/tsfile/encoding/decoder/Decoder.java
@@ -171,8 +171,9 @@ public abstract class Decoder {
case TIMESTAMP:
return new LongRLBEDecoder();
case FLOAT:
+ return new FloatRLBEDecoder();
case DOUBLE:
- return new FloatDecoder(TSEncoding.valueOf(encoding.toString()),
dataType);
+ return new DoubleRLBEDecoder();
default:
throw new TsFileDecodingException(String.format(ERROR_MSG,
encoding, dataType));
}
diff --git
a/java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/TSEncodingBuilder.java
b/java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/TSEncodingBuilder.java
index 18889438..01b1daa8 100644
---
a/java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/TSEncodingBuilder.java
+++
b/java/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/TSEncodingBuilder.java
@@ -342,8 +342,6 @@ public abstract class TSEncodingBuilder {
public static class RLBE extends TSEncodingBuilder {
- private int maxPointNumber = 0;
-
@Override
public Encoder getEncoder(TSDataType type) {
switch (type) {
@@ -354,8 +352,9 @@ public abstract class TSEncodingBuilder {
case TIMESTAMP:
return new LongRLBE();
case FLOAT:
+ return new FloatRLBE();
case DOUBLE:
- return new FloatEncoder(TSEncoding.RLBE, type, maxPointNumber);
+ return new DoubleRLBE();
default:
throw new UnSupportedDataTypeException("RLBE doesn't support data
type: " + type);
}
diff --git
a/java/tsfile/src/test/java/org/apache/tsfile/encoding/decoder/RLBEDecoderTest.java
b/java/tsfile/src/test/java/org/apache/tsfile/encoding/decoder/RLBEDecoderTest.java
index cc5e1fee..c212f2a2 100644
---
a/java/tsfile/src/test/java/org/apache/tsfile/encoding/decoder/RLBEDecoderTest.java
+++
b/java/tsfile/src/test/java/org/apache/tsfile/encoding/decoder/RLBEDecoderTest.java
@@ -18,10 +18,12 @@
*/
package org.apache.tsfile.encoding.decoder;
-import org.apache.tsfile.encoding.encoder.DoublePrecisionEncoderV1;
import org.apache.tsfile.encoding.encoder.DoubleRLBE;
import org.apache.tsfile.encoding.encoder.Encoder;
import org.apache.tsfile.encoding.encoder.FloatRLBE;
+import org.apache.tsfile.encoding.encoder.TSEncodingBuilder;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.file.metadata.enums.TSEncoding;
import org.junit.After;
import org.junit.Before;
@@ -179,7 +181,8 @@ public class RLBEDecoderTest {
@Test
public void testDouble() throws IOException {
- Encoder encoder = new DoublePrecisionEncoderV1();
+ Encoder encoder =
+
TSEncodingBuilder.RLBE.getEncodingBuilder(TSEncoding.RLBE).getEncoder(TSDataType.DOUBLE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
double value = 7.101f;
int num = 1000;
@@ -188,7 +191,7 @@ public class RLBEDecoderTest {
}
encoder.flush(baos);
ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
- Decoder decoder = new DoublePrecisionDecoderV1();
+ Decoder decoder = Decoder.getDecoderByType(TSEncoding.RLBE,
TSDataType.DOUBLE);
for (int i = 0; i < num; i++) {
if (decoder.hasNext(buffer)) {
assertEquals(value + 2 * i, decoder.readDouble(buffer), delta);
@@ -228,7 +231,8 @@ public class RLBEDecoderTest {
private void testDoubleLength(List<Double> valueList, boolean isDebug, int
repeatCount)
throws Exception {
- Encoder encoder = new DoublePrecisionEncoderV1();
+ Encoder encoder =
+
TSEncodingBuilder.RLBE.getEncodingBuilder(TSEncoding.RLBE).getEncoder(TSDataType.DOUBLE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int i = 0; i < repeatCount; i++) {
for (double value : valueList) {
@@ -240,7 +244,7 @@ public class RLBEDecoderTest {
ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
for (int i = 0; i < repeatCount; i++) {
- Decoder decoder = new DoublePrecisionDecoderV1();
+ Decoder decoder = Decoder.getDecoderByType(TSEncoding.RLBE,
TSDataType.DOUBLE);
for (double value : valueList) {
if (decoder.hasNext(buffer)) {
double value_ = decoder.readDouble(buffer);
diff --git a/pom.xml b/pom.xml
index f93d9f90..de857b15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -668,7 +668,7 @@
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
<python.exe.bin>python3</python.exe.bin>
- <python.compiler.argument> </python.compiler.argument>
+ <python.compiler.argument/>
</properties>
</profile>
<!-- Profile for linux amd64 (mainly AMD Processors) (Self-Enabling)
-->
@@ -687,7 +687,7 @@
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
<python.exe.bin>python3</python.exe.bin>
- <python.compiler.argument> </python.compiler.argument>
+ <python.compiler.argument/>
</properties>
</profile>
<!-- Profile for linux aarch64 (mainly newer Mac or Raspberry PI
Processors) (Self-Enabling) -->
@@ -706,7 +706,7 @@
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
<python.exe.bin>python3</python.exe.bin>
- <python.compiler.argument> </python.compiler.argument>
+ <python.compiler.argument/>
</properties>
</profile>
<!-- Profile for mac x86_64 (mainly Intel Processors) (Self-Enabling)
-->
@@ -724,7 +724,7 @@
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
<python.exe.bin>python3</python.exe.bin>
- <python.compiler.argument> </python.compiler.argument>
+ <python.compiler.argument/>
</properties>
</profile>
<!-- Profile for mac aarch64 (mainly AMD Processors) (Self-Enabling)
-->
@@ -742,7 +742,7 @@
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
<python.exe.bin>python3</python.exe.bin>
- <python.compiler.argument> </python.compiler.argument>
+ <python.compiler.argument/>
</properties>
</profile>
<!-- profile for windows x86_64 (mainly Intel Processors)
(Self-Enabling) -->