#!/usr/bin/env python2
# 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.

"""
Mapping from properties to environment variable names
"""
HiBenchEnvPropMappingMandatory=dict(
    JAVA_BIN="java.bin",
    HADOOP_HOME="hibench.hadoop.home",
    HDFS_MASTER="hibench.hdfs.master",
    HADOOP_RELEASE="hibench.hadoop.release",
    HADOOP_EXAMPLES_JAR="hibench.hadoop.examples.jar",
    HADOOP_EXECUTABLE="hibench.hadoop.executable",
    HADOOP_CONF_DIR="hibench.hadoop.configure.dir",
    HIBENCH_HOME="hibench.home",
    HIBENCH_CONF="hibench.configure.dir",

    REPORT_COLUMN_FORMATS="hibench.report.formats",
    SPARKBENCH_JAR="hibench.sparkbench.jar",
    NUM_MAPS="hibench.default.map.parallelism",
    NUM_REDS="hibench.default.shuffle.parallelism",
    INPUT_HDFS="hibench.workload.input",
    OUTPUT_HDFS="hibench.workload.output",

    REDUCER_CONFIG_NAME="hibench.hadoop.reducer.name",
    MAP_CONFIG_NAME="hibench.hadoop.mapper.name",

    MASTERS="hibench.masters.hostnames",
    SLAVES="hibench.slaves.hostnames",
    )

HiBenchEnvPropMapping=dict(
    SPARK_HOME="hibench.spark.home",
    SPARK_MASTER="hibench.spark.master",
    SPARK_EXAMPLES_JAR="hibench.spark.examples.jar",

    HIVE_HOME="hibench.hive.home",
    HIVE_RELEASE="hibench.hive.release",
    HIVEBENCH_TEMPLATE="hibench.hivebench.template.dir",
    MAHOUT_HOME="hibench.mahout.home",
    MAHOUT_RELEASE="hibench.mahout.release",
    NUTCH_HOME="hibench.nutch.home",
    NUTCH_BASE_HDFS="hibench.nutch.base.hdfs",
    NUTCH_INPUT="hibench.nutch.dir.name.input",
    NUTCH_DIR="hibench.nutch.nutchindexing.dir",
    HIBENCH_REPORT="hibench.report.dir", # set in default
    HIBENCH_REPORT_NAME="hibench.report.name", # set in default
    YARN_NUM_EXECUTORS="hibench.yarn.executor.num",
    YARN_EXECUTOR_CORES="hibench.yarn.executor.cores",
    SPARK_YARN_EXECUTOR_MEMORY="spark.executor.memory",
    SPARK_YARN_DRIVER_MEMORY="spark.driver.memory",
    DATA_HDFS="hibench.hdfs.data.dir",
    # For Sleep workload
    MAP_SLEEP_TIME="hibench.sleep.mapper.seconds",
    RED_SLEEP_TIME="hibench.sleep.reducer.seconds",
    HADOOP_SLEEP_JAR="hibench.sleep.job.jar",
    # For Sort, Terasort, Wordcount
    DATASIZE="hibench.workload.datasize",

    # For hive related workload, data scale
    PAGES="hibench.workload.pages",
    USERVISITS="hibench.workload.uservisits",
    HIVE_INPUT="hibench.workload.dir.name.input",
    HIVE_BASE_HDFS="hibench.hive.base.hdfs",
    # For bayes
    CLASSES="hibench.workload.classes",
    BAYES_INPUT="hibench.bayes.dir.name.input",
    DATATOOLS="hibench.hibench.datatool.dir",
    BAYES_BASE_HDFS="hibench.bayes.base.hdfs",
    NGRAMS="hibench.bayes.ngrams",
    # For kmeans
    INPUT_SAMPLE="hibench.kmeans.input.sample",
    INPUT_CLUSTER="hibench.kmeans.input.cluster",
    NUM_OF_CLUSTERS="hibench.kmeans.num_of_clusters",
    NUM_OF_SAMPLES="hibench.kmeans.num_of_samples",
    SAMPLES_PER_INPUTFILE="hibench.kmeans.samples_per_inputfile",
    DIMENSIONS="hibench.kmeans.dimensions",
    MAX_ITERATION="hibench.kmeans.max_iteration",
    K="hibench.kmeans.k",
    # For Logistic Regression
    NUM_EXAMPLES_LR="hibench.lr.examples",
    NUM_FEATURES_LR="hibench.lr.features",
    # For SVM
    NUM_EXAMPLES_SVM="hibench.svm.examples",
    NUM_FEATURES_SVM="hibench.svm.examples",
    NUM_ITERATIONS_SVM="hibench.svm.numIterations",
    STEPSIZE_SVM="hibench.svm.stepSize",
    REGPARAM_SVM="hibench.svm.regParam",
    # For ALS
    NUM_USERS_ALS="hibench.als.users",
    NUM_PRODUCTS_ALS="hibench.als.products",
    SPARSITY_ALS="hibench.als.sparsity",
    IMPLICITPREFS_ALS="hibench.als.implicitprefs",
    RANK_ALS="hibench.als.rank",
    NUM_RECOMMENDS_ALS="hibench.als.recommends",
    NUM_ITERATIONS_ALS="hibench.als.numIterations",
    LAMBDA_ALS="hibench.als.Lambda",
    KYRO_ALS="hibench.als.kyro",
    USERBLOCKS_ALS="hibench.als.numUserBlocks",
    PRODUCTBLOCKS_ALS="hibench.als.numProductBlocks",
    # For PCA
    NUM_EXAMPLES_PCA="hibench.pca.examples",
    NUM_FEATURES_PCA="hibench.pca.features",