Side effect: also sets SharkContext and SparkContextParams in case the client wants to examine or use those.

@param params
@return
@throws DDFException
492515
private SparkContext createSparkContext(Map<String, String> params) throws DDFException {
    this.setSparkContextParams(this.mergeSparkParamsFromSettings(params));
    String ddfSparkJar = params.get("DDFSPARK_JAR");

    String[] jobJars = ddfSparkJar != null ? ddfSparkJar.split(",") : new String[] { };

    ArrayList<String> finalJobJars = new ArrayList<String>();

    // DDFSPARK_JAR could contain directories too, used in case of Databricks Cloud where we don't have the jars at start-up
    // time but the directory and we will search and includes all of jars at run-time
    for (String jobJar: jobJars) {
      if ((!jobJar.endsWith(".jar")) && (new File(jobJar).list() != null)) {
        // This is a directory
        ArrayList<String> jars = Utils.listJars(jobJar);
        if (jars != null) {
          finalJobJars.addAll(jars);
        }

      } else  {
        finalJobJars.add(jobJar);
      }
    }

    mLog.info(">>>>> ddfSparkJar = " + ddfSparkJar);
    for(String jar: finalJobJars) {
      mLog.info(">>>>> " + jar);
    }

    jobJars = new String[finalJobJars.size()];
    jobJars = finalJobJars.toArray(jobJars);

    for (String key : params.keySet()) {
      mLog.info(">>>> key = " + key + ", value = " + params.get(key));
    }

    SparkContext context = SparkUtils.createSparkContext(params.get("SPARK_MASTER"), params.get("SPARK_APPNAME"),
        params.get("SPARK_HOME"), jobJars, params);
    this.mSparkContext = context;
    this.mJavaSparkContext = new JavaSparkContext(context);
    return this.getSparkContext();
  }
1041429
@Override
    public void setParameters(Object[] params) throws CDKException {
        if (params.length > 1) {
            throw new CDKException("weight only expects one parameter");
        }
        if (!(params[0] instanceof String)) {
            throw new CDKException("The parameter must be of type String");
        }
        // ok, all should be fine
        elementName = (String) params[0];
    }
401148
public void setParams(java.util.Collection<UpdateParam> params) {
        if (params == null) {
            this.params = null;
            return;
        }

        this.params = new java.util.ArrayList<UpdateParam>(params);
    }
903871
public Object createContext(Object param) throws Exception {

        Class<?>[] params = mConstr != null ? mConstr.getParameterTypes() : new Class[0];
        if (params.length > 1 && MergedClass.InvocationEventObserver.class.equals(params[1])) {
            return mConstr.newInstance(new Object[] {
                new MergingContextFactory(param),
                new MergedClass.InvocationEventObserver() {
                    public void invokedEvent(String caller, String callee, long elapsedTime) { }
                    public long currentTime() { return 0L; }
            }});
        }
        else {
            return mConstr.newInstance(new Object[] {
                new MergingContextFactory(param)});
        }
    }
849406
private void fillParams(final Map<String, String[]> params, final String queryString, Charset charset) {
        if (StringUtils.hasText(queryString)) {
            final StringTokenizer tokenizer = new StringTokenizer(queryString, "&");
            while (tokenizer.hasMoreTokens()) {
                final String[] nameValuePair = tokenizer.nextToken().split("=");

                try {
                    params.put(URLDecoder.decode(nameValuePair[0], charset.name()),
                            new String[] { URLDecoder.decode(nameValuePair[1], charset.name()) });
                } catch (final UnsupportedEncodingException e) {
                    throw new CitrusRuntimeException(String.format(
                            "Failed to decode query param value '%s=%s'",
                            nameValuePair[0],
                            nameValuePair[1]), e);
                }
            }
        }
    }
1023760
public void setParamsToRuntimeCheck(Predicate<String> paramNames) {
    checkState(this.paramsToRuntimeTypeCheck == null);
    this.paramsToRuntimeTypeCheck = checkNotNull(paramNames);
  }
914592
public final void checkParams(Object[] params, int expected) {
        if(params == null || params.length != expected) {
            throw new RuntimeException("Liquid error: wrong number of arguments (" +
                    (params == null ? 0 : params.length + 1) + " for " + (expected + 1) + ")");
        }
    }
1269453
protected String buildParamsQuery(final Map<String, String> params)
			throws UnsupportedEncodingException {
		StringBuilder builder = new StringBuilder();
		if (params.isEmpty()) {
			return builder.toString();
		}

		String sep = "";
		for (Map.Entry<String, String> entry : params.entrySet()) {
			builder.append(sep);
			builder.append(urlencode(entry.getKey()));
			builder.append("=");
			builder.append(urlencode(entry.getValue()));
			sep = "&";
		}

		return builder.toString();
	}
1192861
@Override
  public Object get(Class<?>... typeSpecs) throws DDFException {
    //    return this.get(this.getSpecsAsString(typeSpecs), true);
    return this.get(Representation.typeSpecsToString(typeSpecs), true);
  }
261737
public DDF newDDF(DDFManager manager) throws DDFException {
    DDF ddf = this.newDDF(new Class<?>[] { DDFManager.class }, new Object[] { manager });
    ddf.getPersistenceHandler().setPersistable(false);
    return ddf;
  }
436413
function(params) {
		var me = this;

		if (Object.keys(model.columns).length == 0) {
			logger.error("Attempting to initialize `" + model.ident + "` instance before filling schema!");
			return null;
		} else if (model.primary === undefined) {
			logger.error("No primary key found for `" + model.ident + "`!");
			return null;
		}

		Object.defineProperty(me, 'values', {
			value: {},
			enumerable: false,
			writable: true,
			configurable: true,
		}); // Raw column values, accessed by setter/getter functions.

		params = params || {};

		/* --- Instance Methods --- */

		/**
		 * Saves the object's properties corresponding to table columns into the database.
		 */
		function save() {
			var act = new NobleMachine(function() {
				setStrs = [];

				for (var key in model.columns) {
					if ([model.primary].indexOf(key) == -1 && me[key] !== undefined) {
						setStrs.push('`' + key + '`' + " = " + nrutil.serialize(me[key]));
					}
				}

				if (model.columns['updatedAt'])
					setStrs.push('`updatedAt` = NOW()');

				var sql;
				if (me[model.primary]) {
					sql = "UPDATE " + model.table
							+ " SET " + setStrs.join(',')
							+ " WHERE `" + model.primary + "` = " + me[model.primary];
				} else {
					if (model.columns['createdAt'])
						setStrs.push('`createdAt` = NOW()');

					sql = "INSERT"
							+ " INTO " + model.table
							+ " SET " + setStrs.join(',');
				}


				act.toNext(db_query(sql));
			});

			act.next(function(result) {
				//log.debug("RESULT: " + JSON.stringify(result));

				if (result.insert_id) {
					me[model.primary] = result.insert_id;
				} else if (!me[model.primary]) {
					act.toError("No insert_id, and no extant primary key!");
					return;
				}

				
				logger.log("Successfully saved `" + model.ident + "` record `" + me[model.primary] + "`");

				act.toNext(me);
			});

			act.error(function(err) {
				logger.error("Error saving `" + model.ident + "` record: " + JSON.stringify(err));
				act.emitError(err);
			});

			return act;
		}

		/**
		 * Reloads the object's properties with the current database values.
		 */
		function reload() {
			var params = {}

			params[model.primary] = me[model.primary]
		
			var act = new NobleMachine(model.find(params));

			act.next(function(newInst) {
				if (newInst) {
					for (var col in model.columns) {
						me[col] = newInst[col];
					}

					act.toNext(me);
				} else {
					for (var key in model.columns) {
						me[key] = undefined
					}

					act.toNext(null);
				}
			});

			return act;
		}

		/**
		 * Removes this object's corresponding database row.
		 */
		function destroy() {
			var act = new NobleMachine(function() {
				if (me.onDestroy) {
					var preact = me.onDestroy();
					if (preact && preact.start instanceof Function) {
						act.toNext(preact)
						return;
					}
				}
			});

			act.next(function() {
				var sql = "DELETE FROM " + model.table
						+ " WHERE `" + model.primary + "` = " + me[model.primary];

				act.toNext(db_query(sql));
			});

			act.next(function() {
				logger.log("Successfully deleted `" + model.ident + "` record `" + me[model.primary] + "`");

				for (var param in me) {
					delete me[param];	
				}
			});

			act.error(function(err) {
				logger.error("Error deleting `" + model.ident + "` record: " + JSON.stringify(err));
				act.emitError(err);
			});

			return act;
		}

		// Generic setter for SQL-correspondent values. Forces typecasting for database compatibility.
		function setValue(key, val) {
			//util.log(key + ": " + JSON.stringify(val));

			if (val === null) {
				me.values[key] = null;
			} else if (val === undefined) {
				me.values[key] = undefined;
			} else {
				type = model.columns[key]['DATA_TYPE'];

				switch (type) {
					case 'datetime':
					case 'timestamp':
						me.values[key] = new Date(val);
						break;
					case 'text':
					case 'varchar':
						me.values[key] = val.toString();
						break;
					case 'int':
					case 'tinyint':
						if (model.columns[key]['COLUMN_TYPE'] == 'tinyint(1)') {
							me.values[key] = !!val // Boolean
						} else {
							me.values[key] = parseInt(val);
						}
						break;
					default:
						me.values[key] = val;
				}
			}
		}

		// Generic getter for SQL-correspondent values.
		function getValue(key) {
			return me.values[key];
		}

		for (var key in model.columns) {
			me.__defineSetter__(key, setValue.bind(me, key));
			me.__defineGetter__(key, getValue.bind(me, key));

			if (params[key] !== undefined) {
				setValue(key, params[key]);
			}
		}

		_.extend(me, {
			save: save,
			reload: reload,
			destroy: destroy,
			setValue: setValue
		});

		if (defFunc !== undefined) {
			defFunc(me);
		}

		return me;
	}
854238
@Override
  public IModel train(String trainMethodName, Object... paramArgs) throws DDFException {
    /**
     * Example signatures we must support:
     * <p/>
     * Unsupervised Training
     * <p/>
     * <code>
     * Kmeans.train(data: RDD[Array[Double]], k: Int, maxIterations: Int, runs: Int, initializationMode: String)
     * </code>
     * <p/>
     * Supervised Training
     * <p/>
     * <code>
     * LogisticRegressionWithSGD.train(input: RDD[LabeledPoint], numIterations: Int, stepSize: Double, miniBatchFraction:
     * Double, initialWeights: Array[Double])
     *
     * SVM.train(input: RDD[LabeledPoint], numIterations: Int, stepSize: Double, regParam: Double, miniBatchFraction:
     * Double)
     * </code>
     */

    // Build the argument type array
    if (paramArgs == null) paramArgs = new Object[0];

    // Locate the training method
    String mappedName = Config.getValueWithGlobalDefault(this.getEngine(), trainMethodName);
    if (!Strings.isNullOrEmpty(mappedName)) trainMethodName = mappedName;

    TrainMethod trainMethod = new TrainMethod(trainMethodName, MLClassMethods.DEFAULT_TRAIN_METHOD_NAME, paramArgs);
    if (trainMethod.getMethod() == null) {
      throw new DDFException(String.format("Cannot locate method specified by %s", trainMethodName));
    }

    // Now we need to map the DDF and its column specs to the input format expected by the method we're invoking
    Object[] allArgs = this.buildArgsForMethod(trainMethod.getMethod(), paramArgs);

    // Invoke the training method
    Object rawModel = trainMethod.classInvoke(allArgs);


    List<Schema.Column> columns = this.getDDF().getSchemaHandler().getColumns();
    String[] trainedColumns = new String[columns.size()];

    for (int i = 0; i < columns.size(); i++) {
      trainedColumns[i] = columns.get(i).getName();
    }

    for (String col : trainedColumns) {
      mLog.info(">>>>>> trainedCol = " + col);
    }

    IModel model = this.newModel(rawModel);
    model.setTrainedColumns(trainedColumns);
    mLog.info(">>>> modelID = " + model.getName());
    this.getManager().addModel(model);
    return model;
  }
1308113
@Override
    public void setParameters(Object[] params) throws CDKException {
        if (params.length > 3) throw new CDKException("PartialPiChargeDescriptor only expects three parameter");

        if (!(params[0] instanceof Integer)) throw new CDKException("The parameter must be of type Integer");
        maxIterations = (Integer) params[0];

        if (params.length > 1 && params[1] != null) {
            if (!(params[1] instanceof Boolean)) throw new CDKException("The parameter must be of type Boolean");
            lpeChecker = (Boolean) params[1];
        }

        if (params.length > 2 && params[2] != null) {
            if (!(params[2] instanceof Integer)) throw new CDKException("The parameter must be of type Integer");
            maxResonStruc = (Integer) params[2];
        }
    }
435624
@Override
    public void setParameters(Object[] params) throws CDKException {
        if (params.length != 2) {
            throw new CDKException("RotatableBondsCount expects two parameters");
        }
        if (!(params[0] instanceof Boolean) || !(params[1] instanceof Boolean)) {
            throw new CDKException("The parameters must be of type Boolean");
        }
        // ok, all should be fine
        includeTerminals = (Boolean) params[0];
        excludeAmides = (Boolean) params[1];
    }
1124877
function(paramd) {
    var self = this

    paramd = defaults(paramd, {
        iri: "http://data.sparkfun.com"
    })

    self.iri = paramd.iri
}
518243
public void setExtraParams(java.util.Collection<ExtraParam> extraParams) {
        if (extraParams == null) {
            this.extraParams = null;
            return;
        }

        this.extraParams = new com.amazonaws.internal.SdkInternalList<ExtraParam>(extraParams);
    }
689309
@Override
    public void setParameters(Object[] params) throws CDKException {
        if (params.length > 1) {
            throw new CDKException("BondCount only expects one parameter");
        }
        if (!(params[0] instanceof String)) {
            throw new CDKException("The parameter must be of type IBond.Order");
        }
        String bondType = (String) params[0];
        if (bondType.length() > 1 || !"sdtq".contains(bondType)) {
            throw new CDKException("The only allowed values for this parameter are 's', 'd', 't', 'q' and ''.");
        }
        // ok, all should be fine
        order = bondType;
    }