You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/09/23 21:23:37 UTC

[GitHub] [druid] kroeders commented on a change in pull request #10427: ServerSelectorStrategy to filter servers with missing required lookups

kroeders commented on a change in pull request #10427:
URL: https://github.com/apache/druid/pull/10427#discussion_r493903568



##########
File path: extensions-contrib/lookup-aware-server-selector/src/main/java/org/apache/druid/client/selector/filter/lookup/LookupAwareFilterStrategy.java
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.client.selector.filter.lookup;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.druid.client.selector.QueryableDruidServer;
+import org.apache.druid.client.selector.filter.ServerFilterStrategy;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.math.expr.Expr;
+import org.apache.druid.query.DataSource;
+import org.apache.druid.query.JoinDataSource;
+import org.apache.druid.query.LookupDataSource;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.dimension.DimensionSpec;
+import org.apache.druid.query.dimension.ExtractionDimensionSpec;
+import org.apache.druid.query.extraction.CascadeExtractionFn;
+import org.apache.druid.query.extraction.ExtractionFn;
+import org.apache.druid.query.groupby.GroupByQuery;
+import org.apache.druid.query.lookup.RegisteredLookupExtractionFn;
+import org.apache.druid.query.search.SearchQuery;
+import org.apache.druid.query.topn.TopNQuery;
+import org.apache.druid.segment.VirtualColumn;
+import org.apache.druid.segment.VirtualColumns;
+import org.apache.druid.segment.virtual.ExpressionVirtualColumn;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@JsonTypeName("lookupsLoaded")
+public class LookupAwareFilterStrategy implements ServerFilterStrategy
+{
+  public static final String LOOKUPS_CONTEXT_KEY = "lookups";
+  public static final String QUERY_LOOKUPS_CACHE_KEY = "__lookups";
+  private final LookupStatusView lookupStatusView;
+
+  @JsonCreator
+  public LookupAwareFilterStrategy(@JacksonInject LookupStatusView lookupStatusView)
+  {
+    this.lookupStatusView = lookupStatusView;
+  }
+
+  @Override
+  public <T> Set<QueryableDruidServer> filter(Query<T> query, Set<QueryableDruidServer> servers)
+  {
+    if (query == null) {
+      return servers;
+    }
+    final Set<String> lookups;
+    if (query.getContext() != null

Review comment:
       I'm not sure about this use of context, but I would prefer to not calculate the associated lookups in each selection. The withOverridenContext methods return a new Query, so maybe some other way to cache it? I was also wondering if it would be better to calculate a blocked list of servers once and then make the FilteringServerSelectorStrategy operate  on that list, which would allow stacking filters to handle other resiliency issues. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org