Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SegmentZKMetadata time handling #7375

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -65,25 +65,35 @@ public String getSegmentName() {

public long getStartTimeMs() {
if (!_startTimeMsCached) {
long startTimeMs = -1;
String startTimeString = _simpleFields.get(Segment.START_TIME);
if (startTimeString != null && Long.parseLong(startTimeString) > 0) {
_startTimeMs = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT)).toMillis(Long.parseLong(startTimeString));
} else {
_startTimeMs = -1;
if (startTimeString != null) {
long startTime = Long.parseLong(startTimeString);
// NOTE: Need to check whether the start time is positive because some old segment ZK metadata contains negative
// start time and null time unit
if (startTime > 0) {
startTimeMs = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT)).toMillis(startTime);
}
}
_startTimeMs = startTimeMs;
_startTimeMsCached = true;
}
return _startTimeMs;
}

public long getEndTimeMs() {
if (!_endTimeMsCached) {
long endTimeMs = -1;
String endTimeString = _simpleFields.get(Segment.END_TIME);
if (endTimeString != null && Long.parseLong(endTimeString) > 0) {
_endTimeMs = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT)).toMillis(Long.parseLong(endTimeString));
} else {
_endTimeMs = -1;
if (endTimeString != null) {
long endTime = Long.parseLong(endTimeString);
// NOTE: Need to check whether the end time is positive because some old segment ZK metadata contains negative
// end time and null time unit
if (endTime > 0) {
endTimeMs = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT)).toMillis(endTime);
}
}
_endTimeMs = endTimeMs;
_endTimeMsCached = true;
}
return _endTimeMs;
Expand Down Expand Up @@ -409,12 +419,10 @@ public Duration getTimeGranularity() {

@Deprecated
public Interval getTimeInterval() {
String startTimeString = _simpleFields.get(Segment.START_TIME);
if (startTimeString != null) {
String endTimeString = _simpleFields.get(Segment.END_TIME);
TimeUnit timeUnit = TimeUnit.valueOf(_simpleFields.get(Segment.TIME_UNIT));
return new Interval(timeUnit.toMillis(Long.parseLong(startTimeString)),
timeUnit.toMillis(Long.parseLong(endTimeString)));
long startTimeMs = getStartTimeMs();
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it is deprecated, and my IDE did not find any callers. If so, may be just remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove all the deprecated ones in a separate PR so that they are easier to track

long endTimeMs = getEndTimeMs();
if (startTimeMs > 0 && endTimeMs > 0) {
return new Interval(startTimeMs, endTimeMs);
} else {
return null;
}
Expand Down