Github user arina-ielchiieva commented on a diff in the pull request:
https://github.com/apache/drill/pull/1021#discussion_r149998367
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileUtil.java
---
@@ -0,0 +1,57 @@
+/*
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+import java.util.Collections;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+public class ProfileUtil {
+ // Mapping query state names to display names
+ private static final Map<String, String> queryStateDisplayName;
+
+ static {
+ Map<String, String> displayNames = Maps.newHashMap();
+ displayNames.put("STARTING", "Starting");
+ displayNames.put("RUNNING", "Running");
+ displayNames.put("COMPLETED", "Succeeded");
+ displayNames.put("CANCELED", "Canceled");
+ displayNames.put("FAILED", "Failed");
+ displayNames.put("CANCELLATION_REQUESTED", "Cancellation Requested");
+ displayNames.put("ENQUEUED", "Enqueued");
+ queryStateDisplayName = Collections.unmodifiableMap(displayNames);
+ }
+
+
+ /**
+ * Utility to return display name for query state
+ * @param queryState
+ * @return display string for query state
+ */
+ public final static String getQueryStateDisplayName(QueryState
queryState) {
+ String state = queryState.name();
+ if (queryStateDisplayName.containsKey(state)) {
--- End diff --
This would be more optimal:
```
String state = queryStateDisplayNames.get(queryState);
if (state == null) {
state = "Unknown State"
}
return state;
```
---