yifan-c commented on code in PR #102: URL: https://github.com/apache/cassandra-analytics/pull/102#discussion_r1995977546
########## cassandra-analytics-common/src/main/java/org/apache/cassandra/bridge/type/InternalDuration.java: ########## @@ -0,0 +1,78 @@ +/* + * 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.cassandra.bridge.type; + +import java.io.Serializable; +import java.util.Objects; + +/** + * Analytics-internal Duration type to bridge CQL Duration type. + */ +public class InternalDuration implements Serializable +{ + private static final long serialVersionUID = -6867844786318937949L; + public final int months; + public final int days; + public final long nanoseconds; + + public InternalDuration(int months, int days, long nanoseconds) + { + this.months = months; + this.days = days; + this.nanoseconds = nanoseconds; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + InternalDuration that = (InternalDuration) o; + return months == that.months && + days == that.days && + nanoseconds == that.nanoseconds; + } + + @Override + public int hashCode() + { + return Objects.hash(months, days, nanoseconds); + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + if (this.months < 0 || this.days < 0 || this.nanoseconds < 0L) + { + builder.append('-'); + } Review Comment: CQL duration validate all non-zero fields are all negative or all positive. Since this is consuming from data that is validated by Cassandra already, I think this condition is fine. -- 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: commits-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org