Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,7 @@ private void readChunkMetadataAndConstructIndexTree() throws IOException {
// serialize the SEPARATOR of MetaData
ReadWriteIOUtils.write(MetaMarker.SEPARATOR, out.wrapAsStream());

TSMIterator tsmIterator =
hasChunkMetadataInDisk
? TSMIterator.getTSMIteratorInDisk(
chunkMetadataTempFile, chunkGroupMetadataList, endPosInCMTForDevice)
: TSMIterator.getTSMIteratorInMemory(chunkGroupMetadataList);
TSMIterator tsmIterator = getTSMIterator();
Map<IDeviceID, MetadataIndexNode> deviceMetadataIndexMap = new TreeMap<>();
Queue<MetadataIndexNode> measurementMetadataIndexQueue = new ArrayDeque<>();
IDeviceID currentDevice = null;
Expand Down Expand Up @@ -532,6 +528,13 @@ private void readChunkMetadataAndConstructIndexTree() throws IOException {
ReadWriteIOUtils.write(size, out.wrapAsStream());
}

protected TSMIterator getTSMIterator() throws IOException {
return hasChunkMetadataInDisk
? TSMIterator.getTSMIteratorInDisk(
chunkMetadataTempFile, chunkGroupMetadataList, endPosInCMTForDevice)
: TSMIterator.getTSMIteratorInMemory(chunkGroupMetadataList);
}

/**
* get the length of normal OutputStream.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.tsfile.file.metadata.TimeseriesMetadata;
import org.apache.tsfile.read.common.Path;
import org.apache.tsfile.read.reader.LocalTsFileInput;
import org.apache.tsfile.read.reader.TsFileInput;
import org.apache.tsfile.utils.Pair;
import org.apache.tsfile.utils.ReadWriteIOUtils;

Expand All @@ -51,8 +52,7 @@ public class DiskTSMIterator extends TSMIterator {
private static final Logger LOG = LoggerFactory.getLogger(DiskTSMIterator.class);

private LinkedList<Long> endPosForEachDevice;
private File cmtFile;
private LocalTsFileInput input;
protected TsFileInput input;
private long fileLength = 0;
private long currentPos = 0;
private long nextEndPosForDevice = 0;
Expand All @@ -65,7 +65,6 @@ protected DiskTSMIterator(
LinkedList<Long> endPosForEachDevice)
throws IOException {
super(chunkGroupMetadataList);
this.cmtFile = cmtFile;
this.endPosForEachDevice = endPosForEachDevice;
this.input = new LocalTsFileInput(cmtFile.toPath());
this.fileLength = cmtFile.length();
Expand All @@ -78,22 +77,24 @@ public boolean hasNext() {
}

@Override
public Pair<Path, TimeseriesMetadata> next() {
public Pair<Path, TimeseriesMetadata> next() throws IOException {
try {
if (remainsInFile) {
// deserialize from file
return getTimeSerisMetadataFromFile();
return getTimeSeriesMetadataFromFile();
} else {
// get from memory iterator
return super.next();
}
} catch (IOException e) {
LOG.error("Meets IOException when reading timeseries metadata from disk", e);
return null;
if (!Thread.currentThread().isInterrupted()) {
LOG.error("Meets IOException when reading timeseries metadata from disk", e);
}
throw e;
}
Comment on lines 89 to 94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May catch ClosedByInterruptException and ignore it.

}

private Pair<Path, TimeseriesMetadata> getTimeSerisMetadataFromFile() throws IOException {
private Pair<Path, TimeseriesMetadata> getTimeSeriesMetadataFromFile() throws IOException {
if (currentPos == nextEndPosForDevice) {
// deserialize the current device name
currentDevice = Deserializer.DEFAULT_DESERIALIZER.deserializeFrom(input.wrapAsInputStream());
Expand Down
Loading