smiklosovic commented on code in PR #4297: URL: https://github.com/apache/cassandra/pull/4297#discussion_r2270577907
########## src/java/org/apache/cassandra/cql3/constraints/ConstraintResolver.java: ########## @@ -0,0 +1,162 @@ +/* + * 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.cql3.constraints; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.ServiceLoader; +import java.util.function.Function; + +import com.google.common.annotations.VisibleForTesting; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.cassandra.cql3.constraints.SatisfiabilityChecker.UnaryFunctionSatisfiabilityChecker; +import org.apache.cassandra.utils.LocalizeString; + +public class ConstraintResolver +{ + private static final Logger logger = LoggerFactory.getLogger(ConstraintResolver.class); + + @VisibleForTesting + public static ConstraintProvider customConstraintProvider = ServiceLoader.load(ConstraintProvider.class).findFirst().orElse(null); Review Comment: @sarankk I was thinking about this and my original patch before creating PR was like that. But then, it opens a lot of "questions" / problems. For example, you might have two providers which provide a constraint of same name. Which one wins? The one which is found first? Is this deterministic? Or we fail? One solution to this problem is to provide `int priority()` method to this interface, then load all provides and sort them by priority and iterate over them like that. But that means that if two providers have same priority then we are where we were (or we might fail in that case). Also it would be more involved when it comes to constraints satisfiability checkers etc ... For all these reasons I just stick with one provider to KISS. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

