List of usage examples for org.apache.solr.client.solrj.response FieldStatsInfo getMean
public Object getMean()
From source file:com.frank.search.solr.core.ResultHelper.java
License:Apache License
private static <T extends SimpleStatsResult> T populateStatsResultWithFieldStatsInfo(T statsResult, FieldStatsInfo value) { statsResult.setMax(value.getMax());//from ww w .ja v a 2s . c o m statsResult.setMin(value.getMin()); statsResult.setCount(value.getCount()); statsResult.setMissing(value.getMissing()); statsResult.setStddev(value.getStddev()); statsResult.setSumOfSquares((Double) new DirectFieldAccessor(value).getPropertyValue("sumOfSquares")); Object mean = value.getMean(); if (mean instanceof Double) { statsResult.setMean((Double) mean); } Object sum = value.getSum(); if (sum instanceof Double) { statsResult.setSum((Double) sum); } return statsResult; }
From source file:com.nridge.ds.solr.SolrResponseBuilder.java
License:Open Source License
private void populateStatistic(QueryResponse aQueryResponse) { Object statObject;//from w w w. j a v a 2s . c om DataField schemaField; FieldStatsInfo fieldStatsInfo; String fieldName, fieldTitle, fieldValue; Logger appLogger = mAppMgr.getLogger(this, "populateStatistic"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); Map<String, FieldStatsInfo> mapFieldStatsInfo = aQueryResponse.getFieldStatsInfo(); if (mapFieldStatsInfo != null) { mDocument.addRelationship(Solr.RESPONSE_STATISTIC, createStatisticsBag()); Relationship statisticRelationship = mDocument.getFirstRelationship(Solr.RESPONSE_STATISTIC); if (statisticRelationship != null) { DataBag statisticsBag = new DataBag(statisticRelationship.getBag()); statisticsBag.setAssignedFlagAll(false); DataTable statisticTable = new DataTable(statisticsBag); DataBag resultBag = mBag; for (Map.Entry<String, FieldStatsInfo> entry : mapFieldStatsInfo.entrySet()) { statisticTable.newRow(); fieldName = entry.getKey(); fieldStatsInfo = entry.getValue(); statisticTable.setValueByName("field_name", fieldName); schemaField = resultBag.getFieldByName(fieldName); if (schemaField == null) fieldTitle = Field.nameToTitle(fieldName); else fieldTitle = schemaField.getTitle(); statisticTable.setValueByName("field_title", fieldTitle); statObject = fieldStatsInfo.getMin(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("min", fieldValue); statObject = fieldStatsInfo.getMax(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("max", fieldValue); statObject = fieldStatsInfo.getCount(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("count", fieldValue); statObject = fieldStatsInfo.getMissing(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("missing", fieldValue); statObject = fieldStatsInfo.getSum(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("sum", fieldValue); statObject = fieldStatsInfo.getMean(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("mean", fieldValue); statObject = fieldStatsInfo.getStddev(); if (statObject == null) fieldValue = StringUtils.EMPTY; else fieldValue = statObject.toString(); statisticTable.setValueByName("standard_deviation", fieldValue); statisticTable.addRow(); } Document facetDocument = new Document(Solr.RESPONSE_STATISTIC, statisticTable); statisticRelationship.add(facetDocument); } } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); }
From source file:org.apache.drill.exec.store.solr.SolrRecordReader.java
License:Apache License
private void processStatsRecord(FieldStatsInfo fieldStatsInfo, String functionName, int statsRecordCounter, int recordCounter, boolean isGroup) { Object fieldValue = null;/*from w w w.ja va 2s . com*/ ValueVector vv1 = vectors.get(String.valueOf(statsRecordCounter)); if (vv1 != null) { if (functionName.equalsIgnoreCase("sum")) { fieldValue = fieldStatsInfo.getSum(); } else if (functionName.equalsIgnoreCase("count")) { fieldValue = fieldStatsInfo.getCount(); } else if (functionName.equalsIgnoreCase("min")) { fieldValue = fieldStatsInfo.getMin(); } else if (functionName.equalsIgnoreCase("max")) { fieldValue = fieldStatsInfo.getMax(); } else if (functionName.equalsIgnoreCase("avg")) { fieldValue = fieldStatsInfo.getMean(); } else { SolrRecordReader.logger.debug("Yet to implement function type [ " + functionName + " ]"); } } processRecord(vv1, fieldValue, recordCounter); }
From source file:org.apache.nifi.processors.solr.QuerySolr.java
License:Apache License
private static void addStatsFromSolrResponseToJsonWriter(final QueryResponse response, final JsonWriter writer) throws IOException { writer.beginObject();// w w w . j av a 2 s .c om writer.name("stats_fields"); writer.beginObject(); for (Map.Entry<String, FieldStatsInfo> entry : response.getFieldStatsInfo().entrySet()) { FieldStatsInfo fsi = entry.getValue(); writer.name(entry.getKey()); writer.beginObject(); writer.name("min").value(fsi.getMin().toString()); writer.name("max").value(fsi.getMax().toString()); writer.name("count").value(fsi.getCount()); writer.name("missing").value(fsi.getMissing()); writer.name("sum").value(fsi.getSum().toString()); writer.name("mean").value(fsi.getMean().toString()); writer.name("sumOfSquares").value(fsi.getSumOfSquares()); writer.name("stddev").value(fsi.getStddev()); writer.endObject(); } writer.endObject(); writer.endObject(); }
From source file:uk.ac.ebi.phenotype.web.controller.BaselineChartsController.java
License:Apache License
private String generateBaselineChartBoxStyle(String parameterStableId, List<FieldStatsInfo> baselinesForParameter) throws SolrServerException, IOException { ParameterDTO parameter = impressService.getParameterByStableId(parameterStableId); //String procedureName = parameter.getProcedures().iterator().next().getName(); System.out.println("procedure names=" + parameter.getProcedureNames()); String yAxisTitle = parameter.getUnitX(); List<String> xAxisLabels = new ArrayList<>(); List<List<String>> boxColumns = new ArrayList<>(); //get the number of decimal places to display int decimalPlaces = getDecimalPlacesToDisplay(baselinesForParameter); System.out.println("decimalPlaces=" + decimalPlaces); Double yMin = new Double(0); Double yMax = new Double(0); for (FieldStatsInfo baseLine : baselinesForParameter) { List<String> boxColumn = new ArrayList<String>(); xAxisLabels.add("'" + baseLine.getName() + "'"); if ((Double) baseLine.getMin() < yMin) { yMin = (Double) baseLine.getMin(); }/*from w ww . j a va2 s . c o m*/ if ((Double) baseLine.getMax() > yMax) { yMax = (Double) baseLine.getMax(); } boxColumn.add(Double .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMin(), decimalPlaces))); double lower = (double) baseLine.getMean() - (double) baseLine.getStddev(); boxColumn.add(Double.toString(ChartUtils.getDecimalAdjustedDouble((Double) lower, decimalPlaces))); boxColumn.add(Double .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMean(), decimalPlaces))); double upper = (double) baseLine.getMean() + (double) baseLine.getStddev(); boxColumn.add(Double.toString(ChartUtils.getDecimalAdjustedDouble((Double) upper, decimalPlaces))); boxColumn.add(Double .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMax(), decimalPlaces))); //System.out.println(baseLine.getMin()+ " " +baseLine.getGenotypeEffect()+" "+baseLine.getMax()); boxColumns.add(boxColumn); //System.out.println("boxColumn="+boxColumn); } List<String> colors = ChartColors.getHighDifferenceColorsRgba(ChartColors.alphaOpaque); String seriesData = "{" + " name: 'Observations'," + " data:" + boxColumns // + " [" // + " [760, 801, 848, 895, 965]," // + " [733, 853, 939, 980, 1080]," // + " [714, 762, 817, 870, 918]," // + " [834, 836, 864, 882, 910] ]" + "," + " tooltip: {" + " headerFormat: '<em>Experiment No {point.key}</em><br/>'" + " }" + " }"; String chartString = "$('#baseline-chart-div').highcharts({" + " colors:" + colors + ", chart: { type: 'boxplot'}, " + " tooltip: { formatter: function () { if(typeof this.point.high === 'undefined')" + "{ return '<b>Observation</b><br/>' + this.point.y; } " + "else { return '<b>Center: ' + this.key + '</b>" + "<br/>Max: ' + this.point.options.high + '" + "<br/>Mean + SD: ' + this.point.options.q3 + '" + "<br/>Mean: ' + this.point.options.median + '" + "<br/>Mean - SD: ' + this.point.options.q1 +'" + "<br/>Min: ' + this.point.options.low" + "; } } } ," + " title: { text: '" + parameter.getName() + " WT Variation By Center', useHTML:true } , subtitle: { text: '" + parameter.getProcedureNames().get(0) + "' }, " + " credits: { enabled: false }, " + " legend: { enabled: false }, " + " xAxis: { categories: " + xAxisLabels + "," + " labels: { " + " rotation: -45, " + " align: 'right', " + " style: { " + " fontSize: '15px'," + " fontFamily: '\"Roboto\", sans-serif'" + " } " + " }, " + " }, \n" + " plotOptions: {" + "series:" + "{ groupPadding: 0.25, pointPadding: -0.5 }" + "}," + " yAxis: { " + "max: " + yMax + ", min: " + yMin + "," + " labels: { },title: { text: '" + yAxisTitle + "' }, tickAmount: 5 }, " + "\n series: [" + seriesData + "] });"; return chartString; }
From source file:uk.ac.ebi.phenotype.web.controller.BaselineChartsController.java
License:Apache License
private String generateBaselineChartBarStyle(String parameterStableId, List<FieldStatsInfo> baselinesForParameter) throws SolrServerException, IOException { ParameterDTO parameter = impressService.getParameterByStableId(parameterStableId); //String procedureName = parameter.getProcedures().iterator().next().getName(); System.out.println("procedure names=" + parameter.getProcedureNames()); String yAxisTitle = parameter.getUnitX(); List<String> xAxisLabels = new ArrayList(); List<String> means = new ArrayList(); for (FieldStatsInfo baseLine : baselinesForParameter) { xAxisLabels.add("'" + baseLine.getName() + "'"); means.add(baseLine.getMean().toString()); System.out.println(baseLine.getMin() + " " + baseLine.getMax() + " " + baseLine.getMean()); }/*w w w.j a va 2 s.c o m*/ //[-9.7, 9.4], int decimalPlaces = ChartUtils.getDecimalPlacesFromStrings(means); System.out.println("decimalPlaces=" + decimalPlaces); List<Float> meanFloats = getDecimalAdjustedValues(means, decimalPlaces); List<String> minAndMax = new ArrayList<>(); for (FieldStatsInfo baseLine : baselinesForParameter) { minAndMax.add( "[" + ChartUtils.getDecimalAdjustedFloat(new Float(baseLine.getMin().toString()), decimalPlaces) + "," + new Float(baseLine.getMax().toString()) + "]"); } String minAndMaxData = StringUtils.join(minAndMax, ","); System.out.println("minAndMaxData=" + minAndMaxData); System.out.println("means=" + means); List<String> colors = ChartColors.getHighDifferenceColorsRgba(ChartColors.alphaOpaque); String chartString = "$('#baseline-chart-div').highcharts({" + " colors:" + colors + ", " + " chart: { " + " type: 'columnrange', inverted: false }, title: { text: '" + parameter.getName() + " WT Variation By Center' }, subtitle: { text: '" + parameter.getProcedureNames().get(0) + "' }," + " plotOptions: { series: { states: { hover: { enabled: false } } } }," + " xAxis: {" + " categories: " + xAxisLabels + "}," + " yAxis: {" + " title: { text: '" + yAxisTitle + "' }" + " }," + " tooltip: {" + " valueSuffix: '" + yAxisTitle + "' }," + " plotOptions: {" + " columnrange: { " + "dataLabels: {" + " enabled: false, formatter: function () { return this.y + '" + yAxisTitle + "'; }" + " }" + " }" + "}, legend: { enabled: false }, tooltip: { enabled: false }," + " series: " + "[ { name: '" + parameter.getName() + yAxisTitle + "', data: [ " + minAndMaxData + " ] }," + " { type: 'scatter', name: 'Observations', data: " + meanFloats + ", marker: { radius: 4 } }]" + " });"; System.out.println("chartString=" + chartString); return chartString; }