leventov commented on a change in pull request #8157: Enum of ResponseContext 
keys
URL: https://github.com/apache/incubator-druid/pull/8157#discussion_r308780090
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/druid/query/context/ResponseContext.java
 ##########
 @@ -44,9 +47,47 @@
 public abstract class ResponseContext
 {
   /**
-   * Keys associated with objects in the context.
+   * The base interface of a response context key.
+   * Should be implemented by every context key.
    */
-  public enum Key
+  public interface BaseKey
+  {
+    String getName();
+    /**
+     * Merge function associated with a key: Object (Object oldValue, Object 
newValue)
+     */
+    BiFunction<Object, Object, Object> getMergeFunction();
+  }
+
+  /**
+   * Keys associated with objects in the context. The enum is 
extension-friendly.
+   * <p>If it's necessary to have some new keys in the context then they could 
be described in a separate enum:
+   * <pre>{@code
+   * public enum ExtensionResponseContextKey implements BaseKey
+   * {
+   *   EXTENSION_KEY_1("extension_key_1"), EXTENSION_KEY_2("extension_key_2");
+   *
+   *   static {
+   *     for (ResponseContextKey key : values()) 
ResponseContext.Key.addKey(key);
+   *   }
+   *
+   *   private final String name;
+   *   private final BiFunction<Object, Object, Object> mergeFunction;
+   *
+   *   ExtensionResponseContextKey(String name)
+   *   {
+   *     this.name = name;
+   *     this.mergeFunction = (oldValue, newValue) -> newValue;
+   *   }
+   *
+   *   @Override public String getName() { return name; }
+   *
+   *   @Override public BiFunction<Object, Object, Object> getMergeFunction() 
{ return mergeFunction; }
+   * }
+   * }</pre>
+   * Make sure all extension enum values added with Key.addKey method.
 
 Review comment:
   Please make `Key.addKey` a `{@link }`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to