From notifications-return-263-archive-asf-public=cust-asf.ponee.io@nemo.apache.org Wed Mar 20 22:45:15 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 397521807BC for ; Wed, 20 Mar 2019 23:45:14 +0100 (CET) Received: (qmail 27944 invoked by uid 500); 20 Mar 2019 22:45:13 -0000 Mailing-List: contact notifications-help@nemo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nemo.apache.org Delivered-To: mailing list notifications@nemo.apache.org Received: (qmail 27872 invoked by uid 99); 20 Mar 2019 22:45:13 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Mar 2019 22:45:13 +0000 From: GitBox To: notifications@nemo.apache.org Subject: [GitHub] [incubator-nemo] taegeonum commented on a change in pull request #203: [NEMO-360] Implementing an 'XGBoostPolicy' Message-ID: <155312191262.22053.4026187710355250479.gitbox@gitbox.apache.org> Date: Wed, 20 Mar 2019 22:45:12 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit taegeonum commented on a change in pull request #203: [NEMO-360] Implementing an 'XGBoostPolicy' URL: https://github.com/apache/incubator-nemo/pull/203#discussion_r267573357 ########## File path: compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/OptimizerUtils.java ########## @@ -0,0 +1,120 @@ +/* + * 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.nemo.compiler.optimizer; + +import org.apache.nemo.common.Pair; +import org.apache.nemo.common.dag.Edge; +import org.apache.nemo.common.dag.Vertex; +import org.apache.nemo.common.exception.DeprecationException; +import org.apache.nemo.common.exception.MetricException; +import org.apache.nemo.common.exception.UnsupportedMethodException; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * Utility class for optimizer. + */ +public final class OptimizerUtils { + private static final BlockingQueue MESSAGE_BUFFER = new LinkedBlockingQueue<>(); + + /** + * Private constructor. + */ + private OptimizerUtils() { + } + + /** + * @param message push the message to the message buffer. + */ + public static void pushMessageBuffer(final String message) { + MESSAGE_BUFFER.add(message); + } + + /** + * @return the message buffer. + */ + public static String takeFromMessageBuffer() { + try { + return MESSAGE_BUFFER.take(); + } catch (InterruptedException e) { + throw new MetricException("Interrupted while waiting for message: " + e); + } + } + + /** + * Restore the formatted string into a pair of vertex/edge id and the execution property. + * @param string the formatted string. + * @return a pair of vertex/edge id and the execution property key index. + */ + public static Pair stringToIdAndEPKeyIndex( + final String string) { + if (string.length() != 9) { + throw new DeprecationException("The metric data is deprecated or does not follow the designated format"); + } + final Integer idx = Integer.parseInt(string.substring(0, 1)); + final Integer numericId = Integer.parseInt(string.substring(1, 5)); + final String id; + if (idx == 1) { + id = Vertex.restoreId(numericId); + } else if (idx == 2) { + id = Edge.restoreId(numericId); + } else { + throw new UnsupportedMethodException("The index " + idx + " cannot be categorized into a vertex or an edge"); + } + return Pair.of(id, Integer.parseInt(string.substring(5, 9))); + } + + /** + * Types of environments to categorize them into. + */ + public enum EnvironmentType { + DEFAULT, + TRANSIENT, + LARGE_SHUFFLE, + DISAGGREGATION, + DATA_SKEW, + STREAMING, + SMALL_SIZE, + } + + /** + * Method to infiltrate keyword-containing string into the enum of Types above. + * @param environmentType the input string. + * @return the formatted string corresponding to each type. + */ + public static String filterEnvironmentTypeString(final String environmentType) { + if (environmentType.toLowerCase().contains("transient")) { + return "_" + EnvironmentType.TRANSIENT.toString().toLowerCase(); Review comment: why do we add "_"? ---------------------------------------------------------------- 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 With regards, Apache Git Services