Skip to content

Commit

Permalink
Modify the return value of DateDataPoint.getValue() (#321)
Browse files Browse the repository at this point in the history
* modify the return value of DateDataPoint.getValue()

* add ut
  • Loading branch information
shuwenwei authored Dec 3, 2024
1 parent 686bbab commit 00e6b7b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void writeTo(long time, ChunkWriterImpl writer) throws IOException {

@Override
public Object getValue() {
return value;
return DateUtils.parseDateExpressionToInt(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.tsfile.utils.TsFileGeneratorUtils;
import org.apache.tsfile.write.chunk.AlignedChunkWriterImpl;
import org.apache.tsfile.write.chunk.ChunkWriterImpl;
import org.apache.tsfile.write.record.TSRecord;
import org.apache.tsfile.write.record.Tablet;
import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
Expand All @@ -54,6 +55,7 @@
import java.nio.ByteBuffer;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -132,6 +134,40 @@ public void writeWithTsRecord() throws IOException, WriteProcessException {
}
}

@Test
public void writeTSRecordWithAllDateType() throws IOException, WriteProcessException {
setEnv(100 * 1024 * 1024, 10 * 1024);
try (TsFileWriter writer = new TsFileWriter(f)) {
List<IMeasurementSchema> measurementList =
Arrays.asList(
new MeasurementSchema("s1", TSDataType.INT32),
new MeasurementSchema("s2", TSDataType.INT64),
new MeasurementSchema("s3", TSDataType.BOOLEAN),
new MeasurementSchema("s4", TSDataType.FLOAT),
new MeasurementSchema("s5", TSDataType.DOUBLE),
new MeasurementSchema("s6", TSDataType.DATE),
new MeasurementSchema("s7", TSDataType.TIMESTAMP),
new MeasurementSchema("s8", TSDataType.TEXT),
new MeasurementSchema("s9", TSDataType.BLOB),
new MeasurementSchema("s10", TSDataType.STRING));
writer.registerAlignedTimeseries("root.test.d1", measurementList);

TSRecord tsRecord = new TSRecord("root.test.d1", 1);
tsRecord.addPoint("s1", 1);
tsRecord.addPoint("s2", 1L);
tsRecord.addPoint("s3", true);
tsRecord.addPoint("s4", 1.0f);
tsRecord.addPoint("s5", 1.0d);
tsRecord.addPoint("s6", LocalDate.now());
tsRecord.addPoint("s7", System.currentTimeMillis());
tsRecord.addPoint("s8", "text value");
tsRecord.addPoint("s9", "blob value");
tsRecord.addPoint("s10", "string value");

writer.writeRecord(tsRecord);
}
}

@Test
public void writeAlignedWithTsRecord() throws IOException, WriteProcessException {
setEnv(100 * 1024 * 1024, 10 * 1024);
Expand Down

0 comments on commit 00e6b7b

Please sign in to comment.