Skip to content

Commit

Permalink
[to dev/1.1] Add readItimeseriesMetadata method (#312)
Browse files Browse the repository at this point in the history
* add readITimeseriesMetadata

* fix compile
  • Loading branch information
shuwenwei authored Nov 26, 2024
1 parent d015e7b commit 670a0f5
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,55 @@ public ITimeSeriesMetadata readITimeseriesMetadata(Path path, boolean ignoreNotE
}
}

/**
* Read the TimeseriesMetadata of the given measurement and its successors from the index node
* into the list.
*
* @param timeseriesMetadataList result holder
* @param node index node to be read from
* @param measurement the desired measurement
* @return true if the measurement exists
* @throws IOException when read fails
*/
public boolean readITimeseriesMetadata(
List<TimeseriesMetadata> timeseriesMetadataList, MetadataIndexNode node, String measurement)
throws IOException {
Pair<IMetadataIndexEntry, Long> measurementMetadataIndexPair =
getMetadataAndEndOffsetOfMeasurementNode(node, measurement, true, null);

if (measurementMetadataIndexPair == null) {
return false;
}
long startOffset = measurementMetadataIndexPair.getLeft().getOffset();
long endOffset = measurementMetadataIndexPair.getRight();
TimeseriesMetadata timeseriesMetadata;
if (endOffset - startOffset >= Integer.MAX_VALUE) {
synchronized (this) {
this.position(startOffset);
try {
timeseriesMetadata = TimeseriesMetadata.deserializeFrom(tsFileInput, true);
} catch (Exception e) {
logger.error(
"Something error happened while deserializing TimeseriesMetadata of file {}", file);
throw e;
}
}
} else {
try {
ByteBuffer buffer =
readData(
measurementMetadataIndexPair.left.getOffset(), measurementMetadataIndexPair.right);
timeseriesMetadata = TimeseriesMetadata.deserializeFrom(buffer, true);
} catch (Exception e) {
logger.error(
"Something error happened while deserializing TimeseriesMetadata of file {}", file);
throw e;
}
}
timeseriesMetadataList.add(timeseriesMetadata);
return true;
}

/**
* Find the leaf node that contains path, return all the sensors in that leaf node which are also
* in allSensors set
Expand Down

0 comments on commit 670a0f5

Please sign in to comment.