summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java b/container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java
new file mode 100644
index 00000000000..65c3480272e
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/AllUnoverridableQueryProfileVisitor.java
@@ -0,0 +1,45 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.search.query.profile;
+
+import com.yahoo.processing.request.CompoundName;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:bratseth@yahoo-inc.com">Jon Bratseth</a>
+ */
+final class AllUnoverridableQueryProfileVisitor extends PrefixQueryProfileVisitor {
+
+ /** A map of query profile types */
+ private Set<CompoundName> unoverridables = new HashSet<>();
+
+ public AllUnoverridableQueryProfileVisitor(CompoundName prefix) {
+ super(prefix);
+ }
+
+ @Override
+ public void onValue(String name, Object value, DimensionBinding binding, QueryProfile owner) {
+ addUnoverridable(name, currentPrefix.append(name), binding, owner);
+ }
+
+ @Override
+ public void onQueryProfileInsidePrefix(QueryProfile profile, DimensionBinding binding, QueryProfile owner) {
+ addUnoverridable(currentPrefix.last(), currentPrefix, binding, owner);
+ }
+
+ private void addUnoverridable(String localName, CompoundName fullName, DimensionBinding binding, QueryProfile owner) {
+ if (owner == null) return;
+
+ Boolean isOverridable = owner.isLocalOverridable(localName, binding);
+ if (isOverridable != null && ! isOverridable)
+ unoverridables.add(fullName);
+ }
+
+ /** Returns the values resulting from this visiting */
+ public Set<CompoundName> getResult() { return unoverridables; }
+
+ /** Returns false - we are not done until we have seen all */
+ public boolean isDone() { return false; }
+
+}