List of usage examples for org.apache.solr.common.params SolrParams getDouble
public double getDouble(String param, double def)
From source file:com.grantingersoll.intell.clustering.KMeansClusteringEngine.java
License:Apache License
@Override public String init(NamedList config, SolrCore core) { String result = super.init(config, core); SolrParams params = SolrParams.toSolrParams(config); this.core = core; String dirStr = params.get("dir"); clusterBaseDir = new File(dirStr); if (clusterBaseDir.isAbsolute() == false) { clusterBaseDir = new File(core.getDataDir(), dirStr); }/*from www . j a va 2 s .co m*/ clusterBaseDir.mkdirs(); inputField = params.get("inputField"); String distMeas = params.get("distanceMeasure"); Class distClass = core.getResourceLoader().findClass(distMeas); try { measure = (DistanceMeasure) distClass.newInstance(); } catch (InstantiationException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unable to load measure class", e); } catch (IllegalAccessException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unable to load measure class", e); } convergence = params.getDouble("convergence", 0.001); maxIters = params.getInt("maxIterations", 20); cacheClusters = params.getBool("cacheClusters", true); cachePoints = params.getBool("cachePoints", true); this.k = params.getInt("k"); //See if we have clusters already File nowFile = new File(clusterBaseDir, "lastJob"); if (nowFile.exists()) { lastSuccessful = readJobDetails(nowFile); } return result; }