All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.solr.client.solrj.response.FieldStatsInfo Maven / Gradle / Ivy

There is a newer version: 9.8.0
Show newest version
/*
 * 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.
 */
package org.apache.solr.client.solrj.response;

import org.apache.solr.common.util.NamedList;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Holds stats info
 *
 *
 * @since solr 1.4
 */
public class FieldStatsInfo implements Serializable {
  final String name;
  
  Object min;
  Object max;
  Object sum;
  Long count;
  Long missing;
  Object mean = null;
  Double sumOfSquares = null;
  Double stddev = null;
  
  Map> facets;
  
  public FieldStatsInfo( NamedList nl, String fname )
  {
    name = fname;
    
    for( Map.Entry entry : nl ) {
      if( "min".equals( entry.getKey() ) ) {
        min = entry.getValue();
      }
      else if( "max".equals( entry.getKey() ) ) {
        max = entry.getValue();
      }
      else if( "sum".equals( entry.getKey() ) ) {
        sum = entry.getValue();
      }
      else if( "count".equals( entry.getKey() ) ) {
        count = (Long)entry.getValue();
      }
      else if( "missing".equals( entry.getKey() ) ) {
        missing = (Long)entry.getValue();
      }
      else if( "mean".equals( entry.getKey() ) ) {
        mean = entry.getValue();
      }
      else if( "sumOfSquares".equals( entry.getKey() ) ) {
        sumOfSquares = (Double)entry.getValue();
      }
      else if( "stddev".equals( entry.getKey() ) ) {
        stddev = (Double)entry.getValue();
      }
      else if( "facets".equals( entry.getKey() ) ) {
        @SuppressWarnings("unchecked")
        NamedList fields = (NamedList)entry.getValue();
        facets = new HashMap>();
        for( Map.Entry ev : fields ) {
          List vals = new ArrayList();
          facets.put( ev.getKey(), vals );
          @SuppressWarnings("unchecked")
          NamedList> vnl = (NamedList>) ev.getValue();
          for( int i=0; i> getFacets() {
    return facets;
  }
  
}