Skip to content

Commit

Permalink
modify DeviceTableModelWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei committed Dec 3, 2024
1 parent 872dd2f commit 1aabcc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.tsfile.write.chunk.AlignedChunkGroupWriterImpl;
import org.apache.tsfile.write.chunk.IChunkGroupWriter;
import org.apache.tsfile.write.chunk.NonAlignedChunkGroupWriterImpl;
import org.apache.tsfile.write.chunk.TableChunkGroupWriterImpl;
import org.apache.tsfile.write.schema.Schema;
import org.apache.tsfile.write.writer.TsFileIOWriter;

Expand Down Expand Up @@ -139,11 +140,15 @@ protected AbstractTableModelTsFileWriter(File file, long chunkGroupSizeThreshold
}
}

protected IChunkGroupWriter tryToInitialGroupWriter(IDeviceID deviceId, boolean isAligned) {
protected IChunkGroupWriter tryToInitialGroupWriter(
IDeviceID deviceId, boolean isAligned, boolean isTableModel) {
IChunkGroupWriter groupWriter = groupWriters.get(deviceId);
if (groupWriter == null) {
if (isAligned) {
groupWriter = new AlignedChunkGroupWriterImpl(deviceId, encryptParam);
groupWriter =
isTableModel
? new TableChunkGroupWriterImpl(deviceId, encryptParam)
: new AlignedChunkGroupWriterImpl(deviceId, encryptParam);
((AlignedChunkGroupWriterImpl) groupWriter)
.setLastTime(alignedDeviceLastTimeMap.get(deviceId));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void write(Tablet table) throws IOException, WriteProcessException {
for (Pair<IDeviceID, Integer> pair : deviceIdEndIndexPairs) {
// get corresponding ChunkGroupWriter and write this Tablet
recordCount +=
tryToInitialGroupWriter(pair.left, isTableWriteAligned)
tryToInitialGroupWriter(pair.left, isTableWriteAligned, true)
.write(table, startIndex, pair.right);
startIndex = pair.right;
}
Expand Down

0 comments on commit 1aabcc8

Please sign in to comment.