You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/11/02 11:16:46 UTC

[37/56] lucene-solr:jira/gradle: Add :solr:contrib:analytics module

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java
deleted file mode 100644
index 5614d6c..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.time.Instant;
-import java.util.Date;
-import java.util.function.Consumer;
-import java.util.function.LongConsumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.value.DateValue;
-import org.apache.solr.analytics.value.DateValue.CastingDateValue;
-
-/**
- * A constant {@link DateValue}. Every call to {@link #getDate()} and other methods will return the same constant value.
- */
-public class ConstantDateValue extends ConstantValue implements CastingDateValue {
-  private final long value;
-  private final Date valueDate;
-  private final String valueStr;
-  public static final String name = "const_date";
-  private final String exprStr;
-
-  public ConstantDateValue(long value) {
-    this.value = value;
-    this.valueDate = new Date(value);
-    this.valueStr = Instant.ofEpochMilli(value).toString();
-    this.exprStr = ConstantValue.createExpressionString(this, valueStr);
-  }
-
-
-  @Override
-  public long getLong() {
-    return value;
-  }
-  @Override
-  public Date getDate() {
-    return valueDate;
-  }
-  @Override
-  public String getString() {
-    return valueStr;
-  }
-  @Override
-  public Object getObject() {
-    return valueDate;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamLongs(LongConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamDates(Consumer<Date> cons) {
-    cons.accept(valueDate);
-  }
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(valueStr);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(valueDate);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java
deleted file mode 100644
index cf5682a..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.value.DoubleValue;
-import org.apache.solr.analytics.value.DoubleValue.CastingDoubleValue;
-
-/**
- * A constant {@link DoubleValue}. Every call to {@link #getDouble()} and other methods will return the same constant value.
- */
-public class ConstantDoubleValue extends ConstantValue implements CastingDoubleValue {
-  private final double value;
-  private final String valueStr;
-  public static final String name = "const_double";
-  private final String exprStr;
-
-  public ConstantDoubleValue(double value) {
-    this.value = value;
-    this.valueStr = Double.toString(value);
-    this.exprStr = ConstantValue.createExpressionString(this, valueStr);
-  }
-
-  @Override
-  public double getDouble() {
-    return value;
-  }
-  @Override
-  public String getString() {
-    return valueStr;
-  }
-  @Override
-  public Object getObject() {
-    return value;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamDoubles(DoubleConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(valueStr);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(value);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java
deleted file mode 100644
index ec495a4..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.util.function.FloatConsumer;
-import org.apache.solr.analytics.value.FloatValue;
-import org.apache.solr.analytics.value.FloatValue.CastingFloatValue;
-
-/**
- * A constant {@link FloatValue}. Every call to {@link #getFloat()} and other methods will return the same constant value.
- */
-public class ConstantFloatValue extends ConstantValue implements CastingFloatValue {
-  private final float value;
-  private final String valueStr;
-  public static final String name = "const_float";
-  private final String exprStr;
-
-  public ConstantFloatValue(float value) {
-    this.value = value;
-    this.valueStr = Float.toString(value);
-    this.exprStr = ConstantValue.createExpressionString(this, valueStr);
-  }
-
-  @Override
-  public float getFloat() {
-    return value;
-  }
-  @Override
-  public double getDouble() {
-    return value;
-  }
-  @Override
-  public String getString() {
-    return valueStr;
-  }
-  @Override
-  public Object getObject() {
-    return value;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamFloats(FloatConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamDoubles(DoubleConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(valueStr);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(value);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java
deleted file mode 100644
index 1e43359..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-import java.util.function.IntConsumer;
-import java.util.function.LongConsumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.util.function.FloatConsumer;
-import org.apache.solr.analytics.value.IntValue;
-import org.apache.solr.analytics.value.IntValue.CastingIntValue;
-
-/**
- * A constant {@link IntValue}. Every call to {@link #getInt()} and other methods will return the same constant value.
- */
-public class ConstantIntValue extends ConstantValue implements CastingIntValue {
-  private final int value;
-  private final String valueStr;
-  public static final String name = "const_int";
-  private final String exprStr;
-
-  public ConstantIntValue(int value) {
-    this.value = value;
-    this.valueStr = Integer.toString(value);
-    this.exprStr = ConstantValue.createExpressionString(this, valueStr);
-  }
-
-
-  @Override
-  public int getInt() {
-    return value;
-  }
-  @Override
-  public long getLong() {
-    return value;
-  }
-  @Override
-  public float getFloat() {
-    return value;
-  }
-  @Override
-  public double getDouble() {
-    return value;
-  }
-  @Override
-  public String getString() {
-    return valueStr;
-  }
-  @Override
-  public Object getObject() {
-    return value;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamInts(IntConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamLongs(LongConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamFloats(FloatConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamDoubles(DoubleConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(valueStr);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(value);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java
deleted file mode 100644
index d4c54d0..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-import java.util.function.LongConsumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.value.LongValue;
-import org.apache.solr.analytics.value.LongValue.CastingLongValue;
-
-/**
- * A constant {@link LongValue}. Every call to {@link #getLong()} and other methods will return the same constant value.
- */
-public class ConstantLongValue extends ConstantValue implements CastingLongValue {
-  private final long value;
-  private final String valueStr;
-  public static final String name = "const_long";
-  private final String exprStr;
-
-  public ConstantLongValue(long value) {
-    this.value = value;
-    this.valueStr = Long.toString(value);
-    this.exprStr = ConstantValue.createExpressionString(this, valueStr);
-  }
-
-
-  @Override
-  public long getLong() {
-    return value;
-  }
-  @Override
-  public double getDouble() {
-    return value;
-  }
-  @Override
-  public String getString() {
-    return valueStr;
-  }
-  @Override
-  public Object getObject() {
-    return value;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamLongs(LongConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamDoubles(DoubleConsumer cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(valueStr);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(value);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java
deleted file mode 100644
index c32a2a3..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.util.function.Consumer;
-
-import org.apache.solr.analytics.facet.compare.ConstantComparator;
-import org.apache.solr.analytics.value.StringValue;
-import org.apache.solr.analytics.value.StringValue.CastingStringValue;
-
-/**
- * A constant {@link StringValue}. Every call to {@link #getString()} and other methods will return the same constant value.
- */
-public class ConstantStringValue extends ConstantValue implements CastingStringValue {
-  String value;
-  public static final String name = "const_str";
-  private final String exprStr;
-
-  public ConstantStringValue(String value) {
-    this.value = value;
-    this.exprStr = ConstantValue.createExpressionString(this, value);
-  }
-
-  @Override
-  public String getString() {
-    return value;
-  }
-  @Override
-  public Object getObject() {
-    return value;
-  }
-  @Override
-  public boolean exists() {
-    return true;
-  }
-
-  @Override
-  public void streamStrings(Consumer<String> cons) {
-    cons.accept(value);
-  }
-  @Override
-  public void streamObjects(Consumer<Object> cons) {
-    cons.accept(value);
-  }
-
-  @Override
-  public ConstantComparator getObjectComparator(String expression) {
-    return new ConstantComparator();
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getExpressionStr() {
-    return exprStr;
-  }
-
-  @Override
-  public ExpressionType getExpressionType() {
-    return ExpressionType.CONST;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java
deleted file mode 100644
index 5691f64..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.analytics.value.constant;
-
-import java.time.Instant;
-import java.time.format.DateTimeParseException;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.solr.analytics.ExpressionFactory.ConstantFunction;
-import org.apache.solr.analytics.value.AnalyticsValue;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-
-/**
- * The parent class of all constant Analytics values.
- * <p>
- * Constant values can be specified in the following ways in analytics requests:
- * <ul>
- * <li> Constant booleans must match one of the following in any case: true, t, false, f
- * <li> Constant strings must be surrounded with "s or 's
- * <li> Constant numbers do not have to be surrounded with anything (floats are currently not supported)
- * <li> Constant dates must be formated in the ISO-8601 instant format
- * </ul>
- */
-public abstract class ConstantValue implements AnalyticsValue {
-  private static final Pattern truePattern = Pattern.compile("^true|t$", Pattern.CASE_INSENSITIVE);
-  private static final Pattern falsePattern = Pattern.compile("^false|f$", Pattern.CASE_INSENSITIVE);
-  
-  public static final ConstantFunction creatorFunction = (param -> {
-    param = param.trim();
-    
-    // Try to create a string
-    if ((param.charAt(0)=='"' && param.charAt(param.length()-1)=='"')
-        || (param.charAt(0)=='\'' && param.charAt(param.length()-1)=='\'')) {
-      return new ConstantStringValue(param.substring(1, param.length()-1));
-    }
-    
-    // Try to create a boolean
-    Matcher m = truePattern.matcher(param);
-    if (m.matches()) {
-      return new ConstantBooleanValue(true);
-    }
-    m = falsePattern.matcher(param);
-    if (m.matches()) {
-      return new ConstantBooleanValue(false);
-    }
-    
-    // Try to create a number
-    try {
-      long longTemp = Long.parseLong(param);
-      if (longTemp == (int) longTemp) {
-        return new ConstantIntValue((int) longTemp);
-      } else {
-        return new ConstantLongValue(longTemp);
-      }
-    } catch (NumberFormatException e1) {
-      try {
-        return new ConstantDoubleValue(Double.parseDouble(param));
-      } catch (NumberFormatException e2) {}
-    }
-    
-    // Try to create a date
-    try {
-      return new ConstantDateValue(Instant.parse(param).toEpochMilli());
-    } catch (DateTimeParseException e) {
-      throw new SolrException(ErrorCode.BAD_REQUEST,"The parameter "+param+" could not be cast to any constant.");
-    }
-    
-  });
-  
-  @Override
-  public AnalyticsValue convertToConstant() {
-    return this;
-  }
-  
-  static String createExpressionString(AnalyticsValueStream func, 
-                                       Object param) {
-    return String.format(Locale.ROOT,"%s(%s)",
-                         func.getName(),
-                         param.toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java
deleted file mode 100644
index eb6f29d..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
- 
-/** 
- * Constant values to be used in analytics expressions.
- */
-package org.apache.solr.analytics.value.constant;
-
-

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/package-info.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/package-info.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/package-info.java
deleted file mode 100644
index 247b592..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/value/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
- 
-/** 
- * Value types for analytics expressions.
- */
-package org.apache.solr.analytics.value;
-
-

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java b/solr/contrib/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java
deleted file mode 100644
index 64eb321..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.handler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import org.apache.lucene.search.MatchNoDocsQuery;
-import org.apache.lucene.search.Query;
-import org.apache.solr.analytics.AnalyticsDriver;
-import org.apache.solr.analytics.AnalyticsRequestManager;
-import org.apache.solr.analytics.AnalyticsRequestParser;
-import org.apache.solr.analytics.ExpressionFactory;
-import org.apache.solr.analytics.stream.AnalyticsShardResponseParser;
-import org.apache.solr.client.solrj.io.ModelCache;
-import org.apache.solr.client.solrj.io.SolrClientCache;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.handler.component.AnalyticsComponent;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.AnalyticsShardResponseWriter;
-import org.apache.solr.response.AnalyticsShardResponseWriter.AnalyticsResponse;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.search.DocSet;
-import org.apache.solr.search.Filter;
-import org.apache.solr.search.QParser;
-import org.apache.solr.search.QParserPlugin;
-import org.apache.solr.search.QueryParsing;
-import org.apache.solr.search.SolrIndexSearcher;
-import org.apache.solr.search.SyntaxError;
-import org.apache.solr.security.AuthorizationContext;
-import org.apache.solr.security.PermissionNameProvider;
-import org.apache.solr.util.plugin.SolrCoreAware;
-
-/**
- * Handler for Analytics shard requests. This handler should only be called by the {@link AnalyticsComponent}
- * since the response is written in a bit-stream, formatted by the {@link AnalyticsShardResponseWriter}
- * that can only be read by the {@link AnalyticsShardResponseParser}.
- */
-public class AnalyticsHandler extends RequestHandlerBase implements SolrCoreAware, PermissionNameProvider {
-  public static final String NAME = "/analytics";
-  private IndexSchema indexSchema;
-
-  static SolrClientCache clientCache = new SolrClientCache();
-  static ModelCache modelCache = null;
-
-  @Override
-  public PermissionNameProvider.Name getPermissionName(AuthorizationContext request) {
-    return PermissionNameProvider.Name.READ_PERM;
-  }
-
-  @Override
-  public void inform(SolrCore core) {
-    core.registerResponseWriter(AnalyticsShardResponseWriter.NAME, new AnalyticsShardResponseWriter());
-    
-    indexSchema = core.getLatestSchema();
-    AnalyticsRequestParser.init();
-  }
-
-  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
-    try {
-      DocSet docs;
-      try {
-        docs = getDocuments(req);
-      } catch (SyntaxError e) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-      }
-      // The olap-style requests are converted to the current format in the AnalyticsComponent
-      // so the AnalyticsHandler only needs to handle current format requests.
-      AnalyticsRequestManager manager = AnalyticsRequestParser.parse(req.getParams().get(AnalyticsRequestParser.analyticsParamName), 
-                                                                new ExpressionFactory(indexSchema),
-                                                                false);
-      // Collect the reduction data for the request
-      SolrIndexSearcher searcher = req.getSearcher();
-      Filter filter = docs.getTopFilter();
-      AnalyticsDriver.drive(manager, searcher, filter, req);
-      
-      // Do not calculate results, instead export the reduction data for this shard.
-      rsp.addResponse(new AnalyticsResponse(manager));
-    } catch (SolrException e) {
-      rsp.addResponse(new AnalyticsResponse(e));
-    }
-  }
-  
-  /**
-   * Get the documents returned by the query and filter queries included in the request.
-   * 
-   * @param req the request sent to the handler
-   * @return the set of documents matching the query
-   * @throws SyntaxError if there is a syntax error in the queries
-   * @throws IOException if an error occurs while searching the index
-   */
-  private DocSet getDocuments(SolrQueryRequest req) throws SyntaxError, IOException {
-    SolrParams params = req.getParams();
-    ArrayList<Query> queries = new ArrayList<>();
-
-    // Query Param
-    String queryString = params.get( CommonParams.Q );
-    
-    String defType = params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE);
-
-    QParser parser = QParser.getParser(queryString, defType, req);
-    Query query = parser.getQuery();
-    if (query == null) {
-      // normalize a null query to a query that matches nothing
-      query = new MatchNoDocsQuery();
-    }
-    queries.add(query);
-
-    // Filter Params
-    String[] fqs = req.getParams().getParams(CommonParams.FQ);
-    if (fqs!=null) {
-      for (String fq : fqs) {
-        if (fq != null && fq.trim().length()!=0) {
-          QParser fqp = QParser.getParser(fq, req);
-          queries.add(fqp.getQuery());
-        }
-      }
-    }
-    return req.getSearcher().getDocSet(queries);
-  }
-
-  @Override
-  public String getDescription() {
-    return NAME;
-  }
-
-  public String getSource() {
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java b/solr/contrib/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java
deleted file mode 100644
index 71c6c92..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.handler.component;
-
-import java.io.IOException;
-
-import org.apache.solr.analytics.AnalyticsDriver;
-import org.apache.solr.analytics.AnalyticsRequestManager;
-import org.apache.solr.analytics.AnalyticsRequestParser;
-import org.apache.solr.analytics.ExpressionFactory;
-import org.apache.solr.analytics.stream.AnalyticsShardRequestManager;
-import org.apache.solr.analytics.util.OldAnalyticsParams;
-import org.apache.solr.analytics.util.OldAnalyticsRequestConverter;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;
-
-/**
- * Computes analytics requests.
- */
-public class AnalyticsComponent extends SearchComponent {
-  public static final String COMPONENT_NAME = "analytics";
-  
-  @Override
-  public void init(NamedList args) {
-    AnalyticsRequestParser.init();
-  }
-
-  @Override
-  public void prepare(ResponseBuilder rb) throws IOException {
-    // First check to see if there is an analytics request using the current format
-    String analyticsRequest = rb.req.getParams().get(AnalyticsRequestParser.analyticsParamName);
-    rb._isOlapAnalytics = false;
-    rb.doAnalytics = false;
-    if (analyticsRequest != null) {
-      rb.doAnalytics = true;
-      rb._analyticsRequestManager = AnalyticsRequestParser.parse(analyticsRequest, new ExpressionFactory(rb.req.getSchema()), rb.isDistrib);
-    }
-    // If there is no request in the current format, check for the old olap-style format
-    else if (rb.req.getParams().getBool(OldAnalyticsParams.OLD_ANALYTICS,false)) {
-      rb._analyticsRequestManager = AnalyticsRequestParser.parse(OldAnalyticsRequestConverter.convert(rb.req.getParams()), new ExpressionFactory(rb.req.getSchema()), rb.isDistrib);
-      rb._isOlapAnalytics = true;
-      rb.doAnalytics = true;
-    }
-    
-    if (rb.doAnalytics) {
-      AnalyticsRequestManager reqManager = (AnalyticsRequestManager)rb._analyticsRequestManager;
-      // Check to see if the request is distributed
-      if (rb.isDistrib) {
-        reqManager.sendShards = true;
-        reqManager.shardStream = new AnalyticsShardRequestManager(rb.req.getParams(), reqManager);
-      } else {
-        reqManager.sendShards = false;
-        rb.setNeedDocSet( true );
-      }
-    }
-  }
-
-  @Override
-  public void process(ResponseBuilder rb) throws IOException {
-    if (!rb.doAnalytics) {
-      return;
-    }
-    AnalyticsRequestManager reqManager = (AnalyticsRequestManager)rb._analyticsRequestManager;
-    // Collect the data and generate a response
-    AnalyticsDriver.drive(reqManager, rb.req.getSearcher(), rb.getResults().docSet.getTopFilter(), rb.req);
-    
-    if (rb._isOlapAnalytics) {
-      rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_OLD_HEADER, reqManager.createOldResponse());
-    } else {
-      rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_HEADER, reqManager.createResponse());
-    }
-
-    rb.doAnalytics = false;
-  }
-  
-  
-  @Override
-  public int distributedProcess(ResponseBuilder rb) throws IOException {
-    if (!rb.doAnalytics || rb.stage != ResponseBuilder.STAGE_EXECUTE_QUERY) {
-      return ResponseBuilder.STAGE_DONE;
-    }
-    AnalyticsRequestManager reqManager = (AnalyticsRequestManager)rb._analyticsRequestManager;
-    if (!reqManager.sendShards){
-      return ResponseBuilder.STAGE_DONE;
-    }
-    
-    // Send out a request to each shard and merge the responses into our AnalyticsRequestManager
-    reqManager.shardStream.sendRequests(rb.req.getCore().getCoreDescriptor().getCollectionName(),
-        rb.req.getCore().getCoreContainer().getZkController().getZkServerAddress());
-    
-    reqManager.sendShards = false;
-    
-    return ResponseBuilder.STAGE_DONE;
-  }
-  
-  @Override
-  public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
-    // We don't want the shard requests to compute analytics, since we send
-    // separate requests for that in distributedProcess() to the AnalyticsHandler
-    sreq.params.remove(AnalyticsRequestParser.analyticsParamName);
-    sreq.params.remove(OldAnalyticsParams.OLD_ANALYTICS);
-    
-    super.modifyRequest(rb, who, sreq);
-  }
-  
-  @Override
-  public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
-    
-    // NO-OP since analytics shard responses are handled through the AnalyticsResponseParser
-    
-    super.handleResponses(rb, sreq);
-  }
- 
-  @Override
-  public void finishStage(ResponseBuilder rb) {
-    if (rb.doAnalytics && rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
-      AnalyticsRequestManager reqManager = (AnalyticsRequestManager)rb._analyticsRequestManager;
-      // Generate responses from the merged shard data
-      if (rb._isOlapAnalytics) {
-        rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_OLD_HEADER, reqManager.createOldResponse());
-      } else {
-        rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_HEADER, reqManager.createResponse());
-      }
-    }
-    
-    super.finishStage(rb);
-  }
-  
-  
-  @Override
-  public String getName() {
-    return COMPONENT_NAME;
-  }
-  
-  @Override
-  public String getDescription() {
-    return "Perform analytics";
-  }
-
-  /*@Override
-  public NamedList getStatistics() {
-    return analyticsCollector.getStatistics();
-  }*/
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/handler/component/package.html
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/handler/component/package.html b/solr/contrib/analytics/src/java/org/apache/solr/handler/component/package.html
deleted file mode 100644
index c5d1103..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/handler/component/package.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<!--
- 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.
--->
-<!-- not a package-info.java, because we already defined this package in core/ -->
-<html>
-<head>
-   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-</head>
-<body>
-<p>
-Search component for the analytics component
-</p>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/handler/package.html
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/handler/package.html b/solr/contrib/analytics/src/java/org/apache/solr/handler/package.html
deleted file mode 100644
index 6a5c2c3..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/handler/package.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<!--
- 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.
--->
-<!-- not a package-info.java, because we already defined this package in core/ -->
-<html>
-<head>
-   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-</head>
-<body>
-<p>
-Handler for distributed analytics requests to shards.
-</p>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.java b/solr/contrib/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.java
deleted file mode 100644
index 52c71ee..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.response;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-
-import org.apache.solr.analytics.AnalyticsRequestManager;
-import org.apache.solr.analytics.stream.AnalyticsShardResponseParser;
-import org.apache.solr.client.solrj.impl.BinaryResponseParser;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.request.SolrQueryRequest;
-
-/**
- * Writes the reduction data of a analytics shard request to a bit-stream to send to the originating shard.
- * The response must be parsed by the {@link AnalyticsShardResponseParser} initialized with the same analytics request
- * as the shard request was sent.
- */
-public class AnalyticsShardResponseWriter implements BinaryQueryResponseWriter {
-  public static final String NAME = "analytics_shard_stream";
-  public static final String ANALYTICS_MANGER = "analyticsManager";
-
-  @Override
-  public void write(OutputStream out, SolrQueryRequest req, SolrQueryResponse response) throws IOException {
-    ((AnalyticsResponse)response.getResponse()).write(new DataOutputStream(out));;
-  }
-
-  @Override
-  public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse response) throws IOException {
-    throw new RuntimeException("This is a binary writer , Cannot write to a characterstream");
-  }
-
-  @Override
-  public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {
-    return BinaryResponseParser.BINARY_CONTENT_TYPE;
-  }
-
-  @Override
-  public void init(NamedList args) {}
-  
-  /**
-   * Manages the streaming of analytics reduction data if no exception occurred.
-   * Otherwise the exception is streamed over.
-   */
-  public static class AnalyticsResponse {
-    private final AnalyticsRequestManager manager;
-    private final SolrException exception;
-    
-    private final boolean requestSuccessful;
-    
-    public AnalyticsResponse(AnalyticsRequestManager manager) {
-      this.manager = manager;
-      this.exception = null;
-      this.requestSuccessful = true;
-    }
-    
-    public AnalyticsResponse(SolrException exception) {
-      this.manager = null;
-      this.exception = exception;
-      this.requestSuccessful = false;
-    }
-    
-    public void write(DataOutputStream output) throws IOException {
-      output.writeBoolean(requestSuccessful);
-      if (requestSuccessful) {
-        manager.exportShardData(output);
-      } else {
-        new ObjectOutputStream(output).writeObject(exception);
-      }
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/org/apache/solr/response/package.html
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/response/package.html b/solr/contrib/analytics/src/java/org/apache/solr/response/package.html
deleted file mode 100644
index dd24f82..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/response/package.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<!--
- 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.
--->
-<!-- not a package-info.java, because we already defined this package in core/ -->
-<html>
-<head>
-   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-</head>
-<body>
-<p>
-Response Writer for distributed analytics response from a shard.
-</p>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/java/overview.html
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/overview.html b/solr/contrib/analytics/src/java/overview.html
deleted file mode 100644
index 68c3ff2..0000000
--- a/solr/contrib/analytics/src/java/overview.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
- 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.
--->
-<html>
-<body>
-Apache Solr Search Server: Analytics Component
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsDriver.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsDriver.java b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsDriver.java
new file mode 100644
index 0000000..21b053f
--- /dev/null
+++ b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsDriver.java
@@ -0,0 +1,82 @@
+/*
+ * 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.analytics;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.search.DocIdSet;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.solr.analytics.AnalyticsRequestManager.StreamingInfo;
+import org.apache.solr.analytics.facet.AbstractSolrQueryFacet.FacetValueQueryExecuter;
+import org.apache.solr.analytics.facet.StreamingFacet;
+import org.apache.solr.analytics.function.ReductionCollectionManager;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.Filter;
+import org.apache.solr.search.SolrIndexSearcher;
+
+public class AnalyticsDriver {
+  
+  /**
+   * Drive the collection of reduction data. This includes overall data as well as faceted data.
+   * 
+   * @param manager of the request to drive
+   * @param searcher the results of the query
+   * @param filter that represents the overall query
+   * @param queryRequest used for the search request
+   * @throws IOException if an error occurs while reading from Solr
+   */
+  public static void drive(AnalyticsRequestManager manager, SolrIndexSearcher searcher, Filter filter, SolrQueryRequest queryRequest) throws IOException {
+    StreamingInfo streamingInfo = manager.getStreamingFacetInfo();
+    Iterable<StreamingFacet> streamingFacets = streamingInfo.streamingFacets;
+    ReductionCollectionManager collectionManager = streamingInfo.streamingCollectionManager;
+    
+    Iterable<FacetValueQueryExecuter> facetExecuters = manager.getFacetExecuters(filter, queryRequest);
+    
+    // Streaming phase (Overall results & Value/Pivot Facets)
+    // Loop through all documents and collect reduction data for streaming facets and overall results
+    if (collectionManager.needsCollection()) {
+      List<LeafReaderContext> contexts = searcher.getTopReaderContext().leaves();
+      for (int leafNum = 0; leafNum < contexts.size(); leafNum++) {
+        LeafReaderContext context = contexts.get(leafNum);
+        DocIdSet dis = filter.getDocIdSet(context, null); // solr docsets already exclude any deleted docs
+        if (dis == null) {
+          continue;
+        }
+        DocIdSetIterator disi = dis.iterator();
+        if (disi != null) {
+          collectionManager.doSetNextReader(context);
+          int doc = disi.nextDoc();
+          while( doc != DocIdSetIterator.NO_MORE_DOCS){
+            // Add a document to the statistics being generated
+            collectionManager.collect(doc);
+            streamingFacets.forEach( facet -> facet.addFacetValueCollectionTargets() );
+            collectionManager.apply();
+            doc = disi.nextDoc();
+          }
+        }
+      }
+    }
+    
+    // Executing phase (Query/Range Facets)
+    // Send additional Solr Queries to compute facet values
+    for (FacetValueQueryExecuter executer : facetExecuters) {
+      executer.execute(searcher);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsExpression.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsExpression.java b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsExpression.java
new file mode 100644
index 0000000..044e371
--- /dev/null
+++ b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsExpression.java
@@ -0,0 +1,64 @@
+/*
+ * 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.analytics;
+
+import org.apache.solr.analytics.function.ReductionCollectionManager;
+import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;
+import org.apache.solr.analytics.value.AnalyticsValue;
+
+/**
+ * A wrapper for a top-level analytics expression.
+ * The expression must have a name and be single valued.
+ */
+public class AnalyticsExpression {
+  private final AnalyticsValue expression;
+  private final String name;
+  
+  public AnalyticsExpression(String name, AnalyticsValue expression) {
+    this.name = name;
+    this.expression = expression;
+  }
+  
+  public String getName() {
+    return name;
+  }
+  
+  public AnalyticsValue getExpression() {
+    return expression;
+  }
+  
+  /**
+   * Get the current value of the expression.
+   * This method can, and will, be called multiple times to return different values.
+   * The value returned is based on the {@link ReductionDataCollection} given
+   * to the {@link ReductionCollectionManager#setData} method.
+   * 
+   * @return the current value of the expression
+   */
+  public Object toObject() {
+    return expression.getObject();
+  }
+  
+  /**
+   * NOTE: Must be called after {@link #toObject()} is called, otherwise the value is not guaranteed to be correct.
+   * 
+   * @return whether the current value of the expression exists.
+   */
+  public boolean exists() {
+    return expression.exists();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsGroupingManager.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsGroupingManager.java b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsGroupingManager.java
new file mode 100644
index 0000000..a95a451
--- /dev/null
+++ b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsGroupingManager.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file inputtributed 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
+ * inputtributed under the License is inputtributed 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.analytics;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.function.Consumer;
+
+import org.apache.solr.analytics.facet.AnalyticsFacet;
+import org.apache.solr.analytics.facet.PivotFacet;
+import org.apache.solr.analytics.facet.AbstractSolrQueryFacet;
+import org.apache.solr.analytics.facet.QueryFacet;
+import org.apache.solr.analytics.facet.RangeFacet;
+import org.apache.solr.analytics.facet.StreamingFacet;
+import org.apache.solr.analytics.facet.ValueFacet;
+import org.apache.solr.analytics.facet.AbstractSolrQueryFacet.FacetValueQueryExecuter;
+import org.apache.solr.analytics.function.ExpressionCalculator;
+import org.apache.solr.analytics.function.ReductionCollectionManager;
+import org.apache.solr.analytics.util.AnalyticsResponseHeadings;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.Filter;
+
+/**
+ * The manager for faceted analytics. This class manages one grouping of facets and expressions to compute
+ * over those facets.
+ * 
+ * <p>
+ * This class will only manage generating faceted results, not overall results.
+ */
+public class AnalyticsGroupingManager {
+  private final String name;
+  private final ReductionCollectionManager reductionCollectionManager;
+
+  private final Collection<AnalyticsExpression> topLevelExpressions;
+  private final ExpressionCalculator expressionCalculator;
+  
+  private final Map<String, AnalyticsFacet> facets;
+  
+  public AnalyticsGroupingManager(String name,
+                                  ReductionCollectionManager reductionCollectionManager,
+                                  Collection<AnalyticsExpression> topLevelExpressions) {
+    this.name = name;
+    this.reductionCollectionManager = reductionCollectionManager;
+
+    this.topLevelExpressions = topLevelExpressions;
+    this.expressionCalculator = new ExpressionCalculator(topLevelExpressions);
+
+    this.facets = new HashMap<>();
+  }
+
+  // This is outside of the method, since it is used in the lambda and cannot be a local non-final variable
+  private boolean hasStreamingFacets;
+  
+  /**
+   * Get the {@link StreamingFacet}s (e.g. {@link ValueFacet} and {@link PivotFacet}) contained within this grouping,
+   * returning them through the given consumer.
+   * 
+   * @param cons where the streaming facets are passed to
+   * @return whether the grouping contains streaming facets
+   */
+  public boolean getStreamingFacets(Consumer<StreamingFacet> cons) {
+    hasStreamingFacets = false;
+    facets.forEach( (name, facet) -> {
+      if (facet instanceof StreamingFacet) {
+        cons.accept((StreamingFacet)facet);
+        hasStreamingFacets = true;
+      }
+    });
+    return hasStreamingFacets;
+  }
+
+  /**
+   * Create the {@link FacetValueQueryExecuter}s for all {@link AbstractSolrQueryFacet}s
+   * (e.g. {@link QueryFacet} and {@link RangeFacet}) contained within this grouping.
+   * The executers are returned through the given consumer.
+   * 
+   * <p>
+   * One {@link FacetValueQueryExecuter} is created for each facet value to be returned for a facet.
+   * Since every {@link AbstractSolrQueryFacet} has discrete and user-defined facet values,
+   * unlike {@link StreamingFacet}s, a discrete number of {@link FacetValueQueryExecuter}s are created and returned.
+   * 
+   * @param filter representing the overall Solr Query of the request,
+   * will be combined with the facet value queries
+   * @param queryRequest from the overall search request
+   * @param cons where the executers are passed to
+   */
+  public void getFacetExecuters(Filter filter, SolrQueryRequest queryRequest, Consumer<FacetValueQueryExecuter> cons) {
+    facets.forEach( (name, facet) -> {
+      if (facet instanceof AbstractSolrQueryFacet) {
+        ((AbstractSolrQueryFacet)facet).createFacetValueExecuters(filter, queryRequest, cons);
+      }
+    });
+  }
+  
+  /**
+   * Add a facet to the grouping. All expressions in this grouping will be computed over the facet.
+   * 
+   * @param facet to compute expressions over
+   */
+  public void addFacet(AnalyticsFacet facet) {
+    facet.setExpressionCalculator(expressionCalculator);
+    facet.setReductionCollectionManager(reductionCollectionManager);
+    facets.put(facet.getName(), facet);
+  }
+  
+  /**
+   * Import the shard data for this grouping from a bit-stream,
+   * exported by the {@link #exportShardData} method in the each of the collection's shards.
+   * 
+   * @param input The bit-stream to import the grouping data from
+   * @throws IOException if an exception occurs while reading from the {@link DataInput}
+   */
+  public void importShardData(DataInput input) throws IOException {
+    // This allows mergeData() to import from the same input everytime it is called
+    // while the facets are importing.
+    reductionCollectionManager.setShardInput(input);
+    
+    int sz = input.readInt();
+    for (int i = 0; i < sz; ++i) {
+      facets.get(input.readUTF()).importShardData(input);
+    }
+  }
+  
+  /**
+   * Export the shard data for this grouping through a bit-stream,
+   * to be imported by the {@link #importShardData} method in the originating shard.
+   * 
+   * @param output The bit-stream to output the grouping data through
+   * @throws IOException if an exception occurs while writing to the {@link DataOutput}
+   */
+  public void exportShardData(DataOutput output) throws IOException {
+    // This allows exportData() to export to the same output everytime it is called
+    // while the facets are exporting.
+    reductionCollectionManager.setShardOutput(output);
+    
+    output.writeInt(facets.size());
+    for (Entry<String,AnalyticsFacet> facet : facets.entrySet()) {
+      output.writeUTF(facet.getKey());
+      facet.getValue().exportShardData(output);
+    }
+  }
+  
+  /**
+   * Get the {@link ReductionCollectionManager} that manages the collection of reduction data for the expressions
+   * contained within this grouping. 
+   * 
+   * @return the grouping's reduction manager
+   */
+  public ReductionCollectionManager getReductionManager() {
+    return reductionCollectionManager;
+  }
+
+  /**
+   * Create the response for this grouping, a mapping from each of it's facets' names to the facet's response.
+   * 
+   * @return the named list representation of the response
+   */
+  public Map<String,Object> createResponse() {
+    Map<String,Object> response = new HashMap<>();
+    
+    // Add the value facet buckets to the output
+    facets.forEach( (name, facet) -> response.put(name, facet.createResponse()) );
+
+    return response;
+  }
+  
+  /**
+   * Create the response for this grouping, but in the old style of response.
+   * This response has a bucket for the following if they are contained in the grouping:
+   * FieldFacets, RangeFacets and QueryFacets.
+   * Each facet's name and response are put into the bucket corresponding to its type.
+   * <p>
+   * Since groupings in the old notation must also return overall results, the overall results are
+   * passed in and the values are used to populate the grouping response.
+   * 
+   * @param overallResults of the expressions to add to the grouping response
+   * @return the named list representation of the response
+   */
+  public NamedList<Object> createOldResponse(Map<String,Object> overallResults) {
+    NamedList<Object> response = new NamedList<>();
+    
+    topLevelExpressions.forEach( expression -> response.add(expression.getName(), overallResults.get(name + expression.getName())));
+
+    NamedList<Object> fieldFacetResults = new NamedList<>();
+    NamedList<Object> rangeFacetResults = new NamedList<>();
+    NamedList<Object> queryFacetResults = new NamedList<>();
+    // Add the field facet buckets to the output
+    facets.forEach( (name, facet) -> {
+      // The old style of request only accepts field facets
+      // So we can assume that all value facets are field facets
+      if (facet instanceof ValueFacet) {
+        fieldFacetResults.add(name, facet.createOldResponse());
+      } else if (facet instanceof RangeFacet) {
+        rangeFacetResults.add(name, facet.createOldResponse());
+      } else if (facet instanceof QueryFacet) {
+        queryFacetResults.add(name, facet.createOldResponse());
+      }
+    });
+    if (fieldFacetResults.size() > 0) {
+      response.add(AnalyticsResponseHeadings.FIELD_FACETS, fieldFacetResults);
+    }
+    if (rangeFacetResults.size() > 0) {
+      response.add(AnalyticsResponseHeadings.RANGE_FACETS, rangeFacetResults);
+    }
+    if (queryFacetResults.size() > 0) {
+      response.add(AnalyticsResponseHeadings.QUERY_FACETS, queryFacetResults);
+    }
+    return response;
+  }
+
+  /**
+   * Get the name of the grouping.
+   * 
+   * @return the grouping name
+   */
+  public String getName() {
+    return name;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsRequestManager.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsRequestManager.java b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsRequestManager.java
new file mode 100644
index 0000000..45b958f
--- /dev/null
+++ b/solr/contrib/analytics/src/main/java/org/apache/solr/analytics/AnalyticsRequestManager.java
@@ -0,0 +1,279 @@
+/*
+ * 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.analytics;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analytics.facet.AbstractSolrQueryFacet;
+import org.apache.solr.analytics.facet.AbstractSolrQueryFacet.FacetValueQueryExecuter;
+import org.apache.solr.analytics.facet.StreamingFacet;
+import org.apache.solr.analytics.function.ExpressionCalculator;
+import org.apache.solr.analytics.function.ReductionCollectionManager;
+import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;
+import org.apache.solr.analytics.stream.AnalyticsShardRequestManager;
+import org.apache.solr.analytics.util.AnalyticsResponseHeadings;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.Filter;
+
+/**
+ * The manager of an entire analytics request.
+ */
+public class AnalyticsRequestManager {
+  private final ReductionCollectionManager ungroupedReductionManager;
+  private ReductionDataCollection ungroupedData;
+  
+  private final Map<String, AnalyticsGroupingManager> groupingManagers;
+  
+  private final Collection<AnalyticsExpression> ungroupedExpressions;
+  private final ExpressionCalculator ungroupedExpressionCalculator;
+  
+  /**
+   * If the request is distributed, the manager for shard requests.
+   */
+  public String analyticsRequest;
+  public AnalyticsShardRequestManager shardStream;
+  public boolean sendShards; 
+  
+  /**
+   * Create an manager with the given ungrouped expressions. This is straightforward in the new
+   * style of request, however in the old olap-style requests all groupings' expressions are expected
+   * to be ungrouped as well.
+   * 
+   * 
+   * @param ungroupedReductionManager to manage the reduction collection for all ungrouped expressions
+   * @param ungroupedExpressions to compute overall results for
+   */
+  public AnalyticsRequestManager(ReductionCollectionManager ungroupedReductionManager,
+                                 Collection<AnalyticsExpression> ungroupedExpressions) {
+    this.ungroupedReductionManager = ungroupedReductionManager;
+    this.ungroupedData = ungroupedReductionManager.newDataCollection();
+    this.ungroupedReductionManager.addLastingCollectTarget(ungroupedData);
+    
+    this.ungroupedExpressions = ungroupedExpressions;
+    this.ungroupedExpressionCalculator = new ExpressionCalculator(ungroupedExpressions);
+    this.groupingManagers = new HashMap<>();
+  }
+  
+  /**
+   * Get the collection manager for ungrouped expressions, including grouped expressions if
+   * the old request notation is used.
+   * 
+   * @return the collection manager for the ungrouped expressions
+   */
+  public ReductionCollectionManager getUngroupedCollectionManager() {
+    return ungroupedReductionManager;
+  }
+  
+  /**
+   * Get the collection manager for all ungrouped expressions, including grouped expressions if
+   * the old request notation is used.
+   * 
+   * @return the collection manager for the ungrouped expressions
+   */
+  public ReductionDataCollection getUngroupedData() {
+    return ungroupedData;
+  }
+  
+  /**
+   * Return all ungrouped expressions, including grouped expressions if
+   * the old request notation is used.
+   * 
+   * @return an {@link Iterable} of the ungrouped expressions
+   */
+  public Iterable<AnalyticsExpression> getUngroupedExpressions() {
+    return ungroupedExpressions;
+  }
+  
+  /**
+   * Generate the results of all ungrouped expressions, including grouped expressions if
+   * the old request notation is used.
+   * 
+   * @param response the response to add the ungrouped results to.
+   */
+  public void addUngroupedResults(Map<String,Object> response) {
+    ungroupedReductionManager.setData(ungroupedData);
+    ungroupedExpressionCalculator.addResults(response);
+  }
+  
+  /**
+   * Generate the results of all ungrouped expressions, including grouped expressions if
+   * the old request notation is used.
+   * 
+   * @return the map containing the ungrouped results
+   */
+  public Map<String,Object> getUngroupedResults() {
+    ungroupedReductionManager.setData(ungroupedData);
+    return ungroupedExpressionCalculator.getResults();
+  }
+  
+  /**
+   * Add a grouping to the request.
+   * 
+   * @param groupingManager that manages the grouping
+   */
+  public void addGrouping(AnalyticsGroupingManager groupingManager) {
+    groupingManagers.put(groupingManager.getName(), groupingManager);
+  }
+  
+  /**
+   * Import the shard data for this request from a bit-stream,
+   * exported by the {@link #exportShardData} method in the each of the collection's shards.
+   * <p>
+   * First the overall data is imported, then the grouping data is imported.
+   * 
+   * @param input The bit-stream to import the shard data from
+   * @throws IOException if an exception occurs while reading from the {@link DataInput}
+   */
+  public synchronized void importShardData(DataInput input) throws IOException {
+    ungroupedReductionManager.setShardInput(input);
+    
+    // The ungroupedData will not exist for the first shard imported
+    if (ungroupedData == null) {
+      ungroupedData = ungroupedReductionManager.newDataCollectionIO();
+    } else {
+      ungroupedReductionManager.prepareReductionDataIO(ungroupedData);
+    }
+    ungroupedReductionManager.mergeData();
+    
+    int size = input.readInt();
+    while (--size >= 0) {
+      String groupingName = input.readUTF();
+      groupingManagers.get(groupingName).importShardData(input);
+    }
+  }
+  
+  /**
+   * Export the shard data for this request through a bit-stream,
+   * to be imported by the {@link #importShardData} method in the originating shard.
+   * <p>
+   * First the overall data is exported, then the grouping data is exported.
+   * 
+   * @param output The bit-stream to output the shard data through
+   * @throws IOException if an exception occurs while writing to the {@link DataOutput}
+   */
+  public void exportShardData(DataOutput output) throws IOException {
+    ungroupedReductionManager.setShardOutput(output);
+    
+    ungroupedReductionManager.prepareReductionDataIO(ungroupedData);
+    ungroupedReductionManager.exportData();
+    
+    output.writeInt(groupingManagers.size());
+    for (String groupingName : groupingManagers.keySet()) {
+      output.writeUTF(groupingName);
+      groupingManagers.get(groupingName).exportShardData(output);
+    }
+  }
+
+  /**
+   * Consolidate the information of all {@link StreamingFacet}s contained within the request, since
+   * they need to be collected along with the overall results during the streaming phase of the 
+   * {@link AnalyticsDriver}.
+   * 
+   * @return the info for all {@link StreamingFacet}s
+   */
+  public StreamingInfo getStreamingFacetInfo() {
+    StreamingInfo streamingInfo = new StreamingInfo();
+    ArrayList<ReductionCollectionManager> groupingCollectors = new ArrayList<>();
+    groupingManagers.values().forEach( grouping -> {
+      // If a grouping has streaming facets, then that groupings expressions
+      // must be collected during the streaming phase. 
+      if (grouping.getStreamingFacets( facet -> streamingInfo.streamingFacets.add(facet) )) {
+        groupingCollectors.add(grouping.getReductionManager());
+      }
+    });
+    
+    // Create an streaming collection manager to manage the collection of all ungrouped expressions and
+    // grouped expressions that are calculated over streaming facets.
+    streamingInfo.streamingCollectionManager = ungroupedReductionManager.merge(groupingCollectors);
+    return streamingInfo;
+  }
+  
+  /**
+   * Class to encapsulate all necessary data for collecting {@link StreamingFacet}s.
+   */
+  public static class StreamingInfo {
+    Collection<StreamingFacet> streamingFacets = new ArrayList<>();
+    /**
+     * Manages the collection of all expressions needed for streaming facets
+     */
+    ReductionCollectionManager streamingCollectionManager;
+  }
+
+  /**
+   * Create the {@link FacetValueQueryExecuter}s for all {@link AbstractSolrQueryFacet}s contained in the request.
+   * 
+   * @param filter representing the overall search query
+   * @param queryRequest of the overall search query
+   * @return an {@link Iterable} of executers
+   */
+  public Iterable<FacetValueQueryExecuter> getFacetExecuters(Filter filter, SolrQueryRequest queryRequest) {
+    ArrayList<FacetValueQueryExecuter> facetExecutors = new ArrayList<>();
+    groupingManagers.values().forEach( grouping -> {
+      grouping.getFacetExecuters(filter, queryRequest, executor -> facetExecutors.add(executor));
+    });
+    return facetExecutors;
+  }
+  
+  /**
+   * Create the response for a request given in the old olap-style format.
+   * The old response returned overall expressions within groupings.
+   * 
+   * @return a {@link NamedList} representation of the response
+   */
+  public NamedList<Object> createOldResponse() {
+    NamedList<Object> analyticsResponse = new NamedList<>();
+    Map<String,Object> ungroupedResults = getUngroupedResults();
+    groupingManagers.forEach( (name, groupingManager) -> {
+      analyticsResponse.add(name, groupingManager.createOldResponse(ungroupedResults));
+    });
+    
+    return analyticsResponse;
+  }
+  
+  /**
+   * Create the response for a request.
+   * 
+   * <p>
+   * NOTE: Analytics requests specified in the old olap-style format
+   * have their responses generated by {@link #createOldResponse()}.
+   * 
+   * @return a {@link Map} representation of the response
+   */
+  public Map<String,Object> createResponse() {
+    Map<String,Object> analyticsResponse = new HashMap<>();
+    if (ungroupedExpressions.size() > 0) {
+      addUngroupedResults(analyticsResponse);
+    }
+
+    Map<String,Object> groupingsResponse = new HashMap<>();
+    groupingManagers.forEach( (name, groupingManager) -> {
+      groupingsResponse.put(name, groupingManager.createResponse());
+    });
+    
+    if (groupingsResponse.size() > 0) {
+      analyticsResponse.put(AnalyticsResponseHeadings.GROUPINGS, groupingsResponse);
+    }
+    return analyticsResponse;
+  }
+}
\ No newline at end of file