package org.autotune.exampleConfigs;

import org.apache.spark.sql.SparkSession;
import org.autotune.NominalParameter;
import org.autotune.NumericParameter;
import org.autotune.TuneableParameters;

import java.io.Serializable;

/**
 * Created by KevinRoj on 21.05.17.
 */
@TuneableParameters(initRandomSearch = 4, cacheNextPoints = 1, reftryAfter = 4)
public class SparkTuneableConf implements Serializable {
    static final long serialVersionUID = 421L;
    @NumericParameter(min = 13421772, max = 671088640)
    public int maxPartitionBytes = 134217728;
    @NominalParameter(values = {"false", "true"})
    public boolean inMemoryColumnarStorageCompressed = true;
    @NumericParameter(min = 2, max = 500)
    public int shufflePartitions = 200;
    @NominalParameter(values = {"false", "true"})
    public boolean shuffleCompress = true;
    @NominalParameter(values = {"false", "true"})
    public boolean shuffleSpillCompress = true;
    @NominalParameter(values = {"false", "true"})
    public boolean broadcastCompress = true;
    @NominalParameter(values = {"false", "true"})
    public boolean rddCompress = false;
    @NumericParameter(min = 1, max = 8)
    public int defaultParallelism = 2;
    @NumericParameter(min = 1, max = 8)
    public long executorCores = 2;
    @NumericParameter(min = 1, max = 4)
    public long taskCpus = 1;

    public SparkSession.Builder setConfig(SparkSession.Builder builder) {
        return builder
                .config("spark.sql.inMemoryColumnarStorage.compressed", this.inMemoryColumnarStorageCompressed)
                .config("spark.sql.files.maxPartitionBytes", this.maxPartitionBytes)
                .config("spark.sql.shuffle.partitions", this.shufflePartitions)
                .config("spark.shuffle.compress", this.shuffleCompress)
                .config("spark.shuffle.spill.compress", this.shuffleSpillCompress)
                .config("spark.broadcast.compress", this.broadcastCompress)
                .config("spark.rdd.compress", this.rddCompress)
                .config("spark.default.parallelism", this.defaultParallelism)
                .config("spark.executor.cores", this.executorCores)
                .config("spark.task.cpus", this.taskCpus);
    }
}

@@ -448,16 +448,63 @@
 = 421L;%0A
+    //from 1.2 MiB to 512 MiB, default 128 MiB%0A
     @Num
@@ -524,23 +524,22 @@
 (min = 1
-3421772
+258000
 , max = 
@@ -1193,33 +1193,33 @@
 (min = 1, max = 
-8
+4
 )%0A    public int
@@ -1240,18 +1240,44 @@
 elism = 
-2;
+4; //default number of cores
 %0A    @Nu
@@ -1306,17 +1306,17 @@
 , max = 
-8
+4
 )%0A    pu
@@ -1341,17 +1341,17 @@
 Cores = 
-2
+4
 ;%0A    @N
@@ -2161,16 +2161,17 @@
 llelism)
+;
 %0A       
@@ -2171,32 +2171,34 @@
                 
+//
 .config(%22spark.e
@@ -2241,32 +2241,34 @@
                 
+//
 .config(%22spark.t

update tuneabel conf