leventov commented on a change in pull request #8157: Enum of ResponseContext keys URL: https://github.com/apache/incubator-druid/pull/8157#discussion_r308785986
########## File path: processing/src/main/java/org/apache/druid/query/context/ResponseContext.java ########## @@ -84,36 +125,81 @@ ETAG("ETag"), /** * Query fail time (current time + timeout). + * The final value in comparison to continuously updated TIMEOUT_AT. */ - QUERY_FAIL_TIME("queryFailTime"), + QUERY_FAIL_DEADLINE_MILLIS("queryFailTime"), /** * Query total bytes gathered. */ QUERY_TOTAL_BYTES_GATHERED("queryTotalBytesGathered"), /** * This variable indicates when a running query should be expired, * and is effective only when 'timeout' of queryContext has a positive value. + * Continuously updated by {@link org.apache.druid.query.scan.ScanQueryEngine} + * by reducing its value on the time of every scan iteration. */ TIMEOUT_AT("timeoutAt"), /** * The number of scanned rows. + * For backward compatibility the context key name still equals to "count". */ - COUNT( + NUM_SCANNED_ROWS( "count", (oldValue, newValue) -> (long) oldValue + (long) newValue ), /** - * CPU consumed while processing a request. + * The total CPU time for threads related to Sequence processing of the query. + * Resulting value on a Broker is a sum of downstream values from historicals / realtime nodes. + * For additional information see {@link org.apache.druid.query.CPUTimeMetricQueryRunner} */ - CPU_CONSUMED( + CPU_CONSUMED_NANOS( "cpuConsumed", (oldValue, newValue) -> (long) oldValue + (long) newValue ); - private final String name; /** - * Merge function associated with a key: Object (Object oldValue, Object newValue) + * TreeMap is used to have the natural ordering of its keys */ + private static Map<String, BaseKey> map = new TreeMap<>(); + + static { + for (BaseKey key : values()) { + addKey(key); + } + } + + /** + * The primary way of registering context keys. + * Only the keys registered this way are considered during the context merge. + */ + public static void addKey(BaseKey key) + { + Preconditions.checkState( + !map.containsKey(key.getName()), + "ResponseContext keys already has the key with [%s] name", + key.getName() + ); + map.put(key.getName(), key); + } + + /** + * Returns a key associated with the name if the key was added via addKey method + */ + public static BaseKey keyOf(String name) + { + return map.get(name); + } + + /** + * Returns all keys the enum contains and the added via addKey method + */ + public static Collection<BaseKey> getKeys() Review comment: Suggested "getAllRegisteredKeys" ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org