gianm commented on code in PR #17564: URL: https://github.com/apache/druid/pull/17564#discussion_r1915338478
########## processing/src/main/java/org/apache/druid/query/policy/RowFilterPolicy.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.druid.query.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; +import org.apache.druid.query.filter.DimFilter; +import org.apache.druid.query.filter.Filter; +import org.apache.druid.segment.CursorBuildSpec; +import org.apache.druid.segment.filter.Filters; + +import javax.annotation.Nonnull; +import java.util.Arrays; +import java.util.Objects; + +/** + * Represents a basic row filter policy restriction. + */ +public class RowFilterPolicy implements Policy +{ + private final DimFilter rowFilter; + + @JsonCreator + RowFilterPolicy(@Nonnull @JsonProperty("rowFilter") DimFilter rowFilter) + { + Preconditions.checkNotNull(rowFilter); Review Comment: [minor] two comments about usage of `checkNotNull`: 1. It's good practice to include the name of the variable in the second argument, so the error message is more useful. 2. It returns the value, so you can do it in one line like `this.rowFilter = Preconditions.checkNotNull(rowFilter, "rowFilter");` ########## processing/src/main/java/org/apache/druid/query/DataSource.java: ########## @@ -118,6 +123,26 @@ public interface DataSource */ DataSource withUpdatedDataSource(DataSource newSource); + /** + * Returns the query with an updated datasource based on the policy restrictions on tables. + * <p> + * If this datasource contains no table, no changes should occur. + * + * @param policyMap a mapping of table names to policy restrictions Review Comment: Please add something to the javadoc about the significance of missing-key vs. `Optional.empty` in the map. -- 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]
