Mrart commented on code in PR #4060: URL: https://github.com/apache/flink-cdc/pull/4060#discussion_r2292796377
########## flink-cdc-common/src/main/java/org/apache/flink/cdc/common/data/TimeData.java: ########## @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.cdc.common.data; + +import java.time.LocalTime; +import java.util.Objects; + +/** + * An internal data structure representing data of {@link + * org.apache.flink.cdc.common.types.TimeType}. + */ +public class TimeData implements Comparable<TimeData> { + + private static final int SECONDS_TO_MILLIS = 1000; + private static final int MILLIS_TO_MICRO = 1000; + private static final int MILLIS_TO_NANO = 1_000_000; + + private final int millisOfDay; + + private TimeData(int millisOfDay) { + this.millisOfDay = millisOfDay; + } + + public static TimeData fromSecondOfDay(int secondOfDay) { + return new TimeData(secondOfDay * SECONDS_TO_MILLIS); + } + + public static TimeData fromMillisOfDay(int millisOfDay) { + return new TimeData(millisOfDay); + } + + public static TimeData fromMicroOfDay(long microOfDay) { + return new TimeData((int) (microOfDay / MILLIS_TO_MICRO)); + } + + public static TimeData fromNanoOfDay(long nanoOfDay) { + // millisOfDay should not exceed 86400000, which is safe to fit into INT. + return new TimeData((int) (nanoOfDay / MILLIS_TO_NANO)); Review Comment: But I seem ok like this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
