Apache Solr open-source search software
SOLR-16661 Remove deprecated Analytics Component in 10.0 (#1622)
Jan Høydahl67afcc228de5
diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradleindex 99275293657..29e43f913ce 100644--- a/gradle/documentation/render-javadoc.gradle+++ b/gradle/documentation/render-javadoc.gradle@@ -116,17 +116,6 @@ configure(project(":solr:modules:analysis-extras")) {}}-configure(project(":solr:modules:analytics")) {- project.tasks.withType(RenderJavadocTask) {- // TODO: clean up split packages SOLR-15604- javadocMissingIgnore = [- "org.apache.solr.handler",- "org.apache.solr.handler.component",- "org.apache.solr.response"- ]- }-}-configure(project(":solr:modules:langid")) {project.tasks.withType(RenderJavadocTask) {// TODO: clean up split packages SOLR-15604diff --git a/settings.gradle b/settings.gradleindex 3e9b0c4e065..65235015950 100644--- a/settings.gradle+++ b/settings.gradle@@ -32,7 +32,6 @@ include "solr:solrj-streaming"include "solr:core"include "solr:server"include "solr:modules:analysis-extras"-include "solr:modules:analytics"include "solr:modules:clustering"include "solr:modules:opentelemetry"include "solr:modules:extraction"diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d3a39aefe04..f5f70eb1174 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -31,6 +31,8 @@ Deprecation Removals* SOLR-15703: Removed deprecated SolrException#log methods (Kevin Risden)+* SOLR-16661: Removed deprecated 'analytics' component (janhoy)+Dependency Upgrades---------------------(No changes)diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.javaindex bb06eac78e1..ea90503ef5c 100644--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java+++ b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java@@ -60,7 +60,6 @@ public class ResponseBuilder {public boolean doExpand;public boolean doStats;public boolean doTerms;- public boolean doAnalytics;public MergeStrategy mergeFieldHandler;public String queryID;@@ -181,8 +180,6 @@ public class ResponseBuilder {StatsInfo _statsInfo;TermsComponent.TermsHelper _termsHelper;SimpleOrderedMap<List<NamedList<Object>>> _pivots;- Object _analyticsRequestManager;- boolean _isOlapAnalytics;// Context fields for groupingpublic final Map<String, Collection<SearchGroup<BytesRef>>> mergedSearchGroups = new HashMap<>();@@ -492,30 +489,6 @@ public class ResponseBuilder {this.nextCursorMark = nextCursorMark;}- public void setAnalytics(boolean doAnalytics) {- this.doAnalytics = doAnalytics;- }-- public boolean isAnalytics() {- return this.doAnalytics;- }-- public void setAnalyticsRequestManager(Object analyticsRequestManager) {- this._analyticsRequestManager = analyticsRequestManager;- }-- public Object getAnalyticsRequestManager() {- return this._analyticsRequestManager;- }-- public void setOlapAnalytics(boolean isOlapAnalytics) {- this._isOlapAnalytics = isOlapAnalytics;- }-- public boolean isOlapAnalytics() {- return this._isOlapAnalytics;- }-public void setCancellation(boolean isCancellation) {this.isCancellation = isCancellation;}diff --git a/solr/core/src/test/org/apache/solr/handler/component/ResponseBuilderTest.java b/solr/core/src/test/org/apache/solr/handler/component/ResponseBuilderTest.javaindex 7adfed4f68e..183ccb8e08c 100644--- a/solr/core/src/test/org/apache/solr/handler/component/ResponseBuilderTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/ResponseBuilderTest.java@@ -38,30 +38,4 @@ public class ResponseBuilderTest extends SolrTestCaseJ4 {ResponseBuilder responseBuilder = new ResponseBuilder(req, rsp, new ArrayList<>(0));assertFalse(responseBuilder.isDistributed());}-- public void testDoAnalyticsAccessors() {- ResponseBuilder rb = new ResponseBuilder(req, rsp, new ArrayList<>(0));- assertFalse(rb.isAnalytics());- rb.setAnalytics(true);- assertTrue(rb.isAnalytics());- rb.setAnalytics(false);- assertFalse(rb.isAnalytics());- }-- public void testIsOlapAnalyticsAccessors() {- ResponseBuilder rb = new ResponseBuilder(req, rsp, new ArrayList<>(0));- assertFalse(rb.isOlapAnalytics());- rb.setOlapAnalytics(true);- assertTrue(rb.isOlapAnalytics());- rb.setOlapAnalytics(false);- assertFalse(rb.isOlapAnalytics());- }-- public void testAnalyticsRequestManagerAccessors() {- ResponseBuilder rb = new ResponseBuilder(req, rsp, new ArrayList<>(0));- assertNull(rb.getAnalyticsRequestManager());- rb.setAnalyticsRequestManager(this);- assertNotNull(rb.getAnalyticsRequestManager());- assertEquals(rb.getAnalyticsRequestManager(), this);- }}diff --git a/solr/modules/analytics/build.gradle b/solr/modules/analytics/build.gradledeleted file mode 100644index 8e5b0d403c3..00000000000--- a/solr/modules/analytics/build.gradle+++ /dev/null@@ -1,36 +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.- */--apply plugin: 'java-library'--description = 'Analytics Package'--dependencies {- implementation project(':solr:core')- implementation project(':solr:solrj')-- implementation 'org.apache.lucene:lucene-core'-- implementation 'com.fasterxml.jackson.core:jackson-annotations'- implementation 'com.fasterxml.jackson.core:jackson-core'- implementation 'com.fasterxml.jackson.core:jackson-databind'-- testImplementation project(':solr:test-framework')- testImplementation 'com.carrotsearch.randomizedtesting:randomizedtesting-runner'- testImplementation 'junit:junit'- testImplementation 'org.slf4j:slf4j-api'-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsDriver.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsDriver.javadeleted file mode 100644index 9903f63d3b1..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsDriver.java+++ /dev/null@@ -1,85 +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;--import java.io.IOException;-import java.util.List;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.search.DocIdSetIterator;-import org.apache.lucene.search.Query;-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.DocSet;-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,- DocSet filter,- SolrQueryRequest queryRequest)- throws IOException {- StreamingInfo streamingInfo = manager.getStreamingFacetInfo();- Iterable<StreamingFacet> streamingFacets = streamingInfo.streamingFacets;- ReductionCollectionManager collectionManager = streamingInfo.streamingCollectionManager;-- Query fq =- filter.makeQuery(); // TODO: passing this along as a DocSet would affect a lot of APIs- Iterable<FacetValueQueryExecuter> facetExecuters = manager.getFacetExecuters(fq, 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);- DocIdSetIterator disi = filter.iterator(context);- 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);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsExpression.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsExpression.javadeleted file mode 100644index 0dfe046f2d9..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsExpression.java+++ /dev/null@@ -1,64 +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;--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();- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsGroupingManager.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsGroupingManager.javadeleted file mode 100644index 99b67b677ca..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsGroupingManager.java+++ /dev/null@@ -1,245 +0,0 @@-/*- * 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.lucene.search.Query;-import org.apache.solr.analytics.facet.AbstractSolrQueryFacet;-import org.apache.solr.analytics.facet.AbstractSolrQueryFacet.FacetValueQueryExecuter;-import org.apache.solr.analytics.facet.AnalyticsFacet;-import org.apache.solr.analytics.facet.PivotFacet;-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.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;--/**- * 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(- Query 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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestManager.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestManager.javadeleted file mode 100644index 93315855cc5..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestManager.java+++ /dev/null@@ -1,292 +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;--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.lucene.search.Query;-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;--/** 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;- private boolean partialResults = false;-- /**- * 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 (Map.Entry<String, AnalyticsGroupingManager> entry : groupingManagers.entrySet()) {- output.writeUTF(entry.getKey());- entry.getValue().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(- Query 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;- }-- public void setPartialResults(boolean b) {- this.partialResults = b;- }-- public boolean isPartialResults() {- return partialResults;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestParser.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestParser.javadeleted file mode 100644index 43b9e9d109c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/AnalyticsRequestParser.java+++ /dev/null@@ -1,656 +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;--import com.fasterxml.jackson.annotation.JsonInclude;-import com.fasterxml.jackson.annotation.JsonInclude.Include;-import com.fasterxml.jackson.annotation.JsonSubTypes;-import com.fasterxml.jackson.annotation.JsonSubTypes.Type;-import com.fasterxml.jackson.annotation.JsonTypeInfo;-import com.fasterxml.jackson.annotation.JsonTypeName;-import com.fasterxml.jackson.core.JsonFactory;-import com.fasterxml.jackson.core.JsonParser;-import com.fasterxml.jackson.core.JsonProcessingException;-import com.fasterxml.jackson.databind.DeserializationFeature;-import com.fasterxml.jackson.databind.ObjectMapper;-import java.io.IOException;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.EnumSet;-import java.util.HashMap;-import java.util.List;-import java.util.ListIterator;-import java.util.Map;-import java.util.function.Predicate;-import java.util.regex.Pattern;-import org.apache.solr.analytics.facet.PivotFacet;-import org.apache.solr.analytics.facet.PivotNode;-import org.apache.solr.analytics.facet.QueryFacet;-import org.apache.solr.analytics.facet.RangeFacet;-import org.apache.solr.analytics.facet.SortableFacet.FacetSortSpecification;-import org.apache.solr.analytics.facet.ValueFacet;-import org.apache.solr.analytics.facet.compare.DelegatingComparator;-import org.apache.solr.analytics.facet.compare.FacetResultsComparator;-import org.apache.solr.analytics.facet.compare.FacetValueComparator;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.ComparableValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;-import org.apache.solr.common.params.FacetParams.FacetRangeInclude;-import org.apache.solr.common.params.FacetParams.FacetRangeOther;-import org.apache.solr.schema.IndexSchema;-import org.apache.solr.schema.SchemaField;--/** Class to manage the parsing of new-style analytics requests. */-public class AnalyticsRequestParser {-- private static ObjectMapper mapper = new ObjectMapper();-- public static void init() {- mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);- mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);- }-- public static final String analyticsParamName = "analytics";-- private static Predicate<String> sortAscending = acceptNames("ascending", "asc", "a");- private static Predicate<String> sortDescending = acceptNames("descending", "desc", "d");-- private static Predicate<String> acceptNames(String... names) {- return Pattern.compile(- "^(?:" + Arrays.stream(names).reduce((a, b) -> a + "|" + b).orElse("") + ")$",- Pattern.CASE_INSENSITIVE)- .asPredicate();- }-- // Defaults- public static final String DEFAULT_SORT_DIRECTION = "ascending";- public static final int DEFAULT_OFFSET = 0;- public static final int DEFAULT_LIMIT = -1;- public static final boolean DEFAULT_HARDEND = false;-- @JsonInclude(Include.NON_EMPTY)- public static class AnalyticsRequest {- public Map<String, String> functions;- public Map<String, String> expressions;-- public Map<String, AnalyticsGroupingRequest> groupings;- }-- public static class AnalyticsGroupingRequest {- public Map<String, String> expressions;-- public Map<String, AnalyticsFacetRequest> facets;- }-- @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")- @JsonSubTypes({- @Type(value = AnalyticsValueFacetRequest.class, name = "value"),- @Type(value = AnalyticsPivotFacetRequest.class, name = "pivot"),- @Type(value = AnalyticsRangeFacetRequest.class, name = "range"),- @Type(value = AnalyticsQueryFacetRequest.class, name = "query")- })- @JsonInclude(Include.NON_EMPTY)- public static interface AnalyticsFacetRequest {}-- @JsonTypeName("value")- public static class AnalyticsValueFacetRequest implements AnalyticsFacetRequest {- public String expression;- public AnalyticsSortRequest sort;- }-- @JsonTypeName("pivot")- public static class AnalyticsPivotFacetRequest implements AnalyticsFacetRequest {- public List<AnalyticsPivotRequest> pivots;- }-- public static class AnalyticsPivotRequest {- public String name;- public String expression;- public AnalyticsSortRequest sort;- }-- @JsonInclude(Include.NON_EMPTY)- public static class AnalyticsSortRequest {- public List<AnalyticsSortCriteriaRequest> criteria;- public int limit = DEFAULT_LIMIT;- public int offset = DEFAULT_OFFSET;- }-- @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")- @JsonSubTypes({- @Type(value = AnalyticsExpressionSortRequest.class, name = "expression"),- @Type(value = AnalyticsFacetValueSortRequest.class, name = "facetvalue")- })- @JsonInclude(Include.NON_EMPTY)- public abstract static class AnalyticsSortCriteriaRequest {- public String direction;- }-- @JsonTypeName("expression")- public static class AnalyticsExpressionSortRequest extends AnalyticsSortCriteriaRequest {- public String expression;- }-- @JsonTypeName("facetvalue")- public static class AnalyticsFacetValueSortRequest extends AnalyticsSortCriteriaRequest {}-- @JsonTypeName("range")- public static class AnalyticsRangeFacetRequest implements AnalyticsFacetRequest {- public String field;- public String start;- public String end;- public List<String> gaps;- public boolean hardend = DEFAULT_HARDEND;- public List<String> include;- public List<String> others;- }-- @JsonTypeName("query")- public static class AnalyticsQueryFacetRequest implements AnalyticsFacetRequest {- public Map<String, String> queries;- }-- /* ***************- * Request & Groupings- * ***************/-- public static AnalyticsRequestManager parse(- AnalyticsRequest request, ExpressionFactory expressionFactory, boolean isDistribRequest)- throws SolrException {- AnalyticsRequestManager manager =- constructRequest(request, expressionFactory, isDistribRequest);- if (isDistribRequest) {- try {- manager.analyticsRequest = mapper.writeValueAsString(request);- } catch (JsonProcessingException e) {- throw new RuntimeException(e);- }- }- return manager;- }-- public static AnalyticsRequestManager parse(- String rawRequest, ExpressionFactory expressionFactory, boolean isDistribRequest)- throws SolrException {- JsonParser parser;- try {- parser =- new JsonFactory()- .createParser(rawRequest)- .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)- .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);- } catch (IOException e1) {- throw new RuntimeException(e1);- }- AnalyticsRequest request;- try {- request = mapper.readValue(parser, AnalyticsRequest.class);- } catch (IOException e) {- throw new RuntimeException(e);- }-- AnalyticsRequestManager manager =- constructRequest(request, expressionFactory, isDistribRequest);- if (isDistribRequest) {- manager.analyticsRequest = rawRequest;- }- return manager;- }-- private static AnalyticsRequestManager constructRequest(- AnalyticsRequest request, ExpressionFactory expressionFactory, boolean isDistribRequest)- throws SolrException {- expressionFactory.startRequest();-- // Functions- if (request.functions != null) {- request.functions.forEach(- (funcSig, retSig) -> expressionFactory.addUserDefinedVariableFunction(funcSig, retSig));- }-- // Expressions- Map<String, AnalyticsExpression> topLevelExpressions;- if (request.expressions != null) {- topLevelExpressions = constructExpressions(request.expressions, expressionFactory);- } else {- topLevelExpressions = new HashMap<>();- }- AnalyticsRequestManager manager =- new AnalyticsRequestManager(- expressionFactory.createReductionManager(isDistribRequest),- topLevelExpressions.values());-- // Groupings- if (request.groupings != null) {- request.groupings.forEach(- (name, grouping) -> {- manager.addGrouping(- constructGrouping(name, grouping, expressionFactory, isDistribRequest));- });- }- return manager;- }-- private static AnalyticsGroupingManager constructGrouping(- String name,- AnalyticsGroupingRequest grouping,- ExpressionFactory expressionFactory,- boolean isDistribRequest)- throws SolrException {- expressionFactory.startGrouping();-- // Expressions- if (grouping.expressions == null || grouping.expressions.size() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Groupings must contain at least one expression, '" + name + "' has none.");- }-- Map<String, AnalyticsExpression> expressions =- constructExpressions(grouping.expressions, expressionFactory);- AnalyticsGroupingManager manager =- new AnalyticsGroupingManager(- name,- expressionFactory.createGroupingReductionManager(isDistribRequest),- expressions.values());-- if (grouping.facets == null) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Groupings must contain at least one facet, '" + name + "' has none.");- }- // Parse the facets- grouping.facets.forEach(- (facetName, facet) -> {- if (facet instanceof AnalyticsValueFacetRequest) {- manager.addFacet(- constructValueFacet(- facetName, (AnalyticsValueFacetRequest) facet, expressionFactory, expressions));- } else if (facet instanceof AnalyticsPivotFacetRequest) {- manager.addFacet(- constructPivotFacet(- facetName, (AnalyticsPivotFacetRequest) facet, expressionFactory, expressions));- } else if (facet instanceof AnalyticsRangeFacetRequest) {- manager.addFacet(- constructRangeFacet(- facetName, (AnalyticsRangeFacetRequest) facet, expressionFactory.getSchema()));- } else if (facet instanceof AnalyticsQueryFacetRequest) {- manager.addFacet(constructQueryFacet(facetName, (AnalyticsQueryFacetRequest) facet));- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The facet type, '"- + facet.getClass().toString()- + "' in "- + "grouping '"- + name- + "' is not a valid type of facet");- }- });-- return manager;- }-- /* ***************- * Expression & Functions- * ***************/-- private static Map<String, AnalyticsExpression> constructExpressions(- Map<String, String> rawExpressions, ExpressionFactory expressionFactory)- throws SolrException {- Map<String, AnalyticsExpression> expressions = new HashMap<>();- rawExpressions.forEach(- (name, expression) -> {- AnalyticsValueStream exprVal = expressionFactory.createExpression(expression);- if (exprVal instanceof AnalyticsValue) {- if (exprVal.getExpressionType().isReduced()) {- expressions.put(name, (new AnalyticsExpression(name, (AnalyticsValue) exprVal)));- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Top-level expressions must be reduced, the '" + name + "' expression is not.");- }- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Top-level expressions must be single-valued, the '"- + name- + "' expression is not.");- }- });- return expressions;- }-- /* ***************- * FACETS- * ***************/-- /*- * Value Facets- */-- private static ValueFacet constructValueFacet(- String name,- AnalyticsValueFacetRequest facetRequest,- ExpressionFactory expressionFactory,- Map<String, AnalyticsExpression> expressions)- throws SolrException {- if (facetRequest.expression == null) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Value Facets must contain a mapping expression to facet over, '" + name + "' has none.");- }-- // The second parameter must be a mapping expression- AnalyticsValueStream expr = expressionFactory.createExpression(facetRequest.expression);- if (!expr.getExpressionType().isUnreduced()) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Value Facet expressions must be mapping expressions, "- + "the following expression in value facet '"- + name- + "' contains a reduction: "- + facetRequest.expression);- }- if (!(expr instanceof StringValueStream)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Value Facet expressions must be castable to string expressions, "- + "the following expression in value facet '"- + name- + "' is not: "- + facetRequest.expression);- }-- ValueFacet facet = new ValueFacet(name, (StringValueStream) expr);-- // Check if the value facet is sorted- if (facetRequest.sort != null) {- facet.setSort(constructSort(facetRequest.sort, expressions));- }- return facet;- }-- /*- * Pivot Facets- */-- private static PivotFacet constructPivotFacet(- String name,- AnalyticsPivotFacetRequest facetRequest,- ExpressionFactory expressionFactory,- Map<String, AnalyticsExpression> expressions)- throws SolrException {- PivotNode<?> topPivot = null;-- // Pivots- if (facetRequest.pivots == null || facetRequest.pivots.size() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Pivot Facets must contain at least one pivot to facet over, '" + name + "' has none.");- }-- ListIterator<AnalyticsPivotRequest> iter =- facetRequest.pivots.listIterator(facetRequest.pivots.size());- while (iter.hasPrevious()) {- topPivot = constructPivot(iter.previous(), topPivot, expressionFactory, expressions);- }-- return new PivotFacet(name, topPivot);- }-- private static PivotNode<?> constructPivot(- AnalyticsPivotRequest pivotRequest,- PivotNode<?> childPivot,- ExpressionFactory expressionFactory,- Map<String, AnalyticsExpression> expressions)- throws SolrException {- if (pivotRequest.name == null || pivotRequest.name.length() == 0) {- throw new SolrException(ErrorCode.BAD_REQUEST, "Pivots must have a name.");- }- if (pivotRequest.expression == null) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Pivots must have an expression to facet over, '" + pivotRequest.name + "' does not.");- }-- // The second parameter must be a mapping expression- AnalyticsValueStream expr = expressionFactory.createExpression(pivotRequest.expression);- if (!expr.getExpressionType().isUnreduced()) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Pivot expressions must be mapping expressions, "- + "the following expression in pivot '"- + pivotRequest.name- + "' contains a reduction: "- + pivotRequest.expression);- }- if (!(expr instanceof StringValueStream)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Pivot expressions must be castable to string expressions, "- + "the following expression in pivot '"- + pivotRequest.name- + "' is not: '"- + pivotRequest.expression);- }-- PivotNode<?> pivot;- if (childPivot == null) {- pivot = new PivotNode.PivotLeaf(pivotRequest.name, (StringValueStream) expr);- } else {- pivot = new PivotNode.PivotBranch<>(pivotRequest.name, (StringValueStream) expr, childPivot);- }-- // Check if the pivot is sorted- if (pivotRequest.sort != null) {- pivot.setSort(constructSort(pivotRequest.sort, expressions));- }- return pivot;- }-- /*- * Range Facets- */-- private static RangeFacet constructRangeFacet(- String name, AnalyticsRangeFacetRequest facetRequest, IndexSchema schema)- throws SolrException {- if (facetRequest.field == null || facetRequest.field.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Range Facets must specify a field to facet over, '" + name + "' does not.");- }- SchemaField field = schema.getFieldOrNull(facetRequest.field);- if (field == null) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Range Facets must have a valid field as the second parameter. The '"- + name- + "' facet "- + "tries to facet over the non-existent field: "- + facetRequest.field);- }-- if (facetRequest.start == null || facetRequest.start.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Range Facets must specify a start value, '" + name + "' does not.");- }- if (facetRequest.end == null || facetRequest.end.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "Range Facets must specify a end value, '" + name + "' does not.");- }- if (facetRequest.gaps == null || facetRequest.gaps.size() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Range Facets must specify a gap or list of gaps to determine facet buckets, '"- + name- + "' does not.");- }- RangeFacet facet =- new RangeFacet(name, field, facetRequest.start, facetRequest.end, facetRequest.gaps);-- facet.setHardEnd(facetRequest.hardend);-- if (facetRequest.include != null && facetRequest.include.size() > 0) {- facet.setInclude(constructInclude(facetRequest.include));- }- if (facetRequest.others != null && facetRequest.others.size() > 0) {- facet.setOthers(constructOthers(facetRequest.others, name));- }- return facet;- }-- private static EnumSet<FacetRangeInclude> constructInclude(List<String> includes)- throws SolrException {- return FacetRangeInclude.parseParam(includes.toArray(new String[includes.size()]));- }-- private static EnumSet<FacetRangeOther> constructOthers(- List<String> othersRequest, String facetName) throws SolrException {- EnumSet<FacetRangeOther> others = EnumSet.noneOf(FacetRangeOther.class);- for (String rawOther : othersRequest) {- if (!others.add(FacetRangeOther.get(rawOther))) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Duplicate include value '" + rawOther + "' found in range facet '" + facetName + "'");- }- }- if (others.contains(FacetRangeOther.NONE)) {- if (others.size() > 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Include value 'NONE' is used with other includes in a range facet '"- + facetName- + "'. "- + "If 'NONE' is used, it must be the only include.");- }- return EnumSet.noneOf(FacetRangeOther.class);- }- if (others.contains(FacetRangeOther.ALL)) {- if (others.size() > 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Include value 'ALL' is used with other includes in a range facet '"- + facetName- + "'. "- + "If 'ALL' is used, it must be the only include.");- }- return EnumSet.of(FacetRangeOther.BEFORE, FacetRangeOther.BETWEEN, FacetRangeOther.AFTER);- }- return others;- }-- /*- * Query Facets- */-- private static QueryFacet constructQueryFacet(- String name, AnalyticsQueryFacetRequest facetRequest) throws SolrException {- if (facetRequest.queries == null || facetRequest.queries.size() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Query Facets must be contain at least 1 query to facet over, '" + name + "' does not.");- }-- // The first param must be the facet name- return new QueryFacet(name, facetRequest.queries);- }-- /*- * Facet Sorting- */-- private static FacetSortSpecification constructSort(- AnalyticsSortRequest sortRequest, Map<String, AnalyticsExpression> expressions)- throws SolrException {- if (sortRequest.criteria == null || sortRequest.criteria.size() == 0) {- throw new SolrException(ErrorCode.BAD_REQUEST, "Sorts must be given at least 1 criteria.");- }-- return new FacetSortSpecification(- constructSortCriteria(sortRequest.criteria, expressions),- sortRequest.limit,- sortRequest.offset);- }-- private static FacetResultsComparator constructSortCriteria(- List<AnalyticsSortCriteriaRequest> criteria, Map<String, AnalyticsExpression> expressions) {- ArrayList<FacetResultsComparator> comparators = new ArrayList<>();- for (AnalyticsSortCriteriaRequest criterion : criteria) {- FacetResultsComparator comparator;- if (criterion instanceof AnalyticsExpressionSortRequest) {- comparator =- constructExpressionSortCriteria(- (AnalyticsExpressionSortRequest) criterion, expressions);- } else if (criterion instanceof AnalyticsFacetValueSortRequest) {- comparator = constructFacetValueSortCriteria((AnalyticsFacetValueSortRequest) criterion);- } else {- // Shouldn't happen- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Sort Criteria must either be expressions or facetValues, '"- + criterion.getClass().getName()- + "' given.");- }- if (criterion.direction != null && criterion.direction.length() > 0) {- if (sortAscending.test(criterion.direction)) {- comparator.setDirection(true);- } else if (sortDescending.test(criterion.direction)) {- comparator.setDirection(false);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Sort direction '" + criterion.direction + " is not a recognized direction.");- }- }- comparators.add(comparator);- }- return DelegatingComparator.joinComparators(comparators);- }-- private static FacetResultsComparator constructExpressionSortCriteria(- AnalyticsExpressionSortRequest criterion, Map<String, AnalyticsExpression> expressions) {- if (criterion.expression == null || criterion.expression.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Expression Sorts must contain an expression parameter, none given.");- }-- AnalyticsExpression expression = expressions.get(criterion.expression);- if (expression == null) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Sort Expression not defined within the grouping: " + criterion.expression);- }- if (!(expression.getExpression() instanceof ComparableValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Expression Sorts must be comparable, the following is not: " + criterion.expression);- }- return ((ComparableValue) expression.getExpression()).getObjectComparator(expression.getName());- }-- private static FacetResultsComparator constructFacetValueSortCriteria(- AnalyticsFacetValueSortRequest criterion) {- return new FacetValueComparator();- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/ExpressionFactory.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/ExpressionFactory.javadeleted file mode 100644index d72126792f6..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/ExpressionFactory.java+++ /dev/null@@ -1,1109 +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;--import java.util.ArrayList;-import java.util.Arrays;-import java.util.HashMap;-import java.util.HashSet;-import java.util.LinkedHashMap;-import java.util.Locale;-import java.util.Map;-import java.util.regex.Matcher;-import java.util.regex.Pattern;-import org.apache.solr.analytics.function.MergingReductionCollectionManager;-import org.apache.solr.analytics.function.ReductionCollectionManager;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.field.AnalyticsField;-import org.apache.solr.analytics.function.field.BooleanField;-import org.apache.solr.analytics.function.field.BooleanMultiField;-import org.apache.solr.analytics.function.field.DateField;-import org.apache.solr.analytics.function.field.DateMultiPointField;-import org.apache.solr.analytics.function.field.DateMultiTrieField;-import org.apache.solr.analytics.function.field.DoubleField;-import org.apache.solr.analytics.function.field.DoubleMultiPointField;-import org.apache.solr.analytics.function.field.DoubleMultiTrieField;-import org.apache.solr.analytics.function.field.FloatField;-import org.apache.solr.analytics.function.field.FloatMultiPointField;-import org.apache.solr.analytics.function.field.FloatMultiTrieField;-import org.apache.solr.analytics.function.field.IntField;-import org.apache.solr.analytics.function.field.IntMultiPointField;-import org.apache.solr.analytics.function.field.IntMultiTrieField;-import org.apache.solr.analytics.function.field.LongField;-import org.apache.solr.analytics.function.field.LongMultiPointField;-import org.apache.solr.analytics.function.field.LongMultiTrieField;-import org.apache.solr.analytics.function.field.StringField;-import org.apache.solr.analytics.function.field.StringMultiField;-import org.apache.solr.analytics.function.mapping.AbsoluteValueFunction;-import org.apache.solr.analytics.function.mapping.AddFunction;-import org.apache.solr.analytics.function.mapping.BottomFunction;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.GTEFunction;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.GTFunction;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.LTEFunction;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.LTFunction;-import org.apache.solr.analytics.function.mapping.ConcatFunction;-import org.apache.solr.analytics.function.mapping.ConcatFunction.SeparatedConcatFunction;-import org.apache.solr.analytics.function.mapping.DateMathFunction;-import org.apache.solr.analytics.function.mapping.DateParseFunction;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.CeilingFunction;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.FloorFunction;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.RoundFunction;-import org.apache.solr.analytics.function.mapping.DivideFunction;-import org.apache.solr.analytics.function.mapping.EqualFunction;-import org.apache.solr.analytics.function.mapping.ExistsFunction;-import org.apache.solr.analytics.function.mapping.FillMissingFunction;-import org.apache.solr.analytics.function.mapping.FilterFunction;-import org.apache.solr.analytics.function.mapping.IfFunction;-import org.apache.solr.analytics.function.mapping.LogFunction;-import org.apache.solr.analytics.function.mapping.LogicFunction.AndFunction;-import org.apache.solr.analytics.function.mapping.LogicFunction.OrFunction;-import org.apache.solr.analytics.function.mapping.MultFunction;-import org.apache.solr.analytics.function.mapping.NegateFunction;-import org.apache.solr.analytics.function.mapping.PowerFunction;-import org.apache.solr.analytics.function.mapping.RemoveFunction;-import org.apache.solr.analytics.function.mapping.ReplaceFunction;-import org.apache.solr.analytics.function.mapping.StringCastFunction;-import org.apache.solr.analytics.function.mapping.SubtractFunction;-import org.apache.solr.analytics.function.mapping.TopFunction;-import org.apache.solr.analytics.function.reduction.CountFunction;-import org.apache.solr.analytics.function.reduction.DocCountFunction;-import org.apache.solr.analytics.function.reduction.MaxFunction;-import org.apache.solr.analytics.function.reduction.MeanFunction;-import org.apache.solr.analytics.function.reduction.MedianFunction;-import org.apache.solr.analytics.function.reduction.MinFunction;-import org.apache.solr.analytics.function.reduction.MissingFunction;-import org.apache.solr.analytics.function.reduction.OrdinalFunction;-import org.apache.solr.analytics.function.reduction.PercentileFunction;-import org.apache.solr.analytics.function.reduction.SumFunction;-import org.apache.solr.analytics.function.reduction.UniqueFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;-import org.apache.solr.schema.BoolField;-import org.apache.solr.schema.DatePointField;-import org.apache.solr.schema.DoublePointField;-import org.apache.solr.schema.FieldType;-import org.apache.solr.schema.FloatPointField;-import org.apache.solr.schema.IndexSchema;-import org.apache.solr.schema.IntPointField;-import org.apache.solr.schema.LongPointField;-import org.apache.solr.schema.SchemaField;-import org.apache.solr.schema.StrField;-import org.apache.solr.schema.TrieDateField;-import org.apache.solr.schema.TrieDoubleField;-import org.apache.solr.schema.TrieFloatField;-import org.apache.solr.schema.TrieIntField;-import org.apache.solr.schema.TrieLongField;--/**- * A factory to parse and create expressions, and capture information about those expressions along- * the way.- *- * <p>In order to use, first call {@link #startRequest()} and create all ungrouped expressions, then- * call {@link #createReductionManager} to get the ungrouped reduction manager. <br>- * Then for each grouping call {@link #startGrouping()} first then create all expressions within- * that grouping, finally calling {@link #createGroupingReductionManager} to get the reduction- * manager for that grouping.- */-public class ExpressionFactory {- private static final Pattern functionNamePattern =- Pattern.compile("^\\s*([^().\\s]+)\\s*(?:\\(.*\\)\\s*)?$", Pattern.CASE_INSENSITIVE);- private static final Pattern functionParamsPattern =- Pattern.compile("^\\s*(?:[^(.)]+)\\s*\\(\\s*(.+)\\s*\\)\\s*$", Pattern.CASE_INSENSITIVE);- private static final String funtionVarParamUniqueName = ".%s_(%d)";-- /** Used to denote a variable length parameter. */- public static final String variableLengthParamSuffix = "..";- /** The character used to denote the start of a for each lambda expression */- public static final char variableForEachSep = ':';- /** The character used to denote the looped parameter in the for each lambda expression */- public static final char variableForEachParam = '_';-- private HashMap<String, VariableFunctionInfo> systemVariableFunctions;- private HashMap<String, VariableFunctionInfo> variableFunctions;- private HashSet<String> variableFunctionNameHistory;-- private HashMap<String, CreatorFunction> expressionCreators;- private final ConstantFunction constantCreator;-- private LinkedHashMap<String, ReductionFunction> reductionFunctions;- private LinkedHashMap<String, ReductionDataCollector<?>> collectors;- private LinkedHashMap<String, AnalyticsField> fields;- private HashMap<String, AnalyticsValueStream> expressions;-- private IndexSchema schema;-- private Map<String, ReductionDataCollector<?>> groupedCollectors;- private Map<String, AnalyticsField> groupedFields;- private boolean isGrouped;-- public ExpressionFactory(IndexSchema schema) {- this.schema = schema;-- expressionCreators = new HashMap<>();- systemVariableFunctions = new HashMap<>();-- constantCreator = ConstantValue.creatorFunction;- addSystemFunctions();- }-- /**- * Get the index schema used by this factory.- *- * @return the index schema- */- public IndexSchema getSchema() {- return schema;- }-- /** Prepare the factory to start building the request. */- public void startRequest() {- reductionFunctions = new LinkedHashMap<>();- collectors = new LinkedHashMap<>();- fields = new LinkedHashMap<>();- expressions = new HashMap<>();-- variableFunctions = new HashMap<>();- variableFunctions.putAll(systemVariableFunctions);- variableFunctionNameHistory = new HashSet<>();-- isGrouped = false;- }-- /**- * Prepare the factory to start building the next grouping. <br>- * NOTE: MUST be called before each new grouping.- */- public void startGrouping() {- groupedCollectors = new HashMap<>();- groupedFields = new HashMap<>();-- isGrouped = true;- }-- /**- * Add a system function to the expression factory. This will be treated as a native function and- * not a variable function.- *- * @param functionName the unique name for the function- * @param functionCreator the creator function to generate an expression- * @return this factory, to easily chain function adds- * @throws SolrException if the functionName is not unique- */- public ExpressionFactory addSystemFunction(- final String functionName, final CreatorFunction functionCreator) throws SolrException {- if (expressionCreators.containsKey(functionName)) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "System function " + functionName + " defined twice.");- }- expressionCreators.put(CountFunction.name, CountFunction.creatorFunction);- return this;- }-- /**- * Add a variable function that will be treated like a system function.- *- * @param functionName the function's name- * @param functionParams the comma separated and ordered parameters of the function (e.g. {@code- * "a,b"} )- * @param returnSignature the return signature of the variable function (e.g. {@code- * div(sum(a,b),count(b))} )- * @return this factory, to easily chain function adds- * @throws SolrException if the name of the function is not unique or the syntax of either- * signature is incorrect- */- public ExpressionFactory addSystemVariableFunction(- final String functionName, final String functionParams, final String returnSignature)- throws SolrException {- return addVariableFunction(- functionName,- Arrays.stream(functionParams.split(","))- .map(param -> param.trim())- .toArray(size -> new String[size]),- returnSignature,- systemVariableFunctions);- }-- /**- * Add a variable function that was defined in an analytics request.- *- * @param functionSignature the function signature of the variable function (e.g. {@code- * func(a,b)} )- * @param returnSignature the return signature of the variable function (e.g. {@code- * div(sum(a,b),count(b))} )- * @return this factory, to easily chain function adds- * @throws SolrException if the name of the function is not unique or the syntax of either- * signature is incorrect- */- public ExpressionFactory addUserDefinedVariableFunction(- final String functionSignature, final String returnSignature) throws SolrException {- return addVariableFunction(functionSignature, returnSignature, variableFunctions);- }-- /**- * Add a variable function to the given map of variable functions.- *- * @param functionSignature the function signature of the variable function (e.g. {@code- * func(a,b)} )- * @param returnSignature the return signature of the variable function (e.g. {@code- * div(sum(a,b),count(b))} )- * @param variableFunctions the map of variable functions to add the new function to- * @return this factory, to easily chain function adds- * @throws SolrException if the name of the function is not unique or the syntax of either- * signature is incorrect- */- private ExpressionFactory addVariableFunction(- final String functionSignature,- final String returnSignature,- Map<String, VariableFunctionInfo> variableFunctions)- throws SolrException {- addVariableFunction(- getFunctionName(functionSignature),- getParams(functionSignature, null, null),- returnSignature,- variableFunctions);- return this;- }-- /**- * Add a variable function to the given map of variable functions.- *- * @param functionName the function's name- * @param functionParams the parameters of the function (this is ordered)- * @param returnSignature the return signature of the variable function (e.g. {@code- * div(sum(a,b),count(b))} )- * @param variableFunctions the map of variable functions to add the new function to- * @return this factory, to easily chain function adds- * @throws SolrException if the name of the function is not unique or the syntax of either- * signature is incorrect- */- private ExpressionFactory addVariableFunction(- final String functionName,- final String[] functionParams,- final String returnSignature,- Map<String, VariableFunctionInfo> variableFunctions)- throws SolrException {- if (expressionCreators.containsKey(functionName)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Users cannot define a variable function with the same name as an existing function: "- + functionName);- }- VariableFunctionInfo varFuncInfo = new VariableFunctionInfo();- varFuncInfo.params = functionParams;- varFuncInfo.returnSignature = returnSignature;- variableFunctions.put(functionName, varFuncInfo);- return this;- }-- /**- * Create a reduction manager to manage the collection of all expressions that have been created- * since {@link #startRequest()} was called.- *- * @param isCloudCollection whether the request is a distributed request- * @return a reduction manager- */- public ReductionCollectionManager createReductionManager(boolean isCloudCollection) {- ReductionDataCollector<?>[] collectorsArr = new ReductionDataCollector<?>[collectors.size()];- collectors.values().toArray(collectorsArr);- if (isCloudCollection) {- return new MergingReductionCollectionManager(collectorsArr, fields.values());- } else {- return new ReductionCollectionManager(collectorsArr, fields.values());- }- }-- /**- * Create a reduction manager to manage the collection of all expressions that have been created- * since {@link #startGrouping()} was called.- *- * @param isCloudCollection whether the request is a distributed request- * @return a reduction manager- */- public ReductionCollectionManager createGroupingReductionManager(boolean isCloudCollection) {- ReductionDataCollector<?>[] collectorsArr =- new ReductionDataCollector<?>[groupedCollectors.size()];- groupedCollectors.values().toArray(collectorsArr);- if (isCloudCollection) {- return new MergingReductionCollectionManager(collectorsArr, groupedFields.values());- } else {- return new ReductionCollectionManager(collectorsArr, groupedFields.values());- }- }-- /**- * Parse and build an expression from the given expression string.- *- * @param expressionStr string that represents the desired expression- * @return the object representation of the expression- * @throws SolrException if an error occurs while constructing the expression- */- public AnalyticsValueStream createExpression(String expressionStr) throws SolrException {- return createExpression(expressionStr, new HashMap<>(), null, null);- }-- /**- * Create an expression from the given expression string, with the given variable function- * information.- *- * @param expressionStr string that represents the desired expression- * @param varFuncParams the current set of variable function parameters and their values. If this- * expression is not a variable function return signature, the map should be empty.- * @param varFuncVarParamName if the current expression is a variable function return signature,- * this must be the name of the variable length parameter if it is included in the function- * signature.- * @param varFuncVarParamValues if the current expression is a variable function return signature,- * this must be the array values of the variable length parameter if they are included when- * calling the function.- * @return the object representation of the expression- * @throws SolrException if an error occurs while constructing the expression- */- private AnalyticsValueStream createExpression(- String expressionStr,- Map<String, AnalyticsValueStream> varFuncParams,- String varFuncVarParamName,- String[] varFuncVarParamValues)- throws SolrException {- AnalyticsValueStream expression;- expressionStr = expressionStr.trim();-- boolean isField = false;- try {- // Try to make a constant value- expression = constantCreator.apply(expressionStr);- } catch (SolrException e1) {- // Not a constant- // If the expression has parens, it is an expression otherwise it is a field- if (!expressionStr.contains("(")) {- // Try to make a field out of it- expression = createField(schema.getField(expressionStr));- isField = true;- } else {- // Must be a function- expression =- createFunction(- expressionStr, varFuncParams, varFuncVarParamName, varFuncVarParamValues);- }- }-- // Try to use an already made expression instead of the new one.- // This will decrease the amount of collection needed to be done.- if (expressions.containsKey(expression.getExpressionStr())) {- expression = expressions.get(expression.getExpressionStr());- // If this is a grouped expression, make sure that the reduction info for the expression is- // included in the grouped reduction manager.- if (expression.getExpressionType() == ExpressionType.REDUCTION && isGrouped) {- ((ReductionFunction) expression)- .synchronizeDataCollectors(- collector -> {- groupedCollectors.put(collector.getExpressionStr(), collector);- return collector;- });- }- } else {- expressions.put(expression.getExpressionStr(), expression);- // Make sure that the reduction info for the expression is included in the reduction manager- // and grouped reduction manager if necessary.- if (expression.getExpressionType() == ExpressionType.REDUCTION) {- reductionFunctions.put(expression.getExpressionStr(), (ReductionFunction) expression);- ((ReductionFunction) expression)- .synchronizeDataCollectors(- collector -> {- String collectorStr = collector.getExpressionStr();- ReductionDataCollector<?> usedCollector = collectors.get(collectorStr);- if (usedCollector == null) {- usedCollector = collector;- collectors.put(collectorStr, collector);- }- if (isGrouped) {- groupedCollectors.put(collectorStr, usedCollector);- }- return usedCollector;- });- }- // Add the field info to the reduction manager- if (isField) {- fields.put(expression.getExpressionStr(), (AnalyticsField) expression);- }- }- // If this is a grouped expression, make sure that the field info is included in the grouped- // reduction manager.- if (isField && isGrouped) {- groupedFields.put(expression.getExpressionStr(), (AnalyticsField) expression);- }- return expression;- }-- /**- * Create a function expression from the given expression string, with the given variable function- * information.- *- * @param expressionStr string that represents the desired expression- * @param varFuncParams the current set of variable function parameters and their values. If this- * expression is not a variable function return signature, the map should be empty.- * @param varFuncVarParamName if the current expression is a variable function return signature,- * this must be the name of the variable length parameter if it is included in the function- * signature.- * @param varFuncVarParamValues if the current expression is a variable function return signature,- * this must be the array values of the variable length parameter if they are included when- * calling the function.- * @return the object representation of the expression- * @throws SolrException if an error occurs while constructing the expression- */- private AnalyticsValueStream createFunction(- String expressionStr,- Map<String, AnalyticsValueStream> varFuncParams,- String varFuncVarParamName,- String[] varFuncVarParamValues)- throws SolrException {- AnalyticsValueStream expression = null;- String name = getFunctionName(expressionStr);-- final String[] params = getParams(expressionStr, varFuncVarParamName, varFuncVarParamValues);- AnalyticsValueStream[] paramStreams = new AnalyticsValueStream[params.length];-- boolean allParamsConstant = true;-- for (int i = 0; i < params.length; i++) {- // First check if the parameter is a variable function variable otherwise create the- // expression- if (varFuncParams.containsKey(params[i])) {- paramStreams[i] = varFuncParams.get(params[i]);- } else {- paramStreams[i] =- createExpression(params[i], varFuncParams, varFuncVarParamName, varFuncVarParamValues);- }-- // Then update whether all of the params are constant- allParamsConstant &= paramStreams[i].getExpressionType().equals(ExpressionType.CONST);- }-- // Check to see if the function name is a variable function name, if so apply the variables to- // the return signature- if (variableFunctions.containsKey(name)) {- if (variableFunctionNameHistory.contains(name)) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The following variable function is self referencing : " + name);- }- variableFunctionNameHistory.add(name);- VariableFunctionInfo newVarFunc = variableFunctions.get(name);- Map<String, AnalyticsValueStream> newVarFuncParams = new HashMap<>();-- boolean varLenEnd = false;-- if (paramStreams.length < newVarFunc.params.length) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The variable function '"- + name- + "' requires at least "- + newVarFunc.params.length- + " parameters."- + " Only "- + paramStreams.length- + " arguments given in the following invocation : "- + expressionStr);- }- for (int i = 0; i < newVarFunc.params.length; ++i) {- String variable = newVarFunc.params[i];- if (variable.endsWith(variableLengthParamSuffix)) {- if (i != newVarFunc.params.length - 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The following invocation of a variable function has the incorrect number of arguments : "- + expressionStr);- }- variable =- variable.substring(0, variable.length() - variableLengthParamSuffix.length()).trim();- int numVars = paramStreams.length - i;- String[] newVarFuncVarParamValues = new String[numVars];- for (int j = 0; j < numVars; ++j) {- // Create a new name for each variable length parameter value- String paramName = String.format(Locale.ROOT, funtionVarParamUniqueName, variable, j);- newVarFuncVarParamValues[j] = paramName;- newVarFuncParams.put(paramName, paramStreams[i + j]);- }- expression =- createFunction(- newVarFunc.returnSignature, newVarFuncParams, variable, newVarFuncVarParamValues);- varLenEnd = true;- } else {- newVarFuncParams.put(variable, paramStreams[i]);- }- }- if (!varLenEnd) {- if (paramStreams.length > newVarFunc.params.length) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The variable function '"- + name- + "' requires "- + newVarFunc.params.length- + " parameters."- + " "- + paramStreams.length- + " arguments given in the following invocation : "- + expressionStr);- }- expression = createExpression(newVarFunc.returnSignature, newVarFuncParams, null, null);- }- variableFunctionNameHistory.remove(name);- } else if (expressionCreators.containsKey(name)) {- // It is a regular system function- expression = expressionCreators.get(name).apply(paramStreams);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The following function does not exist: " + name);- }-- // If the all params are constant, then try to convert the expression to a constant value.- expression = expression.convertToConstant();-- return expression;- }-- /**- * Create an {@link AnalyticsField} out of the given {@link SchemaField}.- *- * <p>Currently only fields with doc-values enabled are supported.- *- * @param field the field to convert for analytics- * @return an analytics representation of the field- * @throws SolrException if the field is not supported by the analytics framework- */- private AnalyticsField createField(SchemaField field) throws SolrException {- String fieldName = field.getName();- if (fields.containsKey(fieldName)) {- return fields.get(fieldName);- }- if (!field.hasDocValues()) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The field " + fieldName + " does not have docValues enabled.");- }- boolean multivalued = field.multiValued();- FieldType fieldType = field.getType();- AnalyticsField aField;- if (fieldType instanceof BoolField) {- if (multivalued) {- aField = new BooleanMultiField(fieldName);- } else {- aField = new BooleanField(fieldName);- }- } else if (fieldType instanceof TrieIntField) {- if (multivalued) {- aField = new IntMultiTrieField(fieldName);- } else {- aField = new IntField(fieldName);- }- } else if (fieldType instanceof IntPointField) {- if (multivalued) {- aField = new IntMultiPointField(fieldName);- } else {- aField = new IntField(fieldName);- }- } else if (fieldType instanceof TrieLongField) {- if (multivalued) {- aField = new LongMultiTrieField(fieldName);- } else {- aField = new LongField(fieldName);- }- } else if (fieldType instanceof LongPointField) {- if (multivalued) {- aField = new LongMultiPointField(fieldName);- } else {- aField = new LongField(fieldName);- }- } else if (fieldType instanceof TrieFloatField) {- if (multivalued) {- aField = new FloatMultiTrieField(fieldName);- } else {- aField = new FloatField(fieldName);- }- } else if (fieldType instanceof FloatPointField) {- if (multivalued) {- aField = new FloatMultiPointField(fieldName);- } else {- aField = new FloatField(fieldName);- }- } else if (fieldType instanceof TrieDoubleField) {- if (multivalued) {- aField = new DoubleMultiTrieField(fieldName);- } else {- aField = new DoubleField(fieldName);- }- } else if (fieldType instanceof DoublePointField) {- if (multivalued) {- aField = new DoubleMultiPointField(fieldName);- } else {- aField = new DoubleField(fieldName);- }- } else if (fieldType instanceof TrieDateField) {- if (multivalued) {- aField = new DateMultiTrieField(fieldName);- } else {- aField = new DateField(fieldName);- }- } else if (fieldType instanceof DatePointField) {- if (multivalued) {- aField = new DateMultiPointField(fieldName);- } else {- aField = new DateField(fieldName);- }- } else if (fieldType instanceof StrField) {- if (multivalued) {- aField = new StringMultiField(fieldName);- } else {- aField = new StringField(fieldName);- }- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "FieldType of the following field not supported by analytics: " + fieldName);- }- return aField;- }-- /**- * Get the name of the top function used in the given expression.- *- * @param expression the expression to find the function name of- * @return the name of the function- * @throws SolrException if the expression has incorrect syntax- */- private static String getFunctionName(String expression) throws SolrException {- Matcher m = functionNamePattern.matcher(expression);- if (!m.matches()) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The following function has no name: " + expression);- }- String name = m.group(1);- return name;- }-- /**- * Get the params of a function.- *- * @param function the function to parse- * @return an array of param strings- * @throws SolrException if the function has incorrect syntax- */- private static String[] getFunctionParams(String function) throws SolrException {- return getParams(function, null, null);- }-- /**- * Parse a function expression string and break up the parameters of the function into separate- * strings.- *- * <p>The parsing replaces the variable length parameter, and lambda for-each's using the variable- * length parameter, with the parameter values in the returned parameter string.- *- * <p>Parsing breaks up parameters by commas (',') and ignores ',' inside of extra parens and- * quotes (both ' and "), since these commas are either splitting up the parameters of nested- * functions or are apart of strings. <br>- * The only escaping that needs to be done is " within a double quote string and ' within a single- * quote string and \ within any string. For example\:- *- * <ul>- * <li>{@code func("This is \" the \\ escaping ' example")} will be treated as {@code func(This- * is " the \ escaping ' example)}- * <li>{@code func('This is " the \\ escaping \' example')} will be treated as {@code func(This- * is " the \ escaping ' example)}- * </ul>- *- * In string constants the \ character is used to escape quotes, so it can never be used alone. in- * order to write a \ you must write \\- *- * @param expression the function expression to parse- * @param varLengthParamName the name of the variable length parameter that is used in the- * expression, pass null if none is used.- * @param varLengthParamValues the values of the variable length parameter that are used in the- * expression, pass null if none are used.- * @return the parsed and split arguments to the function- * @throws SolrException if the expression has incorrect syntax.- */- private static String[] getParams(- String expression, String varLengthParamName, String[] varLengthParamValues)- throws SolrException {- Matcher m = functionParamsPattern.matcher(expression);- if (!m.matches()) {- return new String[0];- }- String paramsStr = m.group(1);-- ArrayList<String> paramsList = new ArrayList<String>();- StringBuilder param = new StringBuilder();-- // Variables to help while filling out the values of for-each lambda functions.- boolean inForEach = false;- int forEachStart = -1;- int forEachIter = -1;- int forEachLevel = -1;-- // The current level of nested parenthesis, 0 means the iteration is in no nested parentheses- int parenCount = 0;- // If the iteration is currently in a single-quote string constant- boolean singleQuoteOn = false;- // If the iteration is currently in a double-quote string constant- boolean doubleQuoteOn = false;- // If the iteration is currently in any kind of string constant- boolean quoteOn = false;- // Is the next character escaped.- boolean escaped = false;-- char[] chars = paramsStr.toCharArray();-- // Iterate through every character, building the params one at a time- for (int i = 0; i < chars.length; ++i) {- char c = chars[i];-- if (c == ' ' && !quoteOn) {- // Ignore white space that is not in string constants- continue;- } else if (c == ',' && parenCount == 0 && !quoteOn) {- // This signifies the end of one parameter and the start of another, since we are not in a- // nested parenthesis or a string constant- String paramStr = param.toString();- if (paramStr.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "Empty parameter in expression: " + expression);- }- // check to see if the parameter is a variable length parameter- if (paramStr.equals(varLengthParamName)) {- // Add every variable length parameter value, since there are a variable amount- for (String paramName : varLengthParamValues) {- paramsList.add(paramName);- }- } else {- paramsList.add(paramStr);- }-- param.setLength(0);- continue;- } else if (c == ',' && !quoteOn && inForEach) {- // separate the for each parameters, so they can be replaced with the result of the for each- if (param.charAt(param.length() - 1) == variableForEachParam- && (param.charAt(param.length() - 2) == '('- || param.charAt(param.length() - 2) == ',')) {- param.setLength(param.length() - 1);- param.append(varLengthParamValues[forEachIter++]);- }- } else if (c == '"' && !singleQuoteOn) {- // Deal with escaping, or ending string constants- if (doubleQuoteOn && !escaped) {- doubleQuoteOn = false;- quoteOn = false;- } else if (!quoteOn) {- doubleQuoteOn = true;- quoteOn = true;- } else {- // only happens if escaped is true- escaped = false;- }- } else if (c == '\'' && !doubleQuoteOn) {- // Deal with escaping, or ending string constants- if (singleQuoteOn && !escaped) {- singleQuoteOn = false;- quoteOn = false;- } else if (!singleQuoteOn) {- singleQuoteOn = true;- quoteOn = true;- } else {- // only happens if escaped is true- escaped = false;- }- } else if (c == '(' && !quoteOn) {- // Reached a further level of nested parentheses- parenCount++;- } else if (c == ')' && !quoteOn) {- // Returned from a level of nested parentheses- parenCount--;- if (parenCount < 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The following expression has extra end parens: " + param.toString());- }- if (inForEach) {- if (param.charAt(param.length() - 1) == variableForEachParam- && (param.charAt(param.length() - 2) == '('- || param.charAt(param.length() - 2) == ',')) {- param.setLength(param.length() - 1);- param.append(varLengthParamValues[forEachIter++]);- }- if (forEachLevel == parenCount) {- // at the end of the for-each start the parsing of the for-each again, with the next- // value of the variable length parameter- if (forEachIter == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "For each statement for variable '"- + varLengthParamName- + "' has no use of lambda variable "- + variableForEachParam);- } else if (forEachIter < varLengthParamValues.length) {- if (parenCount == 0) {- param.append(')');- paramsList.add(param.toString());- param.setLength(0);- } else {- param.append(')');- param.append(',');- }- i = forEachStart;- continue;- } else {- inForEach = false;- }- }- }- }- if (c == '\\') {- // Escaping or escaped backslash- if (!quoteOn) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The following expression has escaped characters outside of quotation marks: "- + expression.toString());- }- if (escaped) {- escaped = false;- } else {- escaped = true;- if (parenCount == 0) {- continue;- }- }- } else if (escaped) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Invalid escape character '"- + c- + "' used in the following expression: "- + expression.toString());- }- if (c == variableForEachSep && !quoteOn && varLengthParamName != null) {- int varStart = param.length() - varLengthParamName.length();- if (varLengthParamName.contentEquals(param.subSequence(varStart, param.length()))) {- inForEach = true;- forEachStart = i;- forEachIter = 0;- forEachLevel = parenCount;- param.setLength(varStart);- continue;- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "For-each called on invalid parameter '" + param.toString().trim());- }- param.append(c);- }- String paramStr = param.toString().trim();- if (paramStr.length() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "Empty parameter in expression: " + expression);- }- if (parenCount > 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The following expression needs more end parens: " + param.toString());- }- if (quoteOn) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "Misplaced quotation marks in expression: " + expression);- }- if (paramStr.equals(varLengthParamName)) {- for (String paramName : varLengthParamValues) {- paramsList.add(paramName);- }- } else {- paramsList.add(paramStr);- }- return paramsList.toArray(new String[paramsList.size()]);- }-- /** Add the natively supported functionality. */- public void addSystemFunctions() {- // Mapping Functions- expressionCreators.put(AbsoluteValueFunction.name, AbsoluteValueFunction.creatorFunction);- expressionCreators.put(AndFunction.name, AndFunction.creatorFunction);- expressionCreators.put(AddFunction.name, AddFunction.creatorFunction);- expressionCreators.put(BottomFunction.name, BottomFunction.creatorFunction);- expressionCreators.put(CeilingFunction.name, CeilingFunction.creatorFunction);- expressionCreators.put(ConcatFunction.name, ConcatFunction.creatorFunction);- expressionCreators.put(SeparatedConcatFunction.name, SeparatedConcatFunction.creatorFunction);- expressionCreators.put(DateMathFunction.name, DateMathFunction.creatorFunction);- expressionCreators.put(DateParseFunction.name, DateParseFunction.creatorFunction);- expressionCreators.put(DivideFunction.name, DivideFunction.creatorFunction);- expressionCreators.put(EqualFunction.name, EqualFunction.creatorFunction);- expressionCreators.put(ExistsFunction.name, ExistsFunction.creatorFunction);- expressionCreators.put(FillMissingFunction.name, FillMissingFunction.creatorFunction);- expressionCreators.put(FilterFunction.name, FilterFunction.creatorFunction);- expressionCreators.put(FloorFunction.name, FloorFunction.creatorFunction);- expressionCreators.put(GTFunction.name, GTFunction.creatorFunction);- expressionCreators.put(GTEFunction.name, GTEFunction.creatorFunction);- expressionCreators.put(IfFunction.name, IfFunction.creatorFunction);- expressionCreators.put(LogFunction.name, LogFunction.creatorFunction);- expressionCreators.put(LTFunction.name, LTFunction.creatorFunction);- expressionCreators.put(LTEFunction.name, LTEFunction.creatorFunction);- expressionCreators.put(MultFunction.name, MultFunction.creatorFunction);- expressionCreators.put(NegateFunction.name, NegateFunction.creatorFunction);- expressionCreators.put(OrFunction.name, OrFunction.creatorFunction);- expressionCreators.put(PowerFunction.name, PowerFunction.creatorFunction);- expressionCreators.put(ReplaceFunction.name, ReplaceFunction.creatorFunction);- expressionCreators.put(RemoveFunction.name, RemoveFunction.creatorFunction);- expressionCreators.put(RoundFunction.name, RoundFunction.creatorFunction);- expressionCreators.put(StringCastFunction.name, StringCastFunction.creatorFunction);- expressionCreators.put(SubtractFunction.name, SubtractFunction.creatorFunction);- expressionCreators.put(TopFunction.name, TopFunction.creatorFunction);-- // Reduction Functions- expressionCreators.put(CountFunction.name, CountFunction.creatorFunction);- expressionCreators.put(DocCountFunction.name, DocCountFunction.creatorFunction);- expressionCreators.put(MaxFunction.name, MaxFunction.creatorFunction);- expressionCreators.put(MeanFunction.name, MeanFunction.creatorFunction);- expressionCreators.put(MedianFunction.name, MedianFunction.creatorFunction);- expressionCreators.put(MinFunction.name, MinFunction.creatorFunction);- expressionCreators.put(MissingFunction.name, MissingFunction.creatorFunction);- expressionCreators.put(OrdinalFunction.name, OrdinalFunction.creatorFunction);- expressionCreators.put(PercentileFunction.name, PercentileFunction.creatorFunction);- expressionCreators.put(SumFunction.name, SumFunction.creatorFunction);- expressionCreators.put(UniqueFunction.name, UniqueFunction.creatorFunction);-- // Variables- addSystemVariableFunction(- WeightedMeanVariableFunction.name,- WeightedMeanVariableFunction.params,- WeightedMeanVariableFunction.function);- addSystemVariableFunction(- SumOfSquaresVariableFunction.name,- SumOfSquaresVariableFunction.params,- SumOfSquaresVariableFunction.function);- addSystemVariableFunction(- SquareRootVariableFunction.name,- SquareRootVariableFunction.params,- SquareRootVariableFunction.function);- addSystemVariableFunction(- VarianceVariableFunction.name,- VarianceVariableFunction.params,- VarianceVariableFunction.function);- addSystemVariableFunction(- SandardDeviationVariableFunction.name,- SandardDeviationVariableFunction.params,- SandardDeviationVariableFunction.function);- addSystemVariableFunction(- CSVVariableFunction.name, CSVVariableFunction.params, CSVVariableFunction.function);- addSystemVariableFunction(- CSVOutputVariableFunction.name,- CSVOutputVariableFunction.params,- CSVOutputVariableFunction.function);- }-- /**- * Used for system analytics functions for initialization. Should take in a list of expression- * parameters and return an expression.- */- @FunctionalInterface- public static interface CreatorFunction {- AnalyticsValueStream apply(AnalyticsValueStream[] t) throws SolrException;- }- /** Used to initialize analytics constants. */- @FunctionalInterface- public static interface ConstantFunction {- AnalyticsValueStream apply(String t) throws SolrException;- }-- static class VariableFunctionInfo {- public String[] params;- public String returnSignature;- }-- static class WeightedMeanVariableFunction {- public static final String name = "wmean";- public static final String params = "a,b";- public static final String function =- DivideFunction.name- + "("- + SumFunction.name- + "("- + MultFunction.name- + "(a,b)),"- + SumFunction.name- + "("- + FilterFunction.name- + "(b,"- + ExistsFunction.name- + "(a))))";- }-- static class SumOfSquaresVariableFunction {- public static final String name = "sumofsquares";- public static final String params = "a";- public static final String function = SumFunction.name + "(" + PowerFunction.name + "(a,2))";- }-- static class SquareRootVariableFunction {- public static final String name = "sqrt";- public static final String params = "a";- public static final String function = PowerFunction.name + "(a,0.5)";- }-- static class VarianceVariableFunction {- public static final String name = "variance";- public static final String params = "a";- public static final String function =- SubtractFunction.name- + "("- + MeanFunction.name- + "("- + PowerFunction.name- + "(a,2)),"- + PowerFunction.name- + "("- + MeanFunction.name- + "(a),2))";- }-- static class SandardDeviationVariableFunction {- public static final String name = "stddev";- public static final String params = "a";- public static final String function =- SquareRootVariableFunction.name + "(" + VarianceVariableFunction.name + "(a))";- }-- static class CSVVariableFunction {- public static final String name = "csv";- public static final String params = "a" + ExpressionFactory.variableLengthParamSuffix;- public static final String function = SeparatedConcatFunction.name + "(',',a)";- }-- static class CSVOutputVariableFunction {- public static final String name = "csv_output";- public static final String params = "a" + ExpressionFactory.variableLengthParamSuffix;- public static final String function =- "concat_sep(',',a"- + ExpressionFactory.variableForEachSep- + FillMissingFunction.name- + "("- + SeparatedConcatFunction.name- + "(';',"- + ExpressionFactory.variableForEachParam- + "),''))";- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/TimeExceededStubException.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/TimeExceededStubException.javadeleted file mode 100644index 200350f2591..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/TimeExceededStubException.java+++ /dev/null@@ -1,35 +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;--import org.apache.solr.common.SolrException;-import org.apache.solr.common.params.CommonParams;-import org.apache.solr.response.SolrQueryResponse;--public final class TimeExceededStubException extends SolrException {- private static final int HTTP_CODE = 524;-- public TimeExceededStubException(Throwable th) {- super(HTTP_CODE, SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, th);- setMetadata("cause", CommonParams.TIME_ALLOWED + " is exceeded");- }-- public static boolean isIt(SolrException e) {- return e.code() == HTTP_CODE- && SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY.equals(e.getMessage());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AbstractSolrQueryFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AbstractSolrQueryFacet.javadeleted file mode 100644index 512acd8f1ba..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AbstractSolrQueryFacet.java+++ /dev/null@@ -1,110 +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.facet;--import java.io.IOException;-import java.util.function.Consumer;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.search.Query;-import org.apache.lucene.search.ScoreMode;-import org.apache.lucene.search.SimpleCollector;-import org.apache.solr.analytics.AnalyticsDriver;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;-import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.search.SolrIndexSearcher;--/**- * Solr Query Facets are AnalyticsFacets that are calculated after the document streaming phase has- * occurred in the {@link AnalyticsDriver} (during which StreamingFacets and overall expressions are- * calculated). {@link AbstractSolrQueryFacet}s should not be confused with {@link QueryFacet}s,- * which are a specific sub-type.- *- * <p>The filtering for these facets is done through issuing additional Solr queries, and collecting- * on the resulting documents. Unlike streaming facets, which have an unspecified amount of facet- * values (facet buckets), the amount of facet values is determined by the user and a Solr query is- * issued for each requested facet value.- */-public abstract class AbstractSolrQueryFacet extends AnalyticsFacet {-- protected AbstractSolrQueryFacet(String name) {- super(name);- }-- /**- * Returns the set of {@link FacetValueQueryExecuter}s, one for each facet value, through the- * given consumer.- *- * <p>Each of these executors will be executed after the streaming phase in the {@link- * AnalyticsDriver}.- *- * @param filter the overall query representing the documents being used for the analytics request- * @param queryRequest the queryRequest- * @param consumer the consumer of each facet value's executer- */- public abstract void createFacetValueExecuters(- final Query filter,- SolrQueryRequest queryRequest,- Consumer<FacetValueQueryExecuter> consumer);-- /**- * This executer is in charge of issuing the Solr query for a facet value and collecting results- * as the query is processed.- */- public class FacetValueQueryExecuter extends SimpleCollector {- private final ReductionDataCollection collection;- private final Query query;-- /**- * Create an executer to collect the given reduction data from the given Solr query.- *- * @param collection The reduction data to collect while querying- * @param query The query used to filter for the facet value- */- public FacetValueQueryExecuter(ReductionDataCollection collection, Query query) {- this.collection = collection;- this.query = query;- }-- @Override- public ScoreMode scoreMode() {- return ScoreMode.COMPLETE_NO_SCORES;- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- collectionManager.doSetNextReader(context);- }-- @Override- public void collect(int doc) throws IOException {- collectionManager.collect(doc);- collectionManager.apply();- }-- /**- * Start the collection for this facet value.- *- * @param searcher the solr searcher- * @throws IOException if an exception occurs during the querying- */- public void execute(SolrIndexSearcher searcher) throws IOException {- collectionManager.clearLastingCollectTargets();- collectionManager.addLastingCollectTarget(collection);- searcher.search(query, this);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AnalyticsFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AnalyticsFacet.javadeleted file mode 100644index 17a96f1d421..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/AnalyticsFacet.java+++ /dev/null@@ -1,167 +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.facet;--import java.io.DataInput;-import java.io.DataOutput;-import java.io.IOException;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.LinkedHashMap;-import java.util.List;-import java.util.Map;-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.function.reduction.data.ReductionData;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.common.util.NamedList;--/** An abstract Facet to break up Analytics data over. */-public abstract class AnalyticsFacet {- protected final Map<String, ReductionDataCollection> reductionData;- protected ReductionCollectionManager collectionManager;- protected ExpressionCalculator expressionCalculator;-- protected final String name;-- public AnalyticsFacet(String name) {- this.reductionData = new LinkedHashMap<>();- this.name = name;- }-- /**- * Set the {@link ReductionCollectionManager} that manages the collection of the expressions- * calculated with this facet.- *- * @param collectionManager The manager for relevant expressions- */- public void setReductionCollectionManager(ReductionCollectionManager collectionManager) {- this.collectionManager = collectionManager;- }-- /**- * Set the {@link ExpressionCalculator} that calculates the collection of the expressions- * requested for this facet.- *- * @param expressionCalculator The calculator for relevant expressions- */- public void setExpressionCalculator(ExpressionCalculator expressionCalculator) {- this.expressionCalculator = expressionCalculator;- }-- /**- * Import the shard data 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 data from- * @throws IOException if an exception occurs while reading from the {@link DataInput}- */- public void importShardData(DataInput input) throws IOException {- int size = input.readInt();- for (int i = 0; i < size; ++i) {- importFacetValue(input, input.readUTF());- }- }- /**- * Import the next facet value's set of {@link ReductionData}.- *- * @param input the bit-stream to import the reduction data from- * @param facetValue the next facet value- * @throws IOException if an exception occurs while reading from the input- */- protected void importFacetValue(DataInput input, String facetValue) throws IOException {- ReductionDataCollection dataCollection = reductionData.get(facetValue);- if (dataCollection == null) {- reductionData.put(facetValue, collectionManager.newDataCollectionIO());- } else {- collectionManager.prepareReductionDataIO(dataCollection);- }-- collectionManager.mergeData();- }-- /**- * Export the shard data through a bit-stream, to be imported by the {@link #importShardData}- * method in the originating shard.- *- * @param output The bit-stream to output the data through- * @throws IOException if an exception occurs while writing to the {@link DataOutput}- */- public void exportShardData(DataOutput output) throws IOException {- output.writeInt(reductionData.size());- for (String facetValue : reductionData.keySet()) {- exportFacetValue(output, facetValue);- }- }- /**- * Export the next facet value's set of {@link ReductionData}.- *- * @param output the bit-stream to output the reduction data to- * @param facetValue the next facet value- * @throws IOException if an exception occurs while reading from the input- */- protected void exportFacetValue(DataOutput output, String facetValue) throws IOException {- output.writeUTF(facetValue);-- collectionManager.prepareReductionDataIO(reductionData.get(facetValue));- collectionManager.exportData();- }-- /**- * Create the old olap-style response of the facet to be returned in the overall analytics- * response.- *- * @return the response of the facet- */- public NamedList<Object> createOldResponse() {- NamedList<Object> nl = new NamedList<>();- reductionData.forEach(- (facetVal, dataCol) -> {- collectionManager.setData(dataCol);- nl.add(facetVal, new NamedList<>(expressionCalculator.getResults()));- });- return nl;- }-- /**- * Create the response of the facet to be returned in the overall analytics response.- *- * @return the response of the facet- */- public Iterable<Map<String, Object>> createResponse() {- List<Map<String, Object>> list = new ArrayList<>();- reductionData.forEach(- (facetVal, dataCol) -> {- Map<String, Object> bucket = new HashMap<>();- bucket.put(AnalyticsResponseHeadings.FACET_VALUE, facetVal);- collectionManager.setData(dataCol);- expressionCalculator.addResults(bucket);- list.add(bucket);- });- return list;- }-- /**- * Get the name of the Facet. This is unique for the grouping.- *- * @return The name of the Facet- */- public String getName() {- return name;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotFacet.javadeleted file mode 100644index 87cf0eeea7f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotFacet.java+++ /dev/null@@ -1,115 +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.facet;--import java.io.DataInput;-import java.io.DataOutput;-import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import org.apache.solr.analytics.function.ExpressionCalculator;-import org.apache.solr.analytics.function.ReductionCollectionManager;-import org.apache.solr.common.util.NamedList;--/**- * A facet that takes in multiple ValueFacet expressions and does analytics calculations over each- * dimension given.- */-public class PivotFacet extends AnalyticsFacet implements StreamingFacet {- private final PivotHead<?> pivotHead;-- public PivotFacet(String name, PivotNode<?> topPivot) {- super(name);- this.pivotHead = new PivotHead<>(topPivot);- }-- @Override- public void setReductionCollectionManager(ReductionCollectionManager collectionManager) {- pivotHead.setReductionCollectionManager(collectionManager);- }-- @Override- public void setExpressionCalculator(ExpressionCalculator expressionCalculator) {- pivotHead.setExpressionCalculator(expressionCalculator);- }-- @Override- public void addFacetValueCollectionTargets() {- pivotHead.addFacetValueCollectionTargets();- }-- @Override- public void importShardData(DataInput input) throws IOException {- pivotHead.importShardData(input);- }-- @Override- public void exportShardData(DataOutput output) throws IOException {- pivotHead.exportShardData(output);- }-- @Override- public NamedList<Object> createOldResponse() {- return new NamedList<>();- }-- @Override- public Iterable<Map<String, Object>> createResponse() {- return pivotHead.createResponse();- }-- /**- * Typed Pivot class that stores the overall Pivot data and head of the Pivot node chain.- *- * <p>This class exists so that the {@link PivotFacet} class doesn't have to be typed ( {@code- * <T>} ).- */- private static class PivotHead<T> implements StreamingFacet {- private final PivotNode<T> topPivot;- private final Map<String, T> pivotValues;-- public PivotHead(PivotNode<T> topPivot) {- this.topPivot = topPivot;- this.pivotValues = new HashMap<>();- }-- public void setReductionCollectionManager(ReductionCollectionManager collectionManager) {- topPivot.setReductionCollectionManager(collectionManager);- }-- public void setExpressionCalculator(ExpressionCalculator expressionCalculator) {- topPivot.setExpressionCalculator(expressionCalculator);- }-- @Override- public void addFacetValueCollectionTargets() {- topPivot.addFacetValueCollectionTargets(pivotValues);- }-- public void importShardData(DataInput input) throws IOException {- topPivot.importPivot(input, pivotValues);- }-- public void exportShardData(DataOutput output) throws IOException {- topPivot.exportPivot(output, pivotValues);- }-- public Iterable<Map<String, Object>> createResponse() {- return topPivot.getPivotedResponse(pivotValues);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.javadeleted file mode 100644index 430ac0ff55f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java+++ /dev/null@@ -1,265 +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.facet;--import java.io.DataInput;-import java.io.DataOutput;-import java.io.IOException;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.List;-import java.util.Map;-import java.util.function.Consumer;-import org.apache.solr.analytics.AnalyticsDriver;-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.function.reduction.data.ReductionData;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.analytics.value.StringValueStream;--/**- * Representation of one layer of a Pivot Facet. A PivotFacet node is individually sortable, and is- * collected during the streaming phase of the {@link AnalyticsDriver}.- */-public abstract class PivotNode<T> extends SortableFacet implements Consumer<String> {- private StringValueStream expression;- protected Map<String, T> currentPivot;-- public PivotNode(String name, StringValueStream expression) {- super(name);- this.expression = expression;- }-- /**- * Determine which facet values match the current document. Add the {@link- * ReductionDataCollection}s of the relevant facet values to the targets of the streaming {@link- * ReductionCollectionManager} so that they are updated with the current document's data.- */- public void addFacetValueCollectionTargets(Map<String, T> pivot) {- currentPivot = pivot;- expression.streamStrings(this);- }-- /**- * Import the shard data from a bit-stream for the given pivot, exported by the {@link- * #exportPivot} method in the each of the collection's shards.- *- * @param input The bit-stream to import the data from- * @param pivot the values for this pivot node and the pivot children (if they exist)- * @throws IOException if an exception occurs while reading from the {@link DataInput}- */- public void importPivot(DataInput input, Map<String, T> pivot) throws IOException {- int size = input.readInt();- currentPivot = pivot;- for (int i = 0; i < size; ++i) {- importPivotValue(input, input.readUTF());- }- }- /**- * Import the next pivot value's set of {@link ReductionData} and children's {@link ReductionData}- * if they exist.- *- * @param input the bit-stream to import the reduction data from- * @param pivotValue the next pivot value- * @throws IOException if an exception occurs while reading from the input- */- protected abstract void importPivotValue(DataInput input, String pivotValue) throws IOException;-- /**- * Export the shard data through a bit-stream for the given pivot, to be imported by the {@link- * #importPivot} method in the originating shard.- *- * @param output The bit-stream to output the data through- * @param pivot the values for this pivot node and the pivot children (if they exist)- * @throws IOException if an exception occurs while writing to the {@link DataOutput}- */- public void exportPivot(DataOutput output, Map<String, T> pivot) throws IOException {- output.writeInt(pivot.size());- for (Map.Entry<String, T> entry : pivot.entrySet()) {- output.writeUTF(entry.getKey());- exportPivotValue(output, entry.getValue());- }- }- /**- * Export the given pivot data, containing {@link ReductionData} and pivot children if they exist.- *- * @param output the bit-stream to output the reduction data to- * @param pivotData the next pivot value data- * @throws IOException if an exception occurs while reading from the input- */- protected abstract void exportPivotValue(DataOutput output, T pivotData) throws IOException;-- /**- * Create the response of the facet to be returned in the overall analytics response.- *- * @param pivot the pivot to create a response for- * @return the response of the facet- */- public abstract Iterable<Map<String, Object>> getPivotedResponse(Map<String, T> pivot);-- /** A pivot node that has no pivot children. */- public static class PivotLeaf extends PivotNode<ReductionDataCollection> {-- public PivotLeaf(String name, StringValueStream expression) {- super(name, expression);- }-- @Override- public void accept(String pivotValue) {- ReductionDataCollection collection = currentPivot.get(pivotValue);- if (collection == null) {- collection = collectionManager.newDataCollectionTarget();- currentPivot.put(pivotValue, collection);- } else {- collectionManager.addCollectTarget(collection);- }- }-- @Override- protected void importPivotValue(DataInput input, String pivotValue) throws IOException {- ReductionDataCollection dataCollection = currentPivot.get(pivotValue);- if (dataCollection == null) {- currentPivot.put(pivotValue, collectionManager.newDataCollectionIO());- } else {- collectionManager.prepareReductionDataIO(dataCollection);- }- collectionManager.mergeData();- }-- @Override- protected void exportPivotValue(DataOutput output, ReductionDataCollection pivotData)- throws IOException {- collectionManager.prepareReductionDataIO(pivotData);- collectionManager.exportData();- }-- @Override- public Iterable<Map<String, Object>> getPivotedResponse(- Map<String, ReductionDataCollection> pivot) {- final List<FacetBucket> facetResults = new ArrayList<>();- pivot.forEach(- (facetVal, dataCol) -> {- collectionManager.setData(dataCol);- facetResults.add(new FacetBucket(facetVal, expressionCalculator.getResults()));- });-- Iterable<FacetBucket> facetResultsIter = applyOptions(facetResults);- final List<Map<String, Object>> results = new ArrayList<>();- // Export each expression in the bucket.- for (FacetBucket bucket : facetResultsIter) {- Map<String, Object> bucketMap = new HashMap<>();- bucketMap.put(AnalyticsResponseHeadings.PIVOT_NAME, name);- bucketMap.put(AnalyticsResponseHeadings.FACET_VALUE, bucket.getFacetValue());- bucketMap.put(AnalyticsResponseHeadings.RESULTS, bucket.getResults());- results.add(bucketMap);- }- return results;- }- }-- /** A pivot node that has pivot children. */- public static class PivotBranch<T> extends PivotNode<PivotBranch.PivotDataPair<T>> {- private final PivotNode<T> childPivot;-- public PivotBranch(String name, StringValueStream expression, PivotNode<T> childPivot) {- super(name, expression);- this.childPivot = childPivot;- }-- @Override- public void setReductionCollectionManager(ReductionCollectionManager collectionManager) {- super.setReductionCollectionManager(collectionManager);- childPivot.setReductionCollectionManager(collectionManager);- }-- @Override- public void setExpressionCalculator(ExpressionCalculator expressionCalculator) {- super.setExpressionCalculator(expressionCalculator);- childPivot.setExpressionCalculator(expressionCalculator);- }-- @Override- public void accept(String pivotValue) {- PivotDataPair<T> pivotData = currentPivot.get(pivotValue);- if (pivotData == null) {- pivotData = new PivotDataPair<>();- pivotData.childPivots = new HashMap<>();- pivotData.pivotReduction = collectionManager.newDataCollectionTarget();- currentPivot.put(pivotValue, pivotData);- } else {- collectionManager.addCollectTarget(pivotData.pivotReduction);- }- childPivot.addFacetValueCollectionTargets(pivotData.childPivots);- }-- @Override- protected void importPivotValue(DataInput input, String pivotValue) throws IOException {- PivotDataPair<T> pivotData = currentPivot.get(pivotValue);- if (pivotData == null) {- pivotData = new PivotDataPair<>();- pivotData.childPivots = new HashMap<>();- pivotData.pivotReduction = collectionManager.newDataCollectionIO();- currentPivot.put(pivotValue, pivotData);- } else {- collectionManager.prepareReductionDataIO(pivotData.pivotReduction);- }- collectionManager.mergeData();- childPivot.importPivot(input, pivotData.childPivots);- }-- @Override- protected void exportPivotValue(DataOutput output, PivotDataPair<T> pivotData)- throws IOException {- collectionManager.prepareReductionDataIO(pivotData.pivotReduction);- collectionManager.exportData();-- childPivot.exportPivot(output, pivotData.childPivots);- }-- @Override- public Iterable<Map<String, Object>> getPivotedResponse(Map<String, PivotDataPair<T>> pivot) {- final List<FacetBucket> facetResults = new ArrayList<>();- pivot.forEach(- (facetVal, dataPair) -> {- collectionManager.setData(dataPair.pivotReduction);- facetResults.add(new FacetBucket(facetVal, expressionCalculator.getResults()));- });-- Iterable<FacetBucket> facetResultsIter = applyOptions(facetResults);- final List<Map<String, Object>> results = new ArrayList<>();- // Export each expression in the bucket.- for (FacetBucket bucket : facetResultsIter) {- Map<String, Object> bucketMap = new HashMap<>();- bucketMap.put(AnalyticsResponseHeadings.PIVOT_NAME, name);- bucketMap.put(AnalyticsResponseHeadings.FACET_VALUE, bucket.getFacetValue());- bucketMap.put(AnalyticsResponseHeadings.RESULTS, bucket.getResults());- bucketMap.put(- AnalyticsResponseHeadings.PIVOT_CHILDREN,- childPivot.getPivotedResponse(pivot.get(bucket.getFacetValue()).childPivots));- results.add(bucketMap);- }- return results;- }-- /** Contains pivot data for {@link PivotNode.PivotBranch} classes. */- protected static class PivotDataPair<T> {- ReductionDataCollection pivotReduction;- Map<String, T> childPivots;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/QueryFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/QueryFacet.javadeleted file mode 100644index 47350a88a6b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/QueryFacet.java+++ /dev/null@@ -1,63 +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.facet;--import java.util.Map;-import java.util.function.Consumer;-import org.apache.lucene.search.Query;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;-import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.search.QParser;-import org.apache.solr.search.QueryUtils;--/** A facet that breaks down the data by additional Solr Queries. */-public class QueryFacet extends AbstractSolrQueryFacet {- private final Map<String, String> queries;-- public QueryFacet(String name, Map<String, String> queries) {- super(name);- this.queries = queries;- }-- @Override- public void createFacetValueExecuters(- final Query filter,- SolrQueryRequest queryRequest,- Consumer<FacetValueQueryExecuter> consumer) {- queries.forEach(- (queryName, query) -> {- final Query q;- try {- q = QParser.getParser(query, queryRequest).getQuery();- } catch (Exception e) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "Invalid query '" + query + "' in query facet '" + getName() + "'",- e);- }- // The searcher sends docIds to the QueryFacetAccumulator which forwards- // them to <code>collectQuery()</code> in this class for collection.- Query queryQuery = QueryUtils.combineQueryAndFilter(q, filter);-- ReductionDataCollection dataCol = collectionManager.newDataCollection();- reductionData.put(queryName, dataCol);- consumer.accept(new FacetValueQueryExecuter(dataCol, queryQuery));- });- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/RangeFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/RangeFacet.javadeleted file mode 100644index 3d41e0831ed..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/RangeFacet.java+++ /dev/null@@ -1,117 +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.facet;--import java.util.EnumSet;-import java.util.List;-import java.util.function.Consumer;-import org.apache.lucene.search.Query;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;-import org.apache.solr.analytics.util.FacetRangeGenerator;-import org.apache.solr.analytics.util.FacetRangeGenerator.FacetRange;-import org.apache.solr.common.params.FacetParams.FacetRangeInclude;-import org.apache.solr.common.params.FacetParams.FacetRangeOther;-import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.schema.SchemaField;-import org.apache.solr.search.QueryUtils;--/** A facet that groups data by a discrete set of ranges. */-public class RangeFacet extends AbstractSolrQueryFacet {- protected final SchemaField field;- protected final String start;- protected final String end;- protected final List<String> gaps;- protected boolean hardEnd = false;- protected EnumSet<FacetRangeInclude> include;- protected EnumSet<FacetRangeOther> others;-- public RangeFacet(String name, SchemaField field, String start, String end, List<String> gaps) {- super(name);- this.field = field;- this.start = start;- this.end = end;- this.gaps = gaps;- include = EnumSet.of(FacetRangeInclude.LOWER);- others = EnumSet.of(FacetRangeOther.NONE);- }-- @Override- public void createFacetValueExecuters(- final Query filter,- SolrQueryRequest queryRequest,- Consumer<FacetValueQueryExecuter> consumer) {- // Computes the end points of the ranges in the rangeFacet- final FacetRangeGenerator<? extends Comparable<?>> rec = FacetRangeGenerator.create(this);- final SchemaField sf = field;-- // Create a rangeFacetAccumulator for each range and- // collect the documents for that range.- for (FacetRange range : rec.getRanges()) {- Query q =- sf.getType()- .getRangeQuery(- null, sf, range.lower, range.upper, range.includeLower, range.includeUpper);- // The searcher sends docIds to the RangeFacetAccumulator which forwards- // them to <code>collectRange()</code> in this class for collection.- Query rangeQuery = QueryUtils.combineQueryAndFilter(q, filter);-- ReductionDataCollection dataCol = collectionManager.newDataCollection();- reductionData.put(range.toString(), dataCol);- consumer.accept(new FacetValueQueryExecuter(dataCol, rangeQuery));- }- }-- public String getStart() {- return start;- }-- public String getEnd() {- return end;- }-- public EnumSet<FacetRangeInclude> getInclude() {- return include;- }-- public void setInclude(EnumSet<FacetRangeInclude> include) {- this.include = include;- }-- public List<String> getGaps() {- return gaps;- }-- public boolean isHardEnd() {- return hardEnd;- }-- public void setHardEnd(boolean hardEnd) {- this.hardEnd = hardEnd;- }-- public EnumSet<FacetRangeOther> getOthers() {- return others;- }-- public void setOthers(EnumSet<FacetRangeOther> others) {- this.others = others;- }-- public SchemaField getField() {- return field;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.javadeleted file mode 100644index 7ef790b60cf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java+++ /dev/null@@ -1,170 +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.facet;--import java.util.ArrayList;-import java.util.Comparator;-import java.util.HashMap;-import java.util.List;-import java.util.Map;-import java.util.stream.Collectors;-import org.apache.solr.analytics.facet.compare.FacetResultsComparator;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.common.util.NamedList;--/** A facet that can be sorted by either the facet value or an expression value. */-public abstract class SortableFacet extends AnalyticsFacet {- protected FacetSortSpecification sort = null;-- protected SortableFacet(String name) {- super(name);- }-- @Override- public NamedList<Object> createOldResponse() {- final NamedList<Object> results = new NamedList<>();- // Export each expression in the bucket.- for (FacetBucket bucket : getBuckets()) {- results.add(bucket.getFacetValue(), new NamedList<>(bucket.getResults()));- }- return results;- }-- @Override- public Iterable<Map<String, Object>> createResponse() {- final List<Map<String, Object>> results = new ArrayList<>();- // Export each expression in the bucket.- for (FacetBucket bucket : getBuckets()) {- Map<String, Object> bucketMap = new HashMap<>();- bucketMap.put(AnalyticsResponseHeadings.FACET_VALUE, bucket.getFacetValue());- bucketMap.put(AnalyticsResponseHeadings.RESULTS, bucket.getResults());- results.add(bucketMap);- }- return results;- }-- private Iterable<FacetBucket> getBuckets() {- final List<FacetBucket> facetResults = new ArrayList<>();- reductionData.forEach(- (facetVal, dataCol) -> {- collectionManager.setData(dataCol);- facetResults.add(new FacetBucket(facetVal, expressionCalculator.getResults()));- });-- return applyOptions(facetResults);- }-- /**- * Apply the sorting options to the given facet results.- *- * @param facetResults to apply sorting options to- * @return the sorted results- */- protected Iterable<FacetBucket> applyOptions(List<FacetBucket> facetResults) {- // Sorting the buckets if a sort specification is provided- if (sort == null || facetResults.isEmpty()) {- return facetResults;- }- Comparator<FacetBucket> comp = sort.getComparator();- facetResults.sort(comp);- // apply the limit- if (sort.getLimit() > 0) {- if (sort.getOffset() > 0) {- facetResults =- facetResults.stream().skip(sort.getOffset()).collect(Collectors.toUnmodifiableList());- }- facetResults =- facetResults.stream().limit(sort.getLimit()).collect(Collectors.toUnmodifiableList());- } else if (sort.getLimit() == 0) {- return new ArrayList<>();- }- return facetResults;- }-- /** Specifies how to sort the buckets of a sortable facet. */- public static class FacetSortSpecification {- private FacetResultsComparator comparator;- protected int limit;- protected int offset;-- public FacetSortSpecification(FacetResultsComparator comparator, int limit, int offset) {- this.comparator = comparator;- this.limit = limit;- this.offset = offset;- }-- public FacetResultsComparator getComparator() {- return comparator;- }-- /**- * Get the maximum number of buckets to be returned.- *- * @return the limit- */- public int getLimit() {- return limit;- }- /**- * Set the maximum number of buckets to be returned.- *- * @param limit the maximum number of buckets- */- public void setLimit(int limit) {- this.limit = limit;- }-- /**- * Get the first bucket to return, has to be used with the {@code limit} option.- *- * @return the bucket offset- */- public int getOffset() {- return offset;- }- }-- public SortableFacet.FacetSortSpecification getSort() {- return sort;- }-- public void setSort(SortableFacet.FacetSortSpecification sort) {- this.sort = sort;- }-- public static class FacetBucket {- private final String facetValue;- private final Map<String, Object> expressionResults;-- public FacetBucket(String facetValue, Map<String, Object> expressionResults) {- this.facetValue = facetValue;- this.expressionResults = expressionResults;- }-- public Object getResult(String expression) {- return expressionResults.get(expression);- }-- public Map<String, Object> getResults() {- return expressionResults;- }-- public String getFacetValue() {- return facetValue;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/StreamingFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/StreamingFacet.javadeleted file mode 100644index 2c1ea69e05f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/StreamingFacet.java+++ /dev/null@@ -1,31 +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.facet;--import org.apache.solr.analytics.AnalyticsDriver;-import org.apache.solr.analytics.function.ReductionCollectionManager;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;--/** A facet that is collected during the streaming phase of the {@link AnalyticsDriver}. */-public interface StreamingFacet {- /**- * Determine which facet values match the current document. Add the {@link- * ReductionDataCollection}s of the relevant facet values to the targets of the streaming {@link- * ReductionCollectionManager} so that they are updated with the current document's data.- */- void addFacetValueCollectionTargets();-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/ValueFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/ValueFacet.javadeleted file mode 100644index 2b27a6ac85d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/ValueFacet.java+++ /dev/null@@ -1,59 +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.facet;--import java.util.function.Consumer;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;-import org.apache.solr.analytics.value.StringValueStream;--/**- * A facet that breaks up data by the values of a mapping expression or field. The mapping- * expression must be castable to a {@link StringValueStream}.- */-public class ValueFacet extends SortableFacet implements StreamingFacet, Consumer<String> {- private StringValueStream expression;-- public ValueFacet(String name, StringValueStream expression) {- super(name);- this.expression = expression;- }-- @Override- public void addFacetValueCollectionTargets() {- expression.streamStrings(this);- }-- @Override- public void accept(String t) {- ReductionDataCollection collection = reductionData.get(t);- if (collection == null) {- collection = collectionManager.newDataCollectionTarget();- reductionData.put(t, collection);- } else {- collectionManager.addCollectTarget(collection);- }- }-- /**- * Get the expression used to create the facet values.- *- * @return a string mapping expression- */- public StringValueStream getExpression() {- return expression;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ConstantComparator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ConstantComparator.javadeleted file mode 100644index ad21e76c009..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ConstantComparator.java+++ /dev/null@@ -1,28 +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.facet.compare;--import org.apache.solr.analytics.facet.SortableFacet.FacetBucket;--/** A results comparator that compares constants. */-public class ConstantComparator extends FacetResultsComparator {-- @Override- public int compare(FacetBucket b1, FacetBucket b2) {- return 0;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/DelegatingComparator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/DelegatingComparator.javadeleted file mode 100644index be87f36c678..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/DelegatingComparator.java+++ /dev/null@@ -1,65 +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.facet.compare;--import java.util.Collection;-import org.apache.solr.analytics.facet.SortableFacet.FacetBucket;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A comparator used to sort the facet-value buckets of facet, using the delegate comparator if two- * values are equal.- */-public class DelegatingComparator extends FacetResultsComparator {- private final Iterable<FacetResultsComparator> comparators;-- /**- * Create a delegating results comparator. This comparator will in succession use the given- * comparators, continuing if the values are equal. Two buckets are considered equal if and only- * if all comparators find them equal- *- * @param comparators the comparators to use in succession- */- private DelegatingComparator(Iterable<FacetResultsComparator> comparators) {- this.comparators = comparators;- }-- public static FacetResultsComparator joinComparators(- Collection<FacetResultsComparator> comparators) throws SolrException {- if (comparators.size() == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "A sort must have at least 1 comparator criteria.");- } else if (comparators.size() == 1) {- return comparators.iterator().next();- } else {- return new DelegatingComparator(comparators);- }- }-- @Override- public int compare(FacetBucket b1, FacetBucket b2) {- int val = 0;- for (FacetResultsComparator comparator : comparators) {- val = comparator.compare(b1, b2);- if (val != 0) {- break;- }- }- return val;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ExpressionComparator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ExpressionComparator.javadeleted file mode 100644index 5b981062455..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/ExpressionComparator.java+++ /dev/null@@ -1,45 +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.facet.compare;--import org.apache.solr.analytics.facet.SortableFacet.FacetBucket;--/** A comparator used to sort the facet-value buckets of facet. */-public class ExpressionComparator<T extends Comparable<T>> extends FacetResultsComparator {- private final String expression;-- /**- * Create an entry comparator comparing the given expression.- *- * @param expression the name of the expression results to compare- */- public ExpressionComparator(String expression) {- this.expression = expression;- }-- @Override- @SuppressWarnings("unchecked")- public int compare(FacetBucket b1, FacetBucket b2) {- T t1 = (T) b1.getResult(expression);- T t2 = (T) b2.getResult(expression);- if (t1 == null || t2 == null) {- return Boolean.compare(t2 == null, t1 == null) * resultMult;- } else {- return t1.compareTo(t2) * resultMult;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetResultsComparator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetResultsComparator.javadeleted file mode 100644index a8abc2001c3..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetResultsComparator.java+++ /dev/null@@ -1,48 +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.facet.compare;--import java.util.Comparator;-import org.apache.solr.analytics.facet.SortableFacet.FacetBucket;--/** A comparator used to sort the buckets of facet. */-public abstract class FacetResultsComparator implements Comparator<FacetBucket> {- protected int resultMult;-- /** Create a results comparator assuming an ascending ordering. */- public FacetResultsComparator() {- setDirection(true);- }-- /**- * Set the order direction for comparison.- *- * @param ascending whether to compare using an ascending ordering- */- public void setDirection(boolean ascending) {- this.resultMult = ascending ? 1 : -1;- }-- /**- * Compare one facet bucket to another.- *- * @param b1 the first bucket to compare- * @param b2 the second bucket to compare- */- @Override- public abstract int compare(FacetBucket b1, FacetBucket b2);-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetValueComparator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetValueComparator.javadeleted file mode 100644index 3ec723f8f87..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/FacetValueComparator.java+++ /dev/null@@ -1,36 +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.facet.compare;--import org.apache.solr.analytics.facet.SortableFacet.FacetBucket;--/**- * A results comparator that compares the name of facet value buckets, which is the string value of- * the facet value.- */-public class FacetValueComparator extends FacetResultsComparator {-- /** Create a facet value comparator. */- public FacetValueComparator() {- super();- }-- @Override- public int compare(FacetBucket b1, FacetBucket b2) {- return b1.getFacetValue().compareTo(b2.getFacetValue()) * resultMult;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/package-info.javadeleted file mode 100644index 6f1ee63e2cd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/compare/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Comparators used to sort the buckets of an analytics facet. */-package org.apache.solr.analytics.facet.compare;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/package-info.javadeleted file mode 100644index 3621dd674eb..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Facets supported by the analytics component. */-package org.apache.solr.analytics.facet;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ExpressionCalculator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ExpressionCalculator.javadeleted file mode 100644index e94b947aad3..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ExpressionCalculator.java+++ /dev/null@@ -1,70 +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.function;--import java.util.HashMap;-import java.util.Map;-import org.apache.solr.analytics.AnalyticsExpression;-import org.apache.solr.analytics.function.ReductionCollectionManager.ReductionDataCollection;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.common.util.NamedList;--/** A class used to generate results for a list of {@link AnalyticsExpression}s. */-public class ExpressionCalculator {- private final Iterable<AnalyticsExpression> expressions;-- public ExpressionCalculator(Iterable<AnalyticsExpression> expressions) {- this.expressions = expressions;- }-- /**- * Calculate results for the list of {@link AnalyticsExpression}s.- *- * <p>NOTE: This method can, and is, called multiple times to generate different responses. <br>- * The results are determined by which {@link ReductionDataCollection} is passed to the {@link- * ReductionCollectionManager#setData} method of the {@link ReductionCollectionManager} managing- * the reduction for the list of {@link AnalyticsExpression}s.- *- * @return a {@link NamedList} containing the results- */- public Map<String, Object> getResults() {- Map<String, Object> exprVals = new HashMap<>();- expressions.forEach(- expr -> {- Object obj = expr.toObject();- if (expr.exists()) {- exprVals.put(expr.getName(), obj);- }- });- return exprVals;- }-- /**- * Calculate results for the list of {@link AnalyticsExpression}s and add them to the given- * response.- *- * <p>NOTE: This method can, and is, called multiple times to generate different responses. <br>- * The results are determined by which {@link ReductionDataCollection} is passed to the {@link- * ReductionCollectionManager#setData} method of the {@link ReductionCollectionManager} managing- * the reduction for the list of {@link AnalyticsExpression}s.- *- * @param response the response to add the results map to.- */- public void addResults(Map<String, Object> response) {- response.put(AnalyticsResponseHeadings.RESULTS, getResults());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/MergingReductionCollectionManager.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/MergingReductionCollectionManager.javadeleted file mode 100644index bb5585aae56..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/MergingReductionCollectionManager.java+++ /dev/null@@ -1,48 +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.function;--import org.apache.solr.analytics.function.field.AnalyticsField;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;--/** The {@link ReductionCollectionManager} used for distributed requests. */-public class MergingReductionCollectionManager extends ReductionCollectionManager {-- public MergingReductionCollectionManager() {- super();- }-- public MergingReductionCollectionManager(- final ReductionDataCollector<?>[] reductionDataCollectors,- final Iterable<AnalyticsField> fields) {- super(reductionDataCollectors, fields);- }-- @Override- protected ReductionCollectionManager createNewManager(- final ReductionDataCollector<?>[] reductionDataCollectors,- final Iterable<AnalyticsField> fields) {- return new MergingReductionCollectionManager(reductionDataCollectors, fields);- }-- @Override- public void setData(ReductionDataCollection dataCollection) {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].setMergedData(dataCollection.dataArr[i]);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionCollectionManager.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionCollectionManager.javadeleted file mode 100644index 37d86a286fb..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionCollectionManager.java+++ /dev/null@@ -1,328 +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.function;--import java.io.DataInput;-import java.io.DataOutput;-import java.io.IOException;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.HashMap;-import java.util.List;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.solr.analytics.function.field.AnalyticsField;-import org.apache.solr.analytics.function.reduction.data.ReductionData;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.stream.reservation.read.ReductionDataReader;-import org.apache.solr.analytics.stream.reservation.write.ReductionDataWriter;-import org.apache.solr.analytics.value.AnalyticsValue;--/**- * The manager of reduction collection. Contains a group of {@link ReductionDataCollector}s which- * will be updated together.- *- * <p>The manager assumes a non-distributed request. {@link MergingReductionCollectionManager} is- * used for distributed requests.- */-public class ReductionCollectionManager {- protected final ReductionDataCollector<?>[] reductionDataCollectors;- private final List<ReductionDataReservation<?, ?>> reservations;-- private final List<ReductionDataReader<?>> readers;- private final List<ReductionDataWriter<?>> writers;-- private final Iterable<AnalyticsField> fields;-- public ReductionCollectionManager() {- this(new ReductionDataCollector<?>[0], new ArrayList<>(0));- }-- /**- * Create a Manager to oversee the given {@link ReductionDataCollector}s.- *- * @param reductionDataCollectors array of collectors that are collecting over the same set of- * data- * @param fields all fields used by the given collectors- */- public ReductionCollectionManager(- final ReductionDataCollector<?>[] reductionDataCollectors,- final Iterable<AnalyticsField> fields) {- this.reductionDataCollectors = reductionDataCollectors;- Arrays.sort(- reductionDataCollectors, (a, b) -> a.getExpressionStr().compareTo(b.getExpressionStr()));-- reservations = new ArrayList<>();- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].submitReservations(reservation -> reservations.add(reservation));- }-- this.fields = fields;-- this.readers = new ArrayList<>();- this.writers = new ArrayList<>();- }-- /**- * Return whether or not the manager needs collection done, which is false if no collectors are- * being managed and true if at least one is.- *- * @return true if at least one collector is being managed- */- public boolean needsCollection() {- return reductionDataCollectors.length > 0;- }-- /**- * Merge this collection manager with others.- *- * @param reductionManagers the collection managers to merge with- * @return a collection manager that manages the union of data collectors from this class and the- * given managers- */- public ReductionCollectionManager merge(Iterable<ReductionCollectionManager> reductionManagers) {- HashMap<String, ReductionDataCollector<?>> mergedCollectors = new HashMap<>();- HashMap<String, AnalyticsField> mergedFields = new HashMap<>();-- for (ReductionDataCollector<?> collector : reductionDataCollectors) {- mergedCollectors.put(collector.getExpressionStr(), collector);- }- fields.forEach(field -> mergedFields.put(field.getExpressionStr(), field));-- reductionManagers.forEach(- manager -> {- for (ReductionDataCollector<?> collector : manager.reductionDataCollectors) {- mergedCollectors.put(collector.getExpressionStr(), collector);- }- manager.fields.forEach(field -> mergedFields.put(field.getExpressionStr(), field));- });- ReductionDataCollector<?>[] collectors = new ReductionDataCollector<?>[mergedCollectors.size()];- mergedCollectors.values().toArray(collectors);- return createNewManager(collectors, mergedFields.values());- }-- /**- * Create an {@link ReductionCollectionManager} to manage the given collectors and fields.- *- * @param reductionDataCollectors Reduction collectors- * @param fields fields used by the reductions- * @return a collection manager- */- protected ReductionCollectionManager createNewManager(- final ReductionDataCollector<?>[] reductionDataCollectors,- final Iterable<AnalyticsField> fields) {- return new ReductionCollectionManager(reductionDataCollectors, fields);- }-- /**- * Get the {@link AnalyticsField}s used in the managed expressions.- *- * @return the fields used- */- public Iterable<AnalyticsField> getUsedFields() {- return fields;- }-- /**- * Set the context of the readers of the used {@link AnalyticsField}s.- *- * @param context the reader context- * @throws IOException if an error occurs while setting the fields' context- */- public void doSetNextReader(LeafReaderContext context) throws IOException {- for (AnalyticsField field : fields) {- field.doSetNextReader(context);- }- }-- /**- * Collect the values from the used {@link AnalyticsField}s.- *- * @param doc the document to collect values for- * @throws IOException if an error occurs during field collection- */- public void collect(int doc) throws IOException {- for (AnalyticsField field : fields) {- field.collect(doc);- }- }-- /**- * Add a {@link ReductionDataCollection} to target while collecting documents. This target is- * valid until the lasting targets are cleared.- *- * @param target data collection to add document data too- */- public void addLastingCollectTarget(ReductionDataCollection target) {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].addLastingCollectTarget(target.dataArr[i]);- }- }- /** Clear lasting collection targets. */- public void clearLastingCollectTargets() {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].clearLastingCollectTargets();- }- }-- /**- * Add a new {@link ReductionDataCollection} to target while collecting the next document. This- * target is only valid for the next {@link #apply()} call.- *- * @return the new data collection being targeted- */- public ReductionDataCollection newDataCollectionTarget() {- ReductionDataCollection newCol = new ReductionDataCollection();- newCol.dataArr = new ReductionData[reductionDataCollectors.length];- for (int i = 0; i < reductionDataCollectors.length; i++) {- newCol.dataArr[i] = reductionDataCollectors[i].newDataTarget();- }- return newCol;- }- /**- * Add a {@link ReductionDataCollection} to target while collecting the next document. This target- * is only valid for the next {@link #apply()} call.- *- * @param target data collection to add document data too- */- public void addCollectTarget(ReductionDataCollection target) {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].addCollectTarget(target.dataArr[i]);- }- }-- /**- * Apply the values of the collected fields through the expressions' logic to the managed data- * collectors. This is called after {@link #collect(int)} has been called and the collection- * targets have been added.- */- public void apply() {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].collectAndApply();- ;- }- }-- /**- * Finalize the reductions with the collected data stored in the parameter. Once the data is- * finalized, the {@link ReductionFunction}s that use these {@link ReductionDataCollector}s act- * like regular {@link AnalyticsValue} classes that can be accessed through their {@code- * get<value-type>} methods.- *- * @param dataCollection the collection of reduction data to compute results for- */- public void setData(ReductionDataCollection dataCollection) {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].setData(dataCollection.dataArr[i]);- }- }-- /**- * Construct a new data collection holding data for all managed data collectors.- *- * @return a new data collection- */- public ReductionDataCollection newDataCollection() {- ReductionDataCollection newCol = new ReductionDataCollection();- newCol.dataArr = new ReductionData[reductionDataCollectors.length];- for (int i = 0; i < reductionDataCollectors.length; i++) {- newCol.dataArr[i] = reductionDataCollectors[i].newData();- }- return newCol;- }-- /**- * Sets the stream of shard data to merge with.- *- * @param input the stream of shard data- */- public void setShardInput(DataInput input) {- readers.clear();- reservations.forEach(resv -> readers.add(resv.createReadStream(input)));- }- /**- * Merge the data from the given shard input stream into the set IO data collectors. Should always- * be called after {@link #setShardInput(DataInput)} and either {@link- * #prepareReductionDataIO(ReductionDataCollection)} or {@link #newDataCollectionIO()} have been- * called.- *- * @throws IOException if an error occurs while reading the shard data- */- public void mergeData() throws IOException {- for (ReductionDataReader<?> reader : readers) {- reader.read();- }- }-- /**- * Sets the stream to export shard data to.- *- * @param output the stream of shard data- */- public void setShardOutput(DataOutput output) {- writers.clear();- reservations.forEach(resv -> writers.add(resv.createWriteStream(output)));- }- /**- * Export the data from the set IO data collectors to the given shard output stream. Should always- * be called after {@link #setShardOutput(DataOutput)} and {@link- * #prepareReductionDataIO(ReductionDataCollection)}.- *- * @throws IOException if an error occurs while writing the shard data- */- public void exportData() throws IOException {- for (ReductionDataWriter<?> writer : writers) {- writer.write();- }- }-- /**- * Set the given data collection to be used for either merging or exporting- *- * @param col collection to export from or merge to- */- public void prepareReductionDataIO(ReductionDataCollection col) {- for (int i = 0; i < reductionDataCollectors.length; i++) {- reductionDataCollectors[i].dataIO(col.dataArr[i]);- }- }-- /**- * Create a new {@link ReductionDataCollection} to merge to or export from. Mainly used for- * creating facet value collectors when merging shard data.- *- * @return the new data collection created- */- public ReductionDataCollection newDataCollectionIO() {- ReductionDataCollection newCol = new ReductionDataCollection();- newCol.dataArr = new ReductionData[reductionDataCollectors.length];- for (int i = 0; i < reductionDataCollectors.length; i++) {- newCol.dataArr[i] = reductionDataCollectors[i].newDataIO();- }- return newCol;- }-- /**- * Holds the collection of {@link ReductionData} that will be updated together.- *- * <p>For example each grouping will have a separate {@link ReductionDataCollection}, and- * ungrouped expressions will have their own as well.- */- public static class ReductionDataCollection {- public ReductionData[] dataArr;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionFunction.javadeleted file mode 100644index 2d50f2f1867..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/ReductionFunction.java+++ /dev/null@@ -1,34 +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.function;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValue;--/** A function that reduces the values of a mapping expression, field or constant. */-public interface ReductionFunction extends AnalyticsValue {-- /**- * Syncs the data collectors with shared versions across the entire Analytics Request so that as- * little data as possible is sent across shards.- *- * @param sync a function that takes in a {@link ReductionDataCollector} and returns a shared- * version- */- void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync);-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/AnalyticsField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/AnalyticsField.javadeleted file mode 100644index d101c302f5f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/AnalyticsField.java+++ /dev/null@@ -1,72 +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.function.field;--import java.io.IOException;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.solr.analytics.value.AnalyticsValueStream;--/**- * An analytics wrapper for Solr Fields.- *- * <p>Currently only fields with Doc Values enabled can be used in Analytics queries.- */-public abstract class AnalyticsField implements AnalyticsValueStream {- protected static final int initialArrayLength = 20;-- protected final String fieldName;-- protected AnalyticsField(String fieldName) {- this.fieldName = fieldName;- }-- @Override- public String getExpressionStr() {- return fieldName;- }-- @Override- public String getName() {- return fieldName;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.FIELD;- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }-- /**- * Set the segment reader context- *- * @param context segment context- * @throws IOException if an error occurs while loading the leaf reader- */- public abstract void doSetNextReader(LeafReaderContext context) throws IOException;-- /**- * Collect the value(s) of the wrapped field for the given document, and store the value.- *- * @param doc ID of the document to collect- * @throws IOException if an error occurs while reading the document.- */- public abstract void collect(int doc) throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanField.javadeleted file mode 100644index 9b343da5458..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanField.java+++ /dev/null@@ -1,113 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedDocValues;-import org.apache.lucene.util.BytesRef;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.BooleanValue.CastingBooleanValue;-import org.apache.solr.schema.BoolField;--/** An analytics wrapper for a single-valued {@link BoolField} with DocValues enabled. */-public class BooleanField extends AnalyticsField implements CastingBooleanValue {- private SortedDocValues docValues;- boolean value;- boolean exists;- int trueOrd;-- public BooleanField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSorted(context.reader(), fieldName);-- // figure out what ord maps to true- int numOrds = docValues.getValueCount();- // if no values in the segment, default trueOrd to something other then -1 (missing)- int trueOrd = -2;- for (int i = 0; i < numOrds; i++) {- final BytesRef br = docValues.lookupOrd(i);- if (br.length == 1 && br.bytes[br.offset] == 'T') {- trueOrd = i;- break;- }- }-- this.trueOrd = trueOrd;- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = trueOrd == docValues.ordValue();- }- }-- @Override- public boolean getBoolean() {- return value;- }-- @Override- public String getString() {- return exists ? Boolean.toString(value) : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Boolean.toString(value));- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<Boolean> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanMultiField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanMultiField.javadeleted file mode 100644index 81b260acb97..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/BooleanMultiField.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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.lucene.util.BytesRef;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.BooleanValueStream.CastingBooleanValueStream;-import org.apache.solr.schema.BoolField;--/** An analytics wrapper for a multi-valued {@link BoolField} with DocValues enabled. */-public class BooleanMultiField extends AnalyticsField implements CastingBooleanValueStream {- private SortedSetDocValues docValues;- private int count;- private boolean[] values;-- private int trueOrd;-- public BooleanMultiField(String fieldName) {- super(fieldName);- count = 0;- values = new boolean[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);-- // figure out what ord maps to true- long numOrds = docValues.getValueCount();- // if no values in the segment, default trueOrd to something other then -1 (missing)- int trueOrd = -2;- for (int i = 0; i < numOrds; i++) {- final BytesRef br = docValues.lookupOrd(i);- if (br.length == 1 && br.bytes[br.offset] == 'T') {- trueOrd = i;- break;- }- }-- this.trueOrd = trueOrd;- }-- @Override- public void collect(int doc) throws IOException {- count = 0;- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- if (count == values.length) {- resizeValues();- }- values[count++] = term == trueOrd;- }- }- }-- private void resizeValues() {- boolean[] newValues = new boolean[values.length * 2];- for (int i = 0; i < count; ++i) {- newValues[i] = values[i];- }- values = newValues;- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamBooleans(value -> cons.accept(Boolean.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamBooleans(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateField.javadeleted file mode 100644index da99807456f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateField.java+++ /dev/null@@ -1,115 +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.function.field;--import java.io.IOException;-import java.time.Instant;-import java.util.Date;-import java.util.function.Consumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.NumericDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.DateValue.CastingDateValue;-import org.apache.solr.schema.DatePointField;-import org.apache.solr.schema.TrieDateField;--/**- * An analytics wrapper for a single-valued {@link TrieDateField} or {@link DatePointField} with- * DocValues enabled.- */-public class DateField extends AnalyticsField implements CastingDateValue {- private NumericDocValues docValues;- private long value;- private boolean exists;-- public DateField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = docValues.longValue();- }- }-- @Override- public long getLong() {- return value;- }-- @Override- public Date getDate() {- return exists ? new Date(value) : null;- }-- @Override- public String getString() {- return exists ? Instant.ofEpochMilli(value).toString() : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamLongs(LongConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamDates(Consumer<Date> cons) {- if (exists) {- cons.accept(new Date(value));- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Instant.ofEpochMilli(value).toString());- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(new Date(value));- }- }-- @Override- public ExpressionComparator<Date> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiPointField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiPointField.javadeleted file mode 100644index 438bd259e07..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiPointField.java+++ /dev/null@@ -1,46 +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.function.field;--import java.time.Instant;-import java.util.Date;-import java.util.function.Consumer;-import org.apache.solr.analytics.value.DateValueStream.CastingDateValueStream;-import org.apache.solr.schema.DatePointField;--/** An analytics wrapper for a multi-valued {@link DatePointField} with DocValues enabled. */-public class DateMultiPointField extends LongMultiPointField implements CastingDateValueStream {-- public DateMultiPointField(String fieldName) {- super(fieldName);- }-- @Override- public void streamDates(Consumer<Date> cons) {- streamLongs(value -> cons.accept(new Date(value)));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs(value -> cons.accept(Instant.ofEpochMilli(value).toString()));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamLongs(value -> cons.accept(new Date(value)));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiTrieField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiTrieField.javadeleted file mode 100644index fb2d5f8819c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DateMultiTrieField.java+++ /dev/null@@ -1,51 +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.function.field;--import java.time.Instant;-import java.util.Date;-import java.util.function.Consumer;-import org.apache.solr.analytics.value.DateValueStream.CastingDateValueStream;-import org.apache.solr.schema.TrieDateField;--/**- * An analytics wrapper for a multi-valued {@link TrieDateField} with DocValues enabled.- *- * @deprecated Trie fields are deprecated as of Solr 7.0- */-@Deprecated-public class DateMultiTrieField extends LongMultiTrieField implements CastingDateValueStream {-- public DateMultiTrieField(String fieldName) {- super(fieldName);- }-- @Override- public void streamDates(Consumer<Date> cons) {- streamLongs(value -> cons.accept(new Date(value)));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs(value -> cons.accept(Instant.ofEpochMilli(value).toString()));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamLongs(value -> cons.accept(new Date(value)));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleField.javadeleted file mode 100644index 43e6d8fe83f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleField.java+++ /dev/null@@ -1,101 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.NumericDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.DoubleValue.CastingDoubleValue;-import org.apache.solr.schema.DoublePointField;-import org.apache.solr.schema.TrieDoubleField;--/**- * An analytics wrapper for a single-valued {@link TrieDoubleField} or {@link DoublePointField} with- * DocValues enabled.- */-public class DoubleField extends AnalyticsField implements CastingDoubleValue {- private NumericDocValues docValues;- private double value;- private boolean exists;-- public DoubleField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = Double.longBitsToDouble(docValues.longValue());- }- }-- @Override- public double getDouble() {- return value;- }-- @Override- public String getString() {- return exists ? Double.toString(value) : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Double.toString(value));- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<Double> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiPointField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiPointField.javadeleted file mode 100644index 76af41e501d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiPointField.java+++ /dev/null@@ -1,81 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedNumericDocValues;-import org.apache.lucene.util.NumericUtils;-import org.apache.solr.analytics.value.DoubleValueStream.CastingDoubleValueStream;-import org.apache.solr.schema.DoublePointField;--/** An analytics wrapper for a multi-valued {@link DoublePointField} with DocValues enabled. */-public class DoubleMultiPointField extends AnalyticsField implements CastingDoubleValueStream {- private SortedNumericDocValues docValues;- private int count;- private double[] values;-- public DoubleMultiPointField(String fieldName) {- super(fieldName);- count = 0;- values = new double[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- if (docValues.advanceExact(doc)) {- count = docValues.docValueCount();- resizeEmptyValues(count);- for (int i = 0; i < count; ++i) {- values[i] = NumericUtils.sortableLongToDouble(docValues.nextValue());- }- } else {- count = 0;- }- }-- private void resizeEmptyValues(int count) {- if (count > values.length) {- values = new double[count];- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamDoubles(value -> cons.accept(Double.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamDoubles(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiTrieField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiTrieField.javadeleted file mode 100644index cecde00d0a1..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/DoubleMultiTrieField.java+++ /dev/null@@ -1,92 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.lucene.util.NumericUtils;-import org.apache.solr.analytics.value.DoubleValueStream.CastingDoubleValueStream;-import org.apache.solr.legacy.LegacyNumericUtils;-import org.apache.solr.schema.TrieDoubleField;--/**- * An analytics wrapper for a multi-valued {@link TrieDoubleField} with DocValues enabled.- *- * @deprecated Trie fields are deprecated as of Solr 7.0- */-@Deprecated-public class DoubleMultiTrieField extends AnalyticsField implements CastingDoubleValueStream {- private SortedSetDocValues docValues;- private int count;- private double[] values;-- public DoubleMultiTrieField(String fieldName) {- super(fieldName);- count = 0;- values = new double[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- count = 0;- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- if (count == values.length) {- resizeValues();- }- values[count++] =- NumericUtils.sortableLongToDouble(- LegacyNumericUtils.prefixCodedToLong(docValues.lookupOrd(term)));- }- }- }-- private void resizeValues() {- double[] newValues = new double[values.length * 2];- for (int i = 0; i < count; ++i) {- newValues[i] = values[i];- }- values = newValues;- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamDoubles(value -> cons.accept(Double.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamDoubles(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatField.javadeleted file mode 100644index fe506f6431f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatField.java+++ /dev/null@@ -1,114 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.NumericDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.FloatValue.CastingFloatValue;-import org.apache.solr.schema.FloatPointField;-import org.apache.solr.schema.TrieFloatField;--/**- * An analytics wrapper for a single-valued {@link TrieFloatField} or {@link FloatPointField} with- * DocValues enabled.- */-public class FloatField extends AnalyticsField implements CastingFloatValue {- private NumericDocValues docValues;- private float value;- private boolean exists;-- public FloatField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = Float.intBitsToFloat((int) docValues.longValue());- }- }-- @Override- public float getFloat() {- return value;- }-- @Override- public double getDouble() {- return (double) value;- }-- @Override- public String getString() {- return exists ? Float.toString(value) : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamFloats(FloatConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- if (exists) {- cons.accept((double) value);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Float.toString(value));- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<Float> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiPointField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiPointField.javadeleted file mode 100644index d1f9417a37d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiPointField.java+++ /dev/null@@ -1,87 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedNumericDocValues;-import org.apache.lucene.util.NumericUtils;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.FloatValueStream.CastingFloatValueStream;-import org.apache.solr.schema.FloatPointField;--/** An analytics wrapper for a multi-valued {@link FloatPointField} with DocValues enabled. */-public class FloatMultiPointField extends AnalyticsField implements CastingFloatValueStream {- private SortedNumericDocValues docValues;- private int count;- private float[] values;-- public FloatMultiPointField(String fieldName) {- super(fieldName);- count = 0;- values = new float[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- if (docValues.advanceExact(doc)) {- count = docValues.docValueCount();- resizeEmptyValues(count);- for (int i = 0; i < count; ++i) {- values[i] = NumericUtils.sortableIntToFloat((int) docValues.nextValue());- }- } else {- count = 0;- }- }-- private void resizeEmptyValues(int count) {- if (count > values.length) {- values = new float[count];- }- }-- @Override- public void streamFloats(FloatConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamFloats(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamFloats(value -> cons.accept(Float.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamFloats(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiTrieField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiTrieField.javadeleted file mode 100644index 1fa9e0fb38a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/FloatMultiTrieField.java+++ /dev/null@@ -1,98 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.lucene.util.NumericUtils;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.FloatValueStream.CastingFloatValueStream;-import org.apache.solr.legacy.LegacyNumericUtils;-import org.apache.solr.schema.TrieFloatField;--/**- * An analytics wrapper for a multi-valued {@link TrieFloatField} with DocValues enabled.- *- * @deprecated Trie fields are deprecated as of Solr 7.0- */-@Deprecated-public class FloatMultiTrieField extends AnalyticsField implements CastingFloatValueStream {- private SortedSetDocValues docValues;- private int count;- private float[] values;-- public FloatMultiTrieField(String fieldName) {- super(fieldName);- count = 0;- values = new float[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- count = 0;- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- if (count == values.length) {- resizeValues();- }- values[count++] =- NumericUtils.sortableIntToFloat(- LegacyNumericUtils.prefixCodedToInt(docValues.lookupOrd(term)));- }- }- }-- private void resizeValues() {- float[] newValues = new float[values.length * 2];- for (int i = 0; i < count; ++i) {- newValues[i] = values[i];- }- values = newValues;- }-- @Override- public void streamFloats(FloatConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamFloats(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamFloats(value -> cons.accept(Float.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamFloats(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntField.javadeleted file mode 100644index b13356f2b18..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntField.java+++ /dev/null@@ -1,140 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.IntConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.NumericDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.IntValue.CastingIntValue;-import org.apache.solr.schema.IntPointField;-import org.apache.solr.schema.TrieIntField;--/**- * An analytics wrapper for a single-valued {@link TrieIntField} or {@link IntPointField} with- * DocValues enabled.- */-public class IntField extends AnalyticsField implements CastingIntValue {- private NumericDocValues docValues;- private int value;- private boolean exists;-- public IntField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = (int) docValues.longValue();- }- }-- @Override- public int getInt() {- return value;- }-- @Override- public long getLong() {- return (long) value;- }-- @Override- public float getFloat() {- return (float) value;- }-- @Override- public double getDouble() {- return (double) value;- }-- @Override- public String getString() {- return exists ? Integer.toString(value) : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamInts(IntConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamLongs(LongConsumer cons) {- if (exists) {- cons.accept((long) value);- }- }-- @Override- public void streamFloats(FloatConsumer cons) {- if (exists) {- cons.accept((float) value);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- if (exists) {- cons.accept((double) value);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Integer.toString(value));- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<Integer> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiPointField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiPointField.javadeleted file mode 100644index 8a401c8bd14..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiPointField.java+++ /dev/null@@ -1,98 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.IntConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedNumericDocValues;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.IntValueStream.CastingIntValueStream;-import org.apache.solr.schema.IntPointField;--/** An analytics wrapper for a multi-valued {@link IntPointField} with DocValues enabled. */-public class IntMultiPointField extends AnalyticsField implements CastingIntValueStream {- private SortedNumericDocValues docValues;- private int count;- private int[] values;-- public IntMultiPointField(String fieldName) {- super(fieldName);- count = 0;- values = new int[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- if (docValues.advanceExact(doc)) {- count = docValues.docValueCount();- resizeEmptyValues(count);- for (int i = 0; i < count; ++i) {- values[i] = (int) docValues.nextValue();- }- } else {- count = 0;- }- }-- private void resizeEmptyValues(int count) {- if (count > values.length) {- values = new int[count];- }- }-- @Override- public void streamInts(IntConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamLongs(LongConsumer cons) {- streamInts(value -> cons.accept((long) value));- }-- @Override- public void streamFloats(FloatConsumer cons) {- streamInts(value -> cons.accept((float) value));- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamInts(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamInts(value -> cons.accept(Integer.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamInts(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiTrieField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiTrieField.javadeleted file mode 100644index f8b44e97892..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/IntMultiTrieField.java+++ /dev/null@@ -1,107 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.IntConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.IntValueStream.CastingIntValueStream;-import org.apache.solr.legacy.LegacyNumericUtils;-import org.apache.solr.schema.TrieIntField;--/**- * An analytics wrapper for a multi-valued {@link TrieIntField} with DocValues enabled.- *- * @deprecated Trie fields are deprecated as of Solr 7.0- */-@Deprecated-public class IntMultiTrieField extends AnalyticsField implements CastingIntValueStream {- private SortedSetDocValues docValues;- private int count;- private int[] values;-- public IntMultiTrieField(String fieldName) {- super(fieldName);- count = 0;- values = new int[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- count = 0;- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- if (count == values.length) {- resizeValues();- }- values[count++] = LegacyNumericUtils.prefixCodedToInt(docValues.lookupOrd(term));- }- }- }-- private void resizeValues() {- int[] newValues = new int[values.length * 2];- for (int i = 0; i < count; ++i) {- newValues[i] = values[i];- }- values = newValues;- }-- @Override- public void streamInts(IntConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamLongs(LongConsumer cons) {- streamInts(value -> cons.accept((long) value));- }-- @Override- public void streamFloats(FloatConsumer cons) {- streamInts(value -> cons.accept((float) value));- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamInts(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamInts(value -> cons.accept(Integer.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamInts(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongField.javadeleted file mode 100644index 4feadd62ba5..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongField.java+++ /dev/null@@ -1,114 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.NumericDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.LongValue.CastingLongValue;-import org.apache.solr.schema.LongPointField;-import org.apache.solr.schema.TrieLongField;--/**- * An analytics wrapper for a single-valued {@link TrieLongField} or {@link LongPointField} with- * DocValues enabled.- */-public class LongField extends AnalyticsField implements CastingLongValue {- private NumericDocValues docValues;- private long value;- private boolean exists;-- public LongField(String fieldName) {- super(fieldName);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- exists = docValues.advanceExact(doc);- if (exists) {- value = docValues.longValue();- }- }-- @Override- public long getLong() {- return value;- }-- @Override- public double getDouble() {- return (double) value;- }-- @Override- public String getString() {- return exists ? Long.toString(value) : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamLongs(LongConsumer cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- if (exists) {- cons.accept((double) value);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(Long.toString(value));- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<Long> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiPointField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiPointField.javadeleted file mode 100644index ddba2d85f06..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiPointField.java+++ /dev/null@@ -1,86 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedNumericDocValues;-import org.apache.solr.analytics.value.LongValueStream.CastingLongValueStream;-import org.apache.solr.schema.LongPointField;--/** An analytics wrapper for a multi-valued {@link LongPointField} with DocValues enabled. */-public class LongMultiPointField extends AnalyticsField implements CastingLongValueStream {- private SortedNumericDocValues docValues;- private int count;- private long[] values;-- public LongMultiPointField(String fieldName) {- super(fieldName);- count = 0;- values = new long[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedNumeric(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- if (docValues.advanceExact(doc)) {- count = docValues.docValueCount();- resizeEmptyValues(count);- for (int i = 0; i < count; ++i) {- values[i] = docValues.nextValue();- }- } else {- count = 0;- }- }-- private void resizeEmptyValues(int count) {- if (count > values.length) {- values = new long[count];- }- }-- @Override- public void streamLongs(LongConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamLongs(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs(value -> cons.accept(Long.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamLongs(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiTrieField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiTrieField.javadeleted file mode 100644index 1402e11f3af..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/LongMultiTrieField.java+++ /dev/null@@ -1,95 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.LongConsumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.solr.analytics.value.LongValueStream.CastingLongValueStream;-import org.apache.solr.legacy.LegacyNumericUtils;-import org.apache.solr.schema.TrieLongField;--/**- * An analytics wrapper for a multi-valued {@link TrieLongField} with DocValues enabled.- *- * @deprecated Trie fields are deprecated as of Solr 7.0- */-@Deprecated-public class LongMultiTrieField extends AnalyticsField implements CastingLongValueStream {- private SortedSetDocValues docValues;- private int count;- private long[] values;-- public LongMultiTrieField(String fieldName) {- super(fieldName);- count = 0;- values = new long[initialArrayLength];- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- count = 0;- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- if (count == values.length) {- resizeValues();- }- values[count++] = LegacyNumericUtils.prefixCodedToLong(docValues.lookupOrd(term));- }- }- }-- private void resizeValues() {- long[] newValues = new long[values.length * 2];- for (int i = 0; i < count; ++i) {- newValues[i] = values[i];- }- values = newValues;- }-- @Override- public void streamLongs(LongConsumer cons) {- for (int i = 0; i < count; ++i) {- cons.accept(values[i]);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamLongs(value -> cons.accept((double) value));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs(value -> cons.accept(Long.toString(value)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamLongs(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringField.javadeleted file mode 100644index 71fc7020a4b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringField.java+++ /dev/null@@ -1,115 +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.function.field;--import java.io.IOException;-import java.util.function.Consumer;-import org.apache.lucene.index.BinaryDocValues;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.FieldInfo;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedDocValues;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.StringValue.CastingStringValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.schema.StrField;--/** An analytics wrapper for a single-valued {@link StrField} with DocValues enabled. */-public class StringField extends AnalyticsField implements CastingStringValue {- private BinaryDocValues binaryDocValues;- private SortedDocValues sortedDocValues;- String value;- boolean exists;-- public StringField(String fieldName) {- super(fieldName);- exists = false;- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- FieldInfo fieldInfo = context.reader().getFieldInfos().fieldInfo(fieldName);- if (fieldInfo == null) {- binaryDocValues = DocValues.emptyBinary();- sortedDocValues = null;- } else {- switch (fieldInfo.getDocValuesType()) {- case BINARY:- binaryDocValues = DocValues.getBinary(context.reader(), fieldName);- sortedDocValues = null;- break;- case SORTED:- binaryDocValues = null;- sortedDocValues = DocValues.getSorted(context.reader(), fieldName);- break;- default:- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "Invalid doc values type " + fieldInfo.getDocValuesType());- }- }- }-- @Override- public void collect(int doc) throws IOException {- if (binaryDocValues == null) {- exists = sortedDocValues.advanceExact(doc);- if (exists) {- value = sortedDocValues.lookupOrd(sortedDocValues.ordValue()).utf8ToString();- }- } else {- exists = binaryDocValues.advanceExact(doc);- if (exists) {- value = binaryDocValues.binaryValue().utf8ToString();- }- }- }-- @Override- public String getString() {- return exists ? value : null;- }-- @Override- public Object getObject() {- return exists ? value : null;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (exists) {- cons.accept(value);- }- }-- @Override- public ExpressionComparator<String> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringMultiField.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringMultiField.javadeleted file mode 100644index 8d609340b2c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/StringMultiField.java+++ /dev/null@@ -1,63 +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.function.field;--import java.io.IOException;-import java.util.ArrayList;-import java.util.function.Consumer;-import org.apache.lucene.index.DocValues;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.index.SortedSetDocValues;-import org.apache.solr.analytics.value.StringValueStream.CastingStringValueStream;-import org.apache.solr.schema.StrField;--/** An analytics wrapper for a multi-valued {@link StrField} with DocValues enabled. */-public class StringMultiField extends AnalyticsField implements CastingStringValueStream {- private SortedSetDocValues docValues;- private ArrayList<String> values;-- public StringMultiField(String fieldName) {- super(fieldName);- values = new ArrayList<>(initialArrayLength);- }-- @Override- public void doSetNextReader(LeafReaderContext context) throws IOException {- docValues = DocValues.getSortedSet(context.reader(), fieldName);- }-- @Override- public void collect(int doc) throws IOException {- values.clear();- if (docValues.advanceExact(doc)) {- int term;- while ((term = (int) docValues.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {- values.add(docValues.lookupOrd(term).utf8ToString());- }- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- values.forEach(value -> cons.accept(value));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- values.forEach(value -> cons.accept(value));- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/package-info.javadeleted file mode 100644index 9a80bafa33d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/field/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Fields to use for analytics expressions. */-package org.apache.solr.analytics.function.field;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AbsoluteValueFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AbsoluteValueFunction.javadeleted file mode 100644index bbeb3bf4603..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AbsoluteValueFunction.java+++ /dev/null@@ -1,68 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An absolute value mapping function.- *- * <p>Takes a numeric ValueStream or Value and returns a ValueStream or Value of the same numeric- * type.- */-public class AbsoluteValueFunction {- public static final String name = "abs";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof IntValueStream) {- return LambdaFunction.createIntLambdaFunction(- name, x -> (x < 0) ? x * -1 : x, (IntValueStream) param);- }- if (param instanceof LongValueStream) {- return LambdaFunction.createLongLambdaFunction(- name, x -> (x < 0) ? x * -1 : x, (LongValueStream) param);- }- if (param instanceof FloatValueStream) {- return LambdaFunction.createFloatLambdaFunction(- name, x -> (x < 0) ? x * -1 : x, (FloatValueStream) param);- }- if (param instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, x -> (x < 0) ? x * -1 : x, (DoubleValueStream) param);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a numeric parameter, "- + param.getExpressionStr()- + " found.");- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AddFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AddFunction.javadeleted file mode 100644index 70802ca62a8..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/AddFunction.java+++ /dev/null@@ -1,84 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An addition mapping function.- *- * <p>Uses:- *- * <ul>- * <li>If a single numeric ValueStream is passed in, a {@link DoubleValue} representing the sum of- * the values for each document is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the sum of the Value and each of the values of the ValueStream for a document- * is returned. (Or the other way, since the Value and ValueStream can be used in either- * order)- * <li>If multiple numeric Values are passed in, a {@link DoubleValue} representing the sum of all- * values is returned.- * </ul>- */-public class AddFunction {- public static final String name = "add";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires parameters.");- } else if (params.length == 1) {- if (params[0] instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a + b, (DoubleValueStream) params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires numeric parameters. Incorrect param: "- + params[0].getExpressionStr());- } else if (params.length == 2) {- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof DoubleValueStream && param2 instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a + b, (DoubleValueStream) param1, (DoubleValueStream) param2);- }- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires numeric parameters.");- }- DoubleValue[] castedParams = new DoubleValue[params.length];- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DoubleValue) {- castedParams[i] = (DoubleValue) params[i];- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires that all parameters be single-valued if more than 2 are given.");- }- }- return LambdaFunction.createDoubleLambdaFunction(name, (a, b) -> a + b, castedParams);- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/BottomFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/BottomFunction.javadeleted file mode 100644index 6a38a0e8098..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/BottomFunction.java+++ /dev/null@@ -1,185 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A bottom mapping function, returning the lowest value found.- *- * <p>Uses:- *- * <ul>- * <li>If a single comparable ValueStream is passed in, a Value (of the same type) representing- * the minimum of the values for each document is returned.- * <li>If multiple comparable Values are passed in, a Value (of the same type) representing the- * minimum of all values is returned.- * </ul>- */-public class BottomFunction {- public static final String name = "bottom";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires paramaters.");- }- AnalyticsValueStream param = params[0];- if (param instanceof DateValueStream) {- if (params.length == 1) {- return LambdaFunction.createDateLambdaFunction(- name, (a, b) -> (a < b) ? a : b, (DateValueStream) param);- }- DateValue[] castedParams = new DateValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DateValue) {- castedParams[i] = (DateValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createDateLambdaFunction(- name, (a, b) -> (a < b) ? a : b, castedParams, false);- }- }- if (param instanceof IntValueStream) {- if (params.length == 1) {- return LambdaFunction.createIntLambdaFunction(- name, (a, b) -> (a < b) ? a : b, (IntValueStream) param);- }- IntValue[] castedParams = new IntValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof IntValue) {- castedParams[i] = (IntValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createIntLambdaFunction(- name, (a, b) -> (a < b) ? a : b, castedParams, false);- }- }- if (param instanceof LongValueStream) {- if (params.length == 1) {- return LambdaFunction.createLongLambdaFunction(- name, (a, b) -> (a < b) ? a : b, (LongValueStream) param);- }- LongValue[] castedParams = new LongValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof LongValue) {- castedParams[i] = (LongValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createLongLambdaFunction(- name, (a, b) -> (a < b) ? a : b, castedParams, false);- }- }- if (param instanceof FloatValueStream) {- if (params.length == 1) {- return LambdaFunction.createFloatLambdaFunction(- name, (a, b) -> (a < b) ? a : b, (FloatValueStream) param);- }- FloatValue[] castedParams = new FloatValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof FloatValue) {- castedParams[i] = (FloatValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createFloatLambdaFunction(- name, (a, b) -> (a < b) ? a : b, castedParams, false);- }- }- if (param instanceof DoubleValueStream) {- if (params.length == 1) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> (a < b) ? a : b, (DoubleValueStream) param);- }- DoubleValue[] castedParams = new DoubleValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DoubleValue) {- castedParams[i] = (DoubleValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> (a < b) ? a : b, castedParams, false);- }- }- if (param instanceof StringValueStream) {- if (params.length == 1) {- return LambdaFunction.createStringLambdaFunction(- name, (a, b) -> (a.compareTo(b) < 0) ? a : b, (StringValueStream) param);- }- StringValue[] castedParams = new StringValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof StringValue) {- castedParams[i] = (StringValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createStringLambdaFunction(- name, (a, b) -> (a.compareTo(b) < 0) ? a : b, castedParams, false);- }- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a comparable parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ComparisonFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ComparisonFunction.javadeleted file mode 100644index 4f445f7db42..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ComparisonFunction.java+++ /dev/null@@ -1,368 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * Contains all comparable functions. Comparable functions accept two comparable (numeric and date)- * parameters and return a BooleanValueStream. The two parameters must be able to be cast to the- * same type.- *- * <p>Uses:- *- * <ul>- * <li>If a two comparable {@link AnalyticsValue}s are passed in, a {@link BooleanValue}- * representing the comparison of the two values for each document is returned.- * <li>If a comparable {@link AnalyticsValue} and a comparable {@link AnalyticsValueStream} are- * passed in, a {@link BooleanValueStream} representing the comparison of the Value and each- * of the values of the ValueStream for the document is returned.- * </ul>- */-public class ComparisonFunction {-- /**- * Create a comparison mapping function, comparing two analytics value (streams) of the same type.- *- * @param name name of the function- * @param comp function to find the result of a comparison- * @param params the parameters to compare- * @return an instance of the requested comparison function using the given parameters- */- public static BooleanValueStream createComparisonFunction(- String name, CompResultFunction comp, AnalyticsValueStream... params) {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- AnalyticsValueStream paramA = params[0];- AnalyticsValueStream paramB = params[1];- if (paramA instanceof DoubleValueStream && paramB instanceof DoubleValueStream) {- if (paramA instanceof DoubleValue) {- if (paramB instanceof DoubleValue) {- return new CompareDoubleValueFunction(- name, (DoubleValue) paramA, (DoubleValue) paramB, comp);- }- return new CompareDoubleStreamFunction(- name, (DoubleValue) paramA, (DoubleValueStream) paramB, comp);- }- if (paramB instanceof DoubleValue) {- return new CompareDoubleStreamFunction(- name, (DoubleValue) paramB, (DoubleValueStream) paramA, reverse(comp));- }- } else if (paramA instanceof DateValueStream && paramB instanceof DateValueStream) {- if (paramA instanceof DateValue) {- if (paramB instanceof DateValue) {- return new CompareDateValueFunction(name, (DateValue) paramA, (DateValue) paramB, comp);- }- return new CompareDateStreamFunction(- name, (DateValue) paramA, (DateValueStream) paramB, comp);- }- if (paramB instanceof DateValue) {- return new CompareDateStreamFunction(- name, (DateValue) paramB, (DateValueStream) paramA, reverse(comp));- }- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires comparable (numeric or date) parameters.");- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires that at least 1 parameter be single-valued.");- }-- /**- * A comparison function that tests whether the first parameter is greater than the second- * parameter- */- public static class GTFunction {- public static final String name = "gt";- public static final CreatorFunction creatorFunction =- (params -> {- return ComparisonFunction.createComparisonFunction(- name,- val -> {- return val > 0;- },- params);- });- }-- /**- * A comparison function that tests whether the first parameter is greater than or equal to the- * second parameter- */- public static class GTEFunction {- public static final String name = "gte";- public static final CreatorFunction creatorFunction =- (params -> {- return ComparisonFunction.createComparisonFunction(- name,- val -> {- return val >= 0;- },- params);- });- }-- /**- * A comparison function that tests whether the first parameter is less than the second parameter- */- public static class LTFunction {- public static final String name = "lt";- public static final CreatorFunction creatorFunction =- (params -> {- return ComparisonFunction.createComparisonFunction(- name,- val -> {- return val < 0;- },- params);- });- }-- /**- * A comparison function that tests whether the first parameter is less than or equal to the- * second parameter- */- public static class LTEFunction {- public static final String name = "lte";- public static final CreatorFunction creatorFunction =- (params -> {- return ComparisonFunction.createComparisonFunction(- name,- val -> {- return val <= 0;- },- params);- });- }-- @FunctionalInterface- public static interface CompResultFunction {- public boolean apply(int compResult);- }-- private static CompResultFunction reverse(CompResultFunction original) {- return val -> original.apply(val * -1);- }-- /** A comparison function for two {@link DoubleValue}s. */- static class CompareDoubleValueFunction extends AbstractBooleanValue {- private final DoubleValue exprA;- private final DoubleValue exprB;- private final CompResultFunction comp;- private final String name;- private final String funcStr;- private final ExpressionType funcType;-- public CompareDoubleValueFunction(- String name, DoubleValue exprA, DoubleValue exprB, CompResultFunction comp) {- this.name = name;- this.exprA = exprA;- this.exprB = exprB;- this.comp = comp;- this.funcStr = AnalyticsValueStream.createExpressionString(name, exprA, exprB);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, exprA, exprB);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- double valueA = exprA.getDouble();- double valueB = exprB.getDouble();- exists = exprA.exists() && exprB.exists();- return exists ? comp.apply(Double.compare(valueA, valueB)) : false;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A comparison function for a {@link DoubleValue} and a {@link DoubleValueStream}. */- static class CompareDoubleStreamFunction extends AbstractBooleanValueStream {- private final DoubleValue baseExpr;- private final DoubleValueStream compExpr;- private final CompResultFunction comp;- private final String name;- private final String funcStr;- private final ExpressionType funcType;-- public CompareDoubleStreamFunction(- String name, DoubleValue baseExpr, DoubleValueStream compExpr, CompResultFunction comp)- throws SolrException {- this.name = name;- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.comp = comp;- this.funcStr = AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, baseExpr, compExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- double baseValue = baseExpr.getDouble();- if (baseExpr.exists()) {- compExpr.streamDoubles(- compValue -> cons.accept(comp.apply(Double.compare(baseValue, compValue))));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A comparison function for two {@link DateValue}s. */- static class CompareDateValueFunction extends AbstractBooleanValue {- private final DateValue exprA;- private final DateValue exprB;- private final CompResultFunction comp;- private final String name;- private final String funcStr;- private final ExpressionType funcType;-- public CompareDateValueFunction(- String name, DateValue exprA, DateValue exprB, CompResultFunction comp) {- this.name = name;- this.exprA = exprA;- this.exprB = exprB;- this.comp = comp;- this.funcStr = AnalyticsValueStream.createExpressionString(name, exprA, exprB);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, exprA, exprB);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- long valueA = exprA.getLong();- long valueB = exprB.getLong();- exists = exprA.exists() && exprB.exists();- return exists ? comp.apply(Long.compare(valueA, valueB)) : false;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A comparison function for a {@link DateValue} and a {@link DateValueStream}. */- static class CompareDateStreamFunction extends AbstractBooleanValueStream {- private final DateValue baseExpr;- private final DateValueStream compExpr;- private final CompResultFunction comp;- private final String name;- private final String funcStr;- private final ExpressionType funcType;-- public CompareDateStreamFunction(- String name, DateValue baseExpr, DateValueStream compExpr, CompResultFunction comp)- throws SolrException {- this.name = name;- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.comp = comp;- this.funcStr = AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, baseExpr, compExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- long baseValue = baseExpr.getLong();- if (baseExpr.exists()) {- compExpr.streamLongs(- compValue -> cons.accept(comp.apply(Long.compare(baseValue, compValue))));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ConcatFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ConcatFunction.javadeleted file mode 100644index a2f396a3e28..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ConcatFunction.java+++ /dev/null@@ -1,142 +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.function.mapping;--import java.util.Arrays;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.mapping.LambdaFunction.TwoStringInStringOutLambda;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A concatenation mapping function, combining the string values of the given parameters. (At least- * 1 parameter is required)- *- * <p>Uses:- *- * <ul>- * <li>If a single {@link StringValueStream} is passed in, a {@link StringValue} representing the- * concatenation of the values for each document is returned. No ordering is guaranteed while- * concatenating.- * <li>If a {@link StringValue} and a {@link StringValueStream} are passed in, a {@link- * StringValueStream} representing the concatenation of the Value and each of the values of- * the ValueStream for a document is returned. (Or the other way, since the Value and- * ValueStream can be used in either order)- * <li>If any number (more than 0) of {@link StringValue}s are passed in, a {@link StringValue}- * representing the concatenation of all values is returned. If any values don't exist, the- * overall concatenation value will still exist with an empty string used for any missing- * values. If none of the parameter values exist, then the overall concatenation value will- * not exist.- * </ul>- */-public class ConcatFunction {- public static final String name = "concat";- public static final CreatorFunction creatorFunction =- (params -> {- return createConcatFunction(name, name, (a, b) -> a + b, params);- });-- /**- * A concatenation mapping function, combining the string values of the given parameters with a- * given separating string. <br>- * The usage is exactly the same as the {@link ConcatFunction}, however a {@link- * ConstantStringValue} separator is added as the first argument of every usage. So the acceptable- * inputs are as follows:- *- * <ul>- * <li>{@value #name} ( {@link ConstantStringValue} , {@link StringValueStream} )- * <li>{@value #name} ( {@link ConstantStringValue} , {@link StringValueStream} , {@link- * StringValue} )- * <li>{@value #name} ( {@link ConstantStringValue} , {@link StringValue} , {@link- * StringValueStream} )- * <li>{@value #name} ( {@link ConstantStringValue} , {@link StringValue} ... )- * </ul>- *- * The {@link ConstantStringValue} separator is used to separate every two (or more) string during- * concatenation. If only one string value exists, then the separator will not be used.- */- public static class SeparatedConcatFunction {- public static final String name = "concat_sep";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length < 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires at least 2 parameters.");- } else if (!(params[0] instanceof StringValue && params[0] instanceof ConstantValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires that the first parameter to be a constant string.");- }- final String sep = ((StringValue) params[0]).getString();- String uniqueName = name + "(" + sep + ")";- return createConcatFunction(- name,- uniqueName,- (a, b) -> a + sep + b,- Arrays.copyOfRange(params, 1, params.length));- });- }-- private static StringValueStream createConcatFunction(- String functionName,- String uniqueName,- TwoStringInStringOutLambda lambda,- AnalyticsValueStream[] params) {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + functionName + " function requires parameters.");- } else if (params.length == 1) {- if (params[0] instanceof StringValueStream) {- return LambdaFunction.createStringLambdaFunction(- uniqueName, lambda, (StringValueStream) params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + functionName + " function requires that all parameters be string-castable.");- } else if (params.length == 2) {- // If it is not a pair of a single valued and multi valued string, then it will be taken care- // of below- if (params[0] instanceof StringValueStream- && params[1] instanceof StringValueStream- && !(params[0] instanceof StringValue && params[1] instanceof StringValue)) {- return LambdaFunction.createStringLambdaFunction(- uniqueName, lambda, (StringValueStream) params[0], (StringValueStream) params[1]);- }- }- StringValue[] castedParams = new StringValue[params.length];- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof StringValue) {- castedParams[i] = (StringValue) params[i];- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + functionName- + " function requires that all parameters be string-castable, and if more than 2 parameters"- + " are provided then all must be single-valued.");- }- }- return LambdaFunction.createStringLambdaFunction(uniqueName, lambda, castedParams, false);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateMathFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateMathFunction.javadeleted file mode 100644index 867d6df4872..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateMathFunction.java+++ /dev/null@@ -1,177 +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.function.mapping;--import java.util.Date;-import java.util.function.Consumer;-import java.util.function.LongConsumer;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;-import org.apache.solr.util.DateMathParser;--/**- * A mapping function that computes date math.- *- * <p>The first parameter is the {@link DateValue} or {@link DateValueStream} to compute date math- * on. (Required) <br>- * The trailing parameters must be constant date math strings (e.g. "+1DAY"). (At least 1 required)- */-public class DateMathFunction {- public static final String name = "date_math";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length < 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires at least 2 paramaters, "- + params.length- + " found.");- }- StringBuilder mathParam = new StringBuilder();- for (int i = 1; i < params.length; ++i) {- if (params[i] instanceof StringValue && params[i] instanceof ConstantValue) {- mathParam.append(((StringValue) params[i]).getString());- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires all math parameters to be a constant strings.");- }- }- if (params[0] instanceof DateValue) {- return new DateMathValueFunction(- (DateValue) params[0], new ConstantStringValue(mathParam.toString()));- } else if (params[0] instanceof DateValueStream) {- return new DateMathStreamFunction(- (DateValueStream) params[0], new ConstantStringValue(mathParam.toString()));- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires a date as the first parameter.");- }- });-- /** DateMath function that supports {@link DateValue}s. */- static class DateMathValueFunction extends AbstractDateValue {- private final DateValue dateParam;- private final String mathParam;- DateMathParser parser = new DateMathParser();- public static final String name = DateMathFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateMathValueFunction(DateValue dateParam, ConstantStringValue mathParam)- throws SolrException {- this.dateParam = dateParam;- this.mathParam = "NOW" + mathParam.getString();- this.exprStr = AnalyticsValueStream.createExpressionString(name, dateParam, mathParam);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, dateParam);- }-- private boolean exists = false;-- @Override- public long getLong() {- Date date = getDate();- return (exists) ? date.getTime() : 0;- }-- @Override- public Date getDate() {- Date date = dateParam.getDate();- if (dateParam.exists()) {- exists = true;- return DateMathParser.parseMath(date, mathParam);- } else {- exists = false;- return null;- }- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** DateMath function that supports {@link DateValueStream}s. */- static class DateMathStreamFunction extends AbstractDateValueStream {- private final DateValueStream dateParam;- private final String mathParam;- public static final String name = DateMathFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateMathStreamFunction(DateValueStream dateParam, ConstantStringValue mathParam)- throws SolrException {- this.dateParam = dateParam;- this.mathParam = "NOW" + mathParam.getString();- this.exprStr = AnalyticsValueStream.createExpressionString(name, dateParam, mathParam);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, dateParam);- }-- @Override- public void streamLongs(LongConsumer cons) {- streamDates(value -> cons.accept(value.getTime()));- }-- @Override- public void streamDates(Consumer<Date> cons) {- dateParam.streamDates(value -> cons.accept(DateMathParser.parseMath(value, mathParam)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateParseFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateParseFunction.javadeleted file mode 100644index c97a3f4e6e5..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DateParseFunction.java+++ /dev/null@@ -1,228 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.function.LongConsumer;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function that converts long or string representations of dates to actual date objects.- *- * <p>The only parameter is the {@link LongValue}, {@link LongValueStream}, {@link DateValue}, or- * {@link DateValueStream} to convert. (Required)- */-public class DateParseFunction {- public static final String name = "date";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- if (params[0] instanceof LongValue) {- return new LongToDateParseFunction((LongValue) params[0]);- } else if (params[0] instanceof LongValueStream) {- return new LongStreamToDateParseFunction((LongValueStream) params[0]);- } else if (params[0] instanceof StringValue) {- return new StringToDateParseFunction((StringValue) params[0]);- } else if (params[0] instanceof StringValueStream) {- return new StringStreamToDateParseFunction((StringValueStream) params[0]);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a string or long parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- }- });-- static class LongToDateParseFunction extends AbstractDateValue {- private final LongValue param;- public static final String name = DateParseFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongToDateParseFunction(LongValue param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public long getLong() {- return param.getLong();- }-- @Override- public boolean exists() {- return param.exists();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamToDateParseFunction extends AbstractDateValueStream {- private final LongValueStream param;- public static final String name = DateParseFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamToDateParseFunction(LongValueStream param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamLongs(LongConsumer cons) {- param.streamLongs(cons);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringToDateParseFunction extends AbstractDateValue {- private final StringValue param;- public static final String name = DateParseFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringToDateParseFunction(StringValue param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public long getLong() {- long value = 0;- try {- String paramStr = param.getString();- exists = param.exists();- if (exists) {- value = Instant.parse(paramStr).toEpochMilli();- }- } catch (DateTimeParseException e) {- exists = false;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamToDateParseFunction extends AbstractDateValueStream {- private final StringValueStream param;- public static final String name = DateParseFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamToDateParseFunction(StringValueStream param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamLongs(LongConsumer cons) {- param.streamStrings(- value -> {- try {- cons.accept(Instant.parse(value).toEpochMilli());- } catch (DateTimeParseException e) {- }- });- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DecimalNumericConversionFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DecimalNumericConversionFunction.javadeleted file mode 100644index 86cc27218ea..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DecimalNumericConversionFunction.java+++ /dev/null@@ -1,285 +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.function.mapping;--import java.util.function.IntConsumer;-import java.util.function.LongConsumer;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An abstract decimal numeric converting mapping function. For example "round()" would convert a- * float to an int and a double to a long.- *- * <p>Takes a numeric Double or Float ValueStream or Value and returns a Long or Int ValueStream or- * Value, respectively.- */-public class DecimalNumericConversionFunction {-- /**- * Create a numeric conversion mapping function.- *- * @param name the name of the function- * @param fconv the method to convert floats to ints- * @param dconv the method to convert doubles to longs- * @param params the parameters of the function- * @return an instance of the conversion function using the given parameters.- */- public static LongValueStream createDecimalConversionFunction(- String name,- ConvertFloatFunction fconv,- ConvertDoubleFunction dconv,- AnalyticsValueStream... params) {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof LongValueStream) {- return (LongValueStream) param;- }- if (param instanceof FloatValueStream) {- if (param instanceof FloatValue) {- return new ConvertFloatValueFunction(name, (FloatValue) param, fconv);- }- return new ConvertFloatStreamFunction(name, (FloatValueStream) param, fconv);- } else if (param instanceof DoubleValueStream) {- if (param instanceof DoubleValue) {- return new ConvertDoubleValueFunction(name, (DoubleValue) param, dconv);- }- return new ConvertDoubleStreamFunction(name, (DoubleValueStream) param, dconv);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires a numeric parameter.");- }- }-- /** A numeric mapping function that returns the floor of the input. */- public static class FloorFunction {- public static final String name = "floor";- public static final CreatorFunction creatorFunction =- (params -> {- return DecimalNumericConversionFunction.createDecimalConversionFunction(- name, val -> (int) Math.floor(val), val -> (long) Math.floor(val), params);- });- }-- /** A numeric mapping function that returns the ceiling of the input. */- public static class CeilingFunction {- public static final String name = "ceil";- public static final CreatorFunction creatorFunction =- (params -> {- return DecimalNumericConversionFunction.createDecimalConversionFunction(- name, val -> (int) Math.ceil(val), val -> (long) Math.ceil(val), params);- });- }-- /** A numeric mapping function that returns the rounded input. */- public static class RoundFunction {- public static final String name = "round";- public static final CreatorFunction creatorFunction =- (params -> {- return DecimalNumericConversionFunction.createDecimalConversionFunction(- name, val -> Math.round(val), val -> Math.round(val), params);- });- }-- @FunctionalInterface- public static interface ConvertFloatFunction {- public int convert(float value);- }-- @FunctionalInterface- public static interface ConvertDoubleFunction {- public long convert(double value);- }-- /** A function to convert a {@link FloatValue} to a {@link IntValue}. */- static class ConvertFloatValueFunction extends AbstractIntValue {- private final String name;- private final FloatValue param;- private final ConvertFloatFunction conv;- private final String funcStr;- private final ExpressionType funcType;-- public ConvertFloatValueFunction(String name, FloatValue param, ConvertFloatFunction conv) {- this.name = name;- this.param = param;- this.conv = conv;- this.funcStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, param);- }-- @Override- public int getInt() {- return conv.convert(param.getFloat());- }-- @Override- public boolean exists() {- return param.exists();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A function to convert a {@link FloatValueStream} to a {@link IntValueStream}. */- static class ConvertFloatStreamFunction extends AbstractIntValueStream {- private final String name;- private final FloatValueStream param;- private final ConvertFloatFunction conv;- private final String funcStr;- private final ExpressionType funcType;-- public ConvertFloatStreamFunction(- String name, FloatValueStream param, ConvertFloatFunction conv) {- this.name = name;- this.param = param;- this.conv = conv;- this.funcStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, param);- }-- @Override- public void streamInts(IntConsumer cons) {- param.streamFloats(value -> cons.accept(conv.convert(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A function to convert a {@link DoubleValue} to a {@link LongValue}. */- static class ConvertDoubleValueFunction extends AbstractLongValue {- private final String name;- private final DoubleValue param;- private final ConvertDoubleFunction conv;- private final String funcStr;- private final ExpressionType funcType;-- public ConvertDoubleValueFunction(String name, DoubleValue param, ConvertDoubleFunction conv) {- this.name = name;- this.param = param;- this.conv = conv;- this.funcStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, param);- }-- @Override- public long getLong() {- return conv.convert(param.getDouble());- }-- @Override- public boolean exists() {- return param.exists();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A function to convert a {@link DoubleValueStream} to a {@link LongValueStream}. */- static class ConvertDoubleStreamFunction extends AbstractLongValueStream {- private final String name;- private final DoubleValueStream param;- private final ConvertDoubleFunction conv;- private final String funcStr;- private final ExpressionType funcType;-- public ConvertDoubleStreamFunction(- String name, DoubleValueStream param, ConvertDoubleFunction conv) {- this.name = name;- this.param = param;- this.conv = conv;- this.funcStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, param);- }-- @Override- public void streamLongs(LongConsumer cons) {- param.streamDoubles(value -> cons.accept(conv.convert(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DivideFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DivideFunction.javadeleted file mode 100644index 99d665738d9..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/DivideFunction.java+++ /dev/null@@ -1,60 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A division mapping function. No checking on divisor value is done. An error will occur if a zero- * divisor is used.- *- * <p>Uses:- *- * <ul>- * <li>If two numeric Values are passed in, a {@link DoubleValue} representing the divison of the- * two values is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the division of the Value and each of the values of the ValueStream for a- * document is returned. (Or the other way, since the Value and ValueStream can be used in- * either order)- * </ul>- */-public class DivideFunction {- public static final String name = "div";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof DoubleValueStream && param2 instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a / b, (DoubleValueStream) param1, (DoubleValueStream) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires numeric parameters.");- }- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/EqualFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/EqualFunction.javadeleted file mode 100644index ccd5a61f116..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/EqualFunction.java+++ /dev/null@@ -1,264 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An equals mapping function, returning whether two values are equal.- *- * <p>Uses:- *- * <ul>- * <li>If two Values are passed in, a {@link BooleanValue} representing the equality of the two- * values for each document is returned.- * <li>If an {@link AnalyticsValue} and an {@link AnalyticsValueStream} are passed in, a {@link- * BooleanValueStream} representing the equality of the Value and each of the values of the- * ValueStream for the document is returned.- * </ul>- */-public class EqualFunction {- public static final String name = "equal";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }-- AnalyticsValueStream paramA = params[0];- AnalyticsValueStream paramB = params[1];-- // Booleans aren't really comparable, so just enable the equal function- if (paramA instanceof BooleanValueStream && paramB instanceof BooleanValueStream) {- if (paramA instanceof BooleanValue) {- if (paramB instanceof BooleanValue) {- return new BooleanValueEqualFunction((BooleanValue) paramA, (BooleanValue) paramB);- }- return new BooleanStreamEqualFunction(- (BooleanValue) paramA, (BooleanValueStream) paramB);- } else if (paramB instanceof BooleanValue) {- return new BooleanStreamEqualFunction(- (BooleanValue) paramB, (BooleanValueStream) paramA);- }- } else if (paramA instanceof DoubleValueStream && paramB instanceof DoubleValueStream) {- return ComparisonFunction.createComparisonFunction(- name,- val -> {- return val == 0;- },- params);- } else if (paramA instanceof AnalyticsValue) {- // This means that the Objects created by the AnalyticsValueStreams are not comparable, so- // use the .equals() method instead- if (paramB instanceof AnalyticsValue) {- return new ValueEqualFunction((AnalyticsValue) paramA, (AnalyticsValue) paramB);- }- return new StreamEqualFunction((AnalyticsValue) paramA, paramB);- } else if (paramB instanceof AnalyticsValue) {- return new StreamEqualFunction((AnalyticsValue) paramB, paramA);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires that at least 1 parameter be single-valued.");- });-- /** An equal function for two {@link BooleanValue}s. */- static class BooleanValueEqualFunction extends AbstractBooleanValue {- private final BooleanValue exprA;- private final BooleanValue exprB;- public static final String name = EqualFunction.name;- private final String funcStr;- private final ExpressionType funcType;-- public BooleanValueEqualFunction(BooleanValue exprA, BooleanValue exprB) {- this.exprA = exprA;- this.exprB = exprB;- this.funcStr = AnalyticsValueStream.createExpressionString(name, exprA, exprB);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, exprA, exprB);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- boolean valueA = exprA.getBoolean();- boolean valueB = exprB.getBoolean();- exists = exprA.exists() && exprB.exists();- return exists ? valueA == valueB : false;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** An equal function for a {@link BooleanValue} and a {@link BooleanValueStream}. */- static class BooleanStreamEqualFunction extends AbstractBooleanValueStream {- private final BooleanValue baseExpr;- private final BooleanValueStream compExpr;- public static final String name = EqualFunction.name;- private final String funcStr;- private final ExpressionType funcType;-- public BooleanStreamEqualFunction(BooleanValue baseExpr, BooleanValueStream compExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.funcStr = AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, baseExpr, compExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean baseValue = baseExpr.getBoolean();- if (baseExpr.exists()) {- compExpr.streamBooleans(compValue -> cons.accept(baseValue == compValue));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** A catch-all equal function for two {@link AnalyticsValue}s. */- static class ValueEqualFunction extends AbstractBooleanValue {- private final AnalyticsValue exprA;- private final AnalyticsValue exprB;- public static final String name = EqualFunction.name;- private final String funcStr;- private final ExpressionType funcType;-- public ValueEqualFunction(AnalyticsValue exprA, AnalyticsValue exprB) {- this.exprA = exprA;- this.exprB = exprB;- this.funcStr = AnalyticsValueStream.createExpressionString(name, exprA, exprB);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, exprA, exprB);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- Object valueA = exprA.getObject();- Object valueB = exprB.getObject();- exists = exprA.exists() && exprB.exists();- return exists ? valueA.equals(valueB) : false;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /**- * A catch-all equal function for an {@link AnalyticsValue} and an {@link AnalyticsValueStream}.- */- static class StreamEqualFunction extends AbstractBooleanValueStream {- private final AnalyticsValue baseExpr;- private final AnalyticsValueStream compExpr;- public static final String name = EqualFunction.name;- private final String funcStr;- private final ExpressionType funcType;-- public StreamEqualFunction(AnalyticsValue baseExpr, AnalyticsValueStream compExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.funcStr = AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(funcStr, baseExpr, compExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- Object baseValue = baseExpr.getObject();- if (baseExpr.exists()) {- compExpr.streamObjects(compValue -> cons.accept(baseValue.equals(compValue)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return funcStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ExistsFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ExistsFunction.javadeleted file mode 100644index 1cd19e55c81..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ExistsFunction.java+++ /dev/null@@ -1,130 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function to test if a value.- *- * <p>Any {@link AnalyticsValueStream} can be passed in, and a {@link BooleanValue} will be returned- * representing whether a value exists.- */-public class ExistsFunction {- public static final String name = "exists";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires 1 parameter.");- }- AnalyticsValueStream param = params[0];- if (param instanceof AnalyticsValue) {- return new ValueExistsFunction((AnalyticsValue) param);- }- return new ValueStreamExistsFunction(param);- });-- /** Exists function that supports {@link AnalyticsValueStream}s. */- static class ValueStreamExistsFunction extends AbstractBooleanValue {- private final AnalyticsValueStream param;- public static final String name = ExistsFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueStreamExistsFunction(AnalyticsValueStream param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists;-- @Override- public boolean getBoolean() {- exists = false;- param.streamObjects(val -> exists = true);- return exists;- }-- @Override- public boolean exists() {- return true;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- /** Exists function that supports {@link AnalyticsValue}s. */- static class ValueExistsFunction extends AbstractBooleanValue {- private final AnalyticsValue param;- public static final String name = ExistsFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueExistsFunction(AnalyticsValue param) throws SolrException {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public boolean getBoolean() {- param.getObject();- return param.exists();- }-- @Override- public boolean exists() {- return true;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FillMissingFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FillMissingFunction.javadeleted file mode 100644index bb356ce0ef4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FillMissingFunction.java+++ /dev/null@@ -1,938 +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.function.mapping;--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.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function to fill all non-existing values with a given value.- *- * <p>Uses:- *- * <ul>- * <li>If two Values are passed in, a Value mimicking the first parameter with the second- * parameter used as filler will be returned.- * <li>If two ValueStreams are passed in, a ValueStream mimicking the first parameter with the- * second parameter used as filler will be returned.- * </ul>- *- * <p>The resulting Value or ValueStream will be typed with the closest super-type of the two- * parameters. (e.g. {@value #name}(double,int) will return a double)- */-public class FillMissingFunction {- public static final String name = "fill_missing";-- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }-- AnalyticsValueStream baseExpr = params[0];- AnalyticsValueStream fillExpr = params[1];- if (baseExpr instanceof DateValue && fillExpr instanceof DateValue) {- return new DateFillMissingFunction((DateValue) baseExpr, (DateValue) fillExpr);- }- if (baseExpr instanceof DateValueStream && fillExpr instanceof DateValueStream) {- return new DateStreamFillMissingFunction(- (DateValueStream) baseExpr, (DateValueStream) fillExpr);- }- if (baseExpr instanceof BooleanValue && fillExpr instanceof BooleanValue) {- return new BooleanFillMissingFunction((BooleanValue) baseExpr, (BooleanValue) fillExpr);- }- if (baseExpr instanceof BooleanValueStream && fillExpr instanceof BooleanValueStream) {- return new BooleanStreamFillMissingFunction(- (BooleanValueStream) baseExpr, (BooleanValueStream) fillExpr);- }- if (baseExpr instanceof IntValue && fillExpr instanceof IntValue) {- return new IntFillMissingFunction((IntValue) baseExpr, (IntValue) fillExpr);- }- if (baseExpr instanceof IntValueStream && fillExpr instanceof IntValueStream) {- return new IntStreamFillMissingFunction(- (IntValueStream) baseExpr, (IntValueStream) fillExpr);- }- if (baseExpr instanceof LongValue && fillExpr instanceof LongValue) {- return new LongFillMissingFunction((LongValue) baseExpr, (LongValue) fillExpr);- }- if (baseExpr instanceof LongValueStream && fillExpr instanceof LongValueStream) {- return new LongStreamFillMissingFunction(- (LongValueStream) baseExpr, (LongValueStream) fillExpr);- }- if (baseExpr instanceof FloatValue && fillExpr instanceof FloatValue) {- return new FloatFillMissingFunction((FloatValue) baseExpr, (FloatValue) fillExpr);- }- if (baseExpr instanceof FloatValueStream && fillExpr instanceof FloatValueStream) {- return new FloatStreamFillMissingFunction(- (FloatValueStream) baseExpr, (FloatValueStream) fillExpr);- }- if (baseExpr instanceof DoubleValue && fillExpr instanceof DoubleValue) {- return new DoubleFillMissingFunction((DoubleValue) baseExpr, (DoubleValue) fillExpr);- }- if (baseExpr instanceof DoubleValueStream && fillExpr instanceof DoubleValueStream) {- return new DoubleStreamFillMissingFunction(- (DoubleValueStream) baseExpr, (DoubleValueStream) fillExpr);- }- if (baseExpr instanceof StringValue && fillExpr instanceof StringValue) {- return new StringFillMissingFunction((StringValue) baseExpr, (StringValue) fillExpr);- }- if (baseExpr instanceof StringValueStream && fillExpr instanceof StringValueStream) {- return new StringStreamFillMissingFunction(- (StringValueStream) baseExpr, (StringValueStream) fillExpr);- }- if (baseExpr instanceof AnalyticsValue && fillExpr instanceof AnalyticsValue) {- return new ValueFillMissingFunction((AnalyticsValue) baseExpr, (AnalyticsValue) fillExpr);- }- return new StreamFillMissingFunction(baseExpr, fillExpr);- });-- static class StreamFillMissingFunction extends AbstractAnalyticsValueStream- implements Consumer<Object> {- private final AnalyticsValueStream baseExpr;- private final AnalyticsValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StreamFillMissingFunction(AnalyticsValueStream baseExpr, AnalyticsValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- Consumer<Object> cons;-- @Override- public void streamObjects(Consumer<Object> cons) {- exists = false;- this.cons = cons;- baseExpr.streamObjects(this);- if (!exists) {- fillExpr.streamObjects(cons);- }- }-- @Override- public void accept(Object value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class ValueFillMissingFunction extends AbstractAnalyticsValue {- private final AnalyticsValue baseExpr;- private final AnalyticsValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueFillMissingFunction(AnalyticsValue baseExpr, AnalyticsValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public Object getObject() {- Object value = baseExpr.getObject();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getObject();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamFillMissingFunction extends AbstractBooleanValueStream- implements BooleanConsumer {- private final BooleanValueStream baseExpr;- private final BooleanValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamFillMissingFunction(- BooleanValueStream baseExpr, BooleanValueStream fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- BooleanConsumer cons;-- @Override- public void streamBooleans(BooleanConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamBooleans(this);- if (!exists) {- fillExpr.streamBooleans(cons);- }- }-- @Override- public void accept(boolean value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanFillMissingFunction extends AbstractBooleanValue {- private final BooleanValue baseExpr;- private final BooleanValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanFillMissingFunction(BooleanValue baseExpr, BooleanValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = baseExpr.getBoolean();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getBoolean();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamFillMissingFunction extends AbstractIntValueStream implements IntConsumer {- private final IntValueStream baseExpr;- private final IntValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamFillMissingFunction(IntValueStream baseExpr, IntValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- IntConsumer cons;-- @Override- public void streamInts(IntConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamInts(this);- if (!exists) {- fillExpr.streamInts(cons);- }- }-- @Override- public void accept(int value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntFillMissingFunction extends AbstractIntValue {- private final IntValue baseExpr;- private final IntValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntFillMissingFunction(IntValue baseExpr, IntValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public int getInt() {- int value = baseExpr.getInt();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getInt();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamFillMissingFunction extends AbstractLongValueStream- implements LongConsumer {- private final LongValueStream baseExpr;- private final LongValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamFillMissingFunction(LongValueStream baseExpr, LongValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- LongConsumer cons;-- @Override- public void streamLongs(LongConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamLongs(this);- if (!exists) {- fillExpr.streamLongs(cons);- }- }-- @Override- public void accept(long value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongFillMissingFunction extends AbstractLongValue {- private final LongValue baseExpr;- private final LongValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongFillMissingFunction(LongValue baseExpr, LongValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getLong();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamFillMissingFunction extends AbstractFloatValueStream- implements FloatConsumer {- private final FloatValueStream baseExpr;- private final FloatValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamFillMissingFunction(FloatValueStream baseExpr, FloatValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- FloatConsumer cons;-- @Override- public void streamFloats(FloatConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamFloats(this);- if (!exists) {- fillExpr.streamFloats(cons);- }- }-- @Override- public void accept(float value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatFillMissingFunction extends AbstractFloatValue {- private final FloatValue baseExpr;- private final FloatValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatFillMissingFunction(FloatValue baseExpr, FloatValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public float getFloat() {- float value = baseExpr.getFloat();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getFloat();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamFillMissingFunction extends AbstractDoubleValueStream- implements DoubleConsumer {- private final DoubleValueStream baseExpr;- private final DoubleValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamFillMissingFunction(DoubleValueStream baseExpr, DoubleValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- DoubleConsumer cons;-- @Override- public void streamDoubles(DoubleConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamDoubles(this);- if (!exists) {- fillExpr.streamDoubles(cons);- }- }-- @Override- public void accept(double value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleFillMissingFunction extends AbstractDoubleValue {- private final DoubleValue baseExpr;- private final DoubleValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleFillMissingFunction(DoubleValue baseExpr, DoubleValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public double getDouble() {- double value = baseExpr.getDouble();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getDouble();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamFillMissingFunction extends AbstractDateValueStream- implements LongConsumer {- private final DateValueStream baseExpr;- private final DateValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamFillMissingFunction(DateValueStream baseExpr, DateValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- LongConsumer cons;-- @Override- public void streamLongs(LongConsumer cons) {- exists = false;- this.cons = cons;- baseExpr.streamLongs(this);- if (!exists) {- fillExpr.streamLongs(cons);- }- }-- @Override- public void accept(long value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateFillMissingFunction extends AbstractDateValue {- private final DateValue baseExpr;- private final DateValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateFillMissingFunction(DateValue baseExpr, DateValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getLong();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamFillMissingFunction extends AbstractStringValueStream- implements Consumer<String> {- private final StringValueStream baseExpr;- private final StringValueStream fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamFillMissingFunction(StringValueStream baseExpr, StringValueStream fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;- Consumer<String> cons;-- @Override- public void streamStrings(Consumer<String> cons) {- exists = false;- this.cons = cons;- baseExpr.streamStrings(this);- if (!exists) {- fillExpr.streamStrings(cons);- }- }-- @Override- public void accept(String value) {- exists = true;- cons.accept(value);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringFillMissingFunction extends AbstractStringValue {- private final StringValue baseExpr;- private final StringValue fillExpr;- public static final String name = FillMissingFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringFillMissingFunction(StringValue baseExpr, StringValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.fillExpr = fillExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, fillExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, fillExpr);- }-- boolean exists = false;-- @Override- public String getString() {- String value = baseExpr.getString();- exists = true;- if (!baseExpr.exists()) {- value = fillExpr.getString();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FilterFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FilterFunction.javadeleted file mode 100644index a4418f05803..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/FilterFunction.java+++ /dev/null@@ -1,796 +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.function.mapping;--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.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function to filter a Value or ValueStream. For each document, the value exists if the- * second parameter is true and it doesn't exist otherwise.- *- * <p>The first parameter can be any type of analytics expression. (Required) <br>- * The second parameter must be a {@link BooleanValue}. (Required)- */-public class FilterFunction {- public static final String name = "filter";-- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- if (!(params[1] instanceof BooleanValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires the second paramater to be single-valued and boolean.");- }-- AnalyticsValueStream baseExpr = params[0];- BooleanValue filterExpr = (BooleanValue) params[1];-- if (baseExpr instanceof DateValue) {- return new DateFilterFunction((DateValue) baseExpr, filterExpr);- }- if (baseExpr instanceof DateValueStream) {- return new DateStreamFilterFunction((DateValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof BooleanValue) {- return new BooleanFilterFunction((BooleanValue) baseExpr, filterExpr);- }- if (baseExpr instanceof BooleanValueStream) {- return new BooleanStreamFilterFunction((BooleanValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof IntValue) {- return new IntFilterFunction((IntValue) baseExpr, filterExpr);- }- if (baseExpr instanceof IntValueStream) {- return new IntStreamFilterFunction((IntValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof LongValue) {- return new LongFilterFunction((LongValue) baseExpr, filterExpr);- }- if (baseExpr instanceof LongValueStream) {- return new LongStreamFilterFunction((LongValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof FloatValue) {- return new FloatFilterFunction((FloatValue) baseExpr, filterExpr);- }- if (baseExpr instanceof FloatValueStream) {- return new FloatStreamFilterFunction((FloatValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof DoubleValue) {- return new DoubleFilterFunction((DoubleValue) baseExpr, filterExpr);- }- if (baseExpr instanceof DoubleValueStream) {- return new DoubleStreamFilterFunction((DoubleValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof StringValue) {- return new StringFilterFunction((StringValue) baseExpr, filterExpr);- }- if (baseExpr instanceof StringValueStream) {- return new StringStreamFilterFunction((StringValueStream) baseExpr, filterExpr);- }- if (baseExpr instanceof AnalyticsValue) {- return new ValueFilterFunction((AnalyticsValue) baseExpr, filterExpr);- }- return new StreamFilterFunction(baseExpr, filterExpr);- });-- static class StreamFilterFunction extends AbstractAnalyticsValueStream {- private final AnalyticsValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StreamFilterFunction(AnalyticsValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamObjects(Consumer<Object> cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamObjects(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class ValueFilterFunction extends AbstractAnalyticsValue {- private final AnalyticsValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueFilterFunction(AnalyticsValue baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public Object getObject() {- Object value = baseExpr.getObject();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamFilterFunction extends AbstractBooleanValueStream {- private final BooleanValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamFilterFunction(BooleanValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamBooleans(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanFilterFunction extends AbstractBooleanValue {- private final BooleanValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanFilterFunction(BooleanValue baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = baseExpr.getBoolean();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamFilterFunction extends AbstractIntValueStream {- private final IntValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamFilterFunction(IntValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamInts(IntConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamInts(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntFilterFunction extends AbstractIntValue {- private final IntValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntFilterFunction(IntValue baseExpr, BooleanValue filterExpr) throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public int getInt() {- int value = baseExpr.getInt();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamFilterFunction extends AbstractLongValueStream {- private final LongValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamFilterFunction(LongValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongFilterFunction extends AbstractLongValue {- private final LongValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongFilterFunction(LongValue baseExpr, BooleanValue filterExpr) throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamFilterFunction extends AbstractFloatValueStream {- private final FloatValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamFilterFunction(FloatValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamFloats(FloatConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamFloats(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatFilterFunction extends AbstractFloatValue {- private final FloatValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatFilterFunction(FloatValue baseExpr, BooleanValue filterExpr) throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public float getFloat() {- float value = baseExpr.getFloat();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamFilterFunction extends AbstractDoubleValueStream {- private final DoubleValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamFilterFunction(DoubleValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamDoubles(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleFilterFunction extends AbstractDoubleValue {- private final DoubleValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleFilterFunction(DoubleValue baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public double getDouble() {- double value = baseExpr.getDouble();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamFilterFunction extends AbstractDateValueStream {- private final DateValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamFilterFunction(DateValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateFilterFunction extends AbstractDateValue {- private final DateValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateFilterFunction(DateValue baseExpr, BooleanValue filterExpr) throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamFilterFunction extends AbstractStringValueStream {- private final StringValueStream baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamFilterFunction(StringValueStream baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- @Override- public void streamStrings(Consumer<String> cons) {- if (filterExpr.getBoolean() && filterExpr.exists()) {- baseExpr.streamStrings(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringFilterFunction extends AbstractStringValue {- private final StringValue baseExpr;- private final BooleanValue filterExpr;- public static final String name = FilterFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringFilterFunction(StringValue baseExpr, BooleanValue filterExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.filterExpr = filterExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, filterExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, filterExpr);- }-- boolean exists = false;-- @Override- public String getString() {- String value = baseExpr.getString();- exists = baseExpr.exists() && filterExpr.getBoolean() && filterExpr.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/IfFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/IfFunction.javadeleted file mode 100644index 1a308f0ffd7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/IfFunction.java+++ /dev/null@@ -1,988 +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.function.mapping;--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.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An if-else mapping function.- *- * <p>Three arguments are required. The first, the conditional parameter, must be a {@link- * BooleanValue} and the later two, the if and else parameters, can be any type of {@link- * AnalyticsValueStream}. For each document, if the conditional value is true then the if-value is- * used otherwise the else-value is used.- *- * <p>The resulting Value or ValueStream will be typed with the closest super-type of the two- * non-conditional parameters. (e.g. {@value #name}(boolean,double,int) will return a double) If two- * {@link AnalyticsValue}s are passed as the if-else parameters, an {@link AnalyticsValue} will be- * returned. If either parameter isn't single-valued, a {@link AnalyticsValueStream} will be- * returned.- */-public class IfFunction extends AbstractAnalyticsValueStream {- private final BooleanValue ifExpr;- private final AnalyticsValueStream thenExpr;- private final AnalyticsValueStream elseExpr;- public static final String name = "if";- private final String exprStr;- private final ExpressionType funcType;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 3) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 3 paramaters, " + params.length + " found.");- }- if (!(params[0] instanceof BooleanValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires single-valued numeric parameters. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- }-- BooleanValue castedIf = (BooleanValue) params[0];- AnalyticsValueStream thenExpr = params[1];- AnalyticsValueStream elseExpr = params[2];-- if (thenExpr instanceof DateValue && elseExpr instanceof DateValue) {- return new DateIfFunction(castedIf, (DateValue) thenExpr, (DateValue) elseExpr);- }- if (thenExpr instanceof DateValueStream && elseExpr instanceof DateValueStream) {- return new DateStreamIfFunction(- castedIf, (DateValueStream) thenExpr, (DateValueStream) elseExpr);- }- if (thenExpr instanceof BooleanValue && elseExpr instanceof BooleanValue) {- return new BooleanIfFunction(castedIf, (BooleanValue) thenExpr, (BooleanValue) elseExpr);- }- if (thenExpr instanceof BooleanValueStream && elseExpr instanceof BooleanValueStream) {- return new BooleanStreamIfFunction(- castedIf, (BooleanValueStream) thenExpr, (BooleanValueStream) elseExpr);- }- if (thenExpr instanceof IntValue && elseExpr instanceof IntValue) {- return new IntIfFunction(castedIf, (IntValue) thenExpr, (IntValue) elseExpr);- }- if (thenExpr instanceof IntValueStream && elseExpr instanceof IntValueStream) {- return new IntStreamIfFunction(- castedIf, (IntValueStream) thenExpr, (IntValueStream) elseExpr);- }- if (thenExpr instanceof LongValue && elseExpr instanceof LongValue) {- return new LongIfFunction(castedIf, (LongValue) thenExpr, (LongValue) elseExpr);- }- if (thenExpr instanceof LongValueStream && elseExpr instanceof LongValueStream) {- return new LongStreamIfFunction(- castedIf, (LongValueStream) thenExpr, (LongValueStream) elseExpr);- }- if (thenExpr instanceof FloatValue && elseExpr instanceof FloatValue) {- return new FloatIfFunction(castedIf, (FloatValue) thenExpr, (FloatValue) elseExpr);- }- if (thenExpr instanceof FloatValueStream && elseExpr instanceof FloatValueStream) {- return new FloatStreamIfFunction(- castedIf, (FloatValueStream) thenExpr, (FloatValueStream) elseExpr);- }- if (thenExpr instanceof DoubleValue && elseExpr instanceof DoubleValue) {- return new DoubleIfFunction(castedIf, (DoubleValue) thenExpr, (DoubleValue) elseExpr);- }- if (thenExpr instanceof DoubleValueStream && elseExpr instanceof DoubleValueStream) {- return new DoubleStreamIfFunction(- castedIf, (DoubleValueStream) thenExpr, (DoubleValueStream) elseExpr);- }- if (thenExpr instanceof StringValue && elseExpr instanceof StringValue) {- return new StringIfFunction(castedIf, (StringValue) thenExpr, (StringValue) elseExpr);- }- if (thenExpr instanceof StringValueStream && elseExpr instanceof StringValueStream) {- return new StringStreamIfFunction(- castedIf, (StringValueStream) thenExpr, (StringValueStream) elseExpr);- }- if (thenExpr instanceof AnalyticsValue && elseExpr instanceof AnalyticsValue) {- return new ValueIfFunction(- castedIf, (AnalyticsValue) thenExpr, (AnalyticsValue) elseExpr);- }- return new IfFunction(castedIf, thenExpr, elseExpr);- });-- public IfFunction(- BooleanValue ifExpr, AnalyticsValueStream thenExpr, AnalyticsValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamObjects(Consumer<Object> cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamObjects(cons);- } else {- elseExpr.streamObjects(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }-- static class ValueIfFunction extends AbstractAnalyticsValue {- private final BooleanValue ifExpr;- private final AnalyticsValue thenExpr;- private final AnalyticsValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueIfFunction(BooleanValue ifExpr, AnalyticsValue thenExpr, AnalyticsValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public Object getObject() {- exists = false;- Object value = null;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getObject();- exists = thenExpr.exists();- } else {- value = elseExpr.getObject();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamIfFunction extends AbstractBooleanValueStream {- private final BooleanValue ifExpr;- private final BooleanValueStream thenExpr;- private final BooleanValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamIfFunction(- BooleanValue ifExpr, BooleanValueStream thenExpr, BooleanValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamBooleans(cons);- } else {- elseExpr.streamBooleans(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanIfFunction extends AbstractBooleanValue {- private final BooleanValue ifExpr;- private final BooleanValue thenExpr;- private final BooleanValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanIfFunction(BooleanValue ifExpr, BooleanValue thenExpr, BooleanValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- exists = false;- boolean value = false;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getBoolean();- exists = thenExpr.exists();- } else {- value = elseExpr.getBoolean();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamIfFunction extends AbstractIntValueStream {- private final BooleanValue ifExpr;- private final IntValueStream thenExpr;- private final IntValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamIfFunction(- BooleanValue ifExpr, IntValueStream thenExpr, IntValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamInts(IntConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamInts(cons);- } else {- elseExpr.streamInts(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntIfFunction extends AbstractIntValue {- private final BooleanValue ifExpr;- private final IntValue thenExpr;- private final IntValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntIfFunction(BooleanValue ifExpr, IntValue thenExpr, IntValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public int getInt() {- exists = false;- int value = 0;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getInt();- exists = thenExpr.exists();- } else {- value = elseExpr.getInt();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamIfFunction extends AbstractLongValueStream {- private final BooleanValue ifExpr;- private final LongValueStream thenExpr;- private final LongValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamIfFunction(- BooleanValue ifExpr, LongValueStream thenExpr, LongValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamLongs(cons);- } else {- elseExpr.streamLongs(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongIfFunction extends AbstractLongValue {- private final BooleanValue ifExpr;- private final LongValue thenExpr;- private final LongValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongIfFunction(BooleanValue ifExpr, LongValue thenExpr, LongValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public long getLong() {- exists = false;- long value = 0;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getLong();- exists = thenExpr.exists();- } else {- value = elseExpr.getLong();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamIfFunction extends AbstractFloatValueStream {- private final BooleanValue ifExpr;- private final FloatValueStream thenExpr;- private final FloatValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamIfFunction(- BooleanValue ifExpr, FloatValueStream thenExpr, FloatValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamFloats(FloatConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamFloats(cons);- } else {- elseExpr.streamFloats(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatIfFunction extends AbstractFloatValue {- private final BooleanValue ifExpr;- private final FloatValue thenExpr;- private final FloatValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatIfFunction(BooleanValue ifExpr, FloatValue thenExpr, FloatValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public float getFloat() {- exists = false;- float value = 0;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getFloat();- exists = thenExpr.exists();- } else {- value = elseExpr.getFloat();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamIfFunction extends AbstractDoubleValueStream {- private final BooleanValue ifExpr;- private final DoubleValueStream thenExpr;- private final DoubleValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamIfFunction(- BooleanValue ifExpr, DoubleValueStream thenExpr, DoubleValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamDoubles(cons);- } else {- elseExpr.streamDoubles(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleIfFunction extends AbstractDoubleValue {- private final BooleanValue ifExpr;- private final DoubleValue thenExpr;- private final DoubleValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleIfFunction(BooleanValue ifExpr, DoubleValue thenExpr, DoubleValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public double getDouble() {- exists = false;- double value = 0;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getDouble();- exists = thenExpr.exists();- } else {- value = elseExpr.getDouble();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamIfFunction extends AbstractDateValueStream {- private final BooleanValue ifExpr;- private final DateValueStream thenExpr;- private final DateValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamIfFunction(- BooleanValue ifExpr, DateValueStream thenExpr, DateValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamLongs(cons);- } else {- elseExpr.streamLongs(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateIfFunction extends AbstractDateValue {- private final BooleanValue ifExpr;- private final DateValue thenExpr;- private final DateValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateIfFunction(BooleanValue ifExpr, DateValue thenExpr, DateValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public long getLong() {- exists = false;- long value = 0;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getLong();- exists = thenExpr.exists();- } else {- value = elseExpr.getLong();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamIfFunction extends AbstractStringValueStream {- private final BooleanValue ifExpr;- private final StringValueStream thenExpr;- private final StringValueStream elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamIfFunction(- BooleanValue ifExpr, StringValueStream thenExpr, StringValueStream elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- @Override- public void streamStrings(Consumer<String> cons) {- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- thenExpr.streamStrings(cons);- } else {- elseExpr.streamStrings(cons);- }- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringIfFunction extends AbstractStringValue {- private final BooleanValue ifExpr;- private final StringValue thenExpr;- private final StringValue elseExpr;- public static final String name = IfFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringIfFunction(BooleanValue ifExpr, StringValue thenExpr, StringValue elseExpr)- throws SolrException {- this.ifExpr = ifExpr;- this.thenExpr = thenExpr;- this.elseExpr = elseExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, ifExpr, thenExpr, elseExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, ifExpr, thenExpr, elseExpr);- }-- private boolean exists = false;-- @Override- public String getString() {- exists = false;- String value = null;- boolean ifValue = ifExpr.getBoolean();- if (ifExpr.exists()) {- if (ifValue) {- value = thenExpr.getString();- exists = thenExpr.exists();- } else {- value = elseExpr.getString();- exists = elseExpr.exists();- }- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LambdaFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LambdaFunction.javadeleted file mode 100644index 01b79e5b337..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LambdaFunction.java+++ /dev/null@@ -1,3834 +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.function.mapping;--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.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * Lambda Functions are used to easily create basic mapping functions.- *- * <p>There are lambda functions for all types: boolean, int, long, float, double, date and string.- * Lambda functions must have parameters of all the same type, which will be the same type as the- * returned Value or ValueStream.- *- * <p>The types of functions that are accepted are: (multi = multi-valued expression, single =- * single-valued expression)- *- * <ul>- * <li>{@code func(single) -> single}- * <li>{@code func(multi) -> multi}- * <li>{@code func(single,single) -> single}- * <li>{@code func(multi,single) -> multi}- * <li>{@code func(single,multi) -> multi}- * <li>{@code func(multi) -> single}- * <li>{@code func(single,single,...) -> single} (You can also specify whether all parameters must- * exist, or at least one must exist for the returned value to exist)- * </ul>- *- * <p>NOTE: The combination of name and parameters MUST be unique for an expression. <br>- * For example consider if {@code join(fieldA, ',')} and {@code join(fieldA, ';')} are both called.- * If the JoinFunction uses: <br>- * {@code LambdaFunction.createStringLambdaFunction("join", (a,b) -> a + sep + b,- * (StringValueStream)params[0])} <br>- * then both the name "join" and single parameter fieldA will be used for two DIFFERENT expressions.- * This does not meet the uniqueness requirmenet and will break the query. <br>- * A solution to this is to name the function using the missing information: <br>- * {@code LambdaFunction.createStringLambdaFunction("join(" + sep + ")", (a,b) -> a + sep + b,- * (StringValueStream)params[0])} <br>- * Therefore both expressions will have fieldA as the only parameter, but the names {@code- * "join(,)"} and {@code "join(;)"} will be different. This meets the uniqueness requirement for- * lambda functions.- */-public class LambdaFunction {- private static final boolean defaultMultiExistsMethod = true;-- /* *********************- *- * Boolean Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued boolean expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (boolean) -> boolean}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static BooleanValueStream createBooleanLambdaFunction(- String name, BoolInBoolOutLambda lambda, BooleanValueStream param) {- if (param instanceof BooleanValue) {- return new BooleanValueInBooleanValueOutFunction(name, lambda, (BooleanValue) param);- } else {- return new BooleanStreamInBooleanStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued boolean expression and returns a single-valued- * boolean expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static BooleanValue createBooleanLambdaFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValueStream param) {- return new BooleanStreamInBooleanValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two booleans to a single boolean. This can take the following- * shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (boolean,boolean) -> boolean}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static BooleanValueStream createBooleanLambdaFunction(- String name,- TwoBoolInBoolOutLambda lambda,- BooleanValueStream param1,- BooleanValueStream param2)- throws SolrException {- if (param1 instanceof BooleanValue && param2 instanceof BooleanValue) {- return new TwoBooleanValueInBooleanValueOutFunction(- name, lambda, (BooleanValue) param1, (BooleanValue) param2);- } else if (param1 instanceof BooleanValue) {- return new BooleanValueBooleanStreamInBooleanStreamOutFunction(- name, lambda, (BooleanValue) param1, param2);- } else if (param2 instanceof BooleanValue) {- return new BooleanStreamBooleanValueInBooleanStreamOutFunction(- name, lambda, param1, (BooleanValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createBooleanLambdaFunction(String,- * TwoBoolInBoolOutLambda, BooleanValue[], boolean)}, using {@value #defaultMultiExistsMethod} for- * the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static BooleanValue createBooleanLambdaFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue[] params) {- return createBooleanLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value- * boolean expressions into a single-value boolean expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static BooleanValue createBooleanLambdaFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiBooleanValueInBooleanValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiBooleanValueInBooleanValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * Integer Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued integer expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (integer) -> integer}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static IntValueStream createIntLambdaFunction(- String name, IntInIntOutLambda lambda, IntValueStream param) {- if (param instanceof IntValue) {- return new IntValueInIntValueOutFunction(name, lambda, (IntValue) param);- } else {- return new IntStreamInIntStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued integer expression and returns a single-valued- * integer expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (integer, integer) ->- * integer}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static IntValue createIntLambdaFunction(- String name, TwoIntInIntOutLambda lambda, IntValueStream param) {- return new IntStreamInIntValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two integers to a single integer. This can take the following- * shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (integer,integer) -> integer}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static IntValueStream createIntLambdaFunction(- String name, TwoIntInIntOutLambda lambda, IntValueStream param1, IntValueStream param2)- throws SolrException {- if (param1 instanceof IntValue && param2 instanceof IntValue) {- return new TwoIntValueInIntValueOutFunction(- name, lambda, (IntValue) param1, (IntValue) param2);- } else if (param1 instanceof IntValue) {- return new IntValueIntStreamInIntStreamOutFunction(name, lambda, (IntValue) param1, param2);- } else if (param2 instanceof IntValue) {- return new IntStreamIntValueInIntStreamOutFunction(name, lambda, param1, (IntValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createIntLambdaFunction(String,- * TwoIntInIntOutLambda, IntValue[], boolean)}, using {@value #defaultMultiExistsMethod} for the- * last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static IntValue createIntLambdaFunction(- String name, TwoIntInIntOutLambda lambda, IntValue[] params) {- return createIntLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value- * integer expressions into a single-value integer expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (integer, integer) ->- * integer}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static IntValue createIntLambdaFunction(- String name, TwoIntInIntOutLambda lambda, IntValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiIntValueInIntValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiIntValueInIntValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * Long Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued long expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (long) -> long}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static LongValueStream createLongLambdaFunction(- String name, LongInLongOutLambda lambda, LongValueStream param) {- if (param instanceof LongValue) {- return new LongValueInLongValueOutFunction(name, lambda, (LongValue) param);- } else {- return new LongStreamInLongStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued long expression and returns a single-valued- * long expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static LongValue createLongLambdaFunction(- String name, TwoLongInLongOutLambda lambda, LongValueStream param) {- return new LongStreamInLongValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two longs to a single long. This can take the following shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (long,long) -> long}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static LongValueStream createLongLambdaFunction(- String name, TwoLongInLongOutLambda lambda, LongValueStream param1, LongValueStream param2)- throws SolrException {- if (param1 instanceof LongValue && param2 instanceof LongValue) {- return new TwoLongValueInLongValueOutFunction(- name, lambda, (LongValue) param1, (LongValue) param2);- } else if (param1 instanceof LongValue) {- return new LongValueLongStreamInLongStreamOutFunction(- name, lambda, (LongValue) param1, param2);- } else if (param2 instanceof LongValue) {- return new LongStreamLongValueInLongStreamOutFunction(- name, lambda, param1, (LongValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createLongLambdaFunction(String,- * TwoLongInLongOutLambda, LongValue[], boolean)}, using {@value #defaultMultiExistsMethod} for- * the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static LongValue createLongLambdaFunction(- String name, TwoLongInLongOutLambda lambda, LongValue[] params) {- return createLongLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value long- * expressions into a single-value long expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (long, long) -> long}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static LongValue createLongLambdaFunction(- String name, TwoLongInLongOutLambda lambda, LongValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiLongValueInLongValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiLongValueInLongValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * Float Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued float expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (float) -> float}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static FloatValueStream createFloatLambdaFunction(- String name, FloatInFloatOutLambda lambda, FloatValueStream param) {- if (param instanceof FloatValue) {- return new FloatValueInFloatValueOutFunction(name, lambda, (FloatValue) param);- } else {- return new FloatStreamInFloatStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued float expression and returns a single-valued- * float expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (float, float) ->- * float}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static FloatValue createFloatLambdaFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValueStream param) {- return new FloatStreamInFloatValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two floats to a single float. This can take the following shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (float,float) -> float}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static FloatValueStream createFloatLambdaFunction(- String name,- TwoFloatInFloatOutLambda lambda,- FloatValueStream param1,- FloatValueStream param2)- throws SolrException {- if (param1 instanceof FloatValue && param2 instanceof FloatValue) {- return new TwoFloatValueInFloatValueOutFunction(- name, lambda, (FloatValue) param1, (FloatValue) param2);- } else if (param1 instanceof FloatValue) {- return new FloatValueFloatStreamInFloatStreamOutFunction(- name, lambda, (FloatValue) param1, param2);- } else if (param2 instanceof FloatValue) {- return new FloatStreamFloatValueInFloatStreamOutFunction(- name, lambda, param1, (FloatValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createFloatLambdaFunction(String,- * TwoFloatInFloatOutLambda, FloatValue[], boolean)}, using {@value #defaultMultiExistsMethod} for- * the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static FloatValue createFloatLambdaFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue[] params) {- return createFloatLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value float- * expressions into a single-value float expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (float, float) ->- * float}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static FloatValue createFloatLambdaFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiFloatValueInFloatValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiFloatValueInFloatValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * Double Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued double expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (double) -> double}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static DoubleValueStream createDoubleLambdaFunction(- String name, DoubleInDoubleOutLambda lambda, DoubleValueStream param) {- if (param instanceof DoubleValue) {- return new DoubleValueInDoubleValueOutFunction(name, lambda, (DoubleValue) param);- } else {- return new DoubleStreamInDoubleStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued double expression and returns a single-valued- * double expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (double, double) ->- * double}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static DoubleValue createDoubleLambdaFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValueStream param) {- return new DoubleStreamInDoubleValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two doubles to a single double. This can take the following- * shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (double,double) -> double}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static DoubleValueStream createDoubleLambdaFunction(- String name,- TwoDoubleInDoubleOutLambda lambda,- DoubleValueStream param1,- DoubleValueStream param2)- throws SolrException {- if (param1 instanceof DoubleValue && param2 instanceof DoubleValue) {- return new TwoDoubleValueInDoubleValueOutFunction(- name, lambda, (DoubleValue) param1, (DoubleValue) param2);- } else if (param1 instanceof DoubleValue) {- return new DoubleValueDoubleStreamInDoubleStreamOutFunction(- name, lambda, (DoubleValue) param1, param2);- } else if (param2 instanceof DoubleValue) {- return new DoubleStreamDoubleValueInDoubleStreamOutFunction(- name, lambda, param1, (DoubleValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createDoubleLambdaFunction(String,- * TwoDoubleInDoubleOutLambda, DoubleValue[], boolean)}, using {@value #defaultMultiExistsMethod}- * for the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static DoubleValue createDoubleLambdaFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params) {- return createDoubleLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value- * double expressions into a single-value double expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (double, double) ->- * double}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static DoubleValue createDoubleLambdaFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiDoubleValueInDoubleValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiDoubleValueInDoubleValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * Date Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued date expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * <p>NOTE: The lambda must work on longs, not Date objects- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (long) -> long}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static DateValueStream createDateLambdaFunction(- String name, LongInLongOutLambda lambda, DateValueStream param) {- if (param instanceof DateValue) {- return new DateValueInDateValueOutFunction(name, lambda, (DateValue) param);- } else {- return new DateStreamInDateStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued date expression and returns a single-valued- * date expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * <p>NOTE: The lambda must work on longs, not Date objects- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (long, long) -> long}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static DateValue createDateLambdaFunction(- String name, TwoLongInLongOutLambda lambda, DateValueStream param) {- return new DateStreamInDateValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two dates to a single date. This can take the following shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * <p>NOTE: The lambda must work on longs, not Date objects- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (long,long) -> long}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static DateValueStream createDateLambdaFunction(- String name, TwoLongInLongOutLambda lambda, DateValueStream param1, DateValueStream param2)- throws SolrException {- if (param1 instanceof DateValue && param2 instanceof DateValue) {- return new TwoDateValueInDateValueOutFunction(- name, lambda, (DateValue) param1, (DateValue) param2);- } else if (param1 instanceof DateValue) {- return new DateValueDateStreamInDateStreamOutFunction(- name, lambda, (DateValue) param1, param2);- } else if (param2 instanceof DateValue) {- return new DateStreamDateValueInDateStreamOutFunction(- name, lambda, param1, (DateValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createDateLambdaFunction(String,- * TwoLongInLongOutLambda, DateValue[], boolean)}, using {@value #defaultMultiExistsMethod} for- * the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static DateValue createDateLambdaFunction(- String name, TwoLongInLongOutLambda lambda, DateValue[] params) {- return createDateLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value date- * expressions into a single-value date expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * <p>NOTE: The lambda must work on longs, not Date objects- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (long, long) -> long}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static DateValue createDateLambdaFunction(- String name, TwoLongInLongOutLambda lambda, DateValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiDateValueInDateValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiDateValueInDateValueOutRequireOneFunction(name, lambda, params);- }- }-- /* *********************- *- * String Functions- *- * *********************/-- /**- * Creates a function that takes in either a single or multi valued string expression and returns- * the same type of expression with the given lambda function applied to every value.- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (String) -> String}- * @param param the expression to apply the lambda to- * @return an expression the same type as was given with the lambda applied- */- public static StringValueStream createStringLambdaFunction(- String name, StringInStringOutLambda lambda, StringValueStream param) {- if (param instanceof StringValue) {- return new StringValueInStringValueOutFunction(name, lambda, (StringValue) param);- } else {- return new StringStreamInStringStreamOutFunction(name, lambda, param);- }- }- /**- * Creates a function that takes in a multi-valued string expression and returns a single-valued- * string expression. The given lambda is used to associatively (order not guaranteed) reduce all- * values for a document down to a single value.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (String, String) ->- * String}- * @param param the expression to be reduced per-document- * @return a single-valued expression which has been reduced for every document- */- public static StringValue createStringLambdaFunction(- String name, TwoStringInStringOutLambda lambda, StringValueStream param) {- return new StringStreamInStringValueOutFunction(name, lambda, param);- }- /**- * Creates a function that maps two strings to a single string. This can take the following- * shapes:- *- * <ul>- * <li>Taking in two single-valued expressions and returning a single-valued expression which- * represents the lambda combination of the inputs.- * <li>Taking in a single-valued expression and a multi-valued expression and returning a- * multi-valued expression which represents the lambda combination of the single-value input- * with each of the values of the multi-value input. <br>- * The inputs can be either {@code func(single,multi)} or {@code func(multi,single)}.- * </ul>- *- * @param name name for the function- * @param lambda the function to be applied to every value: {@code (String,String) -> String}- * @param param1 the first parameter in the lambda- * @param param2 the second parameter in the lambda- * @return a single or multi valued expression combining the two parameters with the given lambda- * @throws SolrException if neither parameter is single-valued- */- public static StringValueStream createStringLambdaFunction(- String name,- TwoStringInStringOutLambda lambda,- StringValueStream param1,- StringValueStream param2)- throws SolrException {- if (param1 instanceof StringValue && param2 instanceof StringValue) {- return new TwoStringValueInStringValueOutFunction(- name, lambda, (StringValue) param1, (StringValue) param2);- } else if (param1 instanceof StringValue) {- return new StringValueStringStreamInStringStreamOutFunction(- name, lambda, (StringValue) param1, param2);- } else if (param2 instanceof StringValue) {- return new StringStreamStringValueInStringStreamOutFunction(- name, lambda, param1, (StringValue) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires at least 1 single-valued parameter.");- }- }- /**- * Forwards the creation of the function to {@link #createStringLambdaFunction(String,- * TwoStringInStringOutLambda, StringValue[], boolean)}, using {@value #defaultMultiExistsMethod}- * for the last argument ({@code allMustExist}).- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (boolean, boolean) ->- * boolean}- * @param params the expressions to reduce- * @return a single-value expression that reduces the parameters with the given lambda- */- public static StringValue createStringLambdaFunction(- String name, TwoStringInStringOutLambda lambda, StringValue[] params) {- return createStringLambdaFunction(name, lambda, params, defaultMultiExistsMethod);- }- /**- * Creates a function that associatively (order is guaranteed) reduces multiple single-value- * string expressions into a single-value string expression for each document. <br>- * For a document, every parameter's value must exist for the resulting value to exist if {@code- * allMustExist} is true. If {@code allMustExist} is false, only one of the parameters' values- * must exist.- *- * @param name name for the function- * @param lambda the associative function used to reduce the values: {@code (String, String) ->- * String}- * @param params the expressions to reduce- * @param allMustExist whether all parameters are required to exist- * @return a single-value expression that reduces the parameters with the given lambda- */- public static StringValue createStringLambdaFunction(- String name, TwoStringInStringOutLambda lambda, StringValue[] params, boolean allMustExist) {- if (allMustExist) {- return new MultiStringValueInStringValueOutRequireAllFunction(name, lambda, params);- } else {- return new MultiStringValueInStringValueOutRequireOneFunction(name, lambda, params);- }- }-- /*- * Single Parameter- */- // Boolean Out- @FunctionalInterface- public static interface BoolInBoolOutLambda {- boolean apply(boolean a);- }-- @FunctionalInterface- public static interface IntInBoolOutLambda {- boolean apply(int a);- }-- @FunctionalInterface- public static interface LongInBoolOutLambda {- boolean apply(long a);- }-- @FunctionalInterface- public static interface FloatInBoolOutLambda {- boolean apply(float a);- }-- @FunctionalInterface- public static interface DoubleInBoolOutLambda {- boolean apply(double a);- }-- @FunctionalInterface- public static interface StringInBoolOutLambda {- boolean apply(double a);- }- // Int Out- @FunctionalInterface- public static interface BoolInIntOutLambda {- int apply(boolean a);- }-- @FunctionalInterface- public static interface IntInIntOutLambda {- int apply(int a);- }-- @FunctionalInterface- public static interface LongInIntOutLambda {- int apply(long a);- }-- @FunctionalInterface- public static interface FloatInIntOutLambda {- int apply(float a);- }-- @FunctionalInterface- public static interface DoubleInIntOutLambda {- int apply(double a);- }-- @FunctionalInterface- public static interface StringInIntOutLambda {- int apply(double a);- }- // Long Out- @FunctionalInterface- public static interface BoolInLongOutLambda {- long apply(boolean a);- }-- @FunctionalInterface- public static interface IntInLongOutLambda {- long apply(int a);- }-- @FunctionalInterface- public static interface LongInLongOutLambda {- long apply(long a);- }-- @FunctionalInterface- public static interface FloatInLongOutLambda {- long apply(float a);- }-- @FunctionalInterface- public static interface DoubleInLongOutLambda {- long apply(double a);- }-- @FunctionalInterface- public static interface StringInLongOutLambda {- long apply(double a);- }- // Float Out- @FunctionalInterface- public static interface BoolInFloatOutLambda {- float apply(boolean a);- }-- @FunctionalInterface- public static interface IntInFloatOutLambda {- float apply(int a);- }-- @FunctionalInterface- public static interface LongInFloatOutLambda {- float apply(long a);- }-- @FunctionalInterface- public static interface FloatInFloatOutLambda {- float apply(float a);- }-- @FunctionalInterface- public static interface DoubleInFloatOutLambda {- float apply(double a);- }-- @FunctionalInterface- public static interface StringInFloatOutLambda {- float apply(String a);- }- // Double Out- @FunctionalInterface- public static interface BoolInDoubleOutLambda {- double apply(boolean a);- }-- @FunctionalInterface- public static interface IntInDoubleOutLambda {- double apply(int a);- }-- @FunctionalInterface- public static interface LongInDoubleOutLambda {- double apply(long a);- }-- @FunctionalInterface- public static interface FloatInDoubleOutLambda {- double apply(float a);- }-- @FunctionalInterface- public static interface DoubleInDoubleOutLambda {- double apply(double a);- }-- @FunctionalInterface- public static interface StringInDoubleOutLambda {- double apply(String a);- }- // String Out- @FunctionalInterface- public static interface BoolInStringOutLambda {- String apply(boolean a);- }-- @FunctionalInterface- public static interface IntInStringOutLambda {- String apply(int a);- }-- @FunctionalInterface- public static interface LongInStringOutLambda {- String apply(long a);- }-- @FunctionalInterface- public static interface FloatInStringOutLambda {- String apply(float a);- }-- @FunctionalInterface- public static interface DoubleInStringOutLambda {- String apply(double a);- }-- @FunctionalInterface- public static interface StringInStringOutLambda {- String apply(String a);- }-- /*- * Two Parameters- */- // Boolean Out- @FunctionalInterface- public static interface TwoBoolInBoolOutLambda {- boolean apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInBoolOutLambda {- boolean apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInBoolOutLambda {- boolean apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInBoolOutLambda {- boolean apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInBoolOutLambda {- boolean apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInBoolOutLambda {- boolean apply(double a, double b);- }- // Int Out- @FunctionalInterface- public static interface TwoBoolInIntOutLambda {- int apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInIntOutLambda {- int apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInIntOutLambda {- int apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInIntOutLambda {- int apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInIntOutLambda {- int apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInIntOutLambda {- int apply(double a, double b);- }- // Long Out- @FunctionalInterface- public static interface TwoBoolInLongOutLambda {- long apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInLongOutLambda {- long apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInLongOutLambda {- long apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInLongOutLambda {- long apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInLongOutLambda {- long apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInLongOutLambda {- long apply(double a, double b);- }- // Float Out- @FunctionalInterface- public static interface TwoBoolInFloatOutLambda {- float apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInFloatOutLambda {- float apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInFloatOutLambda {- float apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInFloatOutLambda {- float apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInFloatOutLambda {- float apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInFloatOutLambda {- float apply(String a, String b);- }- // Double Out- @FunctionalInterface- public static interface TwoBoolInDoubleOutLambda {- double apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInDoubleOutLambda {- double apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInDoubleOutLambda {- double apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInDoubleOutLambda {- double apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInDoubleOutLambda {- double apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInDoubleOutLambda {- double apply(String a, String b);- }- // String Out- @FunctionalInterface- public static interface TwoBoolInStringOutLambda {- String apply(boolean a, boolean b);- }-- @FunctionalInterface- public static interface TwoIntInStringOutLambda {- String apply(int a, int b);- }-- @FunctionalInterface- public static interface TwoLongInStringOutLambda {- String apply(long a, long b);- }-- @FunctionalInterface- public static interface TwoFloatInStringOutLambda {- String apply(float a, float b);- }-- @FunctionalInterface- public static interface TwoDoubleInStringOutLambda {- String apply(double a, double b);- }-- @FunctionalInterface- public static interface TwoStringInStringOutLambda {- String apply(String a, String b);- }-- static class BooleanValueInBooleanValueOutFunction extends AbstractBooleanValue {- private final BooleanValue param;- private final BoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanValueInBooleanValueOutFunction(- String name, BoolInBoolOutLambda lambda, BooleanValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = lambda.apply(param.getBoolean());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamInBooleanStreamOutFunction extends AbstractBooleanValueStream {- private final BooleanValueStream param;- private final BoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamInBooleanStreamOutFunction(- String name, BoolInBoolOutLambda lambda, BooleanValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- param.streamBooleans(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamInBooleanValueOutFunction extends AbstractBooleanValue- implements BooleanConsumer {- private final BooleanValueStream param;- private final TwoBoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamInBooleanValueOutFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private boolean value;-- @Override- public boolean getBoolean() {- exists = false;- param.streamBooleans(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(boolean paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoBooleanValueInBooleanValueOutFunction extends AbstractBooleanValue {- private final BooleanValue param1;- private final BooleanValue param2;- private final TwoBoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoBooleanValueInBooleanValueOutFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue param1, BooleanValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = lambda.apply(param1.getBoolean(), param2.getBoolean());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanValueBooleanStreamInBooleanStreamOutFunction- extends AbstractBooleanValueStream {- private final BooleanValue param1;- private final BooleanValueStream param2;- private final TwoBoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanValueBooleanStreamInBooleanStreamOutFunction(- String name,- TwoBoolInBoolOutLambda lambda,- BooleanValue param1,- BooleanValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean value1 = param1.getBoolean();- if (param1.exists()) {- param2.streamBooleans(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamBooleanValueInBooleanStreamOutFunction- extends AbstractBooleanValueStream {- private final BooleanValueStream param1;- private final BooleanValue param2;- private final TwoBoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamBooleanValueInBooleanStreamOutFunction(- String name,- TwoBoolInBoolOutLambda lambda,- BooleanValueStream param1,- BooleanValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean value2 = param2.getBoolean();- if (param2.exists()) {- param1.streamBooleans(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiBooleanValueInBooleanValueOutFunction extends AbstractBooleanValue {- protected final BooleanValue[] params;- protected final TwoBoolInBoolOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiBooleanValueInBooleanValueOutFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected boolean temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiBooleanValueInBooleanValueOutRequireAllFunction- extends MultiBooleanValueInBooleanValueOutFunction {-- public MultiBooleanValueInBooleanValueOutRequireAllFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue[] params) {- super(name, lambda, params);- }-- @Override- public boolean getBoolean() {- boolean value = params[0].getBoolean();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getBoolean());- exists = params[i].exists();- }- return value;- }- }-- static class MultiBooleanValueInBooleanValueOutRequireOneFunction- extends MultiBooleanValueInBooleanValueOutFunction {-- public MultiBooleanValueInBooleanValueOutRequireOneFunction(- String name, TwoBoolInBoolOutLambda lambda, BooleanValue[] params) {- super(name, lambda, params);- }-- @Override- public boolean getBoolean() {- int i = -1;- boolean value = false;- exists = false;- while (++i < params.length) {- value = params[i].getBoolean();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getBoolean();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class IntValueInIntValueOutFunction extends AbstractIntValue {- private final IntValue param;- private final IntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public IntValueInIntValueOutFunction(String name, IntInIntOutLambda lambda, IntValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public int getInt() {- int value = lambda.apply(param.getInt());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamInIntStreamOutFunction extends AbstractIntValueStream {- private final IntValueStream param;- private final IntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamInIntStreamOutFunction(- String name, IntInIntOutLambda lambda, IntValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamInts(IntConsumer cons) {- param.streamInts(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamInIntValueOutFunction extends AbstractIntValue implements IntConsumer {- private final IntValueStream param;- private final TwoIntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamInIntValueOutFunction(- String name, TwoIntInIntOutLambda lambda, IntValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private int value;-- @Override- public int getInt() {- exists = false;- param.streamInts(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(int paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoIntValueInIntValueOutFunction extends AbstractIntValue {- private final IntValue param1;- private final IntValue param2;- private final TwoIntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoIntValueInIntValueOutFunction(- String name, TwoIntInIntOutLambda lambda, IntValue param1, IntValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public int getInt() {- int value = lambda.apply(param1.getInt(), param2.getInt());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntValueIntStreamInIntStreamOutFunction extends AbstractIntValueStream {- private final IntValue param1;- private final IntValueStream param2;- private final TwoIntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public IntValueIntStreamInIntStreamOutFunction(- String name, TwoIntInIntOutLambda lambda, IntValue param1, IntValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamInts(IntConsumer cons) {- int value1 = param1.getInt();- if (param1.exists()) {- param2.streamInts(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamIntValueInIntStreamOutFunction extends AbstractIntValueStream {- private final IntValueStream param1;- private final IntValue param2;- private final TwoIntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamIntValueInIntStreamOutFunction(- String name, TwoIntInIntOutLambda lambda, IntValueStream param1, IntValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamInts(IntConsumer cons) {- int value2 = param2.getInt();- if (param2.exists()) {- param1.streamInts(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiIntValueInIntValueOutFunction extends AbstractIntValue {- protected final IntValue[] params;- protected final TwoIntInIntOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiIntValueInIntValueOutFunction(- String name, TwoIntInIntOutLambda lambda, IntValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected int temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiIntValueInIntValueOutRequireAllFunction- extends MultiIntValueInIntValueOutFunction {-- public MultiIntValueInIntValueOutRequireAllFunction(- String name, TwoIntInIntOutLambda lambda, IntValue[] params) {- super(name, lambda, params);- }-- @Override- public int getInt() {- int value = params[0].getInt();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getInt());- exists = params[i].exists();- }- return value;- }- }-- static class MultiIntValueInIntValueOutRequireOneFunction- extends MultiIntValueInIntValueOutFunction {-- public MultiIntValueInIntValueOutRequireOneFunction(- String name, TwoIntInIntOutLambda lambda, IntValue[] params) {- super(name, lambda, params);- }-- @Override- public int getInt() {- int i = -1;- int value = 0;- exists = false;- while (++i < params.length) {- value = params[i].getInt();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getInt();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class LongValueInLongValueOutFunction extends AbstractLongValue {- private final LongValue param;- private final LongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public LongValueInLongValueOutFunction(- String name, LongInLongOutLambda lambda, LongValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public long getLong() {- long value = lambda.apply(param.getLong());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamInLongStreamOutFunction extends AbstractLongValueStream {- private final LongValueStream param;- private final LongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamInLongStreamOutFunction(- String name, LongInLongOutLambda lambda, LongValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamLongs(LongConsumer cons) {- param.streamLongs(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamInLongValueOutFunction extends AbstractLongValue implements LongConsumer {- private final LongValueStream param;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamInLongValueOutFunction(- String name, TwoLongInLongOutLambda lambda, LongValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private long value;-- @Override- public long getLong() {- exists = false;- param.streamLongs(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(long paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoLongValueInLongValueOutFunction extends AbstractLongValue {- private final LongValue param1;- private final LongValue param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoLongValueInLongValueOutFunction(- String name, TwoLongInLongOutLambda lambda, LongValue param1, LongValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public long getLong() {- long value = lambda.apply(param1.getLong(), param2.getLong());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongValueLongStreamInLongStreamOutFunction extends AbstractLongValueStream {- private final LongValue param1;- private final LongValueStream param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public LongValueLongStreamInLongStreamOutFunction(- String name, TwoLongInLongOutLambda lambda, LongValue param1, LongValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamLongs(LongConsumer cons) {- long value1 = param1.getLong();- if (param1.exists()) {- param2.streamLongs(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamLongValueInLongStreamOutFunction extends AbstractLongValueStream {- private final LongValueStream param1;- private final LongValue param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamLongValueInLongStreamOutFunction(- String name, TwoLongInLongOutLambda lambda, LongValueStream param1, LongValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamLongs(LongConsumer cons) {- long value2 = param2.getLong();- if (param2.exists()) {- param1.streamLongs(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiLongValueInLongValueOutFunction extends AbstractLongValue {- protected final LongValue[] params;- protected final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiLongValueInLongValueOutFunction(- String name, TwoLongInLongOutLambda lambda, LongValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected long temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiLongValueInLongValueOutRequireAllFunction- extends MultiLongValueInLongValueOutFunction {-- public MultiLongValueInLongValueOutRequireAllFunction(- String name, TwoLongInLongOutLambda lambda, LongValue[] params) {- super(name, lambda, params);- }-- @Override- public long getLong() {- long value = params[0].getLong();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getLong());- exists = params[i].exists();- }- return value;- }- }-- static class MultiLongValueInLongValueOutRequireOneFunction- extends MultiLongValueInLongValueOutFunction {-- public MultiLongValueInLongValueOutRequireOneFunction(- String name, TwoLongInLongOutLambda lambda, LongValue[] params) {- super(name, lambda, params);- }-- @Override- public long getLong() {- int i = -1;- long value = 0;- exists = false;- while (++i < params.length) {- value = params[i].getLong();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getLong();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class FloatValueInFloatValueOutFunction extends AbstractFloatValue {- private final FloatValue param;- private final FloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatValueInFloatValueOutFunction(- String name, FloatInFloatOutLambda lambda, FloatValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public float getFloat() {- float value = lambda.apply(param.getFloat());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamInFloatStreamOutFunction extends AbstractFloatValueStream {- private final FloatValueStream param;- private final FloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamInFloatStreamOutFunction(- String name, FloatInFloatOutLambda lambda, FloatValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamFloats(FloatConsumer cons) {- param.streamFloats(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamInFloatValueOutFunction extends AbstractFloatValue- implements FloatConsumer {- private final FloatValueStream param;- private final TwoFloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamInFloatValueOutFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private float value;-- @Override- public float getFloat() {- exists = false;- param.streamFloats(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(float paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoFloatValueInFloatValueOutFunction extends AbstractFloatValue {- private final FloatValue param1;- private final FloatValue param2;- private final TwoFloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoFloatValueInFloatValueOutFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue param1, FloatValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public float getFloat() {- float value = lambda.apply(param1.getFloat(), param2.getFloat());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatValueFloatStreamInFloatStreamOutFunction extends AbstractFloatValueStream {- private final FloatValue param1;- private final FloatValueStream param2;- private final TwoFloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatValueFloatStreamInFloatStreamOutFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue param1, FloatValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamFloats(FloatConsumer cons) {- float value1 = param1.getFloat();- if (param1.exists()) {- param2.streamFloats(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamFloatValueInFloatStreamOutFunction extends AbstractFloatValueStream {- private final FloatValueStream param1;- private final FloatValue param2;- private final TwoFloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamFloatValueInFloatStreamOutFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValueStream param1, FloatValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamFloats(FloatConsumer cons) {- float value2 = param2.getFloat();- if (param2.exists()) {- param1.streamFloats(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiFloatValueInFloatValueOutFunction extends AbstractFloatValue {- protected final FloatValue[] params;- protected final TwoFloatInFloatOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiFloatValueInFloatValueOutFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected float temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiFloatValueInFloatValueOutRequireAllFunction- extends MultiFloatValueInFloatValueOutFunction {-- public MultiFloatValueInFloatValueOutRequireAllFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue[] params) {- super(name, lambda, params);- }-- @Override- public float getFloat() {- float value = params[0].getFloat();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getFloat());- exists = params[i].exists();- }- return value;- }- }-- static class MultiFloatValueInFloatValueOutRequireOneFunction- extends MultiFloatValueInFloatValueOutFunction {-- public MultiFloatValueInFloatValueOutRequireOneFunction(- String name, TwoFloatInFloatOutLambda lambda, FloatValue[] params) {- super(name, lambda, params);- }-- @Override- public float getFloat() {- int i = -1;- float value = 0;- exists = false;- while (++i < params.length) {- value = params[i].getFloat();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getFloat();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class DoubleValueInDoubleValueOutFunction extends AbstractDoubleValue {- private final DoubleValue param;- private final DoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleValueInDoubleValueOutFunction(- String name, DoubleInDoubleOutLambda lambda, DoubleValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public double getDouble() {- double value = lambda.apply(param.getDouble());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamInDoubleStreamOutFunction extends AbstractDoubleValueStream {- private final DoubleValueStream param;- private final DoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamInDoubleStreamOutFunction(- String name, DoubleInDoubleOutLambda lambda, DoubleValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- param.streamDoubles(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamInDoubleValueOutFunction extends AbstractDoubleValue- implements DoubleConsumer {- private final DoubleValueStream param;- private final TwoDoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamInDoubleValueOutFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private double value;-- @Override- public double getDouble() {- exists = false;- param.streamDoubles(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(double paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoDoubleValueInDoubleValueOutFunction extends AbstractDoubleValue {- private final DoubleValue param1;- private final DoubleValue param2;- private final TwoDoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoDoubleValueInDoubleValueOutFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue param1, DoubleValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public double getDouble() {- double value = lambda.apply(param1.getDouble(), param2.getDouble());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleValueDoubleStreamInDoubleStreamOutFunction extends AbstractDoubleValueStream {- private final DoubleValue param1;- private final DoubleValueStream param2;- private final TwoDoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleValueDoubleStreamInDoubleStreamOutFunction(- String name,- TwoDoubleInDoubleOutLambda lambda,- DoubleValue param1,- DoubleValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double value1 = param1.getDouble();- if (param1.exists()) {- param2.streamDoubles(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamDoubleValueInDoubleStreamOutFunction extends AbstractDoubleValueStream {- private final DoubleValueStream param1;- private final DoubleValue param2;- private final TwoDoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamDoubleValueInDoubleStreamOutFunction(- String name,- TwoDoubleInDoubleOutLambda lambda,- DoubleValueStream param1,- DoubleValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double value2 = param2.getDouble();- if (param2.exists()) {- param1.streamDoubles(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiDoubleValueInDoubleValueOutFunction extends AbstractDoubleValue {- protected final DoubleValue[] params;- protected final TwoDoubleInDoubleOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiDoubleValueInDoubleValueOutFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected double temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiDoubleValueInDoubleValueOutRequireAllFunction- extends MultiDoubleValueInDoubleValueOutFunction {-- public MultiDoubleValueInDoubleValueOutRequireAllFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params) {- super(name, lambda, params);- }-- @Override- public double getDouble() {- double value = params[0].getDouble();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getDouble());- exists = params[i].exists();- }- return value;- }- }-- static class MultiDoubleValueInDoubleValueOutRequireOneFunction- extends MultiDoubleValueInDoubleValueOutFunction {-- public MultiDoubleValueInDoubleValueOutRequireOneFunction(- String name, TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params) {- super(name, lambda, params);- }-- @Override- public double getDouble() {- int i = -1;- double value = 0;- exists = false;- while (++i < params.length) {- value = params[i].getDouble();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getDouble();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class DateValueInDateValueOutFunction extends AbstractDateValue {- private final DateValue param;- private final LongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DateValueInDateValueOutFunction(- String name, LongInLongOutLambda lambda, DateValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public long getLong() {- long value = lambda.apply(param.getLong());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamInDateStreamOutFunction extends AbstractDateValueStream {- private final DateValueStream param;- private final LongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamInDateStreamOutFunction(- String name, LongInLongOutLambda lambda, DateValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamLongs(LongConsumer cons) {- param.streamLongs(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamInDateValueOutFunction extends AbstractDateValue implements LongConsumer {- private final DateValueStream param;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamInDateValueOutFunction(- String name, TwoLongInLongOutLambda lambda, DateValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private long value;-- @Override- public long getLong() {- exists = false;- param.streamLongs(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(long paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoDateValueInDateValueOutFunction extends AbstractDateValue {- private final DateValue param1;- private final DateValue param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoDateValueInDateValueOutFunction(- String name, TwoLongInLongOutLambda lambda, DateValue param1, DateValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public long getLong() {- long value = lambda.apply(param1.getLong(), param2.getLong());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateValueDateStreamInDateStreamOutFunction extends AbstractDateValueStream {- private final DateValue param1;- private final DateValueStream param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DateValueDateStreamInDateStreamOutFunction(- String name, TwoLongInLongOutLambda lambda, DateValue param1, DateValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamLongs(LongConsumer cons) {- long value1 = param1.getLong();- if (param1.exists()) {- param2.streamLongs(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamDateValueInDateStreamOutFunction extends AbstractDateValueStream {- private final DateValueStream param1;- private final DateValue param2;- private final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamDateValueInDateStreamOutFunction(- String name, TwoLongInLongOutLambda lambda, DateValueStream param1, DateValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamLongs(LongConsumer cons) {- long value2 = param2.getLong();- if (param2.exists()) {- param1.streamLongs(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiDateValueInDateValueOutFunction extends AbstractDateValue {- protected final DateValue[] params;- protected final TwoLongInLongOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiDateValueInDateValueOutFunction(- String name, TwoLongInLongOutLambda lambda, DateValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected long temp;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiDateValueInDateValueOutRequireAllFunction- extends LambdaFunction.MultiDateValueInDateValueOutFunction {-- public MultiDateValueInDateValueOutRequireAllFunction(- String name, TwoLongInLongOutLambda lambda, DateValue[] params) {- super(name, lambda, params);- }-- @Override- public long getLong() {- long value = params[0].getLong();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- value = lambda.apply(value, params[i].getLong());- exists = params[i].exists();- }- return value;- }- }-- static class MultiDateValueInDateValueOutRequireOneFunction- extends LambdaFunction.MultiDateValueInDateValueOutFunction {-- public MultiDateValueInDateValueOutRequireOneFunction(- String name, TwoLongInLongOutLambda lambda, DateValue[] params) {- super(name, lambda, params);- }-- @Override- public long getLong() {- int i = -1;- long value = 0;- exists = false;- while (++i < params.length) {- value = params[i].getLong();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getLong();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-- static class StringValueInStringValueOutFunction extends AbstractStringValue {- private final StringValue param;- private final StringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public StringValueInStringValueOutFunction(- String name, StringInStringOutLambda lambda, StringValue param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;-- @Override- public String getString() {- String value = lambda.apply(param.getString());- exists = param.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamInStringStreamOutFunction extends AbstractStringValueStream {- private final StringValueStream param;- private final StringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamInStringStreamOutFunction(- String name, StringInStringOutLambda lambda, StringValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- @Override- public void streamStrings(Consumer<String> cons) {- param.streamStrings(value -> cons.accept(lambda.apply(value)));- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamInStringValueOutFunction extends AbstractStringValue- implements Consumer<String> {- private final StringValueStream param;- private final TwoStringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamInStringValueOutFunction(- String name, TwoStringInStringOutLambda lambda, StringValueStream param) {- this.name = name;- this.lambda = lambda;- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param);- }-- private boolean exists = false;- private String value;-- @Override- public String getString() {- exists = false;- param.streamStrings(this);- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public void accept(String paramValue) {- if (!exists) {- exists = true;- value = paramValue;- } else {- value = lambda.apply(value, paramValue);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class TwoStringValueInStringValueOutFunction extends AbstractStringValue {- private final StringValue param1;- private final StringValue param2;- private final TwoStringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public TwoStringValueInStringValueOutFunction(- String name, TwoStringInStringOutLambda lambda, StringValue param1, StringValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- private boolean exists = false;-- @Override- public String getString() {- String value = lambda.apply(param1.getString(), param2.getString());- exists = param1.exists() && param2.exists();- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringValueStringStreamInStringStreamOutFunction extends AbstractStringValueStream {- private final StringValue param1;- private final StringValueStream param2;- private final TwoStringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public StringValueStringStreamInStringStreamOutFunction(- String name,- TwoStringInStringOutLambda lambda,- StringValue param1,- StringValueStream param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamStrings(Consumer<String> cons) {- String value1 = param1.getString();- if (param1.exists()) {- param2.streamStrings(value2 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamStringValueInStringStreamOutFunction extends AbstractStringValueStream {- private final StringValueStream param1;- private final StringValue param2;- private final TwoStringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamStringValueInStringStreamOutFunction(- String name,- TwoStringInStringOutLambda lambda,- StringValueStream param1,- StringValue param2) {- this.name = name;- this.lambda = lambda;- this.param1 = param1;- this.param2 = param2;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param1, param2);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, param1, param2);- }-- @Override- public void streamStrings(Consumer<String> cons) {- String value2 = param2.getString();- if (param2.exists()) {- param1.streamStrings(value1 -> cons.accept(lambda.apply(value1, value2)));- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- abstract static class MultiStringValueInStringValueOutFunction extends AbstractStringValue {- protected final StringValue[] params;- protected final TwoStringInStringOutLambda lambda;- private final String name;- private final String exprStr;- private final ExpressionType funcType;-- public MultiStringValueInStringValueOutFunction(- String name, TwoStringInStringOutLambda lambda, StringValue[] params) {- this.name = name;- this.lambda = lambda;- this.params = params;- this.exprStr = AnalyticsValueStream.createExpressionString(name, params);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, params);- }-- protected boolean exists = false;- protected String temp = null;-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class MultiStringValueInStringValueOutRequireAllFunction- extends MultiStringValueInStringValueOutFunction {-- public MultiStringValueInStringValueOutRequireAllFunction(- String name, TwoStringInStringOutLambda lambda, StringValue[] params) {- super(name, lambda, params);- }-- @Override- public String getString() {- String value = params[0].getString();- exists = params[0].exists();- for (int i = 1; i < params.length && exists; ++i) {- temp = params[i].getString();- if (params[i].exists()) {- value = lambda.apply(value, temp);- } else {- exists = false;- value = null;- }- }- return value;- }- }-- static class MultiStringValueInStringValueOutRequireOneFunction- extends MultiStringValueInStringValueOutFunction {-- public MultiStringValueInStringValueOutRequireOneFunction(- String name, TwoStringInStringOutLambda lambda, StringValue[] params) {- super(name, lambda, params);- }-- @Override- public String getString() {- int i = -1;- String value = null;- exists = false;- while (++i < params.length) {- value = params[i].getString();- exists = params[i].exists();- if (exists) {- break;- }- }- while (++i < params.length) {- temp = params[i].getString();- if (params[i].exists()) {- value = lambda.apply(value, temp);- }- }- return value;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogFunction.javadeleted file mode 100644index 1fb035edc47..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogFunction.java+++ /dev/null@@ -1,67 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A logarithm mapping function.- *- * <p>Uses:- *- * <ul>- * <li>If one numeric Value or ValueStream is passed in, a {@link DoubleValue} or {@link- * DoubleValueStream} representing the natural logarithm is returned.- * <li>If two numeric Values are passed in, a {@link DoubleValue} representing the logarithm of- * the first with the second as the base is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the logarithm of the Value with each of the values of the ValueStream for a- * document as the base is returned. (Or the other way, since the Value and ValueStream can be- * used in either order)- * </ul>- */-public class LogFunction {- public static final String name = "log";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires at least 1.");- } else if (params.length == 1) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a) -> Math.log(a), (DoubleValueStream) params[0]);- } else if (params.length == 2) {- return LambdaFunction.createDoubleLambdaFunction(- name,- (a, b) -> Math.log(a) / Math.log(b),- (DoubleValueStream) params[0],- (DoubleValueStream) params[1]);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function accepts at most 2 paramaters, "- + params.length- + " found.");- }- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogicFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogicFunction.javadeleted file mode 100644index 295d460cd5a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/LogicFunction.java+++ /dev/null@@ -1,104 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.mapping.LambdaFunction.TwoBoolInBoolOutLambda;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * Contains all logical mapping functions.- *- * <p>Logical mapping functions can be used in the following ways:- *- * <ul>- * <li>If a single {@link BooleanValueStream} is passed in, a {@link BooleanValue} representing- * the logical operation on all of the values for each document is returned.- * <li>If a {@link BooleanValueStream} and a {@link BooleanValue} are passed in, a {@link- * BooleanValue} representing the logical operation on the {@link BooleanValue} and each of- * the values of the {@link BooleanValueStream} for a document is returned. (Or the other way,- * since the Value and ValueStream can be used in either order)- * <li>If multiple {@link BooleanValue}s are passed in, a {@link BooleanValue} representing the- * logical operation on all values is returned.- * </ul>- */-public class LogicFunction {-- private static BooleanValueStream createBitwiseFunction(- String name, TwoBoolInBoolOutLambda comp, AnalyticsValueStream... params) {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires parameters.");- } else if (params.length == 1) {- if (params[0] instanceof BooleanValueStream) {- return LambdaFunction.createBooleanLambdaFunction(- name, comp, (BooleanValueStream) params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires boolean parameters. Incorrect param: "- + params[0].getExpressionStr());- } else if (params.length == 2) {- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof BooleanValueStream && param2 instanceof BooleanValueStream) {- return LambdaFunction.createBooleanLambdaFunction(- name, comp, (BooleanValueStream) param1, (BooleanValueStream) param2);- }- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires boolean parameters.");- }- BooleanValue[] castedParams = new BooleanValue[params.length];- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof BooleanValue) {- castedParams[i] = (BooleanValue) params[i];- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires that all parameters be single-valued if more than 2 are given.");- }- }- return LambdaFunction.createBooleanLambdaFunction(name, comp, castedParams);- }- ;-- /** A mapping function for the logical operation AND. */- public static class AndFunction {- public static final String name = "and";- public static final CreatorFunction creatorFunction =- (params -> {- return LogicFunction.createBitwiseFunction(name, (a, b) -> a && b, params);- });- }-- /** A mapping function for the logical operation OR. */- public static class OrFunction {- public static final String name = "or";- public static final CreatorFunction creatorFunction =- (params -> {- return LogicFunction.createBitwiseFunction(name, (a, b) -> a || b, params);- });- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/MultFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/MultFunction.javadeleted file mode 100644index ebb177c9eb5..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/MultFunction.java+++ /dev/null@@ -1,84 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * An multiplication mapping function.- *- * <p>Uses:- *- * <ul>- * <li>If a single numeric ValueStream is passed in, a {@link DoubleValue} representing the- * multiplication of the values for each document is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the multiplication of the Value and each of the values of the ValueStream for- * a document is returned. (Or the other way, since the Value and ValueStream can be used in- * either order)- * <li>If multiple numeric Values are passed in, a {@link DoubleValue} representing the- * multiplication of all values is returned.- * </ul>- */-public class MultFunction {- public static final String name = "mult";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires parameters.");- } else if (params.length == 1) {- if (params[0] instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a * b, (DoubleValueStream) params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires numeric parameters. Incorrect param: "- + params[0].getExpressionStr());- } else if (params.length == 2) {- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof DoubleValueStream && param2 instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a * b, (DoubleValueStream) param1, (DoubleValueStream) param2);- }- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires numeric parameters.");- }- DoubleValue[] castedParams = new DoubleValue[params.length];- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DoubleValue) {- castedParams[i] = (DoubleValue) params[i];- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires that all parameters be single-valued if more than 2 are given.");- }- }- return LambdaFunction.createDoubleLambdaFunction(name, (a, b) -> a * b, castedParams);- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/NegateFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/NegateFunction.javadeleted file mode 100644index 4159c71dc63..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/NegateFunction.java+++ /dev/null@@ -1,72 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A negation mapping function.- *- * <p>Takes a numeric or boolean ValueStream or Value and returns a ValueStream or Value of the same- * numeric type.- */-public class NegateFunction {- public static final String name = "neg";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof BooleanValueStream) {- return LambdaFunction.createBooleanLambdaFunction(- name, x -> !x, (BooleanValueStream) param);- }- if (param instanceof IntValueStream) {- return LambdaFunction.createIntLambdaFunction(name, x -> x * -1, (IntValueStream) param);- }- if (param instanceof LongValueStream) {- return LambdaFunction.createLongLambdaFunction(- name, x -> x * -1, (LongValueStream) param);- }- if (param instanceof FloatValueStream) {- return LambdaFunction.createFloatLambdaFunction(- name, x -> x * -1, (FloatValueStream) param);- }- if (param instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, x -> x * -1, (DoubleValueStream) param);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a boolean or numeric parameter, "- + param.getExpressionStr()- + " found.");- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/PowerFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/PowerFunction.javadeleted file mode 100644index f8387000e9a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/PowerFunction.java+++ /dev/null@@ -1,62 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A power mapping function.- *- * <p>Uses:- *- * <ul>- * <li>If two numeric Values are passed in, a {@link DoubleValue} representing the first taken to- * the power of the second is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the power of the Value to each of the values of the ValueStream for a document- * is returned. (Or the other way, since the Value and ValueStream can be used in either- * order)- * </ul>- */-public class PowerFunction {- public static final String name = "pow";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof DoubleValueStream && param2 instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name,- (a, b) -> Math.pow(a, b),- (DoubleValueStream) param1,- (DoubleValueStream) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires numeric parameters.");- }- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/RemoveFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/RemoveFunction.javadeleted file mode 100644index 55b86e218bc..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/RemoveFunction.java+++ /dev/null@@ -1,874 +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.function.mapping;--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.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function to remove an {@link AnalyticsValue} from an {@link AnalyticsValue} or an- * {@link AnalyticsValueStream}. For each document, the value exists if it doesn't equal the value- * of the second parameter.- *- * <p>The first parameter can be any type of analytics expression. If the parameter is multi-valued,- * then the return will be multi-valued. (Required) <br>- * The second parameter, which is the value to remove from the first parameter, must be an {@link- * AnalyticsValue}, aka single-valued. (Required)- *- * <p>The resulting Value or ValueStream will be typed with the closest super-type of the two- * parameters. (e.g. {@value #name}(int,float) will return a float)- */-public class RemoveFunction {- public static final String name = "remove";-- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- if (!(params[1] instanceof AnalyticsValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires the remove (2nd) paramater to be single-valued.");- }-- AnalyticsValueStream baseExpr = params[0];- AnalyticsValue removeExpr = (AnalyticsValue) params[1];-- if (baseExpr instanceof DateValue && removeExpr instanceof DateValue) {- return new DateRemoveFunction((DateValue) baseExpr, (DateValue) removeExpr);- }- if (baseExpr instanceof DateValueStream && removeExpr instanceof DateValue) {- return new DateStreamRemoveFunction((DateValueStream) baseExpr, (DateValue) removeExpr);- }- if (baseExpr instanceof BooleanValue && removeExpr instanceof BooleanValue) {- return new BooleanRemoveFunction((BooleanValue) baseExpr, (BooleanValue) removeExpr);- }- if (baseExpr instanceof BooleanValueStream && removeExpr instanceof BooleanValue) {- return new BooleanStreamRemoveFunction(- (BooleanValueStream) baseExpr, (BooleanValue) removeExpr);- }- if (baseExpr instanceof IntValue && removeExpr instanceof IntValue) {- return new IntRemoveFunction((IntValue) baseExpr, (IntValue) removeExpr);- }- if (baseExpr instanceof IntValueStream && removeExpr instanceof IntValue) {- return new IntStreamRemoveFunction((IntValueStream) baseExpr, (IntValue) removeExpr);- }- if (baseExpr instanceof LongValue && removeExpr instanceof LongValue) {- return new LongRemoveFunction((LongValue) baseExpr, (LongValue) removeExpr);- }- if (baseExpr instanceof LongValueStream && removeExpr instanceof LongValue) {- return new LongStreamRemoveFunction((LongValueStream) baseExpr, (LongValue) removeExpr);- }- if (baseExpr instanceof FloatValue && removeExpr instanceof FloatValue) {- return new FloatRemoveFunction((FloatValue) baseExpr, (FloatValue) removeExpr);- }- if (baseExpr instanceof FloatValueStream && removeExpr instanceof FloatValue) {- return new FloatStreamRemoveFunction(- (FloatValueStream) baseExpr, (FloatValue) removeExpr);- }- if (baseExpr instanceof DoubleValue && removeExpr instanceof DoubleValue) {- return new DoubleRemoveFunction((DoubleValue) baseExpr, (DoubleValue) removeExpr);- }- if (baseExpr instanceof DoubleValueStream && removeExpr instanceof DoubleValue) {- return new DoubleStreamRemoveFunction(- (DoubleValueStream) baseExpr, (DoubleValue) removeExpr);- }- if (baseExpr instanceof StringValue && removeExpr instanceof StringValue) {- return new StringRemoveFunction((StringValue) baseExpr, (StringValue) removeExpr);- }- if (baseExpr instanceof StringValueStream && removeExpr instanceof StringValue) {- return new StringStreamRemoveFunction(- (StringValueStream) baseExpr, (StringValue) removeExpr);- }- if (baseExpr instanceof AnalyticsValue) {- return new ValueRemoveFunction((AnalyticsValue) baseExpr, removeExpr);- }- return new StreamRemoveFunction(baseExpr, removeExpr);- });-- static class StreamRemoveFunction extends AbstractAnalyticsValueStream {- private final AnalyticsValueStream baseExpr;- private final AnalyticsValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StreamRemoveFunction(AnalyticsValueStream baseExpr, AnalyticsValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object removeValue = removeExpr.getObject();- if (removeExpr.exists()) {- baseExpr.streamObjects(- value -> {- if (!removeValue.equals(value)) cons.accept(value);- });- } else {- baseExpr.streamObjects(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class ValueRemoveFunction extends AbstractAnalyticsValue {- private final AnalyticsValue baseExpr;- private final AnalyticsValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueRemoveFunction(AnalyticsValue baseExpr, AnalyticsValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public Object getObject() {- Object value = baseExpr.getObject();- exists = false;- if (baseExpr.exists()) {- exists = value.equals(removeExpr.getObject()) ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamRemoveFunction extends AbstractBooleanValueStream {- private final BooleanValueStream baseExpr;- private final BooleanValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamRemoveFunction(BooleanValueStream baseExpr, BooleanValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean removeValue = removeExpr.getBoolean();- if (removeExpr.exists()) {- baseExpr.streamBooleans(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamBooleans(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanRemoveFunction extends AbstractBooleanValue {- private final BooleanValue baseExpr;- private final BooleanValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanRemoveFunction(BooleanValue baseExpr, BooleanValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = baseExpr.getBoolean();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getBoolean() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamRemoveFunction extends AbstractIntValueStream {- private final IntValueStream baseExpr;- private final IntValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamRemoveFunction(IntValueStream baseExpr, IntValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamInts(IntConsumer cons) {- int removeValue = removeExpr.getInt();- if (removeExpr.exists()) {- baseExpr.streamInts(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamInts(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntRemoveFunction extends AbstractIntValue {- private final IntValue baseExpr;- private final IntValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntRemoveFunction(IntValue baseExpr, IntValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public int getInt() {- int value = baseExpr.getInt();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getInt() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamRemoveFunction extends AbstractLongValueStream {- private final LongValueStream baseExpr;- private final LongValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamRemoveFunction(LongValueStream baseExpr, LongValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- long removeValue = removeExpr.getLong();- if (removeExpr.exists()) {- baseExpr.streamLongs(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongRemoveFunction extends AbstractLongValue {- private final LongValue baseExpr;- private final LongValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongRemoveFunction(LongValue baseExpr, LongValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getLong() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamRemoveFunction extends AbstractFloatValueStream {- private final FloatValueStream baseExpr;- private final FloatValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamRemoveFunction(FloatValueStream baseExpr, FloatValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamFloats(FloatConsumer cons) {- float removeValue = removeExpr.getFloat();- if (removeExpr.exists()) {- baseExpr.streamFloats(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamFloats(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatRemoveFunction extends AbstractFloatValue {- private final FloatValue baseExpr;- private final FloatValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatRemoveFunction(FloatValue baseExpr, FloatValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public float getFloat() {- float value = baseExpr.getFloat();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getFloat() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamRemoveFunction extends AbstractDoubleValueStream {- private final DoubleValueStream baseExpr;- private final DoubleValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamRemoveFunction(DoubleValueStream baseExpr, DoubleValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double removeValue = removeExpr.getDouble();- if (removeExpr.exists()) {- baseExpr.streamDoubles(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamDoubles(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleRemoveFunction extends AbstractDoubleValue {- private final DoubleValue baseExpr;- private final DoubleValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleRemoveFunction(DoubleValue baseExpr, DoubleValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public double getDouble() {- double value = baseExpr.getDouble();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getDouble() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamRemoveFunction extends AbstractDateValueStream {- private final DateValueStream baseExpr;- private final DateValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamRemoveFunction(DateValueStream baseExpr, DateValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- long removeValue = removeExpr.getLong();- if (removeExpr.exists()) {- baseExpr.streamLongs(- value -> {- if (removeValue != value) cons.accept(value);- });- } else {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateRemoveFunction extends AbstractDateValue {- private final DateValue baseExpr;- private final DateValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateRemoveFunction(DateValue baseExpr, DateValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = false;- if (baseExpr.exists()) {- exists = value == removeExpr.getLong() ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamRemoveFunction extends AbstractStringValueStream {- private final StringValueStream baseExpr;- private final StringValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamRemoveFunction(StringValueStream baseExpr, StringValue removeExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- @Override- public void streamStrings(Consumer<String> cons) {- String removeValue = removeExpr.getString();- if (removeExpr.exists()) {- baseExpr.streamStrings(- value -> {- if (!removeValue.equals(value)) cons.accept(value);- });- } else {- baseExpr.streamStrings(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringRemoveFunction extends AbstractStringValue {- private final StringValue baseExpr;- private final StringValue removeExpr;- public static final String name = RemoveFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringRemoveFunction(StringValue baseExpr, StringValue removeExpr) throws SolrException {- this.baseExpr = baseExpr;- this.removeExpr = removeExpr;- this.exprStr = AnalyticsValueStream.createExpressionString(name, baseExpr, removeExpr);- this.funcType = AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, removeExpr);- }-- boolean exists = false;-- @Override- public String getString() {- String value = baseExpr.getString();- exists = false;- if (baseExpr.exists()) {- exists = value.equals(removeExpr.getString()) ? (removeExpr.exists() ? false : true) : true;- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ReplaceFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ReplaceFunction.javadeleted file mode 100644index 00014b814e2..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/ReplaceFunction.java+++ /dev/null@@ -1,1073 +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.function.mapping;--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.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function to replace an {@link AnalyticsValue} from an {@link AnalyticsValue} or an- * {@link AnalyticsValueStream} with a different {@link AnalyticsValue}. For each document, all- * values from the base parameter matching the comparison parameter will be replaced with the fill- * parameter.- *- * <p>The first parameter can be any type of analytics expression. If the parameter is multi-valued,- * then the return will be multi-valued. (Required) <br>- * The second parameter, which is the value to compare to the first parameter, must be an {@link- * AnalyticsValue}, aka single-valued. (Required) <br>- * The third parameter, which is the value to fill the first parameter with, must be an {@link- * AnalyticsValue}, aka single-valued. (Required)- *- * <p>The resulting Value or ValueStream will be typed with the closest super-type of the three- * parameters. (e.g. {@value #name}(double,int,float) will return a double)- */-public class ReplaceFunction {- public static final String name = "replace";-- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 3) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 3 paramaters, " + params.length + " found.");- }- if (!(params[1] instanceof AnalyticsValue && params[2] instanceof AnalyticsValue)) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires the comparator and fill parameters to be single-valued.");- }-- AnalyticsValueStream baseExpr = params[0];- AnalyticsValue compExpr = (AnalyticsValue) params[1];- AnalyticsValue fillExpr = (AnalyticsValue) params[2];-- if (baseExpr instanceof DateValue- && compExpr instanceof DateValue- && fillExpr instanceof DateValue) {- return new DateReplaceFunction(- (DateValue) baseExpr, (DateValue) compExpr, (DateValue) fillExpr);- }- if (baseExpr instanceof DateValueStream- && compExpr instanceof DateValue- && fillExpr instanceof DateValue) {- return new DateStreamReplaceFunction(- (DateValueStream) baseExpr, (DateValue) compExpr, (DateValue) fillExpr);- }- if (baseExpr instanceof BooleanValue- && compExpr instanceof BooleanValue- && fillExpr instanceof BooleanValue) {- return new BooleanReplaceFunction(- (BooleanValue) baseExpr, (BooleanValue) compExpr, (BooleanValue) fillExpr);- }- if (baseExpr instanceof BooleanValueStream- && compExpr instanceof BooleanValue- && fillExpr instanceof BooleanValue) {- return new BooleanStreamReplaceFunction(- (BooleanValueStream) baseExpr, (BooleanValue) compExpr, (BooleanValue) fillExpr);- }- if (baseExpr instanceof IntValue- && compExpr instanceof IntValue- && fillExpr instanceof IntValue) {- return new IntReplaceFunction(- (IntValue) baseExpr, (IntValue) compExpr, (IntValue) fillExpr);- }- if (baseExpr instanceof IntValueStream- && compExpr instanceof IntValue- && fillExpr instanceof IntValue) {- return new IntStreamReplaceFunction(- (IntValueStream) baseExpr, (IntValue) compExpr, (IntValue) fillExpr);- }- if (baseExpr instanceof LongValue- && compExpr instanceof LongValue- && fillExpr instanceof LongValue) {- return new LongReplaceFunction(- (LongValue) baseExpr, (LongValue) compExpr, (LongValue) fillExpr);- }- if (baseExpr instanceof LongValueStream- && compExpr instanceof LongValue- && fillExpr instanceof LongValue) {- return new LongStreamReplaceFunction(- (LongValueStream) baseExpr, (LongValue) compExpr, (LongValue) fillExpr);- }- if (baseExpr instanceof FloatValue- && compExpr instanceof FloatValue- && fillExpr instanceof FloatValue) {- return new FloatReplaceFunction(- (FloatValue) baseExpr, (FloatValue) compExpr, (FloatValue) fillExpr);- }- if (baseExpr instanceof FloatValueStream- && compExpr instanceof FloatValue- && fillExpr instanceof FloatValue) {- return new FloatStreamReplaceFunction(- (FloatValueStream) baseExpr, (FloatValue) compExpr, (FloatValue) fillExpr);- }- if (baseExpr instanceof DoubleValue- && compExpr instanceof DoubleValue- && fillExpr instanceof DoubleValue) {- return new DoubleReplaceFunction(- (DoubleValue) baseExpr, (DoubleValue) compExpr, (DoubleValue) fillExpr);- }- if (baseExpr instanceof DoubleValueStream- && compExpr instanceof DoubleValue- && fillExpr instanceof DoubleValue) {- return new DoubleStreamReplaceFunction(- (DoubleValueStream) baseExpr, (DoubleValue) compExpr, (DoubleValue) fillExpr);- }- if (baseExpr instanceof StringValue- && compExpr instanceof StringValue- && fillExpr instanceof StringValue) {- return new StringReplaceFunction(- (StringValue) baseExpr, (StringValue) compExpr, (StringValue) fillExpr);- }- if (baseExpr instanceof StringValueStream- && compExpr instanceof StringValue- && fillExpr instanceof StringValue) {- return new StringStreamReplaceFunction(- (StringValueStream) baseExpr, (StringValue) compExpr, (StringValue) fillExpr);- }- if (baseExpr instanceof AnalyticsValue) {- return new ValueReplaceFunction((AnalyticsValue) baseExpr, compExpr, fillExpr);- }- return new StreamReplaceFunction(baseExpr, compExpr, fillExpr);- });-- static class StreamReplaceFunction extends AbstractAnalyticsValueStream {- private final AnalyticsValueStream baseExpr;- private final AnalyticsValue compExpr;- private final AnalyticsValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StreamReplaceFunction(- AnalyticsValueStream baseExpr, AnalyticsValue compExpr, AnalyticsValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object compValue = compExpr.getObject();- if (compExpr.exists()) {- final Object fillValue = fillExpr.getObject();- final boolean fillExists = fillExpr.exists();- baseExpr.streamObjects(- value -> {- if (value.equals(compValue)) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamObjects(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class ValueReplaceFunction extends AbstractAnalyticsValue {- private final AnalyticsValue baseExpr;- private final AnalyticsValue compExpr;- private final AnalyticsValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public ValueReplaceFunction(- AnalyticsValue baseExpr, AnalyticsValue compExpr, AnalyticsValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public Object getObject() {- Object value = baseExpr.getObject();- exists = baseExpr.exists();- Object comp = compExpr.getObject();- if (exists && compExpr.exists() && value.equals(comp)) {- value = fillExpr.getObject();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanStreamReplaceFunction extends AbstractBooleanValueStream {- private final BooleanValueStream baseExpr;- private final BooleanValue compExpr;- private final BooleanValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanStreamReplaceFunction(- BooleanValueStream baseExpr, BooleanValue compExpr, BooleanValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean compValue = compExpr.getBoolean();- if (compExpr.exists()) {- final boolean fillValue = fillExpr.getBoolean();- final boolean fillExists = fillExpr.exists();- baseExpr.streamBooleans(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamBooleans(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class BooleanReplaceFunction extends AbstractBooleanValue {- private final BooleanValue baseExpr;- private final BooleanValue compExpr;- private final BooleanValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public BooleanReplaceFunction(- BooleanValue baseExpr, BooleanValue compExpr, BooleanValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public boolean getBoolean() {- boolean value = baseExpr.getBoolean();- exists = baseExpr.exists();- boolean comp = compExpr.getBoolean();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getBoolean();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntStreamReplaceFunction extends AbstractIntValueStream {- private final IntValueStream baseExpr;- private final IntValue compExpr;- private final IntValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntStreamReplaceFunction(IntValueStream baseExpr, IntValue compExpr, IntValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamInts(IntConsumer cons) {- int compValue = compExpr.getInt();- if (compExpr.exists()) {- final int fillValue = fillExpr.getInt();- final boolean fillExists = fillExpr.exists();- baseExpr.streamInts(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamInts(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class IntReplaceFunction extends AbstractIntValue {- private final IntValue baseExpr;- private final IntValue compExpr;- private final IntValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public IntReplaceFunction(IntValue baseExpr, IntValue compExpr, IntValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public int getInt() {- int value = baseExpr.getInt();- exists = baseExpr.exists();- int comp = compExpr.getInt();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getInt();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongStreamReplaceFunction extends AbstractLongValueStream {- private final LongValueStream baseExpr;- private final LongValue compExpr;- private final LongValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongStreamReplaceFunction(- LongValueStream baseExpr, LongValue compExpr, LongValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- long compValue = compExpr.getLong();- if (compExpr.exists()) {- final long fillValue = fillExpr.getLong();- final boolean fillExists = fillExpr.exists();- baseExpr.streamLongs(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class LongReplaceFunction extends AbstractLongValue {- private final LongValue baseExpr;- private final LongValue compExpr;- private final LongValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public LongReplaceFunction(LongValue baseExpr, LongValue compExpr, LongValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = baseExpr.exists();- long comp = compExpr.getLong();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getLong();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatStreamReplaceFunction extends AbstractFloatValueStream {- private final FloatValueStream baseExpr;- private final FloatValue compExpr;- private final FloatValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatStreamReplaceFunction(- FloatValueStream baseExpr, FloatValue compExpr, FloatValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamFloats(FloatConsumer cons) {- float compValue = compExpr.getFloat();- if (compExpr.exists()) {- final float fillValue = fillExpr.getFloat();- final boolean fillExists = fillExpr.exists();- baseExpr.streamFloats(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamFloats(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class FloatReplaceFunction extends AbstractFloatValue {- private final FloatValue baseExpr;- private final FloatValue compExpr;- private final FloatValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public FloatReplaceFunction(FloatValue baseExpr, FloatValue compExpr, FloatValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public float getFloat() {- float value = baseExpr.getFloat();- exists = baseExpr.exists();- float comp = compExpr.getFloat();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getFloat();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleStreamReplaceFunction extends AbstractDoubleValueStream {- private final DoubleValueStream baseExpr;- private final DoubleValue compExpr;- private final DoubleValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleStreamReplaceFunction(- DoubleValueStream baseExpr, DoubleValue compExpr, DoubleValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double compValue = compExpr.getDouble();- if (compExpr.exists()) {- final double fillValue = fillExpr.getDouble();- final boolean fillExists = fillExpr.exists();- baseExpr.streamDoubles(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamDoubles(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DoubleReplaceFunction extends AbstractDoubleValue {- private final DoubleValue baseExpr;- private final DoubleValue compExpr;- private final DoubleValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DoubleReplaceFunction(DoubleValue baseExpr, DoubleValue compExpr, DoubleValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public double getDouble() {- double value = baseExpr.getDouble();- exists = baseExpr.exists();- double comp = compExpr.getDouble();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getDouble();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateStreamReplaceFunction extends AbstractDateValueStream {- private final DateValueStream baseExpr;- private final DateValue compExpr;- private final DateValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateStreamReplaceFunction(- DateValueStream baseExpr, DateValue compExpr, DateValue fillExpr) throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamLongs(LongConsumer cons) {- long compValue = compExpr.getLong();- if (compExpr.exists()) {- final long fillValue = fillExpr.getLong();- final boolean fillExists = fillExpr.exists();- baseExpr.streamLongs(- value -> {- if (value == compValue) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamLongs(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class DateReplaceFunction extends AbstractDateValue {- private final DateValue baseExpr;- private final DateValue compExpr;- private final DateValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public DateReplaceFunction(DateValue baseExpr, DateValue compExpr, DateValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public long getLong() {- long value = baseExpr.getLong();- exists = baseExpr.exists();- long comp = compExpr.getLong();- if (exists && compExpr.exists() && value == comp) {- value = fillExpr.getLong();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringStreamReplaceFunction extends AbstractStringValueStream {- private final StringValueStream baseExpr;- private final StringValue compExpr;- private final StringValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringStreamReplaceFunction(- StringValueStream baseExpr, StringValue compExpr, StringValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- @Override- public void streamStrings(Consumer<String> cons) {- String compValue = compExpr.getString();- if (compExpr.exists()) {- final String fillValue = fillExpr.getString();- final boolean fillExists = fillExpr.exists();- baseExpr.streamStrings(- value -> {- if (value.equals(compValue)) {- if (fillExists) {- cons.accept(fillValue);- }- } else {- cons.accept(value);- }- });- } else {- baseExpr.streamStrings(cons);- }- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-- static class StringReplaceFunction extends AbstractStringValue {- private final StringValue baseExpr;- private final StringValue compExpr;- private final StringValue fillExpr;- public static final String name = ReplaceFunction.name;- private final String exprStr;- private final ExpressionType funcType;-- public StringReplaceFunction(StringValue baseExpr, StringValue compExpr, StringValue fillExpr)- throws SolrException {- this.baseExpr = baseExpr;- this.compExpr = compExpr;- this.fillExpr = fillExpr;- this.exprStr =- AnalyticsValueStream.createExpressionString(name, baseExpr, compExpr, fillExpr);- this.funcType =- AnalyticsValueStream.determineMappingPhase(exprStr, baseExpr, compExpr, fillExpr);- }-- boolean exists = false;-- @Override- public String getString() {- String value = baseExpr.getString();- exists = baseExpr.exists();- String comp = compExpr.getString();- if (exists && compExpr.exists() && value.equals(comp)) {- value = fillExpr.getString();- exists = fillExpr.exists();- }- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return funcType;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/StringCastFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/StringCastFunction.javadeleted file mode 100644index 16b139a6555..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/StringCastFunction.java+++ /dev/null@@ -1,47 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A mapping function that casts any input to a {@link StringValue} or {@link StringValueStream}.- */-public class StringCastFunction {- public static final String name = "string";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof StringValueStream) {- return LambdaFunction.createStringLambdaFunction(name, a -> a, (StringValueStream) param);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires a string-castable parameter.");- }- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/SubtractFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/SubtractFunction.javadeleted file mode 100644index 4fb818f2028..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/SubtractFunction.java+++ /dev/null@@ -1,59 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A subtraction mapping function.- *- * <p>Uses:- *- * <ul>- * <li>If two numeric Values are passed in, a {@link DoubleValue} representing the first- * subtracted by the second is returned.- * <li>If a numeric ValueStream and a numeric Value are passed in, a {@link DoubleValueStream}- * representing the Value subtracted by each of the values of the ValueStream for a document- * is returned. (Or the other way, since the Value and ValueStream can be used in either- * order)- * </ul>- */-public class SubtractFunction {- public static final String name = "sub";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramaters, " + params.length + " found.");- }- AnalyticsValueStream param1 = params[0];- AnalyticsValueStream param2 = params[1];- if (param1 instanceof DoubleValueStream && param2 instanceof DoubleValueStream) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> a - b, (DoubleValueStream) param1, (DoubleValueStream) param2);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires numeric parameters.");- }- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/TopFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/TopFunction.javadeleted file mode 100644index bc91682f03b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/TopFunction.java+++ /dev/null@@ -1,185 +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.function.mapping;--import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A top mapping function, returning the highest value found.- *- * <p>Uses:- *- * <ul>- * <li>If a single comparable ValueStream is passed in, a Value (of the same type) representing- * the maximum of the values for each document is returned.- * <li>If multiple comparable Values are passed in, a Value (of the same type) representing the- * maximum of all values is returned.- * </ul>- */-public class TopFunction {- public static final String name = "top";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires paramaters.");- }- AnalyticsValueStream param = params[0];- if (param instanceof DateValueStream) {- if (params.length == 1) {- return LambdaFunction.createDateLambdaFunction(- name, (a, b) -> (a > b) ? a : b, (DateValueStream) param);- }- DateValue[] castedParams = new DateValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DateValue) {- castedParams[i] = (DateValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createDateLambdaFunction(- name, (a, b) -> (a > b) ? a : b, castedParams, false);- }- }- if (param instanceof IntValueStream) {- if (params.length == 1) {- return LambdaFunction.createIntLambdaFunction(- name, (a, b) -> (a > b) ? a : b, (IntValueStream) param);- }- IntValue[] castedParams = new IntValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof IntValue) {- castedParams[i] = (IntValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createIntLambdaFunction(- name, (a, b) -> (a > b) ? a : b, castedParams, false);- }- }- if (param instanceof LongValueStream) {- if (params.length == 1) {- return LambdaFunction.createLongLambdaFunction(- name, (a, b) -> (a > b) ? a : b, (LongValueStream) param);- }- LongValue[] castedParams = new LongValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof LongValue) {- castedParams[i] = (LongValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createLongLambdaFunction(- name, (a, b) -> (a > b) ? a : b, castedParams, false);- }- }- if (param instanceof FloatValueStream) {- if (params.length == 1) {- return LambdaFunction.createFloatLambdaFunction(- name, (a, b) -> (a > b) ? a : b, (FloatValueStream) param);- }- FloatValue[] castedParams = new FloatValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof FloatValue) {- castedParams[i] = (FloatValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createFloatLambdaFunction(- name, (a, b) -> (a > b) ? a : b, castedParams, false);- }- }- if (param instanceof DoubleValueStream) {- if (params.length == 1) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> (a > b) ? a : b, (DoubleValueStream) param);- }- DoubleValue[] castedParams = new DoubleValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof DoubleValue) {- castedParams[i] = (DoubleValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createDoubleLambdaFunction(- name, (a, b) -> (a > b) ? a : b, castedParams, false);- }- }- if (param instanceof StringValueStream) {- if (params.length == 1) {- return LambdaFunction.createStringLambdaFunction(- name, (a, b) -> (a.compareTo(b) > 0) ? a : b, (StringValueStream) param);- }- StringValue[] castedParams = new StringValue[params.length];- boolean tryNextType = false;- for (int i = 0; i < params.length; i++) {- if (params[i] instanceof StringValue) {- castedParams[i] = (StringValue) params[i];- } else {- tryNextType = true;- break;- }- }- if (!tryNextType) {- return LambdaFunction.createStringLambdaFunction(- name, (a, b) -> (a.compareTo(b) > 0) ? a : b, castedParams, false);- }- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a comparable parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- });-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/package-info.javadeleted file mode 100644index a36c2b33c19..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/mapping/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Mapping functions to use for analytics expressions. */-package org.apache.solr.analytics.function.mapping;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/package-info.javadeleted file mode 100644index 33cc373b83b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Functions to use for analytics expressions. */-package org.apache.solr.analytics.function;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/CountFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/CountFunction.javadeleted file mode 100644index 55b29ee41e0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/CountFunction.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.analytics.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.CountCollector;-import org.apache.solr.analytics.function.reduction.data.CountCollector.ExpressionCountCollector;-import org.apache.solr.analytics.function.reduction.data.CountCollector.TotalCountCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A reduction function which either counts the number of values that the parameter expression- * contains, or the number of documents returned if no parameter is given.- */-public class CountFunction extends AbstractLongValue implements ReductionFunction {- private CountCollector collector;- public static final String name = "count";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- return new CountFunction();- }- if (params.length == 1) {- return new CountFunction(params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function a max of 1 paramater, " + params.length + " given.");- });-- public CountFunction() {- this.collector = new TotalCountCollector();- this.exprStr = AnalyticsValueStream.createExpressionString(name);- }-- public CountFunction(AnalyticsValueStream param) {- this.collector = new ExpressionCountCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.count();- }-- @Override- public boolean exists() {- return true;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (CountCollector) sync.apply(collector);- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public String getName() {- return name;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/DocCountFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/DocCountFunction.javadeleted file mode 100644index a90b3464082..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/DocCountFunction.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.analytics.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.CountCollector;-import org.apache.solr.analytics.function.reduction.data.CountCollector.ExpressionCountCollector;-import org.apache.solr.analytics.function.reduction.data.CountCollector.TotalCountCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A reduction function which either counts the number of Solr Documents for which the parameter- * expression exists, or the number of documents returned if no parameter is given.- */-public class DocCountFunction extends AbstractLongValue implements ReductionFunction {- private CountCollector collector;- public static final String name = "doc_count";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length == 0) {- return new DocCountFunction();- }- if (params.length == 1) {- return new DocCountFunction(params[0]);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function accepts at most 1 paramater, " + params.length + " given.");- });-- public DocCountFunction() {- this.collector = new TotalCountCollector();- this.exprStr = AnalyticsValueStream.createExpressionString(name);- }-- public DocCountFunction(AnalyticsValueStream param) {- this.collector = new ExpressionCountCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.docCount();- }-- @Override- public boolean exists() {- return true;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (CountCollector) sync.apply(collector);- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public String getName() {- return name;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MaxFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MaxFunction.javadeleted file mode 100644index 608e4e16f67..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MaxFunction.java+++ /dev/null@@ -1,327 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.MaxCollector.DoubleMaxCollector;-import org.apache.solr.analytics.function.reduction.data.MaxCollector.FloatMaxCollector;-import org.apache.solr.analytics.function.reduction.data.MaxCollector.IntMaxCollector;-import org.apache.solr.analytics.function.reduction.data.MaxCollector.LongMaxCollector;-import org.apache.solr.analytics.function.reduction.data.MaxCollector.StringMaxCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the maximum value of the given expression. */-public class MaxFunction {- public static final String name = "max";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof DateValueStream) {- return new DateMaxFunction((DateValueStream) param);- }- if (param instanceof IntValueStream) {- return new IntMaxFunction((IntValueStream) param);- }- if (param instanceof LongValueStream) {- return new LongMaxFunction((LongValueStream) param);- }- if (param instanceof FloatValueStream) {- return new FloatMaxFunction((FloatValueStream) param);- }- if (param instanceof DoubleValueStream) {- return new DoubleMaxFunction((DoubleValueStream) param);- }- if (param instanceof StringValueStream) {- return new StringMaxFunction((StringValueStream) param);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a comparable parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- });-- static class IntMaxFunction extends AbstractIntValue implements ReductionFunction {- private IntMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public IntMaxFunction(IntValueStream param) {- this.collector = new IntMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public int getInt() {- return collector.exists() ? collector.max() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (IntMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class LongMaxFunction extends AbstractLongValue implements ReductionFunction {- private LongMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public LongMaxFunction(LongValueStream param) {- this.collector = new LongMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.exists() ? collector.max() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (LongMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class FloatMaxFunction extends AbstractFloatValue implements ReductionFunction {- private FloatMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public FloatMaxFunction(FloatValueStream param) {- this.collector = new FloatMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public float getFloat() {- return collector.exists() ? collector.max() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (FloatMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DoubleMaxFunction extends AbstractDoubleValue implements ReductionFunction {- private DoubleMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public DoubleMaxFunction(DoubleValueStream param) {- this.collector = new DoubleMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public double getDouble() {- return collector.exists() ? collector.max() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (DoubleMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DateMaxFunction extends AbstractDateValue implements ReductionFunction {- private LongMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public DateMaxFunction(LongValueStream param) {- this.collector = new LongMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.exists() ? collector.max() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (LongMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class StringMaxFunction extends AbstractStringValue implements ReductionFunction {- private StringMaxCollector collector;- public static final String name = MaxFunction.name;- private final String exprStr;-- public StringMaxFunction(StringValueStream param) {- this.collector = new StringMaxCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public String getString() {- return collector.exists() ? collector.max() : null;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (StringMaxCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MeanFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MeanFunction.javadeleted file mode 100644index 6142578d6bf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MeanFunction.java+++ /dev/null@@ -1,96 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.CountCollector;-import org.apache.solr.analytics.function.reduction.data.CountCollector.ExpressionCountCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.SumCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the mean of the values of the given expression. */-public class MeanFunction extends AbstractDoubleValue implements ReductionFunction {- private SumCollector sumCollector;- private CountCollector countCollector;- public static final String name = "mean";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- DoubleValueStream casted;- try {- casted = (DoubleValueStream) params[0];- } catch (ClassCastException e) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires numeric parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- }- return new MeanFunction(casted);- });-- public MeanFunction(DoubleValueStream param) {- this.sumCollector = new SumCollector(param);- this.countCollector = new ExpressionCountCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public double getDouble() {- return (countCollector.count() > 0) ? sumCollector.sum() / countCollector.count() : 0;- }-- @Override- public boolean exists() {- return sumCollector.exists() && countCollector.count() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- sumCollector = (SumCollector) sync.apply(sumCollector);- countCollector = (CountCollector) sync.apply(countCollector);- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public String getName() {- return name;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MedianFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MedianFunction.javadeleted file mode 100644index d6d27baab42..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MedianFunction.java+++ /dev/null@@ -1,213 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedDoubleListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedFloatListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedIntListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedLongListCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the median value of the given expression. */-public class MedianFunction {- public static final String name = "median";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof DateValueStream) {- return new DateMedianFunction((DateValueStream) param);- } else if (param instanceof IntValueStream) {- return new IntMedianFunction((IntValueStream) param);- } else if (param instanceof LongValueStream) {- return new LongMedianFunction((LongValueStream) param);- } else if (param instanceof FloatValueStream) {- return new FloatMedianFunction((FloatValueStream) param);- } else if (param instanceof DoubleValueStream) {- return new DoubleMedianFunction((DoubleValueStream) param);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires a date or numeric parameter.");- });-- abstract static class NumericMedianFunction<T extends Comparable<T>> extends AbstractDoubleValue- implements ReductionFunction {- protected SortedListCollector<T> collector;- public static final String name = MedianFunction.name;- private final String exprStr;-- public NumericMedianFunction(DoubleValueStream param, SortedListCollector<T> collector) {- this.collector = collector;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- protected abstract double collectOrd(int ord);-- @Override- public double getDouble() {- int size = collector.size();- if (size == 0) {- return 0;- }- if (size % 2 == 0) {- return (collectOrd(size / 2) + collectOrd(size / 2 - 1)) / 2;- } else {- return collectOrd(size / 2);- }- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @SuppressWarnings("unchecked")- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedListCollector<T>) sync.apply(collector);- collector.calcMedian();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class IntMedianFunction extends NumericMedianFunction<Integer> {- public IntMedianFunction(IntValueStream param) {- super((DoubleValueStream) param, new SortedIntListCollector(param));- }-- @Override- protected double collectOrd(int ord) {- return collector.get(ord);- }- }-- static class LongMedianFunction extends NumericMedianFunction<Long> {- public LongMedianFunction(LongValueStream param) {- super((DoubleValueStream) param, new SortedLongListCollector(param));- }-- @Override- protected double collectOrd(int ord) {- return collector.get(ord);- }- }-- static class FloatMedianFunction extends NumericMedianFunction<Float> {- public FloatMedianFunction(FloatValueStream param) {- super((DoubleValueStream) param, new SortedFloatListCollector(param));- }-- @Override- protected double collectOrd(int ord) {- return collector.get(ord);- }- }-- static class DoubleMedianFunction extends NumericMedianFunction<Double> {- public DoubleMedianFunction(DoubleValueStream param) {- super(param, new SortedDoubleListCollector(param));- }-- @Override- protected double collectOrd(int ord) {- return collector.get(ord);- }- }-- static class DateMedianFunction extends AbstractDateValue implements ReductionFunction {- private SortedLongListCollector collector;- public static final String name = MedianFunction.name;- private final String exprStr;-- public DateMedianFunction(DateValueStream param) {- this.collector = new SortedLongListCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- int size = collector.size();- if (size == 0) {- return 0;- }- if (size % 2 == 0) {- return (collector.get(size / 2) + collector.get(size / 2 - 1)) / 2;- } else {- return collector.get(size / 2);- }- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedLongListCollector) sync.apply(collector);- collector.calcMedian();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MinFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MinFunction.javadeleted file mode 100644index 0fa81b86cac..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MinFunction.java+++ /dev/null@@ -1,327 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.MinCollector.DoubleMinCollector;-import org.apache.solr.analytics.function.reduction.data.MinCollector.FloatMinCollector;-import org.apache.solr.analytics.function.reduction.data.MinCollector.IntMinCollector;-import org.apache.solr.analytics.function.reduction.data.MinCollector.LongMinCollector;-import org.apache.solr.analytics.function.reduction.data.MinCollector.StringMinCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the minumum value of the given expression. */-public class MinFunction {- public static final String name = "min";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- if (param instanceof DateValueStream) {- return new DateMinFunction((DateValueStream) param);- }- if (param instanceof IntValueStream) {- return new IntMinFunction((IntValueStream) param);- }- if (param instanceof LongValueStream) {- return new LongMinFunction((LongValueStream) param);- }- if (param instanceof FloatValueStream) {- return new FloatMinFunction((FloatValueStream) param);- }- if (param instanceof DoubleValueStream) {- return new DoubleMinFunction((DoubleValueStream) param);- }- if (param instanceof StringValueStream) {- return new StringMinFunction((StringValueStream) param);- }- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a comparable parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- });-- static class IntMinFunction extends AbstractIntValue implements ReductionFunction {- private IntMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public IntMinFunction(IntValueStream param) {- this.collector = new IntMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public int getInt() {- return collector.exists() ? collector.min() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (IntMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class LongMinFunction extends AbstractLongValue implements ReductionFunction {- private LongMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public LongMinFunction(LongValueStream param) {- this.collector = new LongMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.exists() ? collector.min() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (LongMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class FloatMinFunction extends AbstractFloatValue implements ReductionFunction {- private FloatMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public FloatMinFunction(FloatValueStream param) {- this.collector = new FloatMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public float getFloat() {- return collector.exists() ? collector.min() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (FloatMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DoubleMinFunction extends AbstractDoubleValue implements ReductionFunction {- private DoubleMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public DoubleMinFunction(DoubleValueStream param) {- this.collector = new DoubleMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public double getDouble() {- return collector.exists() ? collector.min() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (DoubleMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DateMinFunction extends AbstractDateValue implements ReductionFunction {- private LongMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public DateMinFunction(LongValueStream param) {- this.collector = new LongMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.exists() ? collector.min() : 0;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (LongMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class StringMinFunction extends AbstractStringValue implements ReductionFunction {- private StringMinCollector collector;- public static final String name = MinFunction.name;- private final String exprStr;-- public StringMinFunction(StringValueStream param) {- this.collector = new StringMinCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public String getString() {- return collector.exists() ? collector.min() : null;- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (StringMinCollector) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MissingFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MissingFunction.javadeleted file mode 100644index 4dfdbdebe97..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/MissingFunction.java+++ /dev/null@@ -1,81 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.CountCollector.ExpressionCountCollector;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A reduction function which returns the number of documents for which the given expression does- * not exist.- */-public class MissingFunction extends AbstractLongValue implements ReductionFunction {- private ExpressionCountCollector collector;- public static final String name = "missing";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- return new MissingFunction(params[0]);- });-- public MissingFunction(AnalyticsValueStream param) {- this.collector = new ExpressionCountCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.missing();- }-- @Override- public boolean exists() {- return true;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (ExpressionCountCollector) sync.apply(collector);- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public String getName() {- return name;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/OrdinalFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/OrdinalFunction.javadeleted file mode 100644index 55baee0f6f0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/OrdinalFunction.java+++ /dev/null@@ -1,393 +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.function.reduction;--import java.util.Locale;-import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedDoubleListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedFloatListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedIntListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedLongListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedStringListCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A reduction function which returns the given ordinal of the sorted values of the given- * expression.- */-public class OrdinalFunction {- public static final String name = "ordinal";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramater, " + params.length + " found.");- }- AnalyticsValueStream percValue = params[0];- int ord = 0;- if (params[0] instanceof IntValue && params[0] instanceof ConstantValue) {- ord = ((IntValue) percValue).getInt();- if (ord == 0) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires the ordinal to be >= 1 or <= -1, 0 is not accepted.");- }- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a constant int value (the ordinal) as the first argument.");- }- AnalyticsValueStream param = params[1];- if (param instanceof DateValueStream) {- return new DateOrdinalFunction((DateValueStream) param, ord);- } else if (param instanceof IntValueStream) {- return new IntOrdinalFunction((IntValueStream) param, ord);- } else if (param instanceof LongValueStream) {- return new LongOrdinalFunction((LongValueStream) param, ord);- } else if (param instanceof FloatValueStream) {- return new FloatOrdinalFunction((FloatValueStream) param, ord);- } else if (param instanceof DoubleValueStream) {- return new DoubleOrdinalFunction((DoubleValueStream) param, ord);- } else if (param instanceof StringValueStream) {- return new StringOrdinalFunction((StringValueStream) param, ord);- }- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires a comparable parameter.");- });-- protected static String createOrdinalExpressionString(AnalyticsValueStream param, double ord) {- return String.format(Locale.ROOT, "%s(%s,%s)", name, ord, param.getExpressionStr());- }-- static class IntOrdinalFunction extends AbstractIntValue implements ReductionFunction {- private SortedIntListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public IntOrdinalFunction(IntValueStream param, int ordinal) {- this.collector = new SortedIntListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public int getInt() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : 0;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : 0;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedIntListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class LongOrdinalFunction extends AbstractLongValue implements ReductionFunction {- private SortedLongListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public LongOrdinalFunction(LongValueStream param, int ordinal) {- this.collector = new SortedLongListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public long getLong() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : 0;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : 0;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedLongListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class FloatOrdinalFunction extends AbstractFloatValue implements ReductionFunction {- private SortedFloatListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public FloatOrdinalFunction(FloatValueStream param, int ordinal) {- this.collector = new SortedFloatListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public float getFloat() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : 0;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : 0;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedFloatListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DoubleOrdinalFunction extends AbstractDoubleValue implements ReductionFunction {- private SortedDoubleListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public DoubleOrdinalFunction(DoubleValueStream param, int ordinal) {- this.collector = new SortedDoubleListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public double getDouble() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : 0;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : 0;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedDoubleListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DateOrdinalFunction extends AbstractDateValue implements ReductionFunction {- private SortedLongListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public DateOrdinalFunction(LongValueStream param, int ordinal) {- this.collector = new SortedLongListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public long getLong() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : 0;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : 0;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedLongListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class StringOrdinalFunction extends AbstractStringValue implements ReductionFunction {- private SortedStringListCollector collector;- private int ordinal;- public static final String name = OrdinalFunction.name;- private final String exprStr;-- public StringOrdinalFunction(StringValueStream param, int ordinal) {- this.collector = new SortedStringListCollector(param);- this.ordinal = ordinal;- this.exprStr = createOrdinalExpressionString(param, ordinal);- }-- @Override- public String getString() {- int size = collector.size();- if (ordinal > 0) {- return ordinal <= size ? collector.get(ordinal - 1) : null;- } else {- return (ordinal * -1) <= size ? collector.get(size + ordinal) : null;- }- }-- @Override- public boolean exists() {- return (ordinal > 0 ? ordinal : (ordinal * -1)) <= collector.size();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedStringListCollector) sync.apply(collector);- collector.calcOrdinal(ordinal);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/PercentileFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/PercentileFunction.javadeleted file mode 100644index 1901f39da0e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/PercentileFunction.java+++ /dev/null@@ -1,373 +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.function.reduction;--import java.util.Locale;-import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedDoubleListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedFloatListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedIntListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedLongListCollector;-import org.apache.solr.analytics.function.reduction.data.SortedListCollector.SortedStringListCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A reduction function which returns the given percentile of the sorted values of the given- * expression.- */-public class PercentileFunction {- public static final String name = "percentile";- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 2) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 2 paramater, " + params.length + " found.");- }- AnalyticsValueStream percValue = params[0];- double perc = 0;- if (percValue instanceof DoubleValue && percValue instanceof ConstantValue) {- perc = ((DoubleValue) percValue).getDouble();- if (perc < 0 || perc >= 100) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a percentile between [0, 100), "- + perc- + " found.");- }- perc /= 100;- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires a constant double value (the percentile) as the first argument.");- }- AnalyticsValueStream param = params[1];- if (param instanceof DateValueStream) {- return new DatePercentileFunction((DateValueStream) param, perc);- } else if (param instanceof IntValueStream) {- return new IntPercentileFunction((IntValueStream) param, perc);- } else if (param instanceof LongValueStream) {- return new LongPercentileFunction((LongValueStream) param, perc);- } else if (param instanceof FloatValueStream) {- return new FloatPercentileFunction((FloatValueStream) param, perc);- } else if (param instanceof DoubleValueStream) {- return new DoublePercentileFunction((DoubleValueStream) param, perc);- } else if (param instanceof StringValueStream) {- return new StringPercentileFunction((StringValueStream) param, perc);- }- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires a comparable parameter.");- });-- protected static String createPercentileExpressionString(- AnalyticsValueStream param, double perc) {- return String.format(Locale.ROOT, "%s(%s,%s)", name, perc, param.getExpressionStr());- }-- static class IntPercentileFunction extends AbstractIntValue implements ReductionFunction {- private SortedIntListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public IntPercentileFunction(IntValueStream param, double percentile) {- this.collector = new SortedIntListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public int getInt() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : 0;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedIntListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class LongPercentileFunction extends AbstractLongValue implements ReductionFunction {- private SortedLongListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public LongPercentileFunction(LongValueStream param, double percentile) {- this.collector = new SortedLongListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public long getLong() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : 0;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedLongListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class FloatPercentileFunction extends AbstractFloatValue implements ReductionFunction {- private SortedFloatListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public FloatPercentileFunction(FloatValueStream param, double percentile) {- this.collector = new SortedFloatListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public float getFloat() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : 0;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedFloatListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DoublePercentileFunction extends AbstractDoubleValue implements ReductionFunction {- private SortedDoubleListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public DoublePercentileFunction(DoubleValueStream param, double percentile) {- this.collector = new SortedDoubleListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public double getDouble() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : 0;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedDoubleListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class DatePercentileFunction extends AbstractDateValue implements ReductionFunction {- private SortedLongListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public DatePercentileFunction(LongValueStream param, double percentile) {- this.collector = new SortedLongListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public long getLong() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : 0;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedLongListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-- static class StringPercentileFunction extends AbstractStringValue implements ReductionFunction {- private SortedStringListCollector collector;- private double percentile;- public static final String name = PercentileFunction.name;- private final String exprStr;-- public StringPercentileFunction(StringValueStream param, double percentile) {- this.collector = new SortedStringListCollector(param);- this.percentile = percentile;- this.exprStr = createPercentileExpressionString(param, percentile);- }-- @Override- public String getString() {- int size = collector.size();- return size > 0 ? collector.get((int) Math.round(percentile * size - .5)) : null;- }-- @Override- public boolean exists() {- return collector.size() > 0;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SortedStringListCollector) sync.apply(collector);- collector.calcPercentile(percentile);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/SumFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/SumFunction.javadeleted file mode 100644index 7a6f1704497..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/SumFunction.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.analytics.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.SumCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the sum of the values of the given expression. */-public class SumFunction extends AbstractDoubleValue implements ReductionFunction {- private SumCollector collector;- public static final String name = "sum";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- DoubleValueStream casted;- try {- casted = (DoubleValueStream) params[0];- } catch (ClassCastException e) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The "- + name- + " function requires numeric parameter. "- + "Incorrect parameter: "- + params[0].getExpressionStr());- }- return new SumFunction(casted);- });-- public SumFunction(DoubleValueStream param) {- this.collector = new SumCollector(param);- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public double getDouble() {- return collector.sum();- }-- @Override- public boolean exists() {- return collector.exists();- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (SumCollector) sync.apply(collector);- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public String getName() {- return name;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/UniqueFunction.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/UniqueFunction.javadeleted file mode 100644index cae0ca19b3d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/UniqueFunction.java+++ /dev/null@@ -1,104 +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.function.reduction;--import java.util.function.UnaryOperator;-import org.apache.solr.analytics.ExpressionFactory.CreatorFunction;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector.UniqueDoubleCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector.UniqueFloatCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector.UniqueIntCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector.UniqueLongCollector;-import org.apache.solr.analytics.function.reduction.data.UniqueCollector.UniqueStringCollector;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/** A reduction function which returns the number of unique values of the given expression. */-public class UniqueFunction extends AbstractLongValue implements ReductionFunction {- private UniqueCollector<?> collector;- public static final String name = "unique";- private final String exprStr;- public static final CreatorFunction creatorFunction =- (params -> {- if (params.length != 1) {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The " + name + " function requires 1 paramater, " + params.length + " found.");- }- AnalyticsValueStream param = params[0];- UniqueCollector<?> collector;- if (param instanceof IntValueStream) {- collector = new UniqueIntCollector((IntValueStream) param);- } else if (param instanceof LongValueStream) {- collector = new UniqueLongCollector((LongValueStream) param);- } else if (param instanceof FloatValueStream) {- collector = new UniqueFloatCollector((FloatValueStream) param);- } else if (param instanceof DoubleValueStream) {- collector = new UniqueDoubleCollector((DoubleValueStream) param);- } else if (param instanceof StringValueStream) {- collector = new UniqueStringCollector((StringValueStream) param);- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST, "The " + name + " function requires a comparable parameter.");- }- return new UniqueFunction(param, collector);- });-- public UniqueFunction(AnalyticsValueStream param, UniqueCollector<?> collector) {- this.collector = collector;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- @Override- public long getLong() {- return collector.count();- }-- @Override- public boolean exists() {- return true;- }-- @Override- public void synchronizeDataCollectors(UnaryOperator<ReductionDataCollector<?>> sync) {- collector = (UniqueCollector<?>) sync.apply(collector);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.REDUCTION;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/CountCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/CountCollector.javadeleted file mode 100644index 10892cf27a4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/CountCollector.java+++ /dev/null@@ -1,181 +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.function.reduction.data;--import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.LongReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.value.AnalyticsValueStream;--public abstract class CountCollector extends ReductionDataCollector<CountCollector.CountData> {- public static final String name = "count";- private final String exprStr;-- public CountCollector(String exprStr) {- this.exprStr = exprStr;- }-- private long count;- private long docCount;-- /**- * The number of Solr Documents for which the given analytics expression exists.- *- * @return the count- */- public long count() {- return count;- }- /**- * The number of Solr Documents used in this reduction.- *- * @return the number of documents- */- public long docCount() {- return docCount;- }-- @Override- public CountData newData() {- CountData data = new CountData();- data.count = 0;- data.missing = 0;- data.docCount = 0;- return data;- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- // Count- consumer.accept(new LongReservation(value -> ioData.count += value, () -> ioData.count));- // DocCount- consumer.accept(new LongReservation(value -> ioData.docCount += value, () -> ioData.docCount));- }-- @Override- public void setMergedData(ReductionData data) {- count = ((CountData) data).count;- docCount = ((CountData) data).docCount;- }-- @Override- public void setData(ReductionData data) {- count = ((CountData) data).count;- docCount = ((CountData) data).docCount;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class CountData extends ReductionData {- long count;- long missing;- long docCount;- }-- /**- * Represents a {@code count(expr)} expression. This collects 3 values:- *- * <p>docCount - The number of Solr Documents for which the wrapped expression exists. count - The- * number of values which wrapped expression contains. missing - The number of Solr Documents for- * which the wrapped expression does not exist.- */- public static class ExpressionCountCollector extends CountCollector {- private final AnalyticsValueStream param;-- public ExpressionCountCollector(AnalyticsValueStream param) {- super(AnalyticsValueStream.createExpressionString(name, param));- this.param = param;- }-- private long missing;-- /**- * The number of Solr Documents for which the given analytics expression does not exist.- *- * @return the number of missing values- */- public long missing() {- return missing;- }-- @Override- public void setMergedData(ReductionData data) {- super.setMergedData(data);- missing = ((CountData) data).missing;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- missing = ((CountData) data).missing;- }-- long tempCount;- int tempMissing;- int tempDocCount;-- @Override- public void collect() {- tempCount = 0;- param.streamObjects(- obj -> {- ++tempCount;- });- tempMissing = tempCount == 0 ? 1 : 0;- tempDocCount = tempCount > 0 ? 1 : 0;- }-- @Override- protected void apply(CountData data) {- data.count += tempCount;- data.missing += tempMissing;- data.docCount += tempDocCount;- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- super.submitReservations(consumer);- // Missing- consumer.accept(new LongReservation(value -> ioData.missing += value, () -> ioData.missing));- }- }-- /**- * Represents a {@code count()} expression. This collects the number of Solr Documents used in a- * result set.- */- public static class TotalCountCollector extends CountCollector {-- public TotalCountCollector() {- super(AnalyticsValueStream.createExpressionString(name));- }-- @Override- protected void apply(CountData data) {- data.count += 1;- data.docCount += 1;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MaxCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MaxCollector.javadeleted file mode 100644index 791b009ebe0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MaxCollector.java+++ /dev/null@@ -1,487 +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.function.reduction.data;--import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.DoubleCheckedReservation;-import org.apache.solr.analytics.stream.reservation.FloatCheckedReservation;-import org.apache.solr.analytics.stream.reservation.IntCheckedReservation;-import org.apache.solr.analytics.stream.reservation.LongCheckedReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.stream.reservation.StringCheckedReservation;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValueStream;--/**- * Collector of max values.- *- * <p>Supported types are:- *- * <ul>- * <li>Int- * <li>Long- * <li>Float- * <li>Double- * <li>Date (through longs)- * <li>String- * </ul>- *- * @param <T> The type of data being processed.- */-public abstract class MaxCollector<T extends ReductionData> extends ReductionDataCollector<T> {- public static final String name = "max";- private final String exprStr;-- protected MaxCollector(AnalyticsValueStream param) {- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- private boolean exists;-- /**- * Returns true if any of the values being reduce exist, and false if none of them do.- *- * @return whether a max value exists- */- public boolean exists() {- return exists;- }-- @Override- public void setMergedData(ReductionData data) {- exists = data.exists;- }-- @Override- public void setData(ReductionData data) {- exists = data.exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class IntMaxCollector extends MaxCollector<IntMaxCollector.MaxData> {- private IntValueStream param;-- public IntMaxCollector(IntValueStream param) {- super(param);- this.param = param;- }-- @Override- public MaxData newData() {- MaxData data = new MaxData();- data.exists = false;- return data;- }-- int max;-- /**- * Returns the max value of the set data.- *- * @return the max- */- public int max() {- return max;- }-- int tempMax;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamInts(- val -> {- if (!tempExists || val > tempMax) {- tempMax = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MaxData data) {- if (tempExists && (!data.exists || tempMax > data.val)) {- data.val = tempMax;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new IntCheckedReservation(- value -> {- if (!ioData.exists || value > ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- public static class MaxData extends ReductionData {- int val;- }- }-- public static class LongMaxCollector extends MaxCollector<LongMaxCollector.MaxData> {- private LongValueStream param;-- public LongMaxCollector(LongValueStream param) {- super(param);- this.param = param;- }-- @Override- public MaxData newData() {- MaxData data = new MaxData();- data.exists = false;- return data;- }-- long max;-- /**- * Returns the max value of the set data.- *- * @return the max- */- public long max() {- return max;- }-- long tempMax;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamLongs(- val -> {- if (!tempExists || val > tempMax) {- tempMax = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MaxData data) {- if (tempExists && (!data.exists || tempMax > data.val)) {- data.val = tempMax;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new LongCheckedReservation(- value -> {- if (!ioData.exists || value > ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- public static class MaxData extends ReductionData {- long val;- }- }-- public static class FloatMaxCollector extends MaxCollector<FloatMaxCollector.MaxData> {- private FloatValueStream param;-- public FloatMaxCollector(FloatValueStream param) {- super(param);- this.param = param;- }-- @Override- public MaxData newData() {- MaxData data = new MaxData();- data.exists = false;- return data;- }-- float max;-- /**- * Returns the max value of the set data.- *- * @return the max- */- public float max() {- return max;- }-- float tempMax;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamFloats(- val -> {- if (!tempExists || val > tempMax) {- tempMax = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MaxData data) {- if (tempExists && (!data.exists || tempMax > data.val)) {- data.val = tempMax;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new FloatCheckedReservation(- value -> {- if (!ioData.exists || value > ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- public static class MaxData extends ReductionData {- float val;- }- }-- public static class DoubleMaxCollector extends MaxCollector<DoubleMaxCollector.MaxData> {- private DoubleValueStream param;-- public DoubleMaxCollector(DoubleValueStream param) {- super(param);- this.param = param;- }-- @Override- public MaxData newData() {- MaxData data = new MaxData();- data.exists = false;- return data;- }-- double max;-- /**- * Returns the max value of the set data.- *- * @return the max- */- public double max() {- return max;- }-- double tempMax;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamDoubles(- val -> {- if (!tempExists || val > tempMax) {- tempMax = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MaxData data) {- if (tempExists && (!data.exists || tempMax > data.val)) {- data.val = tempMax;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new DoubleCheckedReservation(- value -> {- if (!ioData.exists || value > ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- public static class MaxData extends ReductionData {- double val;- }- }-- public static class StringMaxCollector extends MaxCollector<StringMaxCollector.MaxData> {- private StringValueStream param;-- public StringMaxCollector(StringValueStream param) {- super(param);- this.param = param;- }-- @Override- public MaxData newData() {- MaxData data = new MaxData();- data.exists = false;- return data;- }-- String max;-- /**- * Returns the max value of the set data.- *- * @return the max- */- public String max() {- return max;- }-- String tempMax;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamStrings(- val -> {- if (!tempExists || val.compareTo(tempMax) > 0) {- tempMax = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MaxData data) {- if (tempExists && (!data.exists || tempMax.compareTo(data.val) > 0)) {- data.val = tempMax;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new StringCheckedReservation(- value -> {- if (!ioData.exists || value.compareTo(ioData.val) > 0) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- max = ((MaxData) data).val;- }-- public static class MaxData extends ReductionData {- String val;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MinCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MinCollector.javadeleted file mode 100644index f8e5eec8a7e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/MinCollector.java+++ /dev/null@@ -1,487 +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.function.reduction.data;--import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.DoubleCheckedReservation;-import org.apache.solr.analytics.stream.reservation.FloatCheckedReservation;-import org.apache.solr.analytics.stream.reservation.IntCheckedReservation;-import org.apache.solr.analytics.stream.reservation.LongCheckedReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.stream.reservation.StringCheckedReservation;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValueStream;--/**- * Collector of min values.- *- * <p>Supported types are:- *- * <ul>- * <li>Int- * <li>Long- * <li>Float- * <li>Double- * <li>Date (through longs)- * <li>String- * </ul>- *- * @param <T> The type of data being processed.- */-public abstract class MinCollector<T extends ReductionData> extends ReductionDataCollector<T> {- public static final String name = "min";- private final String exprStr;-- protected MinCollector(AnalyticsValueStream param) {- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- private boolean exists;-- /**- * Returns true if any of the values being reduce exist, and false if none of them do.- *- * @return whether a min value exists- */- public boolean exists() {- return exists;- }-- @Override- public void setMergedData(ReductionData data) {- exists = data.exists;- }-- @Override- public void setData(ReductionData data) {- exists = data.exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class IntMinCollector extends MinCollector<IntMinCollector.MinData> {- private IntValueStream param;-- public IntMinCollector(IntValueStream param) {- super(param);- this.param = param;- }-- @Override- public MinData newData() {- MinData data = new MinData();- data.exists = false;- return data;- }-- int min;-- /**- * Returns the min value of the set data.- *- * @return the min- */- public int min() {- return min;- }-- int tempMin;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamInts(- val -> {- if (!tempExists || val < tempMin) {- tempMin = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MinData data) {- if (tempExists && (!data.exists || tempMin < data.val)) {- data.val = tempMin;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new IntCheckedReservation(- value -> {- if (!ioData.exists || value < ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- public static class MinData extends ReductionData {- int val;- }- }-- public static class LongMinCollector extends MinCollector<LongMinCollector.MinData> {- private LongValueStream param;-- public LongMinCollector(LongValueStream param) {- super(param);- this.param = param;- }-- @Override- public MinData newData() {- MinData data = new MinData();- data.exists = false;- return data;- }-- long min;-- /**- * Returns the min value of the set data.- *- * @return the min- */- public long min() {- return min;- }-- long tempMin;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamLongs(- val -> {- if (!tempExists || val < tempMin) {- tempMin = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MinData data) {- if (tempExists && (!data.exists || tempMin < data.val)) {- data.val = tempMin;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new LongCheckedReservation(- value -> {- if (!ioData.exists || value < ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- public static class MinData extends ReductionData {- long val;- }- }-- public static class FloatMinCollector extends MinCollector<FloatMinCollector.MinData> {- private FloatValueStream param;-- public FloatMinCollector(FloatValueStream param) {- super(param);- this.param = param;- }-- @Override- public MinData newData() {- MinData data = new MinData();- data.exists = false;- return data;- }-- float min;-- /**- * Returns the min value of the set data.- *- * @return the min- */- public float min() {- return min;- }-- float tempMin;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamFloats(- val -> {- if (!tempExists || val < tempMin) {- tempMin = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MinData data) {- if (tempExists && (!data.exists || tempMin < data.val)) {- data.val = tempMin;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new FloatCheckedReservation(- value -> {- if (!ioData.exists || value < ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- public static class MinData extends ReductionData {- float val;- }- }-- public static class DoubleMinCollector extends MinCollector<DoubleMinCollector.MinData> {- private DoubleValueStream param;-- public DoubleMinCollector(DoubleValueStream param) {- super(param);- this.param = param;- }-- @Override- public MinData newData() {- MinData data = new MinData();- data.exists = false;- return data;- }-- double min;-- /**- * Returns the min value of the set data.- *- * @return the min- */- public double min() {- return min;- }-- double tempMin;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamDoubles(- val -> {- if (!tempExists || val < tempMin) {- tempMin = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MinData data) {- if (tempExists && (!data.exists || tempMin < data.val)) {- data.val = tempMin;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new DoubleCheckedReservation(- value -> {- if (!ioData.exists || value < ioData.val) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- public static class MinData extends ReductionData {- double val;- }- }-- public static class StringMinCollector extends MinCollector<StringMinCollector.MinData> {- private StringValueStream param;-- public StringMinCollector(StringValueStream param) {- super(param);- this.param = param;- }-- @Override- public MinData newData() {- MinData data = new MinData();- data.exists = false;- return data;- }-- String min;-- /**- * Returns the min value of the set data.- *- * @return the min- */- public String min() {- return min;- }-- String tempMin;- boolean tempExists;-- @Override- public void collect() {- tempExists = false;- param.streamStrings(- val -> {- if (!tempExists || val.compareTo(tempMin) < 0) {- tempMin = val;- tempExists = true;- }- });- }-- @Override- protected void apply(MinData data) {- if (tempExists && (!data.exists || tempMin.compareTo(data.val) < 0)) {- data.val = tempMin;- data.exists = true;- }- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new StringCheckedReservation(- value -> {- if (!ioData.exists || value.compareTo(ioData.val) < 0) {- ioData.val = value;- ioData.exists = true;- }- },- () -> ioData.val,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- @Override- public void setData(ReductionData data) {- super.setData(data);- min = ((MinData) data).val;- }-- public static class MinData extends ReductionData {- String val;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionData.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionData.javadeleted file mode 100644index c3ba4e8dde0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionData.java+++ /dev/null@@ -1,22 +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.function.reduction.data;--/** Base class to store data for {@link ReductionDataCollector}s */-public class ReductionData {- public boolean exists;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionDataCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionDataCollector.javadeleted file mode 100644index 871ccde7e3c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/ReductionDataCollector.java+++ /dev/null@@ -1,179 +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.function.reduction.data;--import java.util.ArrayList;-import java.util.function.Consumer;-import org.apache.solr.analytics.function.ReductionFunction;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.value.AnalyticsValue;--/**- * Manager of a specific instance of {@link ReductionData} collection.- *- * @param <T> the type of reduction data being collected- */-public abstract class ReductionDataCollector<T extends ReductionData> {-- protected ArrayList<T> lastingTargets;- protected ArrayList<T> collectionTargets;- protected T ioData;-- protected ReductionDataCollector() {- lastingTargets = new ArrayList<>();- collectionTargets = new ArrayList<>();- }-- /**- * Submits the data reservations needed for this data collector.- *- * @param consumer the consumer which the reservations are submitted to- */- public abstract void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer);-- /**- * A clean slate to start a new reduction.- *- * @return the new reduction data- */- public abstract T newData();-- /**- * Add a reduction data to target during collection. The given target is valid until the lasting- * targets are cleared.- *- * @param data the data to target- */- @SuppressWarnings("unchecked")- public void addLastingCollectTarget(ReductionData data) {- lastingTargets.add((T) data);- }-- /**- * Clear the lasting collection targets. After this is called the current lasting targets will not- * be affected by future {@link #collectAndApply()} calls.- */- public void clearLastingCollectTargets() {- lastingTargets.clear();- }-- /**- * Create a new reduction data to target during collection. The given target is only valid for one- * call to {@link #collectAndApply()}.- *- * @return the reduction data created- */- public T newDataTarget() {- T data = newData();- collectionTargets.add(data);- return data;- }-- /**- * Add a reduction data to target during collection. The given target is only valid for one call- * to {@link #collectAndApply()}.- *- * @param data the data to target- */- @SuppressWarnings("unchecked")- public void addCollectTarget(ReductionData data) {- collectionTargets.add((T) data);- }-- /**- * Collect the info for the current Solr Document and apply the results to the given collection- * targets.- *- * <p>After application, all non-lasting targets are removed.- */- public void collectAndApply() {- collect();- lastingTargets.forEach(target -> apply(target));- collectionTargets.forEach(target -> apply(target));- collectionTargets.clear();- }-- /** Collect the information from current Solr Document. */- protected void collect() {}-- /**- * Apply the collected info to the given reduction data. Should always be called after a {@link- * #collect()} call.- *- * @param data reduction data to apply collected info to- */- protected abstract void apply(T data);-- /**- * Create a new reduction data to use in exporting and merging.- *- * @return the created reduction data- */- public T newDataIO() {- ioData = newData();- return ioData;- }-- /**- * Set the reduction data to use in exporting and merging.- *- * @param data the data to use- */- @SuppressWarnings("unchecked")- public void dataIO(ReductionData data) {- ioData = (T) data;- }-- /**- * Finalize the reduction with the merged data stored in the parameter. Once the reduction is- * finalized, the {@link ReductionFunction}s that use this data collector act like regular {@link- * AnalyticsValue} classes that can be accessed through their {@code get<value-type>} methods.- *- * <p>(FOR CLOUD)- *- * @param data the merged data to compute a reduction for- */- public abstract void setMergedData(ReductionData data);-- /**- * Finalize the reduction with the collected data stored in the parameter. Once the reduction is- * finalized, the {@link ReductionFunction}s that use this data collector act like regular {@link- * AnalyticsValue} classes that can be accessed through their {@code get<value-type>} methods.- *- * <p>(FOR SINGLE-SHARD)- *- * @param data the collected data to compute a reduction for- */- public abstract void setData(ReductionData data);-- /**- * Get the name of the reduction data collector. This is the same across all instances of the data- * collector.- *- * @return the name- */- public abstract String getName();-- /**- * The unique expression string of the reduction data collector, given all inputs and parameters.- * Used during {@link ReductionDataCollector} syncing. Since the string should be unique, only one- * of expression is kept.- *- * @return the expression string- */- public abstract String getExpressionStr();-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SortedListCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SortedListCollector.javadeleted file mode 100644index 85a405a1855..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SortedListCollector.java+++ /dev/null@@ -1,354 +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.function.reduction.data;--import java.util.ArrayList;-import java.util.HashSet;-import java.util.Iterator;-import java.util.List;-import java.util.Set;-import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.DoubleArrayReservation;-import org.apache.solr.analytics.stream.reservation.FloatArrayReservation;-import org.apache.solr.analytics.stream.reservation.IntArrayReservation;-import org.apache.solr.analytics.stream.reservation.LongArrayReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.stream.reservation.StringArrayReservation;-import org.apache.solr.analytics.util.OrdinalCalculator;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValueStream;--/**- * Collector of sorted lists.- *- * <p>Once the sorted list has been collected, it can be reduced by calculating a median,- * percentiles, or ordinals. All of the above reductions over the same data share one {@link- * SortedListCollector}.- *- * <p>Supported types are:- *- * <ul>- * <li>Int- * <li>Long- * <li>Float- * <li>Double- * <li>Date (through longs)- * <li>String- * </ul>- *- * @param <T> The type of data being processed.- */-public abstract class SortedListCollector<T extends Comparable<T>>- extends ReductionDataCollector<SortedListCollector.SortedListData<T>> {- public static final String name = "sorted";- private final String exprStr;-- protected SortedListCollector(AnalyticsValueStream param, String specificationName) {- this.exprStr =- AnalyticsValueStream.createExpressionString(name + "_" + specificationName, param);-- tempList = new ArrayList<>();-- calcMedian = false;- calcPercs = new HashSet<>();- calcOrds = new HashSet<>();- }-- private List<T> list;-- private boolean calcMedian;- private Set<Double> calcPercs;- private Set<Integer> calcOrds;-- public int size() {- return list.size();- }-- /** Informs the collector that the median needs to be computed. */- public void calcMedian() {- calcMedian = true;- }-- /**- * Informs the collector that the following percentile needs to be computed.- *- * @param percentile requested percentile- */- public void calcPercentile(double percentile) {- calcPercs.add(percentile);- }-- /**- * Informs the collector that the following ordinal needs to be computed.- *- * @param ordinal requested ordinal- */- public void calcOrdinal(int ordinal) {- calcOrds.add(ordinal);- }-- /**- * Once the data has been set by either {@link #setData} or {@link #setMergedData}, this returns- * the value at the given sorted index.- *- * <p>Only the indices specified by {@link #calcMedian}, {@link #calcPercentile}, and {@link- * #calcOrdinal} will contain valid data. All other indices may return unsorted data.- *- * @param index the index of the sorted data to return- */- public T get(int index) {- return list.get(index);- }-- @Override- public SortedListData<T> newData() {- SortedListData<T> data = new SortedListData<>();- data.list = new ArrayList<T>();- data.exists = false;- return data;- }-- ArrayList<T> tempList;-- @Override- protected void apply(SortedListData<T> data) {- data.list.addAll(tempList);- }-- /**- * Starts the import of the shard data.- *- * @param size the size of the incoming shard list- */- protected void startImport(int size) {- ioData.list.ensureCapacity(ioData.list.size() + size);- }-- /**- * Merges the current list with the incoming value.- *- * @param value the next imported value to add- */- protected void importNext(T value) {- ioData.list.add(value);- }-- Iterator<T> iter;- /**- * The list to be exported is unsorted. The lists of all shards will be combined with the {@link- * #startImport} and {@link #importNext} methods.- *- * @return the size of the list being exported.- */- public int startExport() {- iter = ioData.list.iterator();- return ioData.list.size();- }- /**- * Return the next value in the list.- *- * @return the next sorted value- */- public T exportNext() {- return iter.next();- }-- /** Put the given indices in their sorted positions */- @Override- public void setMergedData(ReductionData data) {- setData(data);- }-- /**- * This is where the given indices are put in their sorted positions.- *- * <p>Only the given indices are guaranteed to be in sorted order.- */- @SuppressWarnings("unchecked")- @Override- public void setData(ReductionData data) {- list = ((SortedListData<T>) data).list;- int size = list.size();- if (size <= 1) {- return;- }-- // Ordinals start at 0 and end at size-1- Set<Integer> ordinals = new HashSet<>();- for (double percentile : calcPercs) {- ordinals.add((int) Math.round(percentile * size - .5));- }- for (int ordinal : calcOrds) {- if (ordinal > 0) {- ordinals.add(ordinal - 1);- } else if (ordinal < 0) {- ordinals.add(size + ordinal);- }- }- if (calcMedian) {- int mid = list.size() / 2;- ordinals.add(mid);- if (list.size() % 2 == 0) {- ordinals.add(mid - 1);- }- }- OrdinalCalculator.putOrdinalsInPosition(list, ordinals);- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class SortedListData<D extends Comparable<D>> extends ReductionData {- ArrayList<D> list;- }-- public static class SortedIntListCollector extends SortedListCollector<Integer> {- private IntValueStream param;-- public SortedIntListCollector(IntValueStream param) {- super(param, "int");- this.param = param;- }-- @Override- public void collect() {- tempList.clear();- param.streamInts(val -> tempList.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new IntArrayReservation(- value -> importNext(value),- importSize -> startImport(importSize),- () -> exportNext(),- () -> startExport()));- }- }-- public static class SortedLongListCollector extends SortedListCollector<Long> {- private LongValueStream param;-- public SortedLongListCollector(LongValueStream param) {- super(param, "long");- this.param = param;- }-- @Override- public void collect() {- tempList.clear();- param.streamLongs(val -> tempList.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new LongArrayReservation(- value -> importNext(value),- importSize -> startImport(importSize),- () -> exportNext(),- () -> startExport()));- }- }-- public static class SortedFloatListCollector extends SortedListCollector<Float> {- private FloatValueStream param;-- public SortedFloatListCollector(FloatValueStream param) {- super(param, "float");- this.param = param;- }-- @Override- public void collect() {- tempList.clear();- param.streamFloats(val -> tempList.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new FloatArrayReservation(- value -> importNext(value),- importSize -> startImport(importSize),- () -> exportNext(),- () -> startExport()));- }- }-- public static class SortedDoubleListCollector extends SortedListCollector<Double> {- private DoubleValueStream param;-- public SortedDoubleListCollector(DoubleValueStream param) {- super(param, "double");- this.param = param;- }-- @Override- public void collect() {- tempList.clear();- param.streamDoubles(val -> tempList.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new DoubleArrayReservation(- value -> importNext(value),- importSize -> startImport(importSize),- () -> exportNext(),- () -> startExport()));- }- }-- public static class SortedStringListCollector extends SortedListCollector<String> {- private StringValueStream param;-- public SortedStringListCollector(StringValueStream param) {- super(param, "string");- this.param = param;- }-- @Override- public void collect() {- tempList.clear();- param.streamStrings(val -> tempList.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new StringArrayReservation(- value -> importNext(value),- importSize -> startImport(importSize),- () -> exportNext(),- () -> startExport()));- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SumCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SumCollector.javadeleted file mode 100644index f0db8884242..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/SumCollector.java+++ /dev/null@@ -1,123 +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.function.reduction.data;--import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.DoubleCheckedReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;--/** Collects the sum of the given {@link DoubleValueStream} parameter. */-public class SumCollector extends ReductionDataCollector<SumCollector.SumData> {- private final DoubleValueStream param;- public static final String name = "sum";- private final String exprStr;-- public SumCollector(DoubleValueStream param) {- this.param = param;- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- }-- private double sum;- private boolean exists;-- /**- * Return the sum of the set data- *- * @return the sum- */- public double sum() {- return sum;- }-- /**- * Return whether a sum exists. A sum will always exist if there is at least one existing value- * for the parameter, otherwise the sum does not exist.- *- * @return whether a sum exists- */- public boolean exists() {- return exists;- }-- @Override- public SumData newData() {- SumData data = new SumData();- data.sum = 0;- data.exists = false;- return data;- }-- double tempSum;- boolean tempExists;-- @Override- public void collect() {- tempSum = 0;- tempExists = false;- param.streamDoubles(- val -> {- tempSum += val;- tempExists = true;- });- }-- @Override- protected void apply(SumData data) {- data.sum += tempSum;- data.exists |= tempExists;- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new DoubleCheckedReservation(- value -> {- ioData.sum += value;- ioData.exists = true;- },- () -> ioData.sum,- () -> ioData.exists));- }-- @Override- public void setMergedData(ReductionData data) {- sum = ((SumData) data).sum;- exists = data.exists;- }-- @Override- public void setData(ReductionData data) {- sum = ((SumData) data).sum;- exists = data.exists;- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class SumData extends ReductionData {- double sum;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/UniqueCollector.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/UniqueCollector.javadeleted file mode 100644index 9e0a80b19b2..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/UniqueCollector.java+++ /dev/null@@ -1,230 +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.function.reduction.data;--import java.util.HashSet;-import java.util.Iterator;-import java.util.Set;-import java.util.function.Consumer;-import org.apache.solr.analytics.stream.reservation.DoubleArrayReservation;-import org.apache.solr.analytics.stream.reservation.FloatArrayReservation;-import org.apache.solr.analytics.stream.reservation.IntArrayReservation;-import org.apache.solr.analytics.stream.reservation.LongArrayReservation;-import org.apache.solr.analytics.stream.reservation.ReductionDataReservation;-import org.apache.solr.analytics.stream.reservation.StringArrayReservation;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValueStream;--/**- * Collects the number of unique values that exist for the given parameter.- *- * <p>Supported types are:- *- * <ul>- * <li>Int- * <li>Long- * <li>Float- * <li>Double- * <li>Date (through longs)- * <li>String- * </ul>- */-public abstract class UniqueCollector<T>- extends ReductionDataCollector<UniqueCollector.UniqueData<T>> {- public static final String name = "unique";- private final String exprStr;-- public UniqueCollector(AnalyticsValueStream param) {- this.exprStr = AnalyticsValueStream.createExpressionString(name, param);- this.tempSet = new HashSet<T>();- }-- private long count;-- /**- * Get the count of unique values in the set data.- *- * @return the count of unique values- */- public long count() {- return count;- }-- @Override- public UniqueData<T> newData() {- UniqueData<T> data = new UniqueData<T>();- data.set = new HashSet<>();- data.exists = false;- return data;- }-- Set<T> tempSet;-- @Override- protected void apply(UniqueData<T> data) {- data.set.addAll(tempSet);- }-- Iterator<T> iter;-- public int startExport() {- iter = ioData.set.iterator();- return ioData.set.size();- }-- public T exportNext() {- return iter.next();- }-- @Override- public void setMergedData(ReductionData data) {- count = ((UniqueData<?>) data).set.size();- }-- @Override- public void setData(ReductionData data) {- count = ((UniqueData<?>) data).set.size();- }-- @Override- public String getName() {- return name;- }-- @Override- public String getExpressionStr() {- return exprStr;- }-- public static class UniqueData<T> extends ReductionData {- Set<T> set;- }-- public static class UniqueIntCollector extends UniqueCollector<Integer> {- private IntValueStream param;-- public UniqueIntCollector(IntValueStream param) {- super(param);- this.param = param;- }-- @Override- public void collect() {- tempSet.clear();- param.streamInts(val -> tempSet.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new IntArrayReservation(- value -> ioData.set.add(value), size -> {}, () -> exportNext(), () -> startExport()));- }- }-- public static class UniqueLongCollector extends UniqueCollector<Long> {- private LongValueStream param;-- public UniqueLongCollector(LongValueStream param) {- super(param);- this.param = param;- }-- @Override- public void collect() {- tempSet.clear();- param.streamLongs(val -> tempSet.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new LongArrayReservation(- value -> ioData.set.add(value), size -> {}, () -> exportNext(), () -> startExport()));- }- }-- public static class UniqueFloatCollector extends UniqueCollector<Float> {- private FloatValueStream param;-- public UniqueFloatCollector(FloatValueStream param) {- super(param);- this.param = param;- }-- @Override- public void collect() {- tempSet.clear();- param.streamFloats(val -> tempSet.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new FloatArrayReservation(- value -> ioData.set.add(value), size -> {}, () -> exportNext(), () -> startExport()));- }- }-- public static class UniqueDoubleCollector extends UniqueCollector<Double> {- private DoubleValueStream param;-- public UniqueDoubleCollector(DoubleValueStream param) {- super(param);- this.param = param;- }-- @Override- public void collect() {- tempSet.clear();- param.streamDoubles(val -> tempSet.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new DoubleArrayReservation(- value -> ioData.set.add(value), size -> {}, () -> exportNext(), () -> startExport()));- }- }-- public static class UniqueStringCollector extends UniqueCollector<String> {- private StringValueStream param;-- public UniqueStringCollector(StringValueStream param) {- super(param);- this.param = param;- }-- @Override- public void collect() {- tempSet.clear();- param.streamStrings(val -> tempSet.add(val));- }-- @Override- public void submitReservations(Consumer<ReductionDataReservation<?, ?>> consumer) {- consumer.accept(- new StringArrayReservation(- value -> ioData.set.add(value), size -> {}, () -> exportNext(), () -> startExport()));- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/package-info.javadeleted file mode 100644index 3ba2c0bdddc..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/data/package-info.java+++ /dev/null@@ -1,22 +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.- */--/**- * Reduction data collectors to use while computing analytics expressions. For multi-sharded- * collections, this is the data that is sent from shard to shard.- */-package org.apache.solr.analytics.function.reduction.data;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/package-info.javadeleted file mode 100644index 9df619aeff8..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/function/reduction/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Reduction functions to use for analytics expressions. */-package org.apache.solr.analytics.function.reduction;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/package-info.javadeleted file mode 100644index bc569b9137a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** A solr component to compute complex analytics over search results. */-package org.apache.solr.analytics;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/plugin/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/plugin/package-info.javadeleted file mode 100644index 76ef74497e1..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/plugin/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** MBean plugins for stats collection */-package org.apache.solr.analytics.plugin;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardRequestManager.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardRequestManager.javadeleted file mode 100644index 3ad04a8102a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardRequestManager.java+++ /dev/null@@ -1,245 +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.stream;--import java.io.IOException;-import java.util.ArrayList;-import java.util.Collection;-import java.util.Collections;-import java.util.List;-import java.util.Optional;-import java.util.Random;-import java.util.Set;-import java.util.concurrent.Callable;-import java.util.concurrent.ExecutionException;-import java.util.concurrent.ExecutorService;-import java.util.concurrent.Future;-import org.apache.solr.analytics.AnalyticsRequestManager;-import org.apache.solr.analytics.AnalyticsRequestParser;-import org.apache.solr.analytics.TimeExceededStubException;-import org.apache.solr.client.solrj.SolrClient;-import org.apache.solr.client.solrj.SolrRequest;-import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;-import org.apache.solr.client.solrj.impl.CloudSolrClient;-import org.apache.solr.client.solrj.impl.HttpSolrClient;-import org.apache.solr.client.solrj.request.QueryRequest;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.cloud.ClusterState;-import org.apache.solr.common.cloud.Replica;-import org.apache.solr.common.cloud.Slice;-import org.apache.solr.common.cloud.ZkCoreNodeProps;-import org.apache.solr.common.params.CommonParams;-import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.params.SolrParams;-import org.apache.solr.common.util.ExecutorUtil;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.common.util.SolrNamedThreadFactory;-import org.apache.solr.handler.AnalyticsHandler;-import org.apache.solr.handler.component.AnalyticsComponent;-import org.apache.solr.response.AnalyticsShardResponseWriter;--/**- * This class manages the requesting of shard responses from all shards in the queried collection.- *- * <p>Shard Requests are sent to the {@link AnalyticsHandler} instead of the {@link- * AnalyticsComponent}, which is the entrance to the analytics component for all client requests.- */-public class AnalyticsShardRequestManager {- private final SolrParams params;- protected transient CloudSolrClient cloudSolrClient;- protected transient List<String> replicaUrls;-- /**- * All shards responses, which are received in parallel, are funneled into the manager. So the- * manager must be transient.- */- private final transient AnalyticsRequestManager manager;-- public AnalyticsShardRequestManager(SolrParams params, AnalyticsRequestManager manager) {- this.manager = manager;- this.params = loadParams(params, manager.analyticsRequest);- }-- /**- * Send out shard requests to each shard in the given collection.- *- * @param collection that is being queried- * @param zkHost of the solr cloud hosting the collection- * @throws IOException if an exception occurs while picking shards or sending requests- */- public void sendRequests(String collection, String zkHost) throws IOException {- this.replicaUrls = new ArrayList<>();- this.cloudSolrClient =- new CloudLegacySolrClient.Builder(Collections.singletonList(zkHost), Optional.empty())- .build();- try {- this.cloudSolrClient.connect();- pickShards(collection);- streamFromShards();- } finally {- cloudSolrClient.close();- }- }-- /**- * Pick one replica from each shard to send the shard requests to.- *- * @param collection that is being queried- * @throws IOException if an exception occurs while finding replicas- */- protected void pickShards(String collection) throws IOException {- try {-- ClusterState clusterState = cloudSolrClient.getClusterState();- Set<String> liveNodes = clusterState.getLiveNodes();-- Slice[] slices = clusterState.getCollection(collection).getActiveSlicesArr();-- for (Slice slice : slices) {- Collection<Replica> replicas = slice.getReplicas();- List<Replica> shuffler = new ArrayList<>();- for (Replica replica : replicas) {- if (replica.getState() == Replica.State.ACTIVE- && liveNodes.contains(replica.getNodeName())) shuffler.add(replica);- }-- Collections.shuffle(shuffler, new Random());- Replica rep = shuffler.get(0);- ZkCoreNodeProps zkProps = new ZkCoreNodeProps(rep);- String url = zkProps.getCoreUrl();- replicaUrls.add(url);- }- } catch (Exception e) {- throw new IOException(e);- }- }-- /**- * Send a shard request to each chosen replica, streaming the responses back to the {@link- * AnalyticsRequestManager} through the {@link AnalyticsShardResponseParser}.- *- * <p>A thread pool is used to send the requests simultaneously, and therefore importing the- * results is also done in parallel. However the manager can only import one shard response at a- * time, so the {@link AnalyticsShardResponseParser} is blocked until each import is finished.- *- * @throws IOException if an exception occurs while sending requests.- */- private void streamFromShards() throws IOException {- ExecutorService service =- ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("SolrAnalyticsStream"));- List<Future<SolrException>> futures = new ArrayList<>();- List<AnalyticsShardRequester> openers = new ArrayList<>();- for (String replicaUrl : replicaUrls) {- AnalyticsShardRequester opener = new AnalyticsShardRequester(replicaUrl);- openers.add(opener);- Future<SolrException> future = service.submit(opener);- futures.add(future);- }- try {- for (Future<SolrException> f : futures) {- SolrException e = f.get();- if (e != null) {- if (TimeExceededStubException.isIt(e)) {- manager.setPartialResults(true);- } else {- throw e;- }- }- }- } catch (InterruptedException e1) {- throw new RuntimeException(e1);- } catch (ExecutionException e1) {- throw new RuntimeException(e1);- } finally {- service.shutdown();- for (AnalyticsShardRequester opener : openers) {- opener.close();- }- }- }-- /**- * Create a {@link SolrParams} for shard requests. The only parameters that are copied over from- * the original search request are "q" and "fq".- *- * <p>The request is sent to the {@link AnalyticsHandler} and the output will be encoded in the- * analytics bit-stream format generated by the {@link AnalyticsShardResponseWriter}.- *- * @param paramsIn of the original solr request- * @param analyticsRequest string representation- * @return shard request SolrParams- */- private static SolrParams loadParams(SolrParams paramsIn, String analyticsRequest) {- ModifiableSolrParams solrParams = new ModifiableSolrParams();-- solrParams.add(CommonParams.QT, AnalyticsHandler.NAME);- solrParams.add(CommonParams.WT, AnalyticsShardResponseWriter.NAME);- solrParams.add(CommonParams.Q, paramsIn.get(CommonParams.Q));- solrParams.add(CommonParams.FQ, paramsIn.getParams(CommonParams.FQ));- solrParams.add(CommonParams.TIME_ALLOWED, paramsIn.get(CommonParams.TIME_ALLOWED, "-1"));- solrParams.add(AnalyticsRequestParser.analyticsParamName, analyticsRequest);-- return solrParams;- }-- /**- * A class that opens a connection to a given solr instance, a selected replica of the queried- * collection, and sends a analytics request to the {@link AnalyticsHandler}. The results are- * processed by an {@link AnalyticsShardResponseParser} constructed with the {@link- * AnalyticsRequestManager} passed to the parent {@link AnalyticsShardRequestManager}.- */- protected class AnalyticsShardRequester implements Callable<SolrException> {- private String baseUrl;- SolrClient client;-- /**- * Create a requester for analytics shard data.- *- * @param baseUrl of the replica to send the request to- */- public AnalyticsShardRequester(String baseUrl) {- this.baseUrl = baseUrl;- this.client = null;- }-- /** Send the analytics request to the shard. */- @Override- public SolrException call() throws Exception {- client = new HttpSolrClient.Builder(baseUrl).build();- QueryRequest query = new QueryRequest(params);- query.setPath(AnalyticsHandler.NAME);- query.setResponseParser(new AnalyticsShardResponseParser(manager));- query.setMethod(SolrRequest.METHOD.POST);- NamedList<Object> exception = client.request(query);- if (exception.size() > 0) {- return (SolrException) exception.getVal(0);- }- return null;- }-- /**- * Close the connection to the solr instance.- *- * @throws IOException if an error occurs while closing the connection- */- public void close() throws IOException {- if (client != null) {- client.close();- }- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardResponseParser.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardResponseParser.javadeleted file mode 100644index 1d3210efed4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/AnalyticsShardResponseParser.java+++ /dev/null@@ -1,94 +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.stream;--import java.io.DataInputStream;-import java.io.IOException;-import java.io.InputStream;-import java.io.ObjectInputStream;-import java.io.Reader;-import org.apache.lucene.util.SuppressForbidden;-import org.apache.solr.analytics.AnalyticsRequestManager;-import org.apache.solr.client.solrj.ResponseParser;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.handler.AnalyticsHandler;--/**- * This parser initiates a merge of an Analytics Shard Response, sent from the {@link- * AnalyticsHandler}.- *- * <p>The input stream is immediately sent to the given {@link AnalyticsRequestManager} to merge.- */-public class AnalyticsShardResponseParser extends ResponseParser {- public static final String BINARY_CONTENT_TYPE = "application/octet-stream";- public static final String STREAM = "application/octet-stream";-- private final AnalyticsRequestManager manager;-- /**- * @param manager the manager of the current Analytics Request, will manage the merging of shard- * data- */- public AnalyticsShardResponseParser(AnalyticsRequestManager manager) {- this.manager = manager;- }-- @Override- public String getWriterType() {- return "analytics_shard_stream";- }-- @Override- @SuppressForbidden(reason = "XXX: security hole")- public NamedList<Object> processResponse(InputStream body, String encoding) {- DataInputStream input = new DataInputStream(body);- // check to see if the response is an exception- NamedList<Object> exception = new NamedList<>();- try {- if (input.readBoolean()) {- manager.importShardData(input);- } else {- exception.add("Exception", new ObjectInputStream(input).readObject());- }- } catch (IOException e) {- exception.add(- "Exception",- new SolrException(- ErrorCode.SERVER_ERROR, "Couldn't process analytics shard response", e));- } catch (ClassNotFoundException e1) {- throw new RuntimeException(e1);- }- return exception;- }-- @Override- public String getContentType() {- return BINARY_CONTENT_TYPE;- }-- @Override- public String getVersion() {- return "1";- }-- @Override- public NamedList<Object> processResponse(Reader reader) {- throw new RuntimeException("Cannot handle character stream");- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/package-info.javadeleted file mode 100644index 8f7153ccebf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Classes to manage the I/O between shards. */-package org.apache.solr.analytics.stream;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanArrayReservation.javadeleted file mode 100644index 53fe0c40d93..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanArrayReservation.java+++ /dev/null@@ -1,48 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.BooleanDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.BooleanDataArrayWriter;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanArrayReservation- extends ReductionDataArrayReservation<BooleanConsumer, BooleanSupplier> {-- public BooleanArrayReservation(- BooleanConsumer applier,- IntConsumer sizeApplier,- BooleanSupplier extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public BooleanDataArrayReader createReadStream(DataInput input) {- return new BooleanDataArrayReader(input, applier, sizeApplier);- }-- @Override- public BooleanDataArrayWriter createWriteStream(DataOutput output) {- return new BooleanDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanCheckedReservation.javadeleted file mode 100644index 1788e7802dd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanCheckedReservation.java+++ /dev/null@@ -1,43 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import org.apache.solr.analytics.stream.reservation.read.BooleanCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.BooleanCheckedDataWriter;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanCheckedReservation- extends ReductionCheckedDataReservation<BooleanConsumer, BooleanSupplier> {-- public BooleanCheckedReservation(- BooleanConsumer applier, BooleanSupplier extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public BooleanCheckedDataReader createReadStream(DataInput input) {- return new BooleanCheckedDataReader(input, applier);- }-- @Override- public BooleanCheckedDataWriter createWriteStream(DataOutput output) {- return new BooleanCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanReservation.javadeleted file mode 100644index e7df18536d7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/BooleanReservation.java+++ /dev/null@@ -1,41 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import org.apache.solr.analytics.stream.reservation.read.BooleanDataReader;-import org.apache.solr.analytics.stream.reservation.write.BooleanDataWriter;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanReservation extends ReductionDataReservation<BooleanConsumer, BooleanSupplier> {-- public BooleanReservation(BooleanConsumer applier, BooleanSupplier extractor) {- super(applier, extractor);- }-- @Override- public BooleanDataReader createReadStream(DataInput input) {- return new BooleanDataReader(input, applier);- }-- @Override- public BooleanDataWriter createWriteStream(DataOutput output) {- return new BooleanDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleArrayReservation.javadeleted file mode 100644index 03a3e349990..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleArrayReservation.java+++ /dev/null@@ -1,48 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.DoubleConsumer;-import java.util.function.DoubleSupplier;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.DoubleDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.DoubleDataArrayWriter;--public class DoubleArrayReservation- extends ReductionDataArrayReservation<DoubleConsumer, DoubleSupplier> {-- public DoubleArrayReservation(- DoubleConsumer applier,- IntConsumer sizeApplier,- DoubleSupplier extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public DoubleDataArrayReader createReadStream(DataInput input) {- return new DoubleDataArrayReader(input, applier, sizeApplier);- }-- @Override- public DoubleDataArrayWriter createWriteStream(DataOutput output) {- return new DoubleDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleCheckedReservation.javadeleted file mode 100644index aa90a989b04..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleCheckedReservation.java+++ /dev/null@@ -1,44 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import java.util.function.DoubleConsumer;-import java.util.function.DoubleSupplier;-import org.apache.solr.analytics.stream.reservation.read.DoubleCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.DoubleCheckedDataWriter;--public class DoubleCheckedReservation- extends ReductionCheckedDataReservation<DoubleConsumer, DoubleSupplier> {-- public DoubleCheckedReservation(- DoubleConsumer applier, DoubleSupplier extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public DoubleCheckedDataReader createReadStream(DataInput input) {- return new DoubleCheckedDataReader(input, applier);- }-- @Override- public DoubleCheckedDataWriter createWriteStream(DataOutput output) {- return new DoubleCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleReservation.javadeleted file mode 100644index 6d10127a5cc..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/DoubleReservation.java+++ /dev/null@@ -1,41 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.DoubleConsumer;-import java.util.function.DoubleSupplier;-import org.apache.solr.analytics.stream.reservation.read.DoubleDataReader;-import org.apache.solr.analytics.stream.reservation.write.DoubleDataWriter;--public class DoubleReservation extends ReductionDataReservation<DoubleConsumer, DoubleSupplier> {-- public DoubleReservation(DoubleConsumer applier, DoubleSupplier extractor) {- super(applier, extractor);- }-- @Override- public DoubleDataReader createReadStream(DataInput input) {- return new DoubleDataReader(input, applier);- }-- @Override- public DoubleDataWriter createWriteStream(DataOutput output) {- return new DoubleDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatArrayReservation.javadeleted file mode 100644index 034202c80e9..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatArrayReservation.java+++ /dev/null@@ -1,48 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.FloatDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.FloatDataArrayWriter;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatArrayReservation- extends ReductionDataArrayReservation<FloatConsumer, FloatSupplier> {-- public FloatArrayReservation(- FloatConsumer applier,- IntConsumer sizeApplier,- FloatSupplier extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public FloatDataArrayReader createReadStream(DataInput input) {- return new FloatDataArrayReader(input, applier, sizeApplier);- }-- @Override- public FloatDataArrayWriter createWriteStream(DataOutput output) {- return new FloatDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatCheckedReservation.javadeleted file mode 100644index 4acff59795a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatCheckedReservation.java+++ /dev/null@@ -1,44 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import org.apache.solr.analytics.stream.reservation.read.FloatCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.FloatCheckedDataWriter;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatCheckedReservation- extends ReductionCheckedDataReservation<FloatConsumer, FloatSupplier> {-- public FloatCheckedReservation(- FloatConsumer applier, FloatSupplier extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public FloatCheckedDataReader createReadStream(DataInput input) {- return new FloatCheckedDataReader(input, applier);- }-- @Override- public FloatCheckedDataWriter createWriteStream(DataOutput output) {- return new FloatCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatReservation.javadeleted file mode 100644index 1d827b699ec..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/FloatReservation.java+++ /dev/null@@ -1,41 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import org.apache.solr.analytics.stream.reservation.read.FloatDataReader;-import org.apache.solr.analytics.stream.reservation.write.FloatDataWriter;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatReservation extends ReductionDataReservation<FloatConsumer, FloatSupplier> {-- public FloatReservation(FloatConsumer applier, FloatSupplier extractor) {- super(applier, extractor);- }-- @Override- public FloatDataReader createReadStream(DataInput input) {- return new FloatDataReader(input, applier);- }-- @Override- public FloatDataWriter createWriteStream(DataOutput output) {- return new FloatDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntArrayReservation.javadeleted file mode 100644index d0d1ac39a81..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntArrayReservation.java+++ /dev/null@@ -1,45 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.IntDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.IntDataArrayWriter;--public class IntArrayReservation extends ReductionDataArrayReservation<IntConsumer, IntSupplier> {-- public IntArrayReservation(- IntConsumer applier,- IntConsumer sizeApplier,- IntSupplier extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public IntDataArrayReader createReadStream(DataInput input) {- return new IntDataArrayReader(input, applier, sizeApplier);- }-- @Override- public IntDataArrayWriter createWriteStream(DataOutput output) {- return new IntDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntCheckedReservation.javadeleted file mode 100644index 7913a3019c0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntCheckedReservation.java+++ /dev/null@@ -1,43 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.IntCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.IntCheckedDataWriter;--public class IntCheckedReservation- extends ReductionCheckedDataReservation<IntConsumer, IntSupplier> {-- public IntCheckedReservation(IntConsumer applier, IntSupplier extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public IntCheckedDataReader createReadStream(DataInput input) {- return new IntCheckedDataReader(input, applier);- }-- @Override- public IntCheckedDataWriter createWriteStream(DataOutput output) {- return new IntCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntReservation.javadeleted file mode 100644index 703e94f13e7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/IntReservation.java+++ /dev/null@@ -1,41 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.stream.reservation.read.IntDataReader;-import org.apache.solr.analytics.stream.reservation.write.IntDataWriter;--public class IntReservation extends ReductionDataReservation<IntConsumer, IntSupplier> {-- public IntReservation(IntConsumer applier, IntSupplier extractor) {- super(applier, extractor);- }-- @Override- public IntDataReader createReadStream(DataInput input) {- return new IntDataReader(input, applier);- }-- @Override- public IntDataWriter createWriteStream(DataOutput output) {- return new IntDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongArrayReservation.javadeleted file mode 100644index bc0a6d9f18d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongArrayReservation.java+++ /dev/null@@ -1,48 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import java.util.function.LongConsumer;-import java.util.function.LongSupplier;-import org.apache.solr.analytics.stream.reservation.read.LongDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.LongDataArrayWriter;--public class LongArrayReservation- extends ReductionDataArrayReservation<LongConsumer, LongSupplier> {-- public LongArrayReservation(- LongConsumer applier,- IntConsumer sizeApplier,- LongSupplier extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public LongDataArrayReader createReadStream(DataInput input) {- return new LongDataArrayReader(input, applier, sizeApplier);- }-- @Override- public LongDataArrayWriter createWriteStream(DataOutput output) {- return new LongDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongCheckedReservation.javadeleted file mode 100644index 923ab6cb53e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongCheckedReservation.java+++ /dev/null@@ -1,44 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import java.util.function.LongConsumer;-import java.util.function.LongSupplier;-import org.apache.solr.analytics.stream.reservation.read.LongCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.LongCheckedDataWriter;--public class LongCheckedReservation- extends ReductionCheckedDataReservation<LongConsumer, LongSupplier> {-- public LongCheckedReservation(- LongConsumer applier, LongSupplier extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public LongCheckedDataReader createReadStream(DataInput input) {- return new LongCheckedDataReader(input, applier);- }-- @Override- public LongCheckedDataWriter createWriteStream(DataOutput output) {- return new LongCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongReservation.javadeleted file mode 100644index 72f3bc88b5d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/LongReservation.java+++ /dev/null@@ -1,41 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.LongConsumer;-import java.util.function.LongSupplier;-import org.apache.solr.analytics.stream.reservation.read.LongDataReader;-import org.apache.solr.analytics.stream.reservation.write.LongDataWriter;--public class LongReservation extends ReductionDataReservation<LongConsumer, LongSupplier> {-- public LongReservation(LongConsumer applier, LongSupplier extractor) {- super(applier, extractor);- }-- @Override- public LongDataReader createReadStream(DataInput input) {- return new LongDataReader(input, applier);- }-- @Override- public LongDataWriter createWriteStream(DataOutput output) {- return new LongDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionCheckedDataReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionCheckedDataReservation.javadeleted file mode 100644index 7db0f0f4b20..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionCheckedDataReservation.java+++ /dev/null@@ -1,34 +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.stream.reservation;--import java.util.function.BooleanSupplier;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;--/**- * A reservation allows a {@link ReductionDataCollector} to specify a piece of data it needs to- * export from the shard. This data may, or may not, exist. The {@link ReductionDataCollector} need- * not check while importing/exporting since the Reader/Writers handle all checking.- */-public abstract class ReductionCheckedDataReservation<A, E> extends ReductionDataReservation<A, E> {- protected final BooleanSupplier exists;-- protected ReductionCheckedDataReservation(A applier, E extractor, BooleanSupplier exists) {- super(applier, extractor);- this.exists = exists;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataArrayReservation.javadeleted file mode 100644index 317f7743bd7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataArrayReservation.java+++ /dev/null@@ -1,37 +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.stream.reservation;--import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;--/**- * A reservation allows a {@link ReductionDataCollector} to specify an array of data it needs to- * export from the shard.- */-public abstract class ReductionDataArrayReservation<A, E> extends ReductionDataReservation<A, E> {- protected final IntConsumer sizeApplier;- protected final IntSupplier sizeExtractor;-- protected ReductionDataArrayReservation(- A applier, IntConsumer sizeApplier, E extractor, IntSupplier sizeExtractor) {- super(applier, extractor);- this.sizeApplier = sizeApplier;- this.sizeExtractor = sizeExtractor;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.javadeleted file mode 100644index 446cc2a1978..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.java+++ /dev/null@@ -1,54 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;-import org.apache.solr.analytics.stream.reservation.read.ReductionDataReader;-import org.apache.solr.analytics.stream.reservation.write.ReductionDataWriter;--/**- * A reservation allows a {@link ReductionDataCollector} to specify a piece of data it needs to- * export from the shard.- */-public abstract class ReductionDataReservation<A, E> {- protected final A applier;- protected final E extractor;-- protected ReductionDataReservation(A applier, E extractor) {- this.applier = applier;- this.extractor = extractor;- }-- /**- * Generate a {@link ReductionDataReader} that merges the set of data this reservation represents.- *- * @param input the shard input stream- * @return a reader from the given input- */- public abstract ReductionDataReader<A> createReadStream(DataInput input);-- /**- * Generate a {@link ReductionDataWriter} that exports the set of data this reservation- * represents.- *- * @param output the shard output stream- * @return a writer to the given output- */- public abstract ReductionDataWriter<E> createWriteStream(DataOutput output);-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringArrayReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringArrayReservation.javadeleted file mode 100644index ecc00e4675a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringArrayReservation.java+++ /dev/null@@ -1,48 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.Consumer;-import java.util.function.IntConsumer;-import java.util.function.IntSupplier;-import java.util.function.Supplier;-import org.apache.solr.analytics.stream.reservation.read.StringDataArrayReader;-import org.apache.solr.analytics.stream.reservation.write.StringDataArrayWriter;--public class StringArrayReservation- extends ReductionDataArrayReservation<Consumer<String>, Supplier<String>> {-- public StringArrayReservation(- Consumer<String> applier,- IntConsumer sizeApplier,- Supplier<String> extractor,- IntSupplier sizeExtractor) {- super(applier, sizeApplier, extractor, sizeExtractor);- }-- @Override- public StringDataArrayReader createReadStream(DataInput input) {- return new StringDataArrayReader(input, applier, sizeApplier);- }-- @Override- public StringDataArrayWriter createWriteStream(DataOutput output) {- return new StringDataArrayWriter(output, extractor, sizeExtractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringCheckedReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringCheckedReservation.javadeleted file mode 100644index cde159e9367..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringCheckedReservation.java+++ /dev/null@@ -1,44 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.BooleanSupplier;-import java.util.function.Consumer;-import java.util.function.Supplier;-import org.apache.solr.analytics.stream.reservation.read.StringCheckedDataReader;-import org.apache.solr.analytics.stream.reservation.write.StringCheckedDataWriter;--public class StringCheckedReservation- extends ReductionCheckedDataReservation<Consumer<String>, Supplier<String>> {-- public StringCheckedReservation(- Consumer<String> applier, Supplier<String> extractor, BooleanSupplier exists) {- super(applier, extractor, exists);- }-- @Override- public StringCheckedDataReader createReadStream(DataInput input) {- return new StringCheckedDataReader(input, applier);- }-- @Override- public StringCheckedDataWriter createWriteStream(DataOutput output) {- return new StringCheckedDataWriter(output, extractor, exists);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringReservation.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringReservation.javadeleted file mode 100644index 2ec14060f67..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/StringReservation.java+++ /dev/null@@ -1,42 +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.stream.reservation;--import java.io.DataInput;-import java.io.DataOutput;-import java.util.function.Consumer;-import java.util.function.Supplier;-import org.apache.solr.analytics.stream.reservation.read.StringDataReader;-import org.apache.solr.analytics.stream.reservation.write.StringDataWriter;--public class StringReservation- extends ReductionDataReservation<Consumer<String>, Supplier<String>> {-- public StringReservation(Consumer<String> applier, Supplier<String> extractor) {- super(applier, extractor);- }-- @Override- public StringDataReader createReadStream(DataInput input) {- return new StringDataReader(input, applier);- }-- @Override- public StringDataWriter createWriteStream(DataOutput output) {- return new StringDataWriter(output, extractor);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/package-info.javadeleted file mode 100644index a434f8a4e57..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/package-info.java+++ /dev/null@@ -1,22 +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.- */--/**- * Reservation classes for a single type of data being stored by one Reduction Data Collector. These- * reservations are imported/exported between shards during the streaming process.- */-package org.apache.solr.analytics.stream.reservation;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanCheckedDataReader.javadeleted file mode 100644index 2fb2e05d3cd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanCheckedDataReader extends ReductionCheckedDataReader<BooleanConsumer> {-- public BooleanCheckedDataReader(DataInput inputStream, BooleanConsumer applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readBoolean());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataArrayReader.javadeleted file mode 100644index 59bca768730..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataArrayReader.java+++ /dev/null@@ -1,37 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanDataArrayReader extends ReductionDataArrayReader<BooleanConsumer> {-- public BooleanDataArrayReader(- DataInput inputStream, BooleanConsumer applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readBoolean());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataReader.javadeleted file mode 100644index 9ad92f95f59..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/BooleanDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import org.apache.solr.analytics.util.function.BooleanConsumer;--public class BooleanDataReader extends ReductionDataReader<BooleanConsumer> {-- public BooleanDataReader(DataInput inputStream, BooleanConsumer applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- applier.accept(inputStream.readBoolean());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleCheckedDataReader.javadeleted file mode 100644index 8348e29a36b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.DoubleConsumer;--public class DoubleCheckedDataReader extends ReductionCheckedDataReader<DoubleConsumer> {-- public DoubleCheckedDataReader(DataInput inputStream, DoubleConsumer applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readDouble());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataArrayReader.javadeleted file mode 100644index 7a72129f9c6..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataArrayReader.java+++ /dev/null@@ -1,36 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.DoubleConsumer;-import java.util.function.IntConsumer;--public class DoubleDataArrayReader extends ReductionDataArrayReader<DoubleConsumer> {-- public DoubleDataArrayReader(DataInput inputStream, DoubleConsumer applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readDouble());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataReader.javadeleted file mode 100644index 99129d1c0cf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/DoubleDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.DoubleConsumer;--public class DoubleDataReader extends ReductionDataReader<DoubleConsumer> {-- public DoubleDataReader(DataInput inputStream, DoubleConsumer applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- applier.accept(inputStream.readDouble());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatCheckedDataReader.javadeleted file mode 100644index bdf49560231..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import org.apache.solr.analytics.util.function.FloatConsumer;--public class FloatCheckedDataReader extends ReductionCheckedDataReader<FloatConsumer> {-- public FloatCheckedDataReader(DataInput inputStream, FloatConsumer applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readFloat());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataArrayReader.javadeleted file mode 100644index 534f73e8ef9..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataArrayReader.java+++ /dev/null@@ -1,36 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;--public class FloatDataArrayReader extends ReductionDataArrayReader<FloatConsumer> {-- public FloatDataArrayReader(DataInput inputStream, FloatConsumer applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readFloat());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataReader.javadeleted file mode 100644index 43e0416ddd4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/FloatDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import org.apache.solr.analytics.util.function.FloatConsumer;--public class FloatDataReader extends ReductionDataReader<FloatConsumer> {-- public FloatDataReader(DataInput inputStream, FloatConsumer applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- applier.accept(inputStream.readFloat());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntCheckedDataReader.javadeleted file mode 100644index 8010d1fa8cd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;--public class IntCheckedDataReader extends ReductionCheckedDataReader<IntConsumer> {-- public IntCheckedDataReader(DataInput inputStream, IntConsumer applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readInt());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataArrayReader.javadeleted file mode 100644index 7fe4c85edab..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataArrayReader.java+++ /dev/null@@ -1,35 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;--public class IntDataArrayReader extends ReductionDataArrayReader<IntConsumer> {-- public IntDataArrayReader(DataInput inputStream, IntConsumer applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readInt());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataReader.javadeleted file mode 100644index 0b272cbe266..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/IntDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;--public class IntDataReader extends ReductionDataReader<IntConsumer> {-- public IntDataReader(DataInput inputStream, IntConsumer applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- applier.accept(inputStream.readInt());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongCheckedDataReader.javadeleted file mode 100644index 0e68e73c19c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.LongConsumer;--public class LongCheckedDataReader extends ReductionCheckedDataReader<LongConsumer> {-- public LongCheckedDataReader(DataInput inputStream, LongConsumer applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readLong());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataArrayReader.javadeleted file mode 100644index 4b5f2162fed..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataArrayReader.java+++ /dev/null@@ -1,36 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;-import java.util.function.LongConsumer;--public class LongDataArrayReader extends ReductionDataArrayReader<LongConsumer> {-- public LongDataArrayReader(DataInput inputStream, LongConsumer applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readLong());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataReader.javadeleted file mode 100644index ea18fff9638..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/LongDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.LongConsumer;--public class LongDataReader extends ReductionDataReader<LongConsumer> {-- public LongDataReader(DataInput inputStream, LongConsumer applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- applier.accept(inputStream.readLong());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionCheckedDataReader.javadeleted file mode 100644index e6461fc6bb4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionCheckedDataReader.java+++ /dev/null@@ -1,52 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;--/**- * Abstract class to manage the reading and application of data from a {@link DataInput} stream. The- * data being read may not exist, so the reader first checks before reading.- */-public abstract class ReductionCheckedDataReader<A> extends ReductionDataReader<A> {-- public ReductionCheckedDataReader(DataInput inputStream, A applier) {- super(inputStream, applier);- }-- @Override- /**- * Read a piece of data from the input stream and feed it to the applier. <br>- * First checks that the piece of data exists before reading.- *- * @throws IOException if an exception occurs while reading from the input stream- */- public void read() throws IOException {- if (inputStream.readBoolean()) {- checkedRead();- }- }-- /**- * Read a piece of data from the input stream and feed it to the applier. <br>- * This piece of data is guaranteed to be there.- *- * @throws IOException if an exception occurs while reading from the input stream- */- protected abstract void checkedRead() throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataArrayReader.javadeleted file mode 100644index b9ba9b95a66..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataArrayReader.java+++ /dev/null@@ -1,56 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.IntConsumer;--/**- * Abstract class to manage the reading and application of array data from a {@link DataInput}- * stream.- */-public abstract class ReductionDataArrayReader<A> extends ReductionDataReader<A> {- protected final IntConsumer signal;-- public ReductionDataArrayReader(DataInput inputStream, A applier, IntConsumer signal) {- super(inputStream, applier);-- this.signal = signal;- }-- @Override- /**- * Read an array of data from the input stream and feed it to the applier, first signaling the- * size of the array.- *- * @throws IOException if an exception occurs while reading from the input stream- */- public void read() throws IOException {- int size = inputStream.readInt();- signal.accept(size);- read(size);- }-- /**- * Read an array from the input stream, feeding each member to the applier.- *- * @param size length of the array to read- * @throws IOException if an exception occurs while reading from the input stream- */- protected abstract void read(int size) throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataReader.javadeleted file mode 100644index c454c528076..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/ReductionDataReader.java+++ /dev/null@@ -1,38 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;--/** Abstract class to manage the reading and application of data from a {@link DataInput} stream. */-public abstract class ReductionDataReader<A> {- protected final DataInput inputStream;- protected final A applier;-- public ReductionDataReader(DataInput inputStream, A applier) {- this.inputStream = inputStream;- this.applier = applier;- }-- /**- * Read a piece of data from the input stream and feed it to the applier.- *- * @throws IOException if an exception occurs while reading from the input stream- */- public abstract void read() throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringCheckedDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringCheckedDataReader.javadeleted file mode 100644index c8dc262106b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringCheckedDataReader.java+++ /dev/null@@ -1,33 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.Consumer;--public class StringCheckedDataReader extends ReductionCheckedDataReader<Consumer<String>> {-- public StringCheckedDataReader(DataInput inputStream, Consumer<String> applier) {- super(inputStream, applier);- }-- @Override- public void checkedRead() throws IOException {- applier.accept(inputStream.readUTF());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataArrayReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataArrayReader.javadeleted file mode 100644index 8508a83d23c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataArrayReader.java+++ /dev/null@@ -1,37 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.Consumer;-import java.util.function.IntConsumer;--public class StringDataArrayReader extends ReductionDataArrayReader<Consumer<String>> {-- public StringDataArrayReader(- DataInput inputStream, Consumer<String> applier, IntConsumer signal) {- super(inputStream, applier, signal);- }-- @Override- public void read(int size) throws IOException {- for (int i = 0; i < size; ++i) {- applier.accept(inputStream.readUTF());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataReader.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataReader.javadeleted file mode 100644index b0ce00eab6a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/StringDataReader.java+++ /dev/null@@ -1,35 +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.stream.reservation.read;--import java.io.DataInput;-import java.io.IOException;-import java.util.function.Consumer;--public class StringDataReader extends ReductionDataReader<Consumer<String>> {-- public StringDataReader(DataInput inputStream, Consumer<String> applier) {- super(inputStream, applier);- }-- @Override- public void read() throws IOException {- if (inputStream.readBoolean()) {- applier.accept(inputStream.readUTF());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/package-info.javadeleted file mode 100644index 194cc222bb7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/read/package-info.java+++ /dev/null@@ -1,22 +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.- */--/**- * Reading classes for a single type of data being stored by one Reduction Data Collector. These- * writers are used to import data from shards during the streaming process.- */-package org.apache.solr.analytics.stream.reservation.read;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanCheckedDataWriter.javadeleted file mode 100644index 9482c3169e2..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanCheckedDataWriter.java+++ /dev/null@@ -1,34 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;--public class BooleanCheckedDataWriter extends ReductionCheckedDataWriter<BooleanSupplier> {-- public BooleanCheckedDataWriter(- DataOutput output, BooleanSupplier extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeBoolean(extractor.getAsBoolean());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataArrayWriter.javadeleted file mode 100644index 2cb60ac1a62..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataArrayWriter.java+++ /dev/null@@ -1,37 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import java.util.function.IntSupplier;--public class BooleanDataArrayWriter extends ReductionDataArrayWriter<BooleanSupplier> {-- public BooleanDataArrayWriter(- DataOutput output, BooleanSupplier extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeBoolean(extractor.getAsBoolean());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataWriter.javadeleted file mode 100644index 289cb2e05a8..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/BooleanDataWriter.java+++ /dev/null@@ -1,33 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;--public class BooleanDataWriter extends ReductionDataWriter<BooleanSupplier> {-- public BooleanDataWriter(DataOutput output, BooleanSupplier extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- output.writeBoolean(extractor.getAsBoolean());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleCheckedDataWriter.javadeleted file mode 100644index 767615ce263..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleCheckedDataWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import java.util.function.DoubleSupplier;--public class DoubleCheckedDataWriter extends ReductionCheckedDataWriter<DoubleSupplier> {-- public DoubleCheckedDataWriter(- DataOutput output, DoubleSupplier extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeDouble(extractor.getAsDouble());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataArrayWriter.javadeleted file mode 100644index fb5033e1af8..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataArrayWriter.java+++ /dev/null@@ -1,37 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.DoubleSupplier;-import java.util.function.IntSupplier;--public class DoubleDataArrayWriter extends ReductionDataArrayWriter<DoubleSupplier> {-- public DoubleDataArrayWriter(- DataOutput output, DoubleSupplier extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeDouble(extractor.getAsDouble());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataWriter.javadeleted file mode 100644index 89371a69115..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/DoubleDataWriter.java+++ /dev/null@@ -1,33 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.DoubleSupplier;--public class DoubleDataWriter extends ReductionDataWriter<DoubleSupplier> {-- public DoubleDataWriter(DataOutput output, DoubleSupplier extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- output.writeDouble(extractor.getAsDouble());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatCheckedDataWriter.javadeleted file mode 100644index bd49cfae87c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatCheckedDataWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatCheckedDataWriter extends ReductionCheckedDataWriter<FloatSupplier> {-- public FloatCheckedDataWriter(- DataOutput output, FloatSupplier extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeFloat(extractor.getAsFloat());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataArrayWriter.javadeleted file mode 100644index bbb18727c31..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataArrayWriter.java+++ /dev/null@@ -1,37 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatDataArrayWriter extends ReductionDataArrayWriter<FloatSupplier> {-- public FloatDataArrayWriter(- DataOutput output, FloatSupplier extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeFloat(extractor.getAsFloat());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataWriter.javadeleted file mode 100644index 3294b00cbef..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/FloatDataWriter.java+++ /dev/null@@ -1,33 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import org.apache.solr.analytics.util.function.FloatSupplier;--public class FloatDataWriter extends ReductionDataWriter<FloatSupplier> {-- public FloatDataWriter(DataOutput output, FloatSupplier extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- output.writeFloat(extractor.getAsFloat());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntCheckedDataWriter.javadeleted file mode 100644index d0d68ccef4e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntCheckedDataWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import java.util.function.IntSupplier;--public class IntCheckedDataWriter extends ReductionCheckedDataWriter<IntSupplier> {-- public IntCheckedDataWriter(- DataOutput output, IntSupplier extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeInt(extractor.getAsInt());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataArrayWriter.javadeleted file mode 100644index 7c11223f7ae..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataArrayWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;--public class IntDataArrayWriter extends ReductionDataArrayWriter<IntSupplier> {-- public IntDataArrayWriter(DataOutput output, IntSupplier extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeInt(extractor.getAsInt());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataWriter.javadeleted file mode 100644index effcdc40425..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/IntDataWriter.java+++ /dev/null@@ -1,33 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;--public class IntDataWriter extends ReductionDataWriter<IntSupplier> {-- public IntDataWriter(DataOutput output, IntSupplier extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- output.writeInt(extractor.getAsInt());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongCheckedDataWriter.javadeleted file mode 100644index d106d9d17e3..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongCheckedDataWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import java.util.function.LongSupplier;--public class LongCheckedDataWriter extends ReductionCheckedDataWriter<LongSupplier> {-- public LongCheckedDataWriter(- DataOutput output, LongSupplier extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeLong(extractor.getAsLong());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataArrayWriter.javadeleted file mode 100644index 4ac0c50c00d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataArrayWriter.java+++ /dev/null@@ -1,36 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;-import java.util.function.LongSupplier;--public class LongDataArrayWriter extends ReductionDataArrayWriter<LongSupplier> {-- public LongDataArrayWriter(DataOutput output, LongSupplier extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeLong(extractor.getAsLong());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataWriter.javadeleted file mode 100644index 8a76480f6cc..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/LongDataWriter.java+++ /dev/null@@ -1,33 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.LongSupplier;--public class LongDataWriter extends ReductionDataWriter<LongSupplier> {-- public LongDataWriter(DataOutput output, LongSupplier extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- output.writeLong(extractor.getAsLong());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionCheckedDataWriter.javadeleted file mode 100644index b8ff64db177..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionCheckedDataWriter.java+++ /dev/null@@ -1,60 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;--/**- * Abstract class to manage the extraction and writing of data to a {@link DataOutput} stream. The- * data being written may not exist, so the writer first writes whether the data exists before- * writing the data.- */-public abstract class ReductionCheckedDataWriter<C> extends ReductionDataWriter<C> {- private final BooleanSupplier existsSupplier;-- public ReductionCheckedDataWriter(- DataOutput output, C extractor, BooleanSupplier existsSupplier) {- super(output, extractor);-- this.existsSupplier = existsSupplier;- }-- /**- * Write a piece of data, retrieved from the extractor, to the output stream. <br>- * First writes whether the data exists, then if it does exists writes the data.- *- * @throws IOException if an exception occurs while writing to the output stream- */- @Override- public void write() throws IOException {- boolean exists = existsSupplier.getAsBoolean();- output.writeBoolean(exists);- if (exists) {- checkedWrite();- }- }-- /**- * Write a piece of data, retrieved from the extractor, to the output stream. <br>- * The data being written is guaranteed to exist.- *- * @throws IOException if an exception occurs while writing to the output stream- */- protected abstract void checkedWrite() throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataArrayWriter.javadeleted file mode 100644index 864b5ac821a..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataArrayWriter.java+++ /dev/null@@ -1,54 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;--/**- * Abstract class to manage the extraction and writing of array data to a {@link DataOutput} stream.- */-public abstract class ReductionDataArrayWriter<C> extends ReductionDataWriter<C> {- private final IntSupplier sizeSupplier;-- public ReductionDataArrayWriter(DataOutput output, C extractor, IntSupplier sizeSupplier) {- super(output, extractor);-- this.sizeSupplier = sizeSupplier;- }-- /**- * Write an array of data, retrieved from the extractor, and its size, received from the- * sizeSupplier, to the output stream.- *- * @throws IOException if an exception occurs while writing to the output stream- */- @Override- public void write() throws IOException {- int size = sizeSupplier.getAsInt();- output.writeInt(size);- write(size);- }-- /**- * Write an array of data, retrieved from the extractor, with the given size to the output stream.- *- * @throws IOException if an exception occurs while writing to the output stream- */- protected abstract void write(int size) throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataWriter.javadeleted file mode 100644index 7026117c8ad..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/ReductionDataWriter.java+++ /dev/null@@ -1,41 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;--/**- * Abstract public class to manage the extraction and writing of data to a {@link DataOutput}- * stream.- */-public abstract class ReductionDataWriter<E> {- protected final DataOutput output;- protected final E extractor;-- public ReductionDataWriter(DataOutput output, E extractor) {- this.output = output;- this.extractor = extractor;- }-- /**- * Write a piece of data, retrieved from the extractor, to the output stream.- *- * @throws IOException if an exception occurs while writing to the output stream- */- public abstract void write() throws IOException;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringCheckedDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringCheckedDataWriter.javadeleted file mode 100644index 0664ae83cf6..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringCheckedDataWriter.java+++ /dev/null@@ -1,35 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.BooleanSupplier;-import java.util.function.Supplier;--public class StringCheckedDataWriter extends ReductionCheckedDataWriter<Supplier<String>> {-- public StringCheckedDataWriter(- DataOutput output, Supplier<String> extractor, BooleanSupplier existsSupplier) {- super(output, extractor, existsSupplier);- }-- @Override- public void checkedWrite() throws IOException {- output.writeUTF(extractor.get());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataArrayWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataArrayWriter.javadeleted file mode 100644index 938819a5f9b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataArrayWriter.java+++ /dev/null@@ -1,37 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.IntSupplier;-import java.util.function.Supplier;--public class StringDataArrayWriter extends ReductionDataArrayWriter<Supplier<String>> {-- public StringDataArrayWriter(- DataOutput output, Supplier<String> extractor, IntSupplier sizeSupplier) {- super(output, extractor, sizeSupplier);- }-- @Override- public void write(int size) throws IOException {- for (int i = 0; i < size; ++i) {- output.writeUTF(extractor.get());- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataWriter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataWriter.javadeleted file mode 100644index aadc1be2acd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/StringDataWriter.java+++ /dev/null@@ -1,37 +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.stream.reservation.write;--import java.io.DataOutput;-import java.io.IOException;-import java.util.function.Supplier;--public class StringDataWriter extends ReductionDataWriter<Supplier<String>> {-- public StringDataWriter(DataOutput output, Supplier<String> extractor) {- super(output, extractor);- }-- @Override- public void write() throws IOException {- String temp = extractor.get();- output.writeBoolean(temp != null);- if (temp != null) {- output.writeUTF(temp);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/package-info.javadeleted file mode 100644index 4da0cf348ce..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/stream/reservation/write/package-info.java+++ /dev/null@@ -1,22 +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.- */--/**- * Writing classes for a single type of data being stored by one Reduction Data Collector. These- * writers are used to export data between shards during the streaming process.- */-package org.apache.solr.analytics.stream.reservation.write;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/AnalyticsResponseHeadings.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/AnalyticsResponseHeadings.javadeleted file mode 100644index c955d8a221f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/AnalyticsResponseHeadings.java+++ /dev/null@@ -1,34 +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.util;--/** Holds the headers for analytics responses. */-public class AnalyticsResponseHeadings {-- public static final String COMPLETED_HEADER = "analytics_response";- public static final String RESULTS = "results";- public static final String GROUPINGS = "groupings";- public static final String FACET_VALUE = "value";- public static final String PIVOT_NAME = "pivot";- public static final String PIVOT_CHILDREN = "children";-- // Old Olap-style- public static final String COMPLETED_OLD_HEADER = "stats";- public static final String FIELD_FACETS = "fieldFacets";- public static final String RANGE_FACETS = "rangeFacets";- public static final String QUERY_FACETS = "queryFacets";-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/FacetRangeGenerator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/FacetRangeGenerator.javadeleted file mode 100644index b3709f82b94..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/FacetRangeGenerator.java+++ /dev/null@@ -1,405 +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.util;--import java.util.ArrayList;-import java.util.Date;-import java.util.EnumSet;-import java.util.List;-import java.util.Set;-import org.apache.solr.analytics.facet.RangeFacet;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.params.FacetParams.FacetRangeInclude;-import org.apache.solr.common.params.FacetParams.FacetRangeOther;-import org.apache.solr.schema.FieldType;-import org.apache.solr.schema.NumericFieldType;-import org.apache.solr.schema.SchemaField;-import org.apache.solr.util.DateMathParser;--/** Calculates a set of {@link FacetRange}s for a given {@link RangeFacet}. */-public abstract class FacetRangeGenerator<T extends Comparable<T>> {- protected final SchemaField field;- protected final RangeFacet rangeFacet;-- public FacetRangeGenerator(final RangeFacet rangeFacet) {- this.field = rangeFacet.getField();- this.rangeFacet = rangeFacet;- }-- /**- * Formats a Range endpoint for use as a range label name in the response. Default Impl just uses- * toString()- */- public String formatValue(final T val) {- return val.toString();- }-- /**- * Parses a String param into an Range endpoint value throwing a useful exception if not possible- */- public final T getValue(final String rawval) {- try {- return parseVal(rawval);- } catch (Exception e) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "Can't parse value " + rawval + " for field: " + field.getName(),- e);- }- }-- /**- * Parses a String param into an Range endpoint. Can throw a low level format exception as needed.- */- protected abstract T parseVal(final String rawval) throws java.text.ParseException;-- /**- * Parses a String param into a value that represents the gap and can be included in the response,- * throwing a useful exception if not possible.- *- * <p>Note: uses Object as the return type instead of T for things like Date where gap is just a- * DateMathParser string- */- public final Object getGap(final String gap) {- try {- return parseGap(gap);- } catch (Exception e) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "Can't parse gap " + gap + " for field: " + field.getName(),- e);- }- }-- /**- * Parses a String param into a value that represents the gap and can be included in the response.- * Can throw a low level format exception as needed.- *- * <p>Default Impl calls parseVal- */- protected Object parseGap(final String rawval) throws java.text.ParseException {- return parseVal(rawval);- }-- /**- * Adds the String gap param to a low Range endpoint value to determine the corrisponding high- * Range endpoint value, throwing a useful exception if not possible.- */- public final T addGap(T value, String gap) {- try {- return parseAndAddGap(value, gap);- } catch (Exception e) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "Can't add gap " + gap + " to value " + value + " for field: " + field.getName(),- e);- }- }-- /**- * Adds the String gap param to a low Range endpoint value to determine the corrisponding high- * Range endpoint value. Can throw a low level format exception as needed.- */- protected abstract T parseAndAddGap(T value, String gap) throws java.text.ParseException;-- public static class FacetRange {- public final String name;- public final String lower;- public final String upper;- public final boolean includeLower;- public final boolean includeUpper;- private final String facetValue;-- public FacetRange(- String name, String lower, String upper, boolean includeLower, boolean includeUpper) {- this.name = name;- this.lower = lower;- this.upper = upper;- this.includeLower = includeLower;- this.includeUpper = includeUpper;-- String value = "(*";- if (lower != null) {- value = (includeLower ? "[" : "(") + lower;- }- value += " TO ";- if (upper == null) {- value += "*)";- } else {- value += upper + (includeUpper ? "]" : ")");- }- facetValue = value;- }-- @Override- public String toString() {- return facetValue;- }- }-- public List<FacetRange> getRanges() {-- final T start = getValue(rangeFacet.getStart());- T end = getValue(rangeFacet.getEnd()); // not final, hardend may change this-- if (end.compareTo(start) < 0) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "range facet 'end' comes before 'start': " + end + " < " + start);- }-- // explicitly return the gap. compute this early so we are more- // likely to catch parse errors before attempting math- final List<String> gaps = rangeFacet.getGaps();- String gap = gaps.get(0);-- final EnumSet<FacetRangeInclude> include = rangeFacet.getInclude();-- T low = start;-- List<FacetRange> ranges = new ArrayList<>();-- int gapCounter = 0;-- while (low.compareTo(end) < 0) {- if (gapCounter < gaps.size()) {- gap = gaps.get(gapCounter++);- }- T high = addGap(low, gap);- if (end.compareTo(high) < 0) {- if (rangeFacet.isHardEnd()) {- high = end;- } else {- end = high;- }- }-- if (high.compareTo(low) < 0) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "range facet infinite loop (is gap negative? did the math overflow?)");- }-- if (high.compareTo(low) == 0) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "range facet infinite loop: gap is either zero, or too small relative start/end and caused underflow: "- + low- + " + "- + gap- + " = "- + high);- }-- final boolean includeLower =- (include.contains(FacetRangeInclude.ALL)- || include.contains(FacetRangeInclude.LOWER)- || (include.contains(FacetRangeInclude.EDGE) && 0 == low.compareTo(start)));- final boolean includeUpper =- (include.contains(FacetRangeInclude.ALL)- || include.contains(FacetRangeInclude.UPPER)- || (include.contains(FacetRangeInclude.EDGE) && 0 == high.compareTo(end)));-- final String lowS = formatValue(low);- final String highS = formatValue(high);-- ranges.add(new FacetRange(lowS, lowS, highS, includeLower, includeUpper));- low = high;- }-- final Set<FacetRangeOther> others = rangeFacet.getOthers();- if (null != others && 0 < others.size()) {-- // no matter what other values are listed, we don't do- // anything if "none" is specified.- if (!others.contains(FacetRangeOther.NONE)) {-- boolean all = others.contains(FacetRangeOther.ALL);-- if (all || others.contains(FacetRangeOther.BEFORE)) {- // include upper bound if "outer" or if first gap doesn't already include it- ranges.add(- new FacetRange(- FacetRangeOther.BEFORE.toString(),- null,- formatValue(start),- false,- include.contains(FacetRangeInclude.OUTER)- || include.contains(FacetRangeInclude.ALL)- || !(include.contains(FacetRangeInclude.LOWER)- || include.contains(FacetRangeInclude.EDGE))));- }- if (all || others.contains(FacetRangeOther.AFTER)) {- // include lower bound if "outer" or if last gap doesn't already include it- ranges.add(- new FacetRange(- FacetRangeOther.AFTER.toString(),- formatValue(end),- null,- include.contains(FacetRangeInclude.OUTER)- || include.contains(FacetRangeInclude.ALL)- || !(include.contains(FacetRangeInclude.UPPER)- || include.contains(FacetRangeInclude.EDGE)),- false));- }- if (all || others.contains(FacetRangeOther.BETWEEN)) {- ranges.add(- new FacetRange(- FacetRangeOther.BETWEEN.toString(),- formatValue(start),- formatValue(end),- include.contains(FacetRangeInclude.LOWER)- || include.contains(FacetRangeInclude.EDGE)- || include.contains(FacetRangeInclude.ALL),- include.contains(FacetRangeInclude.UPPER)- || include.contains(FacetRangeInclude.EDGE)- || include.contains(FacetRangeInclude.ALL)));- }- }- }-- return ranges;- }-- public static FacetRangeGenerator<? extends Comparable<?>> create(RangeFacet rangeFacet) {- final SchemaField sf = rangeFacet.getField();- final FieldType ft = sf.getType();- final FacetRangeGenerator<?> calc;- if (ft instanceof NumericFieldType) {- switch (ft.getNumberType()) {- case FLOAT:- calc = new FloatFacetRangeGenerator(rangeFacet);- break;- case DOUBLE:- calc = new DoubleFacetRangeGenerator(rangeFacet);- break;- case INTEGER:- calc = new IntegerFacetRangeGenerator(rangeFacet);- break;- case LONG:- calc = new LongFacetRangeGenerator(rangeFacet);- break;- case DATE:- calc = new DateFacetRangeGenerator(rangeFacet, null);- break;- default:- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "Unable to range facet on numeric field of unexpected type: " + sf.getName());- }- } else {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on non-numeric field: " + sf);- }- return calc;- }-- static class IntegerFacetRangeGenerator extends FacetRangeGenerator<Integer> {- public IntegerFacetRangeGenerator(final RangeFacet rangeFacet) {- super(rangeFacet);- }-- @Override- protected Integer parseVal(String rawval) {- return Integer.valueOf(rawval);- }-- @Override- public Integer parseAndAddGap(Integer value, String gap) {- return value.intValue() + Integer.valueOf(gap).intValue();- }- }-- static class LongFacetRangeGenerator extends FacetRangeGenerator<Long> {- public LongFacetRangeGenerator(final RangeFacet rangeFacet) {- super(rangeFacet);- }-- @Override- protected Long parseVal(String rawval) {- return Long.valueOf(rawval);- }-- @Override- public Long parseAndAddGap(Long value, String gap) {- return value.longValue() + Long.valueOf(gap).longValue();- }- }-- static class FloatFacetRangeGenerator extends FacetRangeGenerator<Float> {- public FloatFacetRangeGenerator(final RangeFacet rangeFacet) {- super(rangeFacet);- }-- @Override- protected Float parseVal(String rawval) {- return Float.valueOf(rawval);- }-- @Override- public Float parseAndAddGap(Float value, String gap) {- return value.floatValue() + Float.valueOf(gap).floatValue();- }- }-- static class DoubleFacetRangeGenerator extends FacetRangeGenerator<Double> {- public DoubleFacetRangeGenerator(final RangeFacet rangeFacet) {- super(rangeFacet);- }-- @Override- protected Double parseVal(String rawval) {- return Double.valueOf(rawval);- }-- @Override- public Double parseAndAddGap(Double value, String gap) {- return value.doubleValue() + Double.valueOf(gap).doubleValue();- }- }-- static class DateFacetRangeGenerator extends FacetRangeGenerator<Date> {- private final Date now;-- public DateFacetRangeGenerator(final RangeFacet rangeFacet, final Date now) {- super(rangeFacet);- this.now = now;- }-- @Override- public String formatValue(Date val) {- return val.toInstant().toString();- }-- @Override- protected Date parseVal(String rawval) {- return DateMathParser.parseMath(now, rawval);- }-- @Override- protected Object parseGap(final String rawval) {- return rawval;- }-- @Override- public Date parseAndAddGap(Date value, String gap) throws java.text.ParseException {- final DateMathParser dmp = new DateMathParser();- dmp.setNow(value);- return dmp.parseMath(gap);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/MedianCalculator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/MedianCalculator.javadeleted file mode 100644index fcbbc69099e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/MedianCalculator.java+++ /dev/null@@ -1,133 +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.util;--import java.util.List;--/**- * Only used for testing. Medians are calculated with the {@link OrdinalCalculator} for actual- * analytics requests.- */-public class MedianCalculator {-- /**- * Calculates the median of the given list of numbers.- *- * @param list A list of {@link Comparable} {@link Number} objects- * @return The median of the given list as a double.- */- public static <T extends Number & Comparable<T>> double getMedian(List<T> list) {- int size = list.size() - 1;- if (size == -1) {- return 0;- }-- select(list, .5 * size, 0, size);-- int firstIdx = (int) (Math.floor(.5 * size));- int secondIdx = (firstIdx <= size && size % 2 == 1) ? firstIdx + 1 : firstIdx;- double result = list.get(firstIdx).doubleValue() * .5 + list.get(secondIdx).doubleValue() * .5;-- return result;- }-- private static <T extends Comparable<T>> void select(- List<T> list, double place, int begin, int end) {- T split;- if (end - begin < 10) {- split = list.get((int) (Math.random() * (end - begin + 1)) + begin);- } else {- split = split(list, begin, end);- }-- OrdinalCalculator.Point result = partition(list, begin, end, split);-- if (place < result.low) {- select(list, place, begin, result.low);- } else if (place > result.high) {- select(list, place, result.high, end);- } else {- if (result.low == (int) (Math.floor(place)) && result.low > begin) {- select(list, result.low, begin, result.low);- }- if (result.high == (int) (Math.ceil(place)) && result.high < end) {- select(list, result.high, result.high, end);- }- }- }-- private static <T extends Comparable<T>> T split(List<T> list, int begin, int end) {- T temp;- int num = (end - begin + 1);- int recursiveSize = (int) Math.sqrt((double) num);- int step = num / recursiveSize;- for (int i = 1; i < recursiveSize; i++) {- int swapFrom = i * step + begin;- int swapTo = i + begin;- temp = list.get(swapFrom);- list.set(swapFrom, list.get(swapTo));- list.set(swapTo, temp);- }- recursiveSize--;- select(list, recursiveSize / 2 + begin, begin, recursiveSize + begin);- return list.get(recursiveSize / 2 + begin);- }-- private static <T extends Comparable<T>> OrdinalCalculator.Point partition(- List<T> list, int begin, int end, T indexElement) {- T temp;- int left, right;- for (left = begin, right = end; left < right; left++, right--) {- while (list.get(left).compareTo(indexElement) < 0) {- left++;- }- while (right != begin - 1 && list.get(right).compareTo(indexElement) >= 0) {- right--;- }- if (right <= left) {- left--;- right++;- break;- }- temp = list.get(left);- list.set(left, list.get(right));- list.set(right, temp);- }- while (left != begin - 1 && list.get(left).compareTo(indexElement) >= 0) {- left--;- }- while (right != end + 1 && list.get(right).compareTo(indexElement) <= 0) {- right++;- }- int rightMove = right + 1;- while (rightMove < end + 1) {- if (list.get(rightMove).equals(indexElement)) {- temp = list.get(rightMove);- list.set(rightMove, list.get(right));- list.set(right, temp);- do {- right++;- } while (list.get(right).equals(indexElement));- if (rightMove <= right) {- rightMove = right;- }- }- rightMove++;- }- return new OrdinalCalculator.Point(left, right);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsParams.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsParams.javadeleted file mode 100644index f2e9c1d5021..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsParams.java+++ /dev/null@@ -1,164 +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.util;--import java.util.ArrayList;-import java.util.Arrays;-import java.util.function.Predicate;-import java.util.regex.Pattern;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsExpressionSortRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRangeFacetRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsSortRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsValueFacetRequest;-import org.apache.solr.analytics.function.mapping.FillMissingFunction;--/** Specifies the format of the old olap-style analytics requests. */-public interface OldAnalyticsParams {- // Old request language- public static final String OLD_ANALYTICS = "olap";-- public static final String OLD_PREFIX = "o|olap";-- public static final String OLD_EXPRESSION = "s|stat|statistic";-- public static final String FIELD_FACET = "(?:ff|fieldfacet)";- public static final String VALUE_FACET = "(?:vf|valuefacet)";- public static final String LIMIT = "(?:l|limit)";- public static final String OFFSET = "(?:off|offset)";- public static final String SHOW_MISSING = "(?:sm|showmissing)";- public static final String SORT_EXPRESSION = "(?:se|sortexpr|sortexpression)";- public static final String OLAP_SORT_EXPRESSION = "(?:ss|sortstat|sortstatistic)";- public static final String SORT_DIRECTION = "(?:sd|sortdirection)";-- public static class FieldFacetParamParser {- public static String regexParamList =- LIMIT- + "|"- + OFFSET- + "|"- + SHOW_MISSING- + "|"- + OLAP_SORT_EXPRESSION- + "|"- + SORT_DIRECTION;-- private static Predicate<String> isLimit =- Pattern.compile("^" + LIMIT + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isOffset =- Pattern.compile("^" + OFFSET + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isShowMissing =- Pattern.compile("^" + SHOW_MISSING + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isSortExpr =- Pattern.compile("^" + OLAP_SORT_EXPRESSION + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isSortDir =- Pattern.compile("^" + SORT_DIRECTION + "$", Pattern.CASE_INSENSITIVE).asPredicate();-- public static void applyParam(AnalyticsValueFacetRequest facet, String param, String value) {- if (isLimit.test(param)) {- getSort(facet).limit = Integer.parseInt(value);- } else if (isOffset.test(param)) {- getSort(facet).offset = Integer.parseInt(value);- } else if (isShowMissing.test(param)) {- facet.expression = FillMissingFunction.name + "(" + facet.expression + ",\"(MISSING)\")";- } else if (isSortExpr.test(param)) {- AnalyticsSortRequest sort = getSort(facet);- AnalyticsExpressionSortRequest criterion;- if (sort.criteria.size() == 0) {- criterion = new AnalyticsExpressionSortRequest();- sort.criteria.add(criterion);- } else {- criterion = (AnalyticsExpressionSortRequest) sort.criteria.get(0);- }- criterion.expression = value;- } else if (isSortDir.test(param)) {- AnalyticsSortRequest sort = getSort(facet);- AnalyticsExpressionSortRequest criterion;- if (sort.criteria.size() == 0) {- criterion = new AnalyticsExpressionSortRequest();- sort.criteria.add(criterion);- } else {- criterion = (AnalyticsExpressionSortRequest) sort.criteria.get(0);- }- criterion.direction = value;- }- }-- public static AnalyticsSortRequest getSort(AnalyticsValueFacetRequest facet) {- if (facet.sort == null) {- facet.sort = new AnalyticsSortRequest();- facet.sort.criteria = new ArrayList<>();- }- return facet.sort;- }- }-- public static final String RANGE_FACET = "(?:rf|rangefacet)";- public static final String START = "(?:st|start)";- public static final String END = "(?:e|end)";- public static final String GAP = "(?:g|gap)";- public static final String HARDEND = "(?:he|hardend)";- public static final String INCLUDE_BOUNDARY = "(?:ib|includebound)";- public static final String OTHER_RANGE = "(?:or|otherrange)";-- public static class RangeFacetParamParser {- public static String regexParamList =- START + "|" + END + "|" + GAP + "|" + HARDEND + "|" + INCLUDE_BOUNDARY + "|" + OTHER_RANGE;-- private static Predicate<String> isStart =- Pattern.compile("^" + START + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isEnd =- Pattern.compile("^" + END + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isGap =- Pattern.compile("^" + GAP + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isHardEnd =- Pattern.compile("^" + HARDEND + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isTrue =- Pattern.compile("^t|true$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isFalse =- Pattern.compile("^f|false$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isInclude =- Pattern.compile("^" + INCLUDE_BOUNDARY + "$", Pattern.CASE_INSENSITIVE).asPredicate();- private static Predicate<String> isOther =- Pattern.compile("^" + OTHER_RANGE + "$", Pattern.CASE_INSENSITIVE).asPredicate();-- public static void applyParam(AnalyticsRangeFacetRequest facet, String param, String[] values) {- if (isStart.test(param)) {- facet.start = values[0];- } else if (isEnd.test(param)) {- facet.end = values[0];- } else if (isGap.test(param)) {- facet.gaps = Arrays.asList(values[0].split(","));- } else if (isHardEnd.test(param)) {- if (isTrue.test(values[0])) {- facet.hardend = true;- } else if (isFalse.test(values[0])) {- facet.hardend = false;- }- } else if (isInclude.test(param)) {- facet.include = Arrays.asList(values);- } else if (isOther.test(param)) {- facet.others = Arrays.asList(values);- }- }- }-- public static final String QUERY_FACET = "(?:qf|queryfacet)";- public static final String QUERY = "(?:q|query)";-- // Defaults- public static final boolean DEFAULT_ABBREVIATE_PREFIX = true;-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsRequestConverter.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsRequestConverter.javadeleted file mode 100644index 10483917b91..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OldAnalyticsRequestConverter.java+++ /dev/null@@ -1,220 +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.util;--import java.util.HashMap;-import java.util.Iterator;-import java.util.regex.Matcher;-import java.util.regex.Pattern;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsGroupingRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsQueryFacetRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRangeFacetRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsValueFacetRequest;-import org.apache.solr.common.params.SolrParams;--/** Converts Analytics Requests in the old olap-style format to the new format. */-public class OldAnalyticsRequestConverter implements OldAnalyticsParams {- // Old language Parsing- private static final Pattern oldExprPattern =- Pattern.compile(- "^(?:" + OLD_PREFIX + ")\\.([^\\.]+)\\.(?:" + OLD_EXPRESSION + ")\\.([^\\.]+)$",- Pattern.CASE_INSENSITIVE);- private static final Pattern oldFieldFacetPattern =- Pattern.compile(- "^(?:" + OLD_PREFIX + ")\\.([^\\.]+)\\.(?:" + FIELD_FACET + ")$",- Pattern.CASE_INSENSITIVE);- private static final Pattern oldFieldFacetParamPattern =- Pattern.compile(- "^(?:"- + OLD_PREFIX- + ")\\.([^\\.]+)\\.(?:"- + FIELD_FACET- + ")\\.(.*(?=\\.))\\.("- + FieldFacetParamParser.regexParamList- + ")$",- Pattern.CASE_INSENSITIVE);- private static final Pattern oldRangeFacetParamPattern =- Pattern.compile(- "^(?:"- + OLD_PREFIX- + ")\\.([^\\.]+)\\.(?:"- + RANGE_FACET- + ")\\.(.*(?=\\.))\\.("- + RangeFacetParamParser.regexParamList- + ")$",- Pattern.CASE_INSENSITIVE);- private static final Pattern oldQueryFacetParamPattern =- Pattern.compile(- "^(?:"- + OLD_PREFIX- + ")\\.([^\\.]+)\\.(?:"- + QUERY_FACET- + ")\\.([^\\.]+)\\.("- + QUERY- + ")$",- Pattern.CASE_INSENSITIVE);-- /**- * Convert the old olap-style Analytics Request in the given params to an analytics request string- * using the current format.- *- * @param params to find the analytics request in- * @return an analytics request string- */- public static AnalyticsRequest convert(SolrParams params) {- AnalyticsRequest request = new AnalyticsRequest();- request.expressions = new HashMap<>();- request.groupings = new HashMap<>();- Iterator<String> paramsIterator = params.getParameterNamesIterator();- while (paramsIterator.hasNext()) {- String param = paramsIterator.next();- CharSequence paramSequence = param.subSequence(0, param.length());- parseParam(request, param, paramSequence, params);- }- return request;- }-- private static void parseParam(- AnalyticsRequest request, String param, CharSequence paramSequence, SolrParams params) {- // Check if grouped expression- Matcher m = oldExprPattern.matcher(paramSequence);- if (m.matches()) {- addExpression(request, m.group(1), m.group(2), params.get(param));- return;- }-- // Check if field facet parameter- m = oldFieldFacetPattern.matcher(paramSequence);- if (m.matches()) {- addFieldFacets(request, m.group(1), params.getParams(param));- return;- }-- // Check if field facet parameter- m = oldFieldFacetParamPattern.matcher(paramSequence);- if (m.matches()) {- setFieldFacetParam(request, m.group(1), m.group(2), m.group(3), params.getParams(param));- return;- }-- // Check if field facet parameter- m = oldFieldFacetParamPattern.matcher(paramSequence);- if (m.matches()) {- setFieldFacetParam(request, m.group(1), m.group(2), m.group(3), params.getParams(param));- return;- }-- // Check if range facet parameter- m = oldRangeFacetParamPattern.matcher(paramSequence);- if (m.matches()) {- setRangeFacetParam(request, m.group(1), m.group(2), m.group(3), params.getParams(param));- return;- }-- // Check if query- m = oldQueryFacetParamPattern.matcher(paramSequence);- if (m.matches()) {- setQueryFacetParam(request, m.group(1), m.group(2), m.group(3), params.getParams(param));- return;- }- }-- private static AnalyticsGroupingRequest getGrouping(AnalyticsRequest request, String name) {- AnalyticsGroupingRequest grouping = request.groupings.get(name);- if (grouping == null) {- grouping = new AnalyticsGroupingRequest();- grouping.expressions = new HashMap<>();- grouping.facets = new HashMap<>();- request.groupings.put(name, grouping);- }- return grouping;- }-- private static void addFieldFacets(- AnalyticsRequest request, String groupingName, String[] params) {- AnalyticsGroupingRequest grouping = getGrouping(request, groupingName);-- for (String param : params) {- if (!grouping.facets.containsKey(param)) {- AnalyticsValueFacetRequest fieldFacet = new AnalyticsValueFacetRequest();- fieldFacet.expression = param;- grouping.facets.put(param, fieldFacet);- }- }- }-- private static void setFieldFacetParam(- AnalyticsRequest request,- String groupingName,- String field,- String paramType,- String[] params) {- AnalyticsGroupingRequest grouping = getGrouping(request, groupingName);-- AnalyticsValueFacetRequest fieldFacet = (AnalyticsValueFacetRequest) grouping.facets.get(field);-- if (fieldFacet == null) {- fieldFacet = new AnalyticsValueFacetRequest();- fieldFacet.expression = field;- grouping.facets.put(field, fieldFacet);- }- FieldFacetParamParser.applyParam(fieldFacet, paramType, params[0]);- }-- private static void setRangeFacetParam(- AnalyticsRequest request,- String groupingName,- String field,- String paramType,- String[] params) {- AnalyticsGroupingRequest grouping = getGrouping(request, groupingName);-- AnalyticsRangeFacetRequest rangeFacet = (AnalyticsRangeFacetRequest) grouping.facets.get(field);- if (rangeFacet == null) {- rangeFacet = new AnalyticsRangeFacetRequest();- rangeFacet.field = field;- grouping.facets.put(field, rangeFacet);- }- RangeFacetParamParser.applyParam(rangeFacet, paramType, params);- }-- private static void setQueryFacetParam(- AnalyticsRequest request,- String groupingName,- String facetName,- String paramType,- String[] params) {- AnalyticsGroupingRequest grouping = getGrouping(request, groupingName);-- AnalyticsQueryFacetRequest queryFacet = new AnalyticsQueryFacetRequest();- queryFacet.queries = new HashMap<>();- if (paramType.equals("query") || paramType.equals("q")) {- for (String param : params) {- queryFacet.queries.put(param, param);- }- }- grouping.facets.put(facetName, queryFacet);- }-- private static void addExpression(- AnalyticsRequest request, String groupingName, String expressionName, String expression) {- request.expressions.put(groupingName + expressionName, expression);-- getGrouping(request, groupingName).expressions.put(expressionName, expression);- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OrdinalCalculator.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OrdinalCalculator.javadeleted file mode 100644index 15cb301851c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/OrdinalCalculator.java+++ /dev/null@@ -1,174 +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.util;--import java.util.Arrays;-import java.util.Collection;-import java.util.List;--/**- * Calculates ordinals of a comparable list by placing them in the correct positions in the list.- *- * <p>Implements the QuickSelect algorithm, but modifies it to select multiple ordinals all at once.- */-public class OrdinalCalculator {- /**- * Calculates a set of ordinal values for a given list of comparable objects. Once the method- * returns, the each ordinal is guaranteed to have the correct value in the list.- *- * @param list the list of {@link Comparable} objects- * @param ordinals the collection ordinals to calculate (0 to (size of list) - 1)- */- public static <T extends Comparable<T>> void putOrdinalsInPosition(- List<T> list, Collection<Integer> ordinals) {- int size = list.size();- if (size == 0) {- return;- }-- int[] ords = new int[ordinals.size()];- int i = 0;- for (int ord : ordinals) {- ords[i++] = ord;- }- ords = Arrays.stream(ords).sorted().filter(ord -> ord >= 0 && ord < size).toArray();-- distributeAndFind(list, ords, 0, ords.length - 1);- }-- private static <T extends Comparable<T>> void distributeAndFind(- List<T> list, int[] ordinals, int beginIdx, int endIdx) {- if (endIdx < beginIdx) {- return;- }- int middleIdxb = beginIdx;- int middleIdxe = beginIdx;- int begin = (beginIdx == 0) ? -1 : ordinals[beginIdx - 1];- int end = (endIdx == ordinals.length - 1) ? list.size() : ordinals[endIdx + 1];- double middle = (begin + end) / 2.0;- for (int i = beginIdx; i <= endIdx; i++) {- double value = Math.abs(ordinals[i] - middle) - Math.abs(ordinals[middleIdxb] - middle);- if (ordinals[i] == ordinals[middleIdxb]) {- middleIdxe = i;- } else if (value < 0) {- middleIdxb = i;- do {- middleIdxe = i;- i++;- } while (i <= endIdx && ordinals[middleIdxb] == ordinals[i]);- break;- }- }-- int middlePlace = ordinals[middleIdxb];- int beginPlace = begin + 1;- int endPlace = end - 1;-- select(list, middlePlace, beginPlace, endPlace);- distributeAndFind(list, ordinals, beginIdx, middleIdxb - 1);- distributeAndFind(list, ordinals, middleIdxe + 1, endIdx);- }-- private static <T extends Comparable<T>> void select(- List<T> list, int place, int begin, int end) {- T split;- if (end - begin < 10) {- split = list.get((int) (Math.random() * (end - begin + 1)) + begin);- } else {- split = split(list, begin, end);- }-- Point result = partition(list, begin, end, split);-- if (place <= result.low) {- select(list, place, begin, result.low);- } else if (place >= result.high) {- select(list, place, result.high, end);- }- }-- private static <T extends Comparable<T>> T split(List<T> list, int begin, int end) {- T temp;- int num = (end - begin + 1);- int recursiveSize = (int) Math.sqrt((double) num);- int step = num / recursiveSize;- for (int i = 1; i < recursiveSize; i++) {- int swapFrom = i * step + begin;- int swapTo = i + begin;- temp = list.get(swapFrom);- list.set(swapFrom, list.get(swapTo));- list.set(swapTo, temp);- }- recursiveSize--;- select(list, recursiveSize / 2 + begin, begin, recursiveSize + begin);- return list.get(recursiveSize / 2 + begin);- }-- private static <T extends Comparable<T>> Point partition(- List<T> list, int begin, int end, T indexElement) {- T temp;- int left, right;- for (left = begin, right = end; left <= right; left++, right--) {- while (list.get(left).compareTo(indexElement) < 0) {- left++;- }- while (right != begin - 1 && list.get(right).compareTo(indexElement) >= 0) {- right--;- }- if (right <= left) {- left--;- right++;- break;- }- temp = list.get(left);- list.set(left, list.get(right));- list.set(right, temp);- }- while (left > begin - 1 && list.get(left).compareTo(indexElement) >= 0) {- left--;- }- while (right < end + 1 && list.get(right).compareTo(indexElement) <= 0) {- right++;- }- int rightMove = right + 1;- while (rightMove < end + 1) {- if (list.get(rightMove).equals(indexElement)) {- temp = list.get(rightMove);- list.set(rightMove, list.get(right));- list.set(right, temp);- do {- right++;- } while (list.get(right).equals(indexElement));- if (rightMove <= right) {- rightMove = right;- }- }- rightMove++;- }- return new Point(left, right);- }-- static class Point {- public int low;- public int high;-- public Point(int low, int high) {- this.low = low;- this.high = high;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.javadeleted file mode 100644index bae37361e53..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java+++ /dev/null@@ -1,60 +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.util.function;--import java.util.Objects;-import java.util.function.Consumer;--/**- * Represents an operation that accepts a single {@code boolean}-valued argument and returns no- * result. This is the primitive type specialization of {@link Consumer} for {@code boolean}. Unlike- * most other functional interfaces, {@code IntConsumer} is expected to operate via side-effects.- *- * <p>This is a <a href="package-summary.html">functional interface</a> whose functional method is- * {@link #accept(boolean)}.- *- * @see Consumer- */-@FunctionalInterface-public interface BooleanConsumer {-- /**- * Performs this operation on the given argument.- *- * @param value the input argument- */- void accept(boolean value);-- /**- * Returns a composed {@code DoubleConsumer} that performs, in sequence, this operation followed- * by the {@code after} operation. If performing either operation throws an exception, it is- * relayed to the caller of the composed operation. If performing this operation throws an- * exception, the {@code after} operation will not be performed.- *- * @param after the operation to perform after this operation- * @return a composed {@code DoubleConsumer} that performs in sequence this operation followed by- * the {@code after} operation- * @throws NullPointerException if {@code after} is null- */- default BooleanConsumer andThen(BooleanConsumer after) {- Objects.requireNonNull(after);- return (boolean t) -> {- accept(t);- after.accept(t);- };- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.javadeleted file mode 100644index 85de26348ad..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java+++ /dev/null@@ -1,60 +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.util.function;--import java.util.Objects;-import java.util.function.Consumer;--/**- * Represents an operation that accepts a single {@code float}-valued argument and returns no- * result. This is the primitive type specialization of {@link Consumer} for {@code float}. Unlike- * most other functional interfaces, {@code IntConsumer} is expected to operate via side-effects.- *- * <p>This is a <a href="package-summary.html">functional interface</a> whose functional method is- * {@link #accept(float)}.- *- * @see Consumer- */-@FunctionalInterface-public interface FloatConsumer {-- /**- * Performs this operation on the given argument.- *- * @param value the input argument- */- void accept(float value);-- /**- * Returns a composed {@code DoubleConsumer} that performs, in sequence, this operation followed- * by the {@code after} operation. If performing either operation throws an exception, it is- * relayed to the caller of the composed operation. If performing this operation throws an- * exception, the {@code after} operation will not be performed.- *- * @param after the operation to perform after this operation- * @return a composed {@code DoubleConsumer} that performs in sequence this operation followed by- * the {@code after} operation- * @throws NullPointerException if {@code after} is null- */- default FloatConsumer andThen(FloatConsumer after) {- Objects.requireNonNull(after);- return (float t) -> {- accept(t);- after.accept(t);- };- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.javadeleted file mode 100644index 0f537e37d7c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java+++ /dev/null@@ -1,41 +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.util.function;--import java.util.function.Supplier;--/**- * Represents a supplier of {@code float}-valued results. This is the {@code float}-producing- * primitive specialization of {@link Supplier}.- *- * <p>There is no requirement that a new or distinct result be returned each time the supplier is- * invoked.- *- * <p>This is a <a href="package-summary.html">functional interface</a> whose functional method is- * {@link #getAsFloat()}.- *- * @see Supplier- */-@FunctionalInterface-public interface FloatSupplier {- /**- * Gets a result.- *- * @return a result- */- float getAsFloat();-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/package-info.javadeleted file mode 100644index 230287536bd..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Pure java functional interfaces. Not specific to analytics. */-package org.apache.solr.analytics.util.function;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/util/package-info.javadeleted file mode 100644index f7442176aad..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/util/package-info.java+++ /dev/null@@ -1,19 +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.- */--/** Utility classes for the analytics component. */-package org.apache.solr.analytics.util;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValue.javadeleted file mode 100644index 7054edf850b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValue.java+++ /dev/null@@ -1,59 +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;--import java.util.function.Consumer;--/**- * A single-valued analytics value.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getObject()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface AnalyticsValue extends AnalyticsValueStream {- /**- * Check whether the current value exists. <br>- * NOTE: The result of this method is only guaranteed after any {@code get<Type>()} method is- * called.- *- * @return whether the current value exists- */- boolean exists();-- /**- * Get the object representation of the current value.- *- * @return the current value- */- Object getObject();-- /** An abstract base for {@link AnalyticsValue} that automatically casts to castable types. */- public abstract static class AbstractAnalyticsValue implements AnalyticsValue {- @Override- public void streamObjects(Consumer<Object> cons) {- Object value = getObject();- if (exists()) {- cons.accept(value);- }- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValueStream.javadeleted file mode 100644index cf4acc32776..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/AnalyticsValueStream.java+++ /dev/null@@ -1,154 +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;--import java.util.Arrays;-import java.util.Locale;-import java.util.function.Consumer;-import org.apache.solr.analytics.ExpressionFactory;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;--/**- * A multi-valued analytics value, the super-type of all Analytics value types.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamObjects},- * resulting in different values on each call.- */-public interface AnalyticsValueStream {- /**- * Get the name of function or value.- *- * @return the name of function/value- */- String getName();- /**- * Get the expression string of the analytics value stream. Must be unique to the expression. If- * passed to {@link ExpressionFactory#createExpression(String)}, the exact same expression should- * be created.- *- * @return the name of function/value- */- String getExpressionStr();- /**- * Stream the object representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamObjects(Consumer<Object> cons);-- /**- * Converts this value to a {@link ConstantValue} if it's expression type is {@link- * ExpressionType#CONST}.- *- * <p>If the value is reduced then no conversion will occur and the value itself will be returned.- *- * @return a constant representation of this value- */- AnalyticsValueStream convertToConstant();-- public abstract static class AbstractAnalyticsValueStream implements AnalyticsValueStream {- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-- /** The types of expressions. */- static enum ExpressionType {- CONST(true, true),- FIELD(true, false),- UNREDUCED_MAPPING(true, false),- REDUCTION(false, true),- REDUCED_MAPPING(false, true);-- private final boolean unreduced;- private final boolean reduced;-- ExpressionType(boolean unreduced, boolean reduced) {- this.unreduced = unreduced;- this.reduced = reduced;- }-- public boolean isUnreduced() {- return unreduced;- }-- public boolean isReduced() {- return reduced;- }- }-- /**- * Get the type of the expression that this class represents.- *- * @return the expression type- */- ExpressionType getExpressionType();-- /**- * Helper to create an expression string for a function.- *- * @param funcName the name of the function- * @param params the parameters of the function- * @return a valid expression string for the function.- */- static String createExpressionString(String funcName, AnalyticsValueStream... params) {- return String.format(- Locale.ROOT,- "%s(%s)",- funcName,- Arrays.stream(params)- .map(param -> param.getExpressionStr())- .reduce((a, b) -> a + "," + b)- .orElseGet(() -> ""));- }-- /**- * Determine whether the expression is a unreduced mapping expression, a reduced mapping- * expression, or a constant.- *- * @param exprString the string representing the expression, used when creating exceptions- * @param params the parameters- * @return the expression type- * @throws SolrException if the params are incompatable types, for example if reduced and- * unreduced params are both included- */- static ExpressionType determineMappingPhase(String exprString, AnalyticsValueStream... params)- throws SolrException {- boolean unreduced = true;- boolean reduced = true;- for (AnalyticsValueStream param : params) {- unreduced &= param.getExpressionType().isUnreduced();- reduced &= param.getExpressionType().isReduced();- }- if (unreduced && reduced) {- return ExpressionType.CONST;- } else if (unreduced) {- return ExpressionType.UNREDUCED_MAPPING;- } else if (reduced) {- return ExpressionType.REDUCED_MAPPING;- } else {- throw new SolrException(- ErrorCode.BAD_REQUEST,- "The following expression contains incorrect parameters. "- + "(ReductionFunctions cannot be in the paramters of other ReductionFunctions): "- + exprString);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValue.javadeleted file mode 100644index 3b2aa43dbd7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValue.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;--import java.util.function.Consumer;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.constant.ConstantBooleanValue;--/**- * A single-valued analytics value that can be represented as a boolean.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getBoolean()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface BooleanValue extends BooleanValueStream, AnalyticsValue {- /**- * Get the boolean representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- boolean getBoolean();-- /**- * An interface that represents all of the types a {@link BooleanValue} should be able to cast to.- */- public static interface CastingBooleanValue extends BooleanValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingBooleanValue} that automatically casts to all types if- * {@link #getBoolean()} and {@link #exists()} are implemented.- */- public abstract static class AbstractBooleanValue implements CastingBooleanValue {- @Override- public String getString() {- boolean val = getBoolean();- return exists() ? Boolean.toString(val) : null;- }-- @Override- public Object getObject() {- boolean val = getBoolean();- return exists() ? val : null;- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- boolean val = getBoolean();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantBooleanValue(getBoolean());- }- return this;- }-- @Override- public ExpressionComparator<Boolean> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValueStream.javadeleted file mode 100644index 84f4a7a62cf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/BooleanValueStream.java+++ /dev/null@@ -1,62 +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;--import java.util.function.Consumer;-import org.apache.solr.analytics.util.function.BooleanConsumer;--/**- * A multi-valued analytics value that can be represented as a boolean.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamBooleans},- * resulting in different values on each call.- */-public interface BooleanValueStream extends AnalyticsValueStream {- /**- * Stream the boolean representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamBooleans(BooleanConsumer cons);-- /**- * An interface that represents all of the types a {@link BooleanValueStream} should be able to- * cast to.- */- public static interface CastingBooleanValueStream extends BooleanValueStream, StringValueStream {}-- /**- * An abstract base for {@link CastingBooleanValueStream} that automatically casts to all types if- * {@link #streamBooleans} is implemented.- */- public abstract static class AbstractBooleanValueStream implements CastingBooleanValueStream {- @Override- public void streamStrings(Consumer<String> cons) {- streamBooleans((boolean val) -> cons.accept(Boolean.toString(val)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamBooleans((boolean val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/ComparableValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/ComparableValue.javadeleted file mode 100644index 300ba10ccca..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/ComparableValue.java+++ /dev/null@@ -1,30 +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;--import org.apache.solr.analytics.facet.compare.FacetResultsComparator;--/** A single-valued analytics value that can be compared and used to sort a facet. */-public interface ComparableValue extends AnalyticsValue {- /**- * Create an entry comparator used to sort the facet-value buckets of a facet.- *- * @param expression the name of the expression in the results array- * @return a comparator to sort the buckets with- */- FacetResultsComparator getObjectComparator(String expression);-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValue.javadeleted file mode 100644index 44ee20ac8d0..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValue.java+++ /dev/null@@ -1,119 +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;--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.ExpressionComparator;-import org.apache.solr.analytics.value.constant.ConstantDateValue;--/**- * A single-valued analytics value that can be represented as a date.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getDate()} and- * {@link #exists()}, resulting in different values on each call.- *- * <p>NOTE: Most date expressions work with the {@code long} representation of the date, so that- * less objects need to be created during execution.- */-public interface DateValue extends DateValueStream, LongValue {- /**- * Get the date representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- Date getDate();-- /**- * An interface that represents all of the types a {@link DateValue} should be able to cast to.- */- public static interface CastingDateValue- extends DateValue, LongValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingDateValue} that automatically casts to all types if {@link- * #getLong()} and {@link #exists()} are implemented.- */- public abstract static class AbstractDateValue implements CastingDateValue {- @Override- public Date getDate() {- long val = getLong();- return exists() ? new Date(val) : null;- }-- @Override- public String getString() {- long val = getLong();- return exists() ? Instant.ofEpochMilli(val).toString() : null;- }-- @Override- public Object getObject() {- return getDate();- }-- @Override- public void streamDates(Consumer<Date> cons) {- Date val = getDate();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamLongs(LongConsumer cons) {- long val = getLong();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantDateValue(getLong());- }- return this;- }-- @Override- public ExpressionComparator<Date> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValueStream.javadeleted file mode 100644index db0ca1a1166..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DateValueStream.java+++ /dev/null@@ -1,72 +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;--import java.time.Instant;-import java.util.Date;-import java.util.function.Consumer;--/**- * A multi-valued analytics value that can be represented as a date.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamDates},- * resulting in different values on each call.- *- * <p>NOTE: Most date expressions work with the {@code long} representation of the date, so that- * less objects need to be created during execution.- */-public interface DateValueStream extends LongValueStream {- /**- * Stream the date representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamDates(Consumer<Date> cons);-- /**- * An interface that represents all of the types a {@link DateValueStream} should be able to cast- * to.- */- public static interface CastingDateValueStream- extends DateValueStream, LongValueStream, StringValueStream {}-- /**- * An abstract base for {@link CastingDateValueStream} that automatically casts to all types if- * {@link #streamLongs} is implemented.- */- public abstract static class AbstractDateValueStream implements CastingDateValueStream {- @Override- public void streamDates(Consumer<Date> cons) {- streamLongs((long val) -> cons.accept(new Date(val)));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs((long val) -> cons.accept(Instant.ofEpochMilli(val).toString()));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamDates((Date val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValue.javadeleted file mode 100644index cde4d67b3a7..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValue.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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.constant.ConstantDoubleValue;--/**- * A single-valued analytics value that can be represented as a date.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getDouble()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface DoubleValue extends DoubleValueStream, AnalyticsValue {- /**- * Get the double representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- double getDouble();-- /**- * An interface that represents all of the types a {@link DoubleValue} should be able to cast to.- */- public static interface CastingDoubleValue extends DoubleValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingDoubleValue} that automatically casts to all types if {@link- * #getDouble()} and {@link #exists()} are implemented.- */- public abstract static class AbstractDoubleValue implements CastingDoubleValue {- @Override- public String getString() {- double val = getDouble();- return exists() ? Double.toString(val) : null;- }-- @Override- public Object getObject() {- double val = getDouble();- return exists() ? val : null;- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double val = getDouble();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantDoubleValue(getDouble());- }- return this;- }-- @Override- public ExpressionComparator<Double> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValueStream.javadeleted file mode 100644index 915e400af3d..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/DoubleValueStream.java+++ /dev/null@@ -1,62 +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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;--/**- * A multi-valued analytics value that can be represented as a boolean.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamDoubles},- * resulting in different values on each call.- */-public interface DoubleValueStream extends AnalyticsValueStream {- /**- * Stream the double representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamDoubles(DoubleConsumer cons);-- /**- * An interface that represents all of the types a {@link DoubleValueStream} should be able to- * cast to.- */- public static interface CastingDoubleValueStream extends DoubleValueStream, StringValueStream {}-- /**- * An abstract base for {@link CastingDoubleValueStream} that automatically casts to all types if- * {@link #streamDoubles} is implemented.- */- public abstract static class AbstractDoubleValueStream implements CastingDoubleValueStream {- @Override- public void streamStrings(Consumer<String> cons) {- streamDoubles((double val) -> cons.accept(Double.toString(val)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamDoubles((double val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValue.javadeleted file mode 100644index 05885b48136..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValue.java+++ /dev/null@@ -1,115 +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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.constant.ConstantFloatValue;--/**- * A single-valued analytics value that can be represented as a float.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getFloat()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface FloatValue extends FloatValueStream, AnalyticsValue {- /**- * Get the float representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- float getFloat();-- /**- * An interface that represents all of the types a {@link FloatValue} should be able to cast to.- */- public static interface CastingFloatValue- extends FloatValue, DoubleValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingFloatValue} that automatically casts to all types if {@link- * #getFloat()} and {@link #exists()} are implemented.- */- public abstract static class AbstractFloatValue implements CastingFloatValue {- @Override- public double getDouble() {- return getFloat();- }-- @Override- public String getString() {- float val = getFloat();- return exists() ? Float.toString(val) : null;- }-- @Override- public Object getObject() {- float val = getFloat();- return exists() ? val : null;- }-- @Override- public void streamFloats(FloatConsumer cons) {- float val = getFloat();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double val = getDouble();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantFloatValue(getFloat());- }- return this;- }-- @Override- public ExpressionComparator<Float> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValueStream.javadeleted file mode 100644index 8787d39ee46..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/FloatValueStream.java+++ /dev/null@@ -1,69 +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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;--/**- * A multi-valued analytics value that can be represented as a float.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamFloats},- * resulting in different values on each call.- */-public interface FloatValueStream extends AnalyticsValueStream {- /**- * Stream the float representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamFloats(FloatConsumer cons);-- /**- * An interface that represents all of the types a {@link FloatValueStream} should be able to cast- * to.- */- public static interface CastingFloatValueStream- extends FloatValueStream, DoubleValueStream, StringValueStream {}-- /**- * An abstract base for {@link CastingFloatValueStream} that automatically casts to all types if- * {@link #streamFloats} is implemented.- */- public abstract static class AbstractFloatValueStream implements CastingFloatValueStream {- @Override- public void streamDoubles(DoubleConsumer cons) {- streamFloats((float val) -> cons.accept(val));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamFloats((float val) -> cons.accept(Float.toString(val)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamFloats((float val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValue.javadeleted file mode 100644index fdbf076838c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValue.java+++ /dev/null@@ -1,141 +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;--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.ExpressionComparator;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.constant.ConstantIntValue;--/**- * A single-valued analytics value that can be represented as an int.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getInt()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface IntValue extends IntValueStream, AnalyticsValue {- /**- * Get the int representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- int getInt();-- /** An interface that represents all of the types a {@link IntValue} should be able to cast to. */- public static interface CastingIntValue- extends IntValue, LongValue, FloatValue, DoubleValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingIntValue} that automatically casts to all types if {@link- * #getInt()} and {@link #exists()} are implemented.- */- public abstract static class AbstractIntValue implements CastingIntValue {- @Override- public long getLong() {- return getInt();- }-- @Override- public float getFloat() {- return getInt();- }-- @Override- public double getDouble() {- return getInt();- }-- @Override- public String getString() {- int val = getInt();- return exists() ? Integer.toString(val) : null;- }-- @Override- public Object getObject() {- int val = getInt();- return exists() ? val : null;- }-- @Override- public void streamInts(IntConsumer cons) {- int val = getInt();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamLongs(LongConsumer cons) {- long val = getLong();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamFloats(FloatConsumer cons) {- float val = getFloat();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double val = getDouble();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantIntValue(getInt());- }- return this;- }-- @Override- public ExpressionComparator<Integer> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValueStream.javadeleted file mode 100644index 595d5d269ed..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/IntValueStream.java+++ /dev/null@@ -1,85 +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;--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.util.function.FloatConsumer;--/**- * A multi-valued analytics value that can be represented as a int.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamInts},- * resulting in different values on each call.- */-public interface IntValueStream extends AnalyticsValueStream {- /**- * Stream the int representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamInts(IntConsumer cons);-- /**- * An interface that represents all of the types a {@link IntValueStream} should be able to cast- * to.- */- public static interface CastingIntValueStream- extends IntValueStream,- LongValueStream,- FloatValueStream,- DoubleValueStream,- StringValueStream {}-- /**- * An abstract base for {@link CastingIntValueStream} that automatically casts to all types if- * {@link #streamInts} is implemented.- */- public abstract static class AbstractIntValueStream implements CastingIntValueStream {- @Override- public void streamLongs(LongConsumer cons) {- streamInts((int val) -> cons.accept(val));- }-- @Override- public void streamFloats(FloatConsumer cons) {- streamInts((int val) -> cons.accept(val));- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- streamInts((int val) -> cons.accept(val));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamInts((int val) -> cons.accept(Integer.toString(val)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamInts((int val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValue.javadeleted file mode 100644index 001cace5b97..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValue.java+++ /dev/null@@ -1,115 +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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.LongConsumer;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.constant.ConstantLongValue;--/**- * A single-valued analytics value that can be represented as a long.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getLong()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface LongValue extends LongValueStream, AnalyticsValue {- /**- * Get the long representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- long getLong();-- /**- * An interface that represents all of the types a {@link LongValue} should be able to cast to.- */- public static interface CastingLongValue- extends LongValue, DoubleValue, StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingLongValue} that automatically casts to all types if {@link- * #getLong()} and {@link #exists()} are implemented.- */- public abstract static class AbstractLongValue implements CastingLongValue {- @Override- public double getDouble() {- return getLong();- }-- @Override- public String getString() {- long val = getLong();- return exists() ? Long.toString(val) : null;- }-- @Override- public Object getObject() {- long val = getLong();- return exists() ? val : null;- }-- @Override- public void streamLongs(LongConsumer cons) {- long val = getLong();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- double val = getDouble();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamStrings(Consumer<String> cons) {- String val = getString();- if (exists()) {- cons.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> cons) {- Object val = getObject();- if (exists()) {- cons.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantLongValue(getLong());- }- return this;- }-- @Override- public ExpressionComparator<Long> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.javadeleted file mode 100644index 3a50ba15daf..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.java+++ /dev/null@@ -1,69 +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;--import java.util.function.Consumer;-import java.util.function.DoubleConsumer;-import java.util.function.LongConsumer;--/**- * A multi-valued analytics value that can be represented as a long.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamLongs},- * resulting in different values on each call.- */-public interface LongValueStream extends AnalyticsValueStream {- /**- * Stream the long representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamLongs(LongConsumer cons);-- /**- * An interface that represents all of the types a {@link LongValueStream} should be able to cast- * to.- */- public static interface CastingLongValueStream- extends LongValueStream, DoubleValueStream, StringValueStream {}-- /**- * An abstract base for {@link CastingLongValueStream} that automatically casts to all types if- * {@link #streamLongs} is implemented.- */- public abstract static class AbstractLongValueStream implements CastingLongValueStream {- @Override- public void streamDoubles(DoubleConsumer cons) {- streamLongs((long val) -> cons.accept((double) val));- }-- @Override- public void streamStrings(Consumer<String> cons) {- streamLongs((long val) -> cons.accept(Long.toString(val)));- }-- @Override- public void streamObjects(Consumer<Object> cons) {- streamLongs((long val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValue.javadeleted file mode 100644index 2beefb4cd94..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValue.java+++ /dev/null@@ -1,84 +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;--import java.util.function.Consumer;-import org.apache.solr.analytics.facet.compare.ExpressionComparator;-import org.apache.solr.analytics.value.constant.ConstantStringValue;--/**- * A single-valued analytics value that can be represented as a string.- *- * <p>The back-end production of the value can change inbetween calls to {@link #getString()} and- * {@link #exists()}, resulting in different values on each call.- */-public interface StringValue extends StringValueStream, AnalyticsValue {- /**- * Get the String representation of the current value.- *- * <p>NOTE: The value returned is not valid unless calling {@link #exists()} afterwards returns- * {@code TRUE}.- *- * @return the current value- */- String getString();-- /**- * An interface that represents all of the types a {@link StringValue} should be able to cast to.- */- public static interface CastingStringValue extends StringValue, ComparableValue {}-- /**- * An abstract base for {@link CastingStringValue} that automatically casts to all types if {@link- * #getString()} and {@link #exists()} are implemented.- */- public abstract static class AbstractStringValue implements CastingStringValue {- @Override- public String getObject() {- return getString();- }-- @Override- public void streamStrings(Consumer<String> func) {- String val = getString();- if (exists()) {- func.accept(val);- }- }-- @Override- public void streamObjects(Consumer<Object> func) {- Object val = getObject();- if (exists()) {- func.accept(val);- }- }-- @Override- public AnalyticsValue convertToConstant() {- if (getExpressionType().equals(ExpressionType.CONST)) {- return new ConstantStringValue(getString());- }- return this;- }-- @Override- public ExpressionComparator<String> getObjectComparator(String expression) {- return new ExpressionComparator<>(expression);- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValueStream.javadeleted file mode 100644index e2465b1392f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/StringValueStream.java+++ /dev/null@@ -1,56 +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;--import java.util.function.Consumer;--/**- * A multi-valued analytics value that can be represented as a String.- *- * <p>The back-end production of the value can change inbetween calls to {@link #streamStrings},- * resulting in different values on each call.- */-public interface StringValueStream extends AnalyticsValueStream {- /**- * Stream the String representations of all current values, if any exist.- *- * @param cons The consumer to accept the values- */- void streamStrings(Consumer<String> cons);-- /**- * An interface that represents all of the types a {@link StringValueStream} should be able to- * cast to.- */- public static interface CastingStringValueStream extends StringValueStream {}-- /**- * An abstract base for {@link CastingStringValueStream} that automatically casts to all types if- * {@link #streamStrings} is implemented.- */- public abstract static class AbstractStringValueStream implements CastingStringValueStream {- @Override- public void streamObjects(Consumer<Object> cons) {- streamStrings((String val) -> cons.accept(val));- }-- @Override- public AnalyticsValueStream convertToConstant() {- return this;- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantBooleanValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantBooleanValue.javadeleted file mode 100644index 59b2842abed..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantBooleanValue.java+++ /dev/null@@ -1,96 +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.util.function.BooleanConsumer;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValue.CastingBooleanValue;--/**- * A constant {@link BooleanValue}. Every call to {@link #getBoolean()} and other methods will- * return the same constant value.- */-public class ConstantBooleanValue extends ConstantValue implements CastingBooleanValue {- private final boolean value;- private final String valueStr;- public static final String name = "const_bool";- private final String exprStr;-- public ConstantBooleanValue(boolean value) {- this.value = value;- this.valueStr = Boolean.toString(value);- this.exprStr = ConstantValue.createExpressionString(this, valueStr);- }-- @Override- public boolean getBoolean() {- return value;- }-- @Override- public String getString() {- return valueStr;- }-- @Override- public Object getObject() {- return value;- }-- @Override- public boolean exists() {- return true;- }-- @Override- public void streamBooleans(BooleanConsumer 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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.javadeleted file mode 100644index 0f61e82bf2e..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDateValue.java+++ /dev/null@@ -1,109 +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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.javadeleted file mode 100644index 7863aa3ded4..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantDoubleValue.java+++ /dev/null@@ -1,95 +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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.javadeleted file mode 100644index 49e519ebcc6..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantFloatValue.java+++ /dev/null@@ -1,106 +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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.javadeleted file mode 100644index e655559af86..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantIntValue.java+++ /dev/null@@ -1,128 +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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.javadeleted file mode 100644index df641a7188b..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java+++ /dev/null@@ -1,106 +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((double) 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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.javadeleted file mode 100644index a169b443583..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantStringValue.java+++ /dev/null@@ -1,82 +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;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.javadeleted file mode 100644index 83b08ad4d35..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantValue.java+++ /dev/null@@ -1,101 +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());- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.javadeleted file mode 100644index 1c6d1ca5514..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/package-info.java+++ /dev/null@@ -1,19 +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;diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/package-info.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/package-info.javadeleted file mode 100644index e5dabe2fe5f..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/package-info.java+++ /dev/null@@ -1,19 +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;diff --git a/solr/modules/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java b/solr/modules/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.javadeleted file mode 100644index eb5fcf4a93c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/handler/AnalyticsHandler.java+++ /dev/null@@ -1,146 +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.index.ExitableDirectoryReader;-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.TimeExceededStubException;-import org.apache.solr.analytics.stream.AnalyticsShardResponseParser;-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.QParser;-import org.apache.solr.search.QParserPlugin;-import org.apache.solr.search.QueryParsing;-import org.apache.solr.search.QueryUtils;-import org.apache.solr.search.SolrIndexSearcher;-import org.apache.solr.search.SolrQueryTimeoutImpl;-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;-- @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();- }-- @Override- public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {-- SolrQueryTimeoutImpl.set(req);- 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();- AnalyticsDriver.drive(manager, searcher, docs, 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));- } catch (ExitableDirectoryReader.ExitingReaderException e) {- rsp.addResponse(new AnalyticsResponse(new TimeExceededStubException(e)));- } finally {- SolrQueryTimeoutImpl.reset();- }- }-- /**- * 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- queries.addAll(QueryUtils.parseFilterQueries(req));- return req.getSearcher().getDocSet(queries);- }-- @Override- public String getDescription() {- return NAME;- }-- public String getSource() {- return null;- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java b/solr/modules/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.javadeleted file mode 100644index c93ebf51de3..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/handler/component/AnalyticsComponent.java+++ /dev/null@@ -1,178 +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.AnalyticsResponseHeadings;-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.logging.DeprecationLog;-import org.apache.solr.response.SolrQueryResponse;--/** Computes analytics requests. */-@Deprecated(since = "9.2")-public class AnalyticsComponent extends SearchComponent {- public static final String COMPONENT_NAME = "analytics";-- @Override- public void init(NamedList<?> args) {- DeprecationLog.log(- "analytics", "The Analytics component is deprecated. See upgrade notes for more.");- 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.setOlapAnalytics(false);- rb.setAnalytics(false);- boolean isDistributed = rb.isDistributed();- if (analyticsRequest != null) {- rb.setAnalytics(true);- rb.setAnalyticsRequestManager(- AnalyticsRequestParser.parse(- analyticsRequest, new ExpressionFactory(rb.req.getSchema()), isDistributed));- }- // 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.setAnalyticsRequestManager(- AnalyticsRequestParser.parse(- OldAnalyticsRequestConverter.convert(rb.req.getParams()),- new ExpressionFactory(rb.req.getSchema()),- isDistributed));- rb.setOlapAnalytics(true);- rb.setAnalytics(true);- }-- if (rb.isAnalytics()) {- AnalyticsRequestManager reqManager = getAnalyticsRequestManager(rb);-- // Check to see if the request is distributed- if (isDistributed) {- 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.isAnalytics()) {- return;- }- AnalyticsRequestManager reqManager = getAnalyticsRequestManager(rb);- // Collect the data and generate a response- AnalyticsDriver.drive(reqManager, rb.req.getSearcher(), rb.getResults().docSet, rb.req);-- if (rb.isOlapAnalytics()) {- rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_OLD_HEADER, reqManager.createOldResponse());- } else {- rb.rsp.add(AnalyticsResponseHeadings.COMPLETED_HEADER, reqManager.createResponse());- }-- rb.setAnalytics(false);- rb.setOlapAnalytics(false);- }-- @Override- public int distributedProcess(ResponseBuilder rb) throws IOException {- if (!rb.isAnalytics() || rb.stage != ResponseBuilder.STAGE_EXECUTE_QUERY) {- return ResponseBuilder.STAGE_DONE;- }- AnalyticsRequestManager reqManager = getAnalyticsRequestManager(rb);- 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.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.isAnalytics() && rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {- AnalyticsRequestManager reqManager = getAnalyticsRequestManager(rb);- // 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());- }- if (reqManager.isPartialResults()) {- rb.rsp- .getResponseHeader()- .asShallowMap()- .put(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, true);- }- }-- super.finishStage(rb);- }-- @Override- public String getName() {- return COMPONENT_NAME;- }-- @Override- public String getDescription() {- return "Perform analytics";- }-- private AnalyticsRequestManager getAnalyticsRequestManager(ResponseBuilder rb) {- return (AnalyticsRequestManager) rb.getAnalyticsRequestManager();- }-- /*@Override- public NamedList getStatistics() {- return analyticsCollector.getStatistics();- }*/-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/handler/component/package.html b/solr/modules/analytics/src/java/org/apache/solr/handler/component/package.htmldeleted file mode 100644index c5d1103e304..00000000000--- a/solr/modules/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>diff --git a/solr/modules/analytics/src/java/org/apache/solr/handler/package.html b/solr/modules/analytics/src/java/org/apache/solr/handler/package.htmldeleted file mode 100644index 6a5c2c3b9b2..00000000000--- a/solr/modules/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>diff --git a/solr/modules/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.java b/solr/modules/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.javadeleted file mode 100644index bfbb334bb8c..00000000000--- a/solr/modules/analytics/src/java/org/apache/solr/response/AnalyticsShardResponseWriter.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.response;--import java.io.DataOutputStream;-import java.io.IOException;-import java.io.ObjectOutputStream;-import java.io.OutputStream;-import java.io.Writer;-import org.apache.lucene.util.SuppressForbidden;-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.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;- }-- /**- * 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;- }-- @SuppressForbidden(reason = "XXX: security hole")- public void write(DataOutputStream output) throws IOException {- output.writeBoolean(requestSuccessful);- if (requestSuccessful) {- manager.exportShardData(output);- } else {- new ObjectOutputStream(output).writeObject(exception);- }- }- }-}diff --git a/solr/modules/analytics/src/java/org/apache/solr/response/package.html b/solr/modules/analytics/src/java/org/apache/solr/response/package.htmldeleted file mode 100644index dd24f829387..00000000000--- a/solr/modules/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>diff --git a/solr/modules/analytics/src/java/overview.html b/solr/modules/analytics/src/java/overview.htmldeleted file mode 100644index 58a95d351a0..00000000000--- a/solr/modules/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 module-</body>-</html>diff --git a/solr/modules/analytics/src/test-files/log4j2.xml b/solr/modules/analytics/src/test-files/log4j2.xmldeleted file mode 100644index 96f69f1dc8b..00000000000--- a/solr/modules/analytics/src/test-files/log4j2.xml+++ /dev/null@@ -1,42 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!--- 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.- -->-<!-- We're configuring testing to be synchronous due to "logging polution", see SOLR-13268 -->-<Configuration>- <Appenders>- <Console name="STDERR" target="SYSTEM_ERR">- <PatternLayout>- <Pattern>- %maxLen{%-4r %-5p (%t) [%notEmpty{n:%X{node_name}}%notEmpty{ c:%X{collection}}%notEmpty{ s:%X{shard}}%notEmpty{ r:%X{replica}}%notEmpty{ x:%X{core}}%notEmpty{ t:%X{trace_id}}] %c{1.} %m%notEmpty{- =>%ex{short}}}{10240}%n- </Pattern>- </PatternLayout>- </Console>- </Appenders>- <Loggers>- <!-- Use <AsyncLogger/<AsyncRoot and <Logger/<Root for asynchronous logging or synchonous logging respectively -->- <Logger name="org.apache.zookeeper" level="WARN"/>- <Logger name="org.apache.hadoop" level="WARN"/>- <Logger name="org.apache.directory" level="WARN"/>- <Logger name="org.apache.solr.hadoop" level="INFO"/>- <Logger name="org.eclipse.jetty" level="INFO"/>-- <Root level="INFO">- <AppenderRef ref="STDERR"/>- </Root>- </Loggers>-</Configuration>diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/expressions.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/expressions.txtdeleted file mode 100644index 6f5c91641cd..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/expressions.txt+++ /dev/null@@ -1,65 +0,0 @@-o.ar.s.sum=sum(int_id)-o.ar.s.unique=unique(long_ld)-o.ar.s.su=add(sum(int_id),unique(long_ld))-o.ar.s.mean=mean(int_id)-o.ar.s.count=count(long_ld)-o.ar.s.median=median(int_id)-o.ar.s.mcm=add(mean(int_id),count(long_ld),median(int_id))--o.mr.s.sum=sum(int_id)-o.mr.s.unique=unique(long_ld)-o.mr.s.su=mult(sum(int_id),unique(long_ld))-o.mr.s.mean=mean(int_id)-o.mr.s.count=count(long_ld)-o.mr.s.median=median(int_id)-o.mr.s.mcm=mult(mean(int_id),count(long_ld),median(int_id))--o.dr.s.sum=sum(int_id)-o.dr.s.unique=unique(long_ld)-o.dr.s.su=div(sum(int_id),unique(long_ld))-o.dr.s.mean=mean(int_id)-o.dr.s.count=count(long_ld)-o.dr.s.mc=div(mean(int_id),count(long_ld))--o.pr.s.sum=sum(int_id)-o.pr.s.unique=unique(long_ld)-o.pr.s.su=pow(sum(int_id),unique(long_ld))-o.pr.s.mean=mean(int_id)-o.pr.s.count=count(long_ld)-o.pr.s.mc=pow(mean(int_id),count(long_ld))--o.nr.s.sum=sum(int_id)-o.nr.s.s=neg(sum(int_id))-o.nr.s.count=count(long_ld)-o.nr.s.c=neg(count(long_ld))--o.avr.s.sum=sum(int_id)-o.avr.s.s=abs(neg(sum(int_id)))-o.avr.s.count=count(long_ld)-o.avr.s.c=abs(neg(count(long_ld)))--o.cnr.s.c8=8-o.cnr.s.c10=10.0--o.dmr.s.median=median(date_dtd)-o.dmr.s.cme="+2YEARS"-o.dmr.s.dmme=date_math(median(date_dtd),"+2YEARS")-o.dmr.s.max=max(date_dtd)-o.dmr.s.cma="+2MONTHS"-o.dmr.s.dmma=date_math(max(date_dtd),"+2MONTHS")--o.cdr.s.cd1=1800-12-31T23:59:59Z-o.cdr.s.cs1="1800-12-31T23:59:59Z"-o.cdr.s.cd2=1804-06-30T23:59:59Z-o.cdr.s.cs2="1804-06-30T23:59:59Z"--o.csr.s.cs1="this is the first"-o.csr.s.cs2="this is the second"-o.csr.s.cs3="this is the third"--o.cr.s.csmin="this is the first"-o.cr.s.min=min(string_sd)-o.cr.s.ccmin=concat("this is the first",min(string_sd))-o.cr.s.csmax="this is the second"-o.cr.s.max=max(string_sd)-o.cr.s.ccmax=concat("this is the second",max(string_sd))diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetSorting.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetSorting.txtdeleted file mode 100644index 4663217669d..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetSorting.txt+++ /dev/null@@ -1,4 +0,0 @@-o.ar.s.min=min(double_dd)-o.ar.s.max=max(long_ld)-o.ar.ff=string_sd-o.ar.ff.string_sd.sortstatistic=mindiff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetWithDottedFields.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetWithDottedFields.txtdeleted file mode 100644index 162cbbdc19a..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/facetWithDottedFields.txt+++ /dev/null@@ -1,16 +0,0 @@-o.df1.s.mean=mean(long.dotfield)-o.df1.ff=long.dotfield-o.df1.ff.long.dotfield.ss=mean-o.df1.ff.long.dotfield.sd=asc--o.df2.s.count=count(long.dotfield)-o.df2.rf=long.dotfield-o.df2.rf.long.dotfield.st=5-o.df2.rf.long.dotfield.end=30-o.df2.rf.long.dotfield.hardend=True-o.df2.rf.long.dotfield.g=5-o.df2.rf.long.dotfield.ib=lower-o.df2.rf.long.dotfield.or=all---diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacetExtras.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacetExtras.txtdeleted file mode 100644index 3979f57bd95..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacetExtras.txt+++ /dev/null@@ -1,66 +0,0 @@-o.sr.s.mean=mean(int_id)-o.sr.s.median=median(int_id)-o.sr.s.count=count(int_id)-o.sr.s.percentile_20=percentile(20,int_id)-o.sr.ff=long_ld-o.sr.ff.long_ld.ss=mean-o.sr.ff.long_ld.sd=asc-o.sr.ff=float_fd-o.sr.ff.float_fd.ss=median-o.sr.ff.float_fd.sd=desc-o.sr.ff=double_dd-o.sr.ff.double_dd.ss=count-o.sr.ff.double_dd.sd=asc-o.sr.ff=string_sd-o.sr.ff.string_sd.ss=percentile_20-o.sr.ff.string_sd.sd=desc--o.lr.s.mean=mean(int_id)-o.lr.s.median=median(int_id)-o.lr.s.count=count(int_id)-o.lr.s.percentile_20=percentile(20,int_id)-o.lr.ff=long_ld-o.lr.ff.long_ld.ss=mean-o.lr.ff.long_ld.sd=asc-o.lr.ff.long_ld.limit=5-o.lr.ff=float_fd-o.lr.ff.float_fd.ss=median-o.lr.ff.float_fd.sd=desc-o.lr.ff.float_fd.limit=3-o.lr.ff=double_dd-o.lr.ff.double_dd.ss=count-o.lr.ff.double_dd.sd=asc-o.lr.ff.double_dd.limit=7-o.lr.ff=string_sd-o.lr.ff.string_sd.ss=percentile_20-o.lr.ff.string_sd.sd=desc-o.lr.ff.string_sd.limit=1----o.offAll.s.mean=mean(int_id)-o.offAll.ff=long_ld-o.offAll.ff.long_ld.ss=mean-o.offAll.ff.long_ld.sd=asc-o.offAll.ff.long_ld.limit=7--o.off0.s.mean=mean(int_id)-o.off0.ff=long_ld-o.off0.ff.long_ld.ss=mean-o.off0.ff.long_ld.sd=asc-o.off0.ff.long_ld.limit=2-o.off0.ff.long_ld.offset=0--o.off1.s.mean=mean(int_id)-o.off1.ff=long_ld-o.off1.ff.long_ld.ss=mean-o.off1.ff.long_ld.sd=asc-o.off1.ff.long_ld.limit=2-o.off1.ff.long_ld.offset=2--o.off2.s.mean=mean(int_id)-o.off2.ff=long_ld-o.off2.ff.long_ld.ss=mean-o.off2.ff.long_ld.sd=asc-o.off2.ff.long_ld.limit=3-o.off2.ff.long_ld.offset=4diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacets.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacets.txtdeleted file mode 100644index 5ba5953a0c8..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/fieldFacets.txt+++ /dev/null@@ -1,132 +0,0 @@-o.sum.s.int=sum(int_id)-o.sum.s.long=sum(long_ld)-o.sum.s.float=sum(float_fd)-o.sum.s.double=sum(double_dd)-o.sum.ff=string_sd-o.sum.ff=date_dtd--o.mean.s.int=mean(int_id)-o.mean.s.long=mean(long_ld)-o.mean.s.float=mean(float_fd)-o.mean.s.double=mean(double_dd)-o.mean.ff=string_sd-o.mean.ff=date_dtd--o.sumOfSquares.s.int=sumofsquares(int_id)-o.sumOfSquares.s.long=sumofsquares(long_ld)-o.sumOfSquares.s.float=sumofsquares(float_fd)-o.sumOfSquares.s.double=sumofsquares(double_dd)-o.sumOfSquares.ff=string_sd-o.sumOfSquares.ff=date_dtd--o.stddev.s.int=stddev(int_id)-o.stddev.s.long=stddev(long_ld)-o.stddev.s.float=stddev(float_fd)-o.stddev.s.double=stddev(double_dd)-o.stddev.ff=string_sd-o.stddev.ff=date_dtd--o.median.s.int=median(int_id)-o.median.s.long=median(long_ld)-o.median.s.float=median(float_fd)-o.median.s.double=median(double_dd)-o.median.ff=string_sd-o.median.ff=date_dtd--o.percentile_20n.s.int=percentile(20,int_id)-o.percentile_20n.s.long=percentile(20,long_ld)-o.percentile_20n.s.float=percentile(20,float_fd)-o.percentile_20n.s.double=percentile(20,double_dd)-o.percentile_20n.ff=string_sd-o.percentile_20n.ff=date_dtd--o.percentile_20.s.str=percentile(20,string_sd)-o.percentile_20.s.date=percentile(20,date_dtd)-o.percentile_20.ff=int_id-o.percentile_20.ff=long_ld--o.percentile_60n.s.int=percentile(60,int_id)-o.percentile_60n.s.long=percentile(60,long_ld)-o.percentile_60n.s.float=percentile(60,float_fd)-o.percentile_60n.s.double=percentile(60,double_dd)-o.percentile_60n.ff=string_sd-o.percentile_60n.ff=date_dtd--o.percentile_60.s.str=percentile(60,string_sd)-o.percentile_60.s.date=percentile(60,date_dtd)-o.percentile_60.ff=int_id-o.percentile_60.ff=long_ld--o.minn.s.int=min(int_id)-o.minn.s.long=min(long_ld)-o.minn.s.float=min(float_fd)-o.minn.s.double=min(double_dd)-o.minn.ff=string_sd-o.minn.ff=date_dtd--o.min.s.str=min(string_sd)-o.min.s.date=min(date_dtd)-o.min.ff=int_id-o.min.ff=long_ld--o.maxn.s.int=max(int_id)-o.maxn.s.long=max(long_ld)-o.maxn.s.float=max(float_fd)-o.maxn.s.double=max(double_dd)-o.maxn.ff=string_sd-o.maxn.ff=date_dtd--o.max.s.str=max(string_sd)-o.max.s.date=max(date_dtd)-o.max.ff=int_id-o.max.ff=long_ld--o.countn.s.int=count(int_id)-o.countn.s.long=count(long_ld)-o.countn.s.float=count(float_fd)-o.countn.s.double=count(double_dd)-o.countn.ff=string_sd-o.countn.ff=date_dtd--o.count.s.str=count(string_sd)-o.count.s.date=count(date_dtd)-o.count.ff=int_id-o.count.ff=long_ld--o.uniquen.s.int=unique(int_id)-o.uniquen.s.long=unique(long_ld)-o.uniquen.s.float=unique(float_fd)-o.uniquen.s.double=unique(double_dd)-o.uniquen.ff=string_sd-o.uniquen.ff=date_dtd--o.unique.s.str=unique(string_sd)-o.unique.s.date=unique(date_dtd)-o.unique.ff=int_id-o.unique.ff=long_ld--o.missingn.s.int=missing(int_id)-o.missingn.s.long=missing(long_ld)-o.missingn.s.float=missing(float_fd)-o.missingn.s.double=missing(double_dd)-o.missingn.ff=string_sd-o.missingn.ff=date_dtd--o.missing.s.str=missing(string_sd)-o.missing.s.date=missing(date_dtd)-o.missing.ff=int_id-o.missing.ff=long_ld--o.multivalued.s.mean=mean(int_id)-o.multivalued.ff=long_ldm-o.multivalued.ff=string_sdm-o.multivalued.ff=date_dtdm--o.missingf.s.mean=mean(int_id)-o.missingf.ff=date_dtd-o.missingf.ff.date_dtd.dim=true-o.missingf.ff=string_sd-o.missingf.ff.string_sd.dim=true-o.missingf.ff.string_sd.sm=true-o.missingf.ff=date_dtdm-o.missingf.ff.date_dtdm.sm=truediff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/functions.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/functions.txtdeleted file mode 100644index ce735832492..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/functions.txt+++ /dev/null@@ -1,57 +0,0 @@-o.ar.s.sum=sum(add(int_id,float_fd))-o.ar.s.sumc=sum(add_if_dd)-o.ar.s.mean=mean(add(long_ld,double_dd,float_fd))-o.ar.s.meanc=mean(add_ldf_dd)--o.mr.s.sum=sum(mult(int_id,float_fd))-o.mr.s.sumc=sum(mult_if_dd)-o.mr.s.mean=mean(mult(long_ld,double_dd,float_fd))-o.mr.s.meanc=mean(mult_ldf_dd)--o.dr.s.sum=sum(div(int_id,float_fd))-o.dr.s.sumc=sum(div_if_dd)-o.dr.s.mean=mean(div(long_ld,double_dd))-o.dr.s.meanc=mean(div_ld_dd)--o.pr.s.sum=sum(pow(int_id,float_fd))-o.pr.s.sumc=sum(pow_if_dd)-o.pr.s.mean=mean(pow(long_ld,double_dd))-o.pr.s.meanc=mean(pow_ld_dd)--o.nr.s.sum=sum(neg(int_id))-o.nr.s.sumc=sum(neg_id)-o.nr.s.mean=mean(neg(long_ld))-o.nr.s.meanc=mean(neg_ld)--o.avr.s.sum=sum(abs(neg(int_id)))-o.avr.s.sumc=sum(int_id)-o.avr.s.mean=mean(abs(neg(int_id)))-o.avr.s.meanc=mean(int_id)--o.cnr.s.sum=sum(8)-o.cnr.s.sumc=sum(const_8_dd)-o.cnr.s.mean=mean(10)-o.cnr.s.meanc=mean(const_10_dd)--o.dmr.s.median=median(date_math(date_dtd,"+2YEARS"))-o.dmr.s.medianc=median(dm_2y_dtd)-o.dmr.s.max=max(date_math(date_dtd,"+2MONTHS"))-o.dmr.s.maxc=max(dm_2m_dtd)--o.cdr.s.median=median(1800-06-30T23:59:59Z)-o.cdr.s.medianc=median(const_00_dtd)-o.cdr.s.max=max(1804-06-30T23:59:59Z)-o.cdr.s.maxc=max(const_04_dtd)--o.csr.s.min=min("this is the first")-o.csr.s.minc=min(const_first_sd)-o.csr.s.max=max("this is the second")-o.csr.s.maxc=max(const_second_sd)--o.cr.s.min=concat("this is the first",min(string_sd))-o.cr.s.minc=min(concat_first_sd)-o.cr.s.max=concat("this is the second",max(string_sd))-o.cr.s.maxc=max(concat_second_sd)--o.ms.s.min=min(miss_dd)-o.ms.s.max=max(miss_dd)diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/noFacets.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/noFacets.txtdeleted file mode 100644index 84e43ebaf6b..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/noFacets.txt+++ /dev/null@@ -1,74 +0,0 @@-o.sr.s.int_id=sum(int_id)-o.sr.s.long_ld=sum(long_ld)-o.sr.s.float_fd=sum(float_fd)-o.sr.s.double_dd=sum(double_dd)--o.sosr.s.int_id=sumofsquares(int_id)-o.sosr.s.long_ld=sumofsquares(long_ld)-o.sosr.s.float_fd=sumofsquares(float_fd)-o.sosr.s.double_dd=sumofsquares(double_dd)--o.mr.s.int_id=mean(int_id)-o.mr.s.long_ld=mean(long_ld)-o.mr.s.float_fd=mean(float_fd)-o.mr.s.double_dd=mean(double_dd)--o.str.s.int_id=stddev(int_id)-o.str.s.long_ld=stddev(long_ld)-o.str.s.float_fd=stddev(float_fd)-o.str.s.double_dd=stddev(double_dd)--o.medr.s.int_id=median(int_id)-o.medr.s.long_ld=median(long_ld)-o.medr.s.float_fd=median(float_fd)-o.medr.s.double_dd=median(double_dd)-o.medr.s.date_dtd=median(date_dtd)--o.p2r.s.int_id=percentile(20,int_id)-o.p2r.s.long_ld=percentile(20,long_ld)-o.p2r.s.float_fd=percentile(20,float_fd)-o.p2r.s.double_dd=percentile(20,double_dd)-o.p2r.s.date_dtd=percentile(20,date_dtd)-o.p2r.s.string_sd=percentile(20,string_sd)--o.p6r.s.int_id=percentile(60,int_id)-o.p6r.s.long_ld=percentile(60,long_ld)-o.p6r.s.float_fd=percentile(60,float_fd)-o.p6r.s.double_dd=percentile(60,double_dd)-o.p6r.s.date_dtd=percentile(60,date_dtd)-o.p6r.s.string_sd=percentile(60,string_sd)--o.mir.s.int_id=min(int_id)-o.mir.s.long_ld=min(long_ld)-o.mir.s.float_fd=min(float_fd)-o.mir.s.double_dd=min(double_dd)-o.mir.s.date_dtd=min(date_dtd)-o.mir.s.string_sd=min(string_sd)--o.mar.s.int_id=max(int_id)-o.mar.s.long_ld=max(long_ld)-o.mar.s.float_fd=max(float_fd)-o.mar.s.double_dd=max(double_dd)-o.mar.s.date_dtd=max(date_dtd)-o.mar.s.string_sd=max(string_sd)--o.cr.s.int_id=count(int_id)-o.cr.s.long_ld=count(long_ld)-o.cr.s.float_fd=count(float_fd)-o.cr.s.double_dd=count(double_dd)-o.cr.s.date_dtd=count(date_dtd)-o.cr.s.string_sd=count(string_sd)--o.ur.s.int_id=unique(int_id)-o.ur.s.long_ld=unique(long_ld)-o.ur.s.float_fd=unique(float_fd)-o.ur.s.double_dd=unique(double_dd)-o.ur.s.date_dtd=unique(date_dtd)-o.ur.s.string_sd=unique(string_sd)--o.misr.s.int_id=missing(int_id)-o.misr.s.long_ld=missing(long_ld)-o.misr.s.float_fd=missing(float_fd)-o.misr.s.double_dd=missing(double_dd)-o.misr.s.date_dtd=missing(date_dtd)-o.misr.s.string_sd=missing(string_sd)diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/queryFacets.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/queryFacets.txtdeleted file mode 100644index 84d8fc6c54d..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/queryFacets.txt+++ /dev/null@@ -1,27 +0,0 @@-o.ir.s.sum=sum(int_id)-o.ir.s.mean=mean(int_id)-o.ir.s.median=median(int_id)-o.ir.s.percentile_8=percentile(8,int_id)-o.ir.ff=string_sd-o.ir.ff.string_sd.h=true-o.ir.qf=float1-o.ir.qf.float1.q=float_fd:[* TO 50]-o.ir.qf=float2-o.ir.qf.float2.q=float_fd:[* TO 30]--o.lr.s.sum=sum(long_ld)-o.lr.s.mean=mean(long_ld)-o.lr.s.median=median(long_ld)-o.lr.s.percentile_8=percentile(8,long_ld)-o.lr.qf=string-o.lr.qf.string.q=string_sd:abc1-o.lr.qf.string.q=string_sd:abc2--o.fr.s.sum=sum(float_fd)-o.fr.s.mean=mean(float_fd)-o.fr.s.median=median(float_fd)-o.fr.s.percentile_8=percentile(8,float_fd)-o.fr.qf=lad-o.fr.qf.lad.q=long_ld:[20 TO *]-o.fr.qf.lad.q=long_ld:[30 TO *]-o.fr.qf.lad.q=double_dd:[* TO 50]diff --git a/solr/modules/analytics/src/test-files/solr/analytics/legacy/rangeFacets.txt b/solr/modules/analytics/src/test-files/solr/analytics/legacy/rangeFacets.txtdeleted file mode 100644index 29aae5d3132..00000000000--- a/solr/modules/analytics/src/test-files/solr/analytics/legacy/rangeFacets.txt+++ /dev/null@@ -1,161 +0,0 @@-o.ri.s.sum=sum(int_id)-o.ri.s.mean=mean(int_id)-o.ri.s.median=median(int_id)-o.ri.s.count=count(int_id)-o.ri.s.sumOfSquares=sumofsquares(int_id)-o.ri.rf=long_ld-o.ri.rf.long_ld.st=5-o.ri.rf.long_ld.e=30-o.ri.rf.long_ld.g=5-o.ri.rf.long_ld.ib=lower-o.ri.rf.long_ld.or=all-o.ri.rf=double_dd-o.ri.rf.double_dd.st=3-o.ri.rf.double_dd.e=39-o.ri.rf.double_dd.g=7-o.ri.rf.double_dd.ib=upper-o.ri.rf.double_dd.ib=outer-o.ri.rf.double_dd.or=all-o.ri.rf=date_dtd-o.ri.rf.date_dtd.st=1007-01-01T23:59:59Z-o.ri.rf.date_dtd.e=1044-01-01T23:59:59Z-o.ri.rf.date_dtd.g=+7YEARS-o.ri.rf.date_dtd.ib=lower-o.ri.rf.date_dtd.ib=edge-o.ri.rf.date_dtd.ib=outer-o.ri.rf.date_dtd.or=all--o.rf.s.sum=sum(float_fd)-o.rf.s.mean=mean(float_fd)-o.rf.s.median=median(float_fd)-o.rf.s.count=count(float_fd)-o.rf.s.sumOfSquares=sumofsquares(float_fd)-o.rf.rf=long_ld-o.rf.rf.long_ld.st=0-o.rf.rf.long_ld.e=29-o.rf.rf.long_ld.g=4-o.rf.rf.long_ld.ib=all-o.rf.rf.long_ld.or=all-o.rf.rf=double_dd-o.rf.rf.double_dd.st=4-o.rf.rf.double_dd.e=47-o.rf.rf.double_dd.g=11-o.rf.rf.double_dd.ib=edge-o.rf.rf.double_dd.or=all-o.rf.rf=date_dtd-o.rf.rf.date_dtd.st=1004-01-01T23:59:59Z-o.rf.rf.date_dtd.e=1046-01-01T23:59:59Z-o.rf.rf.date_dtd.g=+5YEARS-o.rf.rf.date_dtd.ib=upper-o.rf.rf.date_dtd.ib=edge-o.rf.rf.date_dtd.or=all--o.hi.s.sum=sum(int_id)-o.hi.s.mean=mean(int_id)-o.hi.s.median=median(int_id)-o.hi.s.count=count(int_id)-o.hi.s.sumOfSquares=sumofsquares(int_id)-o.hi.rf=long_ld-o.hi.rf.long_ld.st=5-o.hi.rf.long_ld.e=30-o.hi.rf.long_ld.g=5-o.hi.rf.long_ld.he=true-o.hi.rf.long_ld.ib=lower-o.hi.rf.long_ld.or=all-o.hi.rf=double_dd-o.hi.rf.double_dd.st=3-o.hi.rf.double_dd.e=39-o.hi.rf.double_dd.g=7-o.hi.rf.double_dd.he=true-o.hi.rf.double_dd.ib=upper-o.hi.rf.double_dd.ib=outer-o.hi.rf.double_dd.or=all-o.hi.rf=date_dtd-o.hi.rf.date_dtd.st=1007-01-01T23:59:59Z-o.hi.rf.date_dtd.e=1044-01-01T23:59:59Z-o.hi.rf.date_dtd.g=+7YEARS-o.hi.rf.date_dtd.he=true-o.hi.rf.date_dtd.ib=lower-o.hi.rf.date_dtd.ib=edge-o.hi.rf.date_dtd.ib=outer-o.hi.rf.date_dtd.or=all--o.hf.s.sum=sum(float_fd)-o.hf.s.mean=mean(float_fd)-o.hf.s.median=median(float_fd)-o.hf.s.count=count(float_fd)-o.hf.s.sumOfSquares=sumofsquares(float_fd)-o.hf.rf=long_ld-o.hf.rf.long_ld.st=0-o.hf.rf.long_ld.e=29-o.hf.rf.long_ld.g=4-o.hf.rf.long_ld.he=true-o.hf.rf.long_ld.ib=all-o.hf.rf.long_ld.or=all-o.hf.rf=double_dd-o.hf.rf.double_dd.st=4-o.hf.rf.double_dd.e=47-o.hf.rf.double_dd.g=11-o.hf.rf.double_dd.he=true-o.hf.rf.double_dd.ib=edge-o.hf.rf.double_dd.or=all-o.hf.rf=date_dtd-o.hf.rf.date_dtd.st=1004-01-01T23:59:59Z-o.hf.rf.date_dtd.e=1046-01-01T23:59:59Z-o.hf.rf.date_dtd.g=+5YEARS-o.hf.rf.date_dtd.he=true-o.hf.rf.date_dtd.ib=upper-o.hf.rf.date_dtd.ib=edge-o.hf.rf.date_dtd.or=all--o.mi.s.sum=sum(int_id)-o.mi.s.mean=mean(int_id)-o.mi.s.median=median(int_id)-o.mi.s.count=count(int_id)-o.mi.s.sumOfSquares=sumofsquares(int_id)-o.mi.rf=long_ld-o.mi.rf.long_ld.st=5-o.mi.rf.long_ld.e=30-o.mi.rf.long_ld.g=4,2,6,3-o.mi.rf.long_ld.ib=lower-o.mi.rf.long_ld.or=all-o.mi.rf=double_dd-o.mi.rf.double_dd.st=3-o.mi.rf.double_dd.e=39-o.mi.rf.double_dd.g=3,1,7-o.mi.rf.double_dd.ib=upper-o.mi.rf.double_dd.ib=outer-o.mi.rf.double_dd.or=all-o.mi.rf=date_dtd-o.mi.rf.date_dtd.st=1007-01-01T23:59:59Z-o.mi.rf.date_dtd.e=1044-01-01T23:59:59Z-o.mi.rf.date_dtd.g=+2YEARS,+7YEARS-o.mi.rf.date_dtd.ib=lower-o.mi.rf.date_dtd.ib=edge-o.mi.rf.date_dtd.ib=outer-o.mi.rf.date_dtd.or=all--o.mf.s.sum=sum(float_fd)-o.mf.s.mean=mean(float_fd)-o.mf.s.median=median(float_fd)-o.mf.s.count=count(float_fd)-o.mf.s.sumOfSquares=sumofsquares(float_fd)-o.mf.rf=long_ld-o.mf.rf.long_ld.st=0-o.mf.rf.long_ld.e=29-o.mf.rf.long_ld.g=1,4-o.mf.rf.long_ld.ib=all-o.mf.rf.long_ld.or=all-o.mf.rf=double_dd-o.mf.rf.double_dd.st=4-o.mf.rf.double_dd.e=47-o.mf.rf.double_dd.g=2,3,11-o.mf.rf.double_dd.ib=edge-o.mf.rf.double_dd.or=all-o.mf.rf=date_dtd-o.mf.rf.date_dtd.st=1004-01-01T23:59:59Z-o.mf.rf.date_dtd.e=1046-01-01T23:59:59Z-o.mf.rf.date_dtd.g=+4YEARS,+5YEARS-o.mf.rf.date_dtd.ib=upper-o.mf.rf.date_dtd.ib=edge-o.mf.rf.date_dtd.or=alldiff --git a/solr/modules/analytics/src/test-files/solr/collection1/conf/schema-analytics.xml b/solr/modules/analytics/src/test-files/solr/collection1/conf/schema-analytics.xmldeleted file mode 100644index deb282f498b..00000000000--- a/solr/modules/analytics/src/test-files/solr/collection1/conf/schema-analytics.xml+++ /dev/null@@ -1,131 +0,0 @@-<?xml version="1.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.--->--<!-- The Solr schema file. This file should be named "schema.xml" and- should be located where the classloader for the Solr webapp can find it.-- This schema is used for testing, and as such has everything and the- kitchen sink thrown in. See example/solr/conf/schema.xml for a- more concise example.-- -->--<schema name="schema-analytics" version="1.6">--- <!-- field type definitions... note that the "name" attribute is- just a label to be used by field definitions. The "class"- attribute and any other attributes determine the real type and- behavior of the fieldType.- -->-- <!-- numeric field types that store and index the text- value verbatim (and hence don't sort correctly or support range queries.)- These are provided more for backward compatability, allowing one- to create a schema that matches an existing lucene index.- -->- <fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="float" class="${solr.tests.FloatFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="long" class="${solr.tests.LongFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="double" class="${solr.tests.DoubleFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional- seconds part (.999) is optional.- -->- <fieldType name="date" class="${solr.tests.DateFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>-- <!-- Numeric Trie Fields -->- <fieldType name="int_trie" class="solr.TrieIntField" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="float_trie" class="solr.TrieFloatField" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="long_trie" class="solr.TrieLongField" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="double_trie" class="solr.TrieDoubleField" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="date_trie" class="solr.TrieDateField" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>-- <!-- Numeric Trie Fields -->- <fieldType name="int_pnt" class="solr.IntPointField" docValues="true" />- <fieldType name="float_pnt" class="solr.FloatPointField" docValues="true" />- <fieldType name="long_pnt" class="solr.LongPointField" docValues="true" />- <fieldType name="double_pnt" class="solr.DoublePointField" docValues="true" />- <fieldType name="date_pnt" class="solr.DatePointField" docValues="true" />-- <field name="long.dotfield" type="long_pnt"/>-- <fieldType name="boolean" class="solr.BoolField" docValues="true"/>- <fieldType name="string" class="solr.StrField" docValues="true"/>--- <field name="id" type="string" multiValued="false" required="true"/>-- <dynamicField name="*_b" type="boolean" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_bm" type="boolean" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_bd" type="boolean" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_bdm" type="boolean" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_i" type="int" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_im" type="int" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_i_t" type="int_trie" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_im_t" type="int_trie" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_i_p" type="int_pnt" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_im_p" type="int_pnt" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_id" type="int" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_idm" type="int" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_l" type="long" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_lm" type="long" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_l_t" type="long_trie" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_lm_t" type="long_trie" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_l_p" type="long_pnt" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_lm_p" type="long_pnt" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_ld" type="long" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_ldm" type="long" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_f" type="float" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_fm" type="float" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_f_t" type="float_trie" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_fm_t" type="float_trie" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_f_p" type="float_pnt" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_fm_p" type="float_pnt" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_fd" type="float" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_fdm" type="float" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_d" type="double" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dm" type="double" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_d_t" type="double_trie" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dm_t" type="double_trie" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_d_p" type="double_pnt" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dm_p" type="double_pnt" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dd" type="double" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_ddm" type="double" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_dt" type="date" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dtm" type="date" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dt_t" type="date_trie" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dtm_t" type="date_trie" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dt_p" type="date_pnt" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dtm_p" type="date_pnt" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dtd" type="date" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_dtdm" type="date" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_s" type="string" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_sd" type="string" indexed="true" stored="true" multiValued="false"/>- <dynamicField name="*_sdm" type="string" indexed="true" stored="true" multiValued="true"/>--- <uniqueKey>id</uniqueKey>--</schema>diff --git a/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig-analytics.xml b/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig-analytics.xmldeleted file mode 100644index 4c359a67c6a..00000000000--- a/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig-analytics.xml+++ /dev/null@@ -1,42 +0,0 @@-<?xml version="1.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.--->--<config>- <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>- <dataDir>${solr.data.dir:}</dataDir>- <xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>- <schemaFactory class="ClassicIndexSchemaFactory"/>-- <requestHandler name="/select" class="solr.SearchHandler">- <arr name="components">- <str>query</str>- <str>facet</str>- <str>analytics</str>- <str>highlight</str>- <str>debug</str>- <str>expand</str>- </arr>- </requestHandler>-- <searchComponent name="analytics" class="org.apache.solr.handler.component.AnalyticsComponent" />-- <requestHandler name="/analytics" class="org.apache.solr.handler.AnalyticsHandler" />--</config>diff --git a/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml b/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xmldeleted file mode 100644index ecf1f1468fc..00000000000--- a/solr/modules/analytics/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml+++ /dev/null@@ -1,46 +0,0 @@-<?xml version="1.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.--->-<!----A solrconfig.xml snippet containing indexConfig settings for randomized testing.---->-<indexConfig>- <!-- this sys property is not set by SolrTestCaseJ4 because we ideally want to use- the RandomMergePolicy in all tests - but some tests expect very specific- Merge behavior, so those tests can set it as needed.- -->- <mergePolicyFactory class="${solr.tests.mergePolicyFactory:org.apache.solr.util.RandomMergePolicyFactory}" />-- <useCompoundFile>${useCompoundFile:false}</useCompoundFile>-- <maxBufferedDocs>${solr.tests.maxBufferedDocs}</maxBufferedDocs>- <ramBufferSizeMB>${solr.tests.ramBufferSizeMB}</ramBufferSizeMB>-- <mergeScheduler class="${solr.tests.mergeScheduler}" />-- <writeLockTimeout>1000</writeLockTimeout>- <commitLockTimeout>10000</commitLockTimeout>-- <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should- use the single process lockType for speed - but tests that explicitly need- to vary the lockType canset it as needed.- -->- <lockType>${solr.tests.lockType:single}</lockType>-</indexConfig>diff --git a/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/schema.xml b/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/schema.xmldeleted file mode 100644index cb9ad1396ee..00000000000--- a/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/schema.xml+++ /dev/null@@ -1,78 +0,0 @@-<?xml version="1.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.--->--<!-- The Solr schema file for cloud analytics, version 1.6 -->--<schema name="cloud-analytics" version="1.6">-- <fieldType name="boolean" class="solr.BoolField" docValues="true" sortMissingLast="true"/>- <fieldType name="string" class="solr.StrField" docValues="true" sortMissingLast="true"/>-- <fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0" />- <fieldType name="float" class="${solr.tests.FloatFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0" />- <fieldType name="long" class="${solr.tests.LongFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="double" class="${solr.tests.DoubleFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>- <fieldType name="date" class="${solr.tests.DateFieldType}" docValues="true" precisionStep="0" omitNorms="true" positionIncrementGap="0" />-- <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>-- <!-- for versioning -->- <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>- <!-- points to the root document of a block of nested documents -->- <field name="_root_" type="string" indexed="true" stored="true"/>-- <field name="_route_" type="string" indexed="true" stored="true" multiValued="false"/>-- <!-- dynamic fields with doc-values (for analytics) -->- <dynamicField name="*_i" type="int" indexed="true" stored="true"/>- <dynamicField name="*_im" type="int" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_id" type="int" indexed="true" stored="true"/>- <dynamicField name="*_idm" type="int" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_s" type="string" indexed="true" stored="true" />- <dynamicField name="*_sm" type="string" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_sd" type="string" indexed="true" stored="true" />- <dynamicField name="*_sdm" type="string" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_l" type="long" indexed="true" stored="true"/>- <dynamicField name="*_lm" type="long" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_ld" type="long" indexed="true" stored="true"/>- <dynamicField name="*_ldm" type="long" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>- <dynamicField name="*_bm" type="boolean" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_bd" type="boolean" indexed="true" stored="true"/>- <dynamicField name="*_bdm" type="boolean" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_f" type="float" indexed="true" stored="true"/>- <dynamicField name="*_fm" type="float" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_fd" type="float" indexed="true" stored="true"/>- <dynamicField name="*_fdm" type="float" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_d" type="double" indexed="true" stored="true"/>- <dynamicField name="*_dm" type="double" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dd" type="double" indexed="true" stored="true"/>- <dynamicField name="*_ddm" type="double" indexed="true" stored="true" multiValued="true"/>-- <dynamicField name="*_dt" type="date" indexed="true" stored="true"/>- <dynamicField name="*_dtm" type="date" indexed="true" stored="true" multiValued="true"/>- <dynamicField name="*_dtd" type="date" indexed="true" stored="true"/>- <dynamicField name="*_dtdm" type="date" indexed="true" stored="true" multiValued="true"/>-- <uniqueKey>id</uniqueKey>-</schema>diff --git a/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/solrconfig.xml b/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/solrconfig.xmldeleted file mode 100644index 102e39e8444..00000000000--- a/solr/modules/analytics/src/test-files/solr/configsets/cloud-analytics/conf/solrconfig.xml+++ /dev/null@@ -1,59 +0,0 @@-<?xml version="1.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.--->--<!-- Minimal solrconfig.xml with /select, /admin and /update only -->--<config>-- <dataDir>${solr.data.dir:}</dataDir>-- <directoryFactory name="DirectoryFactory"- class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>- <schemaFactory class="ClassicIndexSchemaFactory"/>-- <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>-- <updateHandler class="solr.DirectUpdateHandler2">- <commitWithin>- <softCommit>${solr.commitwithin.softcommit:true}</softCommit>- </commitWithin>- <updateLog></updateLog>- </updateHandler>-- <requestHandler name="/select" class="solr.SearchHandler">- <lst name="defaults">- <str name="echoParams">explicit</str>- <str name="indent">true</str>- <str name="df">text</str>- </lst>-- <arr name="components">- <str>query</str>- <str>facet</str>- <str>analytics</str>- <str>highlight</str>- <str>debug</str>- <str>expand</str>- </arr>- </requestHandler>-- <searchComponent name="analytics" class="org.apache.solr.handler.component.AnalyticsComponent" />- <requestHandler name="/analytics" class="org.apache.solr.handler.AnalyticsHandler" />-</config>-diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.javadeleted file mode 100644index 2bedb3fe32a..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java+++ /dev/null@@ -1,311 +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;--import java.util.Arrays;-import java.util.HashSet;-import java.util.Set;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.ReductionCollectionManager;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.apache.solr.schema.IndexSchema;-import org.junit.AfterClass;-import org.junit.BeforeClass;-import org.junit.Test;--public class ExpressionFactoryTest extends SolrTestCaseJ4 {-- private static IndexSchema indexSchema;-- @BeforeClass- public static void createSchemaAndFields() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- assertU(- adoc(- "id",- "1",- "int_i",- "1",- "int_im",- "1",- "long_l",- "1",- "long_lm",- "1",- "float_f",- "1",- "float_fm",- "1",- "double_d",- "1",- "double_dm",- "1",- "date_dt",- "1800-12-31T23:59:59Z",- "date_dtm",- "1800-12-31T23:59:59Z",- "string_s",- "1",- "string_sm",- "1",- "boolean_b",- "true",- "boolean_bm",- "false"));- assertU(commit());-- indexSchema = h.getCore().getLatestSchema();- }-- @AfterClass- public static void cleanUp() throws Exception {- indexSchema = null;- }-- private ExpressionFactory getExpressionFactory() {- ExpressionFactory fact = new ExpressionFactory(indexSchema);- fact.startRequest();- return fact;- }-- @Test- public void userDefinedVariableFunctionTest() {- ExpressionFactory fact = getExpressionFactory();-- // Single parameter function- fact.startRequest();- fact.addUserDefinedVariableFunction("single_func(a)", "sum(add(a,double_d,float_f))");- assertEquals(- "div(sum(add(int_i,double_d,float_f)),count(string_s))",- fact.createExpression("div(single_func(int_i),count(string_s))").getExpressionStr());-- // Multi parameter function- fact.startRequest();- fact.addUserDefinedVariableFunction("multi_func(a,b,c)", "median(if(boolean_b,add(a,b),c))");- assertEquals(- "div(median(if(boolean_b,add(int_i,double_d),float_f)),count(string_s))",- fact.createExpression("div(multi_func(int_i,double_d,float_f),count(string_s))")- .getExpressionStr());-- // Function within function- fact.startRequest();- fact.addUserDefinedVariableFunction("inner_func(a,b)", "div(add(a,b),b)");- fact.addUserDefinedVariableFunction("outer_func(a,b,c)", "pow(inner_func(a,b),c)");- assertEquals(- "div(median(pow(div(add(int_i,double_d),double_d),float_f)),count(string_s))",- fact.createExpression("div(median(outer_func(int_i,double_d,float_f)),count(string_s))")- .getExpressionStr());-- // Variable parameter function- fact.startRequest();- fact.addUserDefinedVariableFunction("var_func(a,b..)", "div(add(b),a)");- assertEquals(- "unique(div(add(double_d,float_f),int_i))",- fact.createExpression("unique(var_func(int_i,double_d,float_f))").getExpressionStr());- assertEquals(- "unique(div(add(double_d,float_f,long_l),int_i))",- fact.createExpression("unique(var_func(int_i,double_d,float_f,long_l))")- .getExpressionStr());-- // Variable parameter function with for-each- fact.startRequest();- fact.addUserDefinedVariableFunction("var_func_fe(a,b..)", "div(add(b:abs(_)),a)");- assertEquals(- "unique(div(add(abs(double_d),abs(float_f)),int_i))",- fact.createExpression("unique(var_func_fe(int_i,double_d,float_f))").getExpressionStr());- assertEquals(- "unique(div(add(abs(double_d),abs(float_f),abs(long_l)),int_i))",- fact.createExpression("unique(var_func_fe(int_i,double_d,float_f,long_l))")- .getExpressionStr());- }-- @Test- public void reuseFunctionsTest() {- ExpressionFactory fact = getExpressionFactory();-- // Two ungrouped exactly the same expression- fact.startRequest();- assertSame(- "The objects of the two mapping expressions are not the same.",- fact.createExpression("pow(int_i,double_d)"),- fact.createExpression("pow(int_i,double_d)"));- assertSame(- "The objects of the two reduced expressions are not the same.",- fact.createExpression("unique(add(int_i,double_d))"),- fact.createExpression("unique(add(int_i,double_d))"));-- // Two ungrouped different expressions- fact.startRequest();- assertNotSame(- "The objects of the two mapping expressions are not the same.",- fact.createExpression("pow(int_i,double_d)"),- fact.createExpression("pow(int_i,float_f)"));- assertNotSame(- "The objects of the two reduced expressions are not the same.",- fact.createExpression("unique(add(int_i,double_d))"),- fact.createExpression("unique(add(int_i,float_f))"));-- // Grouped and ungrouped mapping expression- fact.startRequest();- Object ungrouped = fact.createExpression("pow(int_i,double_d)");- fact.startGrouping();- Object grouped = fact.createExpression("pow(int_i,double_d)");- assertSame("The objects of the two mapping expressions are not the same.", ungrouped, grouped);-- // Grouped and ungrouped diferent mapping expressions- fact.startRequest();- ungrouped = fact.createExpression("pow(int_i,double_d)");- fact.startGrouping();- grouped = fact.createExpression("pow(int_i,float_f)");- assertNotSame(- "The objects of the two mapping expressions are not the same.", ungrouped, grouped);-- // Grouped and ungrouped reduced expression.- fact.startRequest();- ungrouped = fact.createExpression("unique(add(int_i,double_d))");- fact.startGrouping();- grouped = fact.createExpression("unique(add(int_i,double_d))");- assertSame("The objects of the two mapping expressions are not the same.", ungrouped, grouped);-- // Grouped and ungrouped different reduced expressions.- fact.startRequest();- ungrouped = fact.createExpression("unique(add(int_i,double_d))");- fact.startGrouping();- grouped = fact.createExpression("unique(add(int_i,float_f))");- assertNotSame("The objects of the two mapping expressions are the same.", ungrouped, grouped);- }-- @Test- public void constantFunctionConversionTest() {- ExpressionFactory fact = getExpressionFactory();- fact.startRequest();-- assertTrue(fact.createExpression("add(1,2)") instanceof ConstantValue);- assertTrue(fact.createExpression("add(1,2,2,3,4)") instanceof ConstantValue);- assertTrue(fact.createExpression("add(1)") instanceof ConstantValue);- assertTrue(fact.createExpression("concat(add(1,2), ' is a number')") instanceof ConstantValue);-- assertFalse(fact.createExpression("sum(add(1,2))") instanceof ConstantValue);- assertFalse(fact.createExpression("sum(int_i)") instanceof ConstantValue);- assertFalse(fact.createExpression("sub(1,long_l)") instanceof ConstantValue);- }-- public void testReductionManager(- ReductionCollectionManager manager, boolean hasExpressions, String... fields) {- Set<String> usedFields = new HashSet<>(Arrays.asList(fields));- manager- .getUsedFields()- .forEach(- field -> {- assertTrue(- "Field '"- + field.getName()- + "' is either not unique or should not exist in the reductionManager.",- usedFields.remove(field.getName()));- });- assertEquals(hasExpressions, manager.needsCollection());- }-- @Test- public void reductionManagerCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- // No expressions- fact.startRequest();- testReductionManager(fact.createReductionManager(false), false);-- // No fields- fact.startRequest();- fact.createExpression("sum(add(1,2))");- testReductionManager(fact.createReductionManager(false), true);-- // Multiple expressions- fact.startRequest();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- testReductionManager(fact.createReductionManager(false), true, "int_i", "float_f", "double_d");- }-- @Test- public void groupingReductionManagerCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- // No grouped expressions- fact.startRequest();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- fact.startGrouping();- testReductionManager(fact.createGroupingReductionManager(false), false);-- // No grouped fields- fact.startRequest();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- fact.startGrouping();- fact.createExpression("sum(add(1,2))");- testReductionManager(fact.createGroupingReductionManager(false), true);-- // Single grouping, no ungrouped- fact.startRequest();- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "double_d");-- // Single grouping, with ungrouped- fact.startRequest();- fact.createExpression("count(string_s)");- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "double_d");-- // Multiple groupings, no ungrouped- fact.startRequest();- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "double_d");- fact.startGrouping();- testReductionManager(fact.createGroupingReductionManager(false), false);- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("ordinal(1,concat(string_s,'-extra'))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "string_s");-- // Multiple groupings, with grouped- fact.startRequest();- fact.createExpression("count(string_s)");- fact.createExpression("median(date_math(date_dt,'+1DAY'))");- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("sum(add(int_i,double_d))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "double_d");- fact.startGrouping();- testReductionManager(fact.createGroupingReductionManager(false), false);- fact.startGrouping();- fact.createExpression("unique(add(int_i,float_f))");- fact.createExpression("ordinal(1,concat(string_s,'-extra'))");- testReductionManager(- fact.createGroupingReductionManager(false), true, "int_i", "float_f", "string_s");- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/NoFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/NoFacetTest.javadeleted file mode 100644index 27e5bb08a5d..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/NoFacetTest.java+++ /dev/null@@ -1,188 +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;--import java.util.HashMap;-import java.util.Map;-import org.junit.BeforeClass;-import org.junit.Test;--public class NoFacetTest extends SolrAnalyticsTestCase {-- @BeforeClass- public static void populate() throws Exception {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void countTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("count(long_l)", 10L));- expressions.put("multi", new ETP("count(string_sm)", 30L));-- testExpressions(expressions);- }-- @Test- public void docCountTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("doc_count(date_dt)", 13L));- expressions.put("multi", new ETP("doc_count(float_fm)", 16L));-- testExpressions(expressions);- }-- @Test- public void missingTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("missing(string_s)", 5L));- expressions.put("multi", new ETP("missing(date_dtm)", 7L));-- testExpressions(expressions);- }-- @Test- public void uniqueTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("unique(int_i)", 6L));- expressions.put("longs", new ETP("unique(long_lm)", 2L));- expressions.put("float", new ETP("unique(float_f)", 5L));- expressions.put("doubles", new ETP("unique(double_dm)", 8L));- expressions.put("dates", new ETP("unique(date_dt)", 2L));- expressions.put("strings", new ETP("unique(string_sm)", 6L));-- testExpressions(expressions);- }-- @Test- public void minTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("min(int_i)", 1));- expressions.put("longs", new ETP("min(long_lm)", 1L));- expressions.put("float", new ETP("min(float_f)", 1.0F));- expressions.put("doubles", new ETP("min(double_dm)", 1.0));- expressions.put("dates", new ETP("min(date_dt)", "1801-12-31T23:59:59Z"));- expressions.put("strings", new ETP("min(string_sm)", "str1"));-- testExpressions(expressions);- }-- @Test- public void maxTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("max(int_i)", 6));- expressions.put("longs", new ETP("max(long_lm)", 11L));- expressions.put("float", new ETP("max(float_f)", 5.0F));- expressions.put("doubles", new ETP("max(double_dm)", 14.0));- expressions.put("dates", new ETP("max(date_dt)", "1802-12-31T23:59:59Z"));- expressions.put("strings", new ETP("max(string_sm)", "str3_second"));-- testExpressions(expressions);- }-- @Test- public void sumTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("sum(int_i)", 57.0));- expressions.put("multi", new ETP("sum(long_lm)", 120.0));-- testExpressions(expressions);- }-- @Test- public void meanTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("mean(int_i)", 3.3529411764));- expressions.put("multi", new ETP("mean(long_lm)", 6.0));-- testExpressions(expressions);- }-- @Test- public void weightedMeanTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("wmean(int_i, long_l)", 3.33333333333));- expressions.put("multi", new ETP("wmean(double_d, float_f)", 2.470588235));-- testExpressions(expressions);- }-- @Test- public void sumOfSquaresTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("sumofsquares(int_i)", 237.0));- expressions.put("multi", new ETP("sumofsquares(long_lm)", 1220.0));-- testExpressions(expressions);- }-- @Test- public void varianceTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("variance(int_i)", 2.6989619377162));- expressions.put("multi", new ETP("variance(long_lm)", 25.0));-- testExpressions(expressions);- }-- @Test- public void standardDeviationTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("single", new ETP("stddev(int_i)", 1.6428517698551));- expressions.put("multi", new ETP("stddev(long_lm)", 5.0));-- testExpressions(expressions);- }-- @Test- public void medianTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("median(int_i)", 3.0));- expressions.put("longs", new ETP("median(long_lm)", 6.0));- expressions.put("float", new ETP("median(float_f)", 3.0));- expressions.put("doubles", new ETP("median(double_dm)", 7.5));- expressions.put("dates", new ETP("median(date_dt)", "1801-12-31T23:59:59Z"));-- testExpressions(expressions);- }-- @Test- public void percentileTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("percentile(20,int_i)", 2));- expressions.put("longs", new ETP("percentile(80,long_lm)", 11L));- expressions.put("float", new ETP("percentile(40,float_f)", 2.0F));- expressions.put("doubles", new ETP("percentile(50,double_dm)", 11.0));- expressions.put("dates", new ETP("percentile(0,date_dt)", "1801-12-31T23:59:59Z"));- expressions.put("strings", new ETP("percentile(99.99,string_sm)", "str3_second"));-- testExpressions(expressions);- }-- @Test- public void ordinalTest() throws Exception {- Map<String, ETP> expressions = new HashMap<>();- expressions.put("int", new ETP("ordinal(15,int_i)", 5));- expressions.put("longs", new ETP("ordinal(11,long_lm)", 11L));- expressions.put("float", new ETP("ordinal(-5,float_f)", 4.0F));- expressions.put("doubles", new ETP("ordinal(1,double_dm)", 1.0));- expressions.put("dates", new ETP("ordinal(-1,date_dt)", "1802-12-31T23:59:59Z"));- expressions.put("strings", new ETP("ordinal(6,string_sm)", "str1_second"));-- testExpressions(expressions);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/OverallAnalyticsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/OverallAnalyticsTest.javadeleted file mode 100644index a118b80a2df..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/OverallAnalyticsTest.java+++ /dev/null@@ -1,262 +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;--import org.apache.solr.analytics.facet.SolrAnalyticsFacetTestCase;-import org.junit.BeforeClass;-import org.junit.Test;--public class OverallAnalyticsTest extends SolrAnalyticsFacetTestCase {-- @BeforeClass- public static void populate() {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void pivotFacetTest() throws Exception {- String analyticsRequest =- "{"- + "\n 'expressions' : { "- + "\n 'floor_mean_add' : 'floor(mean(add(int_i,long_lm)))', "- + "\n 'consts' : 'max(mod(\\'_\\', string_s, 1800-01-01T11:59:59Z))' "- + "\n }, "- + "\n 'functions' : { "- + "\n 'mod(a,b..)' : 'concat_sep(a, b:concat(_,\\'-con\\'))', "- + "\n 'rep_0(num)' : 'fill_missing(num,0)' "- + "\n }, "- + "\n 'groupings': { "- + "\n 'grouping0' : { "- + "\n 'expressions' : { "- + "\n 'mean' : 'mean(float_f)', "- + "\n 'count2' : 'count(string_sm)' "- + "\n }, "- + "\n 'facets' : { "- + "\n 'ranges' : { "- + "\n 'type' : 'range', "- + "\n 'field': 'int_im', "- + "\n 'start': '2', "- + "\n 'end' : '13', "- + "\n 'gaps' : ['2', '5', '3'], "- + "\n 'hardend' : false "- + "\n } "- + "\n } "- + "\n }, "- + "\n 'grouping1' : { "- + "\n 'expressions' : { "- + "\n 'mean' : 'mean(rep_0(int_i))', "- + "\n 'count' : 'count(long_lm)' "- + "\n }, "- + "\n 'facets' : { "- + "\n 'queries' : { "- + "\n 'type' : 'query', "- + "\n 'queries' : { "- + "\n 'float < 3' : 'float_f:[* TO 3]', "- + "\n 'string = 1, date = 2' : 'string_s:\"str1\" AND date_dt:\"1802-12-31T23:59:59Z\"' "- + "\n } "- + "\n }, "- + "\n 'pivoting' : { "- + "\n 'type' : 'pivot', "- + "\n 'pivots' : [ "- + "\n { "- + "\n 'name' : 'strings', "- + "\n 'expression' : 'string_sm', "- + "\n 'sort' : { "- + "\n 'criteria' : [ "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'mean', "- + "\n 'direction' : 'ascending' "- + "\n }, "- + "\n { "- + "\n 'type' : 'facetvalue', "- + "\n 'direction' : 'descending' "- + "\n } "- + "\n ], "- + "\n 'limit' : 3, "- + "\n 'offset' : 1 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'name' : 'date', "- + "\n 'expression' : 'fill_missing(date_dt, \\'No Date\\')', "- + "\n 'sort' : { "- + "\n 'criteria' : [ "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'count', "- + "\n 'direction' : 'ascending' "- + "\n }, "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'mean', "- + "\n 'direction' : 'ascending' "- + "\n } "- + "\n ], "- + "\n 'limit' : 2 "- + "\n } "- + "\n } "- + "\n ] "- + "\n } "- + "\n } "- + "\n } "- + "\n } "- + "\n} ";-- String test =- "== {"- + "\n 'results' : { "- + "\n 'floor_mean_add' : 9, "- + "\n 'consts' : 'str3-con_1800-01-01T11:59:59Z-con' "- + "\n }, "- + "\n 'groupings' : { "- + "\n 'grouping0' : { "- + "\n 'ranges' : [ "- + "\n { "- + "\n 'value' : '[2 TO 4)', "- + "\n 'results' : { "- + "\n 'mean' : 3.5, "- + "\n 'count2' : 10 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'value' : '[4 TO 9)', "- + "\n 'results' : { "- + "\n 'mean' : 3.2, "- + "\n 'count2' : 12 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'value' : '[9 TO 12)', "- + "\n 'results' : { "- + "\n 'mean' : 2.0, "- + "\n 'count2' : 4 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'value' : '[12 TO 15)', "- + "\n 'results' : { "- + "\n 'mean' : 3.75, "- + "\n 'count2' : 14 "- + "\n } "- + "\n } "- + "\n ] "- + "\n }, "- + "\n 'grouping1': { "- + "\n 'queries' : [ "- + "\n { "- + "\n 'value' : 'float < 3', "- + "\n 'results' : { "- + "\n 'mean' : 2.1, "- + "\n 'count' : 14 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'value' : 'string = 1, date = 2', "- + "\n 'results' : { "- + "\n 'mean' : 4.0, "- + "\n 'count' : 4 "- + "\n } "- + "\n } "- + "\n ], "- + "\n 'pivoting':["- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str3', "- + "\n 'results' : { "- + "\n 'mean' : 2.6, "- + "\n 'count' : 10 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 4.0, "- + "\n 'count' : 2 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : 'No Date', "- + "\n 'results' : { "- + "\n 'mean' : 2.0, "- + "\n 'count' : 4 "- + "\n } "- + "\n } "- + "\n ]"- + "\n }, "- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str2_second', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 1.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1801-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n } "- + "\n ]"- + "\n }, "- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str2', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 1.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1801-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n } "- + "\n ]"- + "\n } "- + "\n ]"- + "\n }"- + "\n }"- + "\n}";-- testAnalytics(analyticsRequest, test);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/SolrAnalyticsTestCase.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/SolrAnalyticsTestCase.javadeleted file mode 100644index 9fae8c2c17f..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/SolrAnalyticsTestCase.java+++ /dev/null@@ -1,448 +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;--import java.io.IOException;-import java.time.Instant;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Comparator;-import java.util.Date;-import java.util.List;-import java.util.Map;-import java.util.stream.Collectors;-import org.apache.solr.JSONTestUtil;-import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.request.CollectionAdminRequest;-import org.apache.solr.client.solrj.request.QueryRequest;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.client.solrj.response.QueryResponse;-import org.apache.solr.cloud.AbstractDistribZkTestBase;-import org.apache.solr.cloud.SolrCloudTestCase;-import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.params.SolrParams;-import org.apache.solr.common.util.Utils;-import org.junit.BeforeClass;--public class SolrAnalyticsTestCase extends SolrCloudTestCase {- private static final double DEFAULT_DELTA = .0000001;-- protected static final String COLLECTIONORALIAS = "collection1";- protected static final int TIMEOUT = DEFAULT_TIMEOUT;- protected static final String id = "id";-- private static UpdateRequest cloudReq;-- @BeforeClass- public static void setupCollection() throws Exception {- // Single-sharded core- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- // Solr Cloud- configureCluster(4).addConfig("conf", configset("cloud-analytics")).configure();-- CollectionAdminRequest.createCollection(COLLECTIONORALIAS, "conf", 2, 1)- .process(cluster.getSolrClient());- AbstractDistribZkTestBase.waitForRecoveriesToFinish(- COLLECTIONORALIAS, cluster.getZkStateReader(), false, true, TIMEOUT);-- new UpdateRequest().deleteByQuery("*:*").commit(cluster.getSolrClient(), COLLECTIONORALIAS);-- cloudReq = new UpdateRequest();- }-- protected static void cleanIndex() throws Exception {- h.update("<delete><query>*:*</query></delete>");-- new UpdateRequest().deleteByQuery("*:*").commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- protected static void addDoc(List<String> fieldsAndValues) {- assertU(adoc(fieldsAndValues.toArray(new String[0])));- cloudReq.add(fieldsAndValues.toArray(new String[0]));- }-- protected static void commitDocs() {- assertU(commit());- try {- cloudReq.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- } catch (Exception e) {- throw new RuntimeException(e);- }- cloudReq = new UpdateRequest();- }-- public static final int INT = 7;- public static final int LONG = 2;- public static final int FLOAT = 6;- public static final int DOUBLE = 5;- public static final int DATE = 3;- public static final int STRING = 4;- public static final int NUM_LOOPS = 20;-- protected static void populateDocsForAnalyticsTests() {- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- String dt = (1800 + j % DATE) + "-12-31T23:59:59Z";- String dtm = (1800 + j % DATE + 10) + "-12-31T23:59:59Z";- String s = "str" + (j % STRING);- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);-- if (i != 0) {- fields.add("int_i");- fields.add("" + i);- fields.add("int_im");- fields.add("" + i);- fields.add("int_im");- fields.add("" + (i + 10));- }-- if (l != 0l) {- fields.add("long_l");- fields.add("" + l);- fields.add("long_lm");- fields.add("" + l);- fields.add("long_lm");- fields.add("" + (l + 10));- }-- if (f != 0.0f) {- fields.add("float_f");- fields.add("" + f);- fields.add("float_fm");- fields.add("" + f);- fields.add("float_fm");- fields.add("" + (f + 10));- }-- if (d != 0.0d) {- fields.add("double_d");- fields.add("" + d);- fields.add("double_dm");- fields.add("" + d);- fields.add("double_dm");- fields.add("" + (d + 10));- }-- if ((j % DATE) != 0) {- fields.add("date_dt");- fields.add(dt);- fields.add("date_dtm");- fields.add(dt);- fields.add("date_dtm");- fields.add(dtm);- }-- if ((j % STRING) != 0) {- fields.add("string_s");- fields.add(s);- fields.add("string_sm");- fields.add(s);- fields.add("string_sm");- fields.add(s + "_second");- }-- addDoc(fields);- }- commitDocs();- }-- private void testResults(SolrParams params, String analyticsRequest, String... tests) {- String coreJson = queryCoreJson(params);- Object cloudObj = queryCloudObject(params);-- for (String test : tests) {- if (test == null || test.length() == 0) continue;- // Single-Sharded- String err = null;- try {- err = JSONTestUtil.match(coreJson, test, DEFAULT_DELTA);- } catch (Exception e) {- err = e.getMessage();- } finally {- assertNull(- "query failed JSON validation. test= Single-Sharded Collection"- + "\n error="- + err- + "\n expected ="- + test- + "\n response = "- + coreJson- + "\n analyticsRequest = "- + analyticsRequest,- err);- }-- // Cloud- err = null;- try {- err = JSONTestUtil.matchObj(cloudObj, test, DEFAULT_DELTA);- } catch (Exception e) {- err = e.getMessage();- } finally {- assertNull(- "query failed JSON validation. test= Solr Cloud Collection"- + "\n error="- + err- + "\n expected ="- + test- + "\n response = "- + Utils.toJSONString(cloudObj)- + "\n analyticsRequest = "- + analyticsRequest,- err);- }- }- }-- private String queryCoreJson(SolrParams params) {- try {- return JQ(req(params));- } catch (Exception e) {- throw new RuntimeException(e);- }- }-- private Object queryCloudObject(SolrParams params) {- QueryResponse resp;- try {- cluster.waitForAllNodes(10);- QueryRequest qreq = new QueryRequest(params);- resp = qreq.process(cluster.getSolrClient(), COLLECTIONORALIAS);- } catch (Exception e) {- throw new RuntimeException(e);- }- return convertDatesToStrings(resp.getResponse().asShallowMap());- }-- protected void testAnalytics(String analyticsRequest, String... tests)- throws IOException, InterruptedException, SolrServerException {- ModifiableSolrParams params = new ModifiableSolrParams();- params.set("q", "*:*");- params.set("indent", "true");- params.set("rows", "0");- params.set("wt", "json");-- params.set("analytics", analyticsRequest);-- String[] revisedTests =- Arrays.stream(tests)- .map(test -> "analytics_response/" + test)- .toArray(size -> new String[size]);- testResults(params, analyticsRequest, revisedTests);- }-- protected void testExpressions(Map<String, ETP> expressions) throws Exception {- StringBuilder analyticsRequest = new StringBuilder("{ \"expressions\": {");- String expressionsStr =- expressions.entrySet().stream()- .map(entry -> '"' + entry.getKey() + "\":\"" + entry.getValue().expression + '"')- .reduce((a, b) -> a + ',' + b)- .orElseGet(() -> "");- analyticsRequest.append(expressionsStr);- analyticsRequest.append("}}");-- String results =- expressions.entrySet().stream()- .map(entry -> '"' + entry.getKey() + "\":" + entry.getValue().expectedResultStr())- .reduce((a, b) -> a + ',' + b)- .orElseGet(() -> "");-- testAnalytics(analyticsRequest.toString(), "results=={" + results + ", \"_UNORDERED_\":true}");- }-- protected void testGrouping(- String grouping,- Map<String, String> expressions,- Map<String, String> facets,- Map<String, List<FVP>> results,- boolean sortAscending)- throws Exception {- testGroupingSorted(- grouping,- expressions,- facets,- results,- ", 'sort': { 'criteria' : [{'type': 'facetvalue', 'direction': '"- + (sortAscending ? "ascending" : "descending")- + "'}]}",- (fvp1, fvp2) -> fvp1.facetValue.compareTo(fvp2.facetValue),- sortAscending);- }-- @SuppressWarnings("unchecked")- protected void testGrouping(- String grouping,- Map<String, String> expressions,- Map<String, String> facets,- Map<String, List<FVP>> results,- String sortExpression,- boolean sortAscending)- throws Exception {- testGroupingSorted(- grouping,- expressions,- facets,- results,- ", 'sort': { 'criteria' : [{'type': 'expression', 'expression': '"- + sortExpression- + "', 'direction': '"- + (sortAscending ? "ascending" : "descending")- + "'}]}",- (fvp1, fvp2) ->- fvp1.expectedResults- .get(sortExpression)- .compareTo(fvp2.expectedResults.get(sortExpression)),- sortAscending);- }-- protected void testGrouping(- String grouping,- Map<String, String> expressions,- Map<String, String> facets,- Map<String, List<FVP>> results)- throws Exception {- testGroupingSorted(- grouping, expressions, facets, results, "", (fvp1, fvp2) -> fvp1.compareTo(fvp2), true);- }-- private void testGroupingSorted(- String grouping,- Map<String, String> expressions,- Map<String, String> facets,- Map<String, List<FVP>> results,- String sort,- Comparator<FVP> comparator,- boolean sortAscending)- throws Exception {- StringBuilder analyticsRequest =- new StringBuilder("{ \"groupings\": { \"" + grouping + "\" : { \"expressions\" : {");- String expressionsStr =- expressions.entrySet().stream()- .map(entry -> '"' + entry.getKey() + "\":\"" + entry.getValue() + '"')- .collect(Collectors.joining(" , "));- analyticsRequest.append(expressionsStr);- analyticsRequest.append("}, \"facets\": {");- String facetsStr =- facets.entrySet().stream()- .map(- entry ->- '"'- + entry.getKey()- + "\":"- + entry.getValue().replaceFirst("}\\s*$", sort)- + "}")- .collect(Collectors.joining(" , "));- analyticsRequest.append(facetsStr);- analyticsRequest.append("}}}}");-- String groupingResults =- results.entrySet().stream()- .map(- facet -> {- String resultList =- facet.getValue().stream()- .sorted(sortAscending ? comparator : comparator.reversed())- .map(fvp -> fvp.toJsonResults())- .collect(Collectors.joining(" , "));- return '"' + facet.getKey() + "\" : [ " + resultList + " ]";- })- .collect(Collectors.joining(" , "));-- testAnalytics(- analyticsRequest.toString(),- "groupings/" + grouping + "=={" + groupingResults + ", \"_UNORDERED_\":true}");- }-- private static String resultToJson(Object result) {- if (result instanceof String) {- return '"' + result.toString() + '"';- }- return result.toString();- }-- /*- * Expression Test Pair, contains the expression and the expected result- */- protected static class ETP {- final String expression;- final Object expectedResult;-- public ETP(String expression, Object expectedResult) {- this.expression = expression;- this.expectedResult = expectedResult;- }-- public String expectedResultStr() {- if (expectedResult instanceof String) {- return '"' + expectedResult.toString() + '"';- }- return expectedResult.toString();- }- }-- /*- * FacetValuePair, contains the expression and the expected result- */- @SuppressWarnings("rawtypes")- protected static class FVP implements Comparable<FVP> {- private final int order;- public final String facetValue;- public final Map<String, Comparable> expectedResults;-- public FVP(int order, String facetValue, Map<String, Comparable> expectedResults) {- this.order = order;- this.facetValue = facetValue;- this.expectedResults = expectedResults;- }-- public String toJsonResults() {- String valueResults =- expectedResults.entrySet().stream()- .map(result -> '"' + result.getKey() + "\":" + resultToJson(result.getValue()))- .collect(Collectors.joining(" , "));- return "{ \"value\" : \""- + facetValue- + "\", \"results\": { "- + valueResults- + ", \"_UNORDERED_\":true } }";- }-- @Override- public int compareTo(FVP other) {- return Integer.compare(order, other.order);- }- }-- @SuppressWarnings("unchecked")- protected static Object convertDatesToStrings(Object value) {- if (value instanceof Date) {- return Instant.ofEpochMilli(((Date) value).getTime()).toString();- } else if (value instanceof Map) {- ((Map<String, Object>) value).replaceAll((key, obj) -> convertDatesToStrings(obj));- } else if (value instanceof List) {- ((List<Object>) value).replaceAll(obj -> convertDatesToStrings(obj));- }- return value;- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.javadeleted file mode 100644index 8de7a51befa..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java+++ /dev/null@@ -1,175 +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.facet;--import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import org.apache.solr.analytics.SolrAnalyticsTestCase;-import org.junit.BeforeClass;-import org.junit.Test;--@ThreadLeakLingering(linger = 0)-public class PivotFacetTest extends SolrAnalyticsFacetTestCase {-- @BeforeClass- public static void populate() {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void pivotFacetTest() throws Exception {- String analyticsRequest =- "{"- + "\n 'groupings': { "- + "\n 'grouping' : { "- + "\n 'expressions' : { "- + "\n 'mean' : 'mean(fill_missing(int_i,0))', "- + "\n 'count' : 'count(long_lm)' "- + "\n }, "- + "\n 'facets' : { "- + "\n 'pivoting' : { "- + "\n 'type' : 'pivot', "- + "\n 'pivots' : [ "- + "\n { "- + "\n 'name' : 'strings', "- + "\n 'expression' : 'string_sm', "- + "\n 'sort' : { "- + "\n 'criteria' : [ "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'mean', "- + "\n 'direction' : 'ascending' "- + "\n }, "- + "\n { "- + "\n 'type' : 'facetvalue', "- + "\n 'direction' : 'descending' "- + "\n } "- + "\n ], "- + "\n 'limit' : 3, "- + "\n 'offset' : 1 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'name' : 'date', "- + "\n 'expression' : 'fill_missing(date_dt, \\'No Date\\')', "- + "\n 'sort' : { "- + "\n 'criteria' : [ "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'count', "- + "\n 'direction' : 'ascending' "- + "\n }, "- + "\n { "- + "\n 'type' : 'expression', "- + "\n 'expression' : 'mean', "- + "\n 'direction' : 'ascending' "- + "\n } "- + "\n ], "- + "\n 'limit' : 2 "- + "\n } "- + "\n } "- + "\n ] "- + "\n } "- + "\n } "- + "\n } "- + "\n } "- + "\n} ";-- String test =- "groupings=={'grouping':{'pivoting':["- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str3', "- + "\n 'results' : { "- + "\n 'mean' : 2.6, "- + "\n 'count' : 10 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 4.0, "- + "\n 'count' : 2 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : 'No Date', "- + "\n 'results' : { "- + "\n 'mean' : 2.0, "- + "\n 'count' : 4 "- + "\n } "- + "\n } "- + "\n ]"- + "\n }, "- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str2_second', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 1.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1801-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n } "- + "\n ]"- + "\n }, "- + "\n { "- + "\n 'pivot' : 'strings', "- + "\n 'value' : 'str2', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n }, "- + "\n 'children' : [ "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1802-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 1.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n }, "- + "\n { "- + "\n 'pivot' : 'date', "- + "\n 'value' : '1801-12-31T23:59:59Z', "- + "\n 'results' : { "- + "\n 'mean' : 3.0, "- + "\n 'count' : 0 "- + "\n } "- + "\n } "- + "\n ]"- + "\n } "- + "\n]}}";-- testAnalytics(analyticsRequest, test);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.javadeleted file mode 100644index fc3097631ff..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java+++ /dev/null@@ -1,53 +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.facet;--import java.util.HashMap;-import java.util.Map;-import org.apache.solr.analytics.SolrAnalyticsTestCase;-import org.junit.BeforeClass;-import org.junit.Test;--public class QueryFacetTest extends SolrAnalyticsFacetTestCase {-- @BeforeClass- public static void populate() {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void queryFacetTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(int_i)");- expressions.put("count", "count(string_sm)");-- // Value Facet "with_missing"- addFacet(- "with_missing",- "{ 'type':'query', 'queries':{'q1':'long_l:1 AND float_f:1.0','q2':'double_dm:[3 TO 11] OR double_dm:1'}}");-- addFacetValue("q1");- addFacetResult("mean", 4.0);- addFacetResult("count", 8L);-- addFacetValue("q2");- addFacetResult("mean", 38.0 / 11.0);- addFacetResult("count", 18L);-- testGrouping(expressions);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.javadeleted file mode 100644index e99c514ecb5..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java+++ /dev/null@@ -1,270 +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.facet;--import java.util.HashMap;-import java.util.Map;-import org.apache.solr.analytics.SolrAnalyticsTestCase;-import org.junit.BeforeClass;-import org.junit.Test;--public class RangeFacetTest extends SolrAnalyticsFacetTestCase {-- @BeforeClass- public static void populate() {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void intRangeHardEndTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(float_f)");- expressions.put("count", "count(string_sm)");-- // Hard end on- addFacet(- "hard_end_on",- "{ 'type':'range', "- + " 'field': 'int_im', "- + " 'start': '2', "- + " 'end' : '13', "- + " 'gaps' : ['2', '5', '3'], "- + " 'hardend' : true }");-- addFacetValue("[2 TO 4)");- addFacetResult("mean", 3.5);- addFacetResult("count", 10L);-- addFacetValue("[4 TO 9)");- addFacetResult("mean", 16.0 / 5.0);- addFacetResult("count", 12L);-- addFacetValue("[9 TO 12)");- addFacetResult("mean", 2.0);- addFacetResult("count", 4L);-- addFacetValue("[12 TO 13)");- addFacetResult("mean", 3.0);- addFacetResult("count", 4L);-- // Hard end off- addFacet(- "hard_end_off",- "{ 'type':'range', "- + " 'field': 'int_im', "- + " 'start': '2', "- + " 'end' : '13', "- + " 'gaps' : ['2', '5', '3'], "- + " 'hardend' : false }");-- addFacetValue("[2 TO 4)");- addFacetResult("mean", 3.5);- addFacetResult("count", 10L);-- addFacetValue("[4 TO 9)");- addFacetResult("mean", 16.0 / 5.0);- addFacetResult("count", 12L);-- addFacetValue("[9 TO 12)");- addFacetResult("mean", 2.0);- addFacetResult("count", 4L);-- addFacetValue("[12 TO 15)");- addFacetResult("mean", 30.0 / 8.0);- addFacetResult("count", 14L);-- testGrouping(expressions);- }-- @Test- public void doubleOthersTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(float_f)");- expressions.put("count", "count(string_sm)");-- addFacet(- "before_between",- "{ 'type':'range', "- + " 'field': 'double_d', "- + " 'start': '2', "- + " 'end' : '4', "- + " 'gaps' : ['1'], "- + " 'others' : ['before', 'between'] }");-- addFacetValue("[2.0 TO 3.0)");- addFacetResult("mean", 8.0 / 3.0);- addFacetResult("count", 6L);-- addFacetValue("[3.0 TO 4.0)");- addFacetResult("mean", 2.0);- addFacetResult("count", 6L);-- addFacetValue("(* TO 2.0)");- addFacetResult("mean", 10.0 / 3.0);- addFacetResult("count", 6L);-- addFacetValue("[2.0 TO 4.0)");- addFacetResult("mean", 14.0 / 6.0);- addFacetResult("count", 12L);-- addFacet(- "after",- "{ 'type':'range', "- + " 'field': 'double_d', "- + " 'start': '2', "- + " 'end' : '4', "- + " 'gaps' : ['1'], "- + " 'others' : ['after'] }");-- addFacetValue("[2.0 TO 3.0)");- addFacetResult("mean", 8.0 / 3.0);- addFacetResult("count", 6L);-- addFacetValue("[3.0 TO 4.0)");- addFacetResult("mean", 2.0);- addFacetResult("count", 6L);-- addFacetValue("[4.0 TO *)");- addFacetResult("mean", 2.5);- addFacetResult("count", 6L);-- testGrouping(expressions);- }-- @Test- public void dateIncludeTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(float_f)");- expressions.put("count", "count(string_sm)");-- addFacet(- "lower_upper",- "{ 'type':'range', "- + " 'field': 'date_dt', "- + " 'start': '1801-12-31T23:59:59Z', "- + " 'end' : '1803-12-31T23:59:59Z', "- + " 'gaps' : ['+1YEAR'], "- + " 'include' : ['lower', 'upper'] }");-- addFacetValue("[1801-12-31T23:59:59Z TO 1802-12-31T23:59:59Z]");- addFacetResult("mean", 37.0 / 13.0);- addFacetResult("count", 20L);-- addFacetValue("[1802-12-31T23:59:59Z TO 1803-12-31T23:59:59Z]");- addFacetResult("mean", 3.5);- addFacetResult("count", 10L);-- testGrouping(expressions);-- addFacet(- "lower_upper",- "{ 'type':'range', "- + " 'field': 'date_dt', "- + " 'start': '1801-12-31T23:59:59Z', "- + " 'end' : '1803-12-31T23:59:59Z', "- + " 'gaps' : ['+1YEAR'], "- + " 'include' : ['lower','edge'] }");-- addFacetValue("[1801-12-31T23:59:59Z TO 1802-12-31T23:59:59Z)");- addFacetResult("mean", 16.0 / 7.0);- addFacetResult("count", 10L);-- addFacetValue("[1802-12-31T23:59:59Z TO 1803-12-31T23:59:59Z]");- addFacetResult("mean", 3.5);- addFacetResult("count", 10L);-- testGrouping(expressions);- }-- @Test- public void floatIncludeOuterTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(int_i)");- expressions.put("count", "count(string_sm)");-- addFacet(- "include_outer",- "{ 'type':'range', "- + " 'field': 'float_f', "- + " 'start': '1', "- + " 'end' : '5', "- + " 'gaps' : ['2'], "- + " 'include' : ['outer'], "- + " 'others' : ['all'] }");-- addFacetValue("(1.0 TO 3.0)");- addFacetResult("mean", 1.5);- addFacetResult("count", 4L);-- addFacetValue("(3.0 TO 5.0)");- addFacetResult("mean", 3.0);- addFacetResult("count", 2L);-- addFacetValue("(* TO 1.0]");- addFacetResult("mean", 4.0);- addFacetResult("count", 8L);-- addFacetValue("[5.0 TO *)");- addFacetResult("mean", 4.0);- addFacetResult("count", 6L);-- addFacetValue("(1.0 TO 5.0)");- addFacetResult("mean", 18.0 / 8.0);- addFacetResult("count", 12L);-- testGrouping(expressions);- }-- @Test- public void floatIncludeAllTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("mean", "mean(int_i)");- expressions.put("count", "count(string_sm)");-- addFacet(- "include_all",- "{ 'type':'range', "- + " 'field': 'float_f', "- + " 'start': '1', "- + " 'end' : '5', "- + " 'gaps' : ['2'], "- + " 'include' : ['all'], "- + " 'others' : ['all'] }");-- addFacetValue("[1.0 TO 3.0]");- addFacetResult("mean", 21.0 / 8.0);- addFacetResult("count", 18L);-- addFacetValue("[3.0 TO 5.0]");- addFacetResult("mean", 3.0);- addFacetResult("count", 14L);-- addFacetValue("(* TO 1.0]");- addFacetResult("mean", 4.0);- addFacetResult("count", 8L);-- addFacetValue("[5.0 TO *)");- addFacetResult("mean", 4.0);- addFacetResult("count", 6L);-- addFacetValue("[1.0 TO 5.0]");- addFacetResult("mean", 3.0);- addFacetResult("count", 26L);-- testGrouping(expressions);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.javadeleted file mode 100644index 0e905b1d03d..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java+++ /dev/null@@ -1,80 +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.facet;--import java.util.ArrayList;-import java.util.HashMap;-import java.util.List;-import java.util.Map;-import org.apache.solr.analytics.SolrAnalyticsTestCase;-import org.junit.Before;--public class SolrAnalyticsFacetTestCase extends SolrAnalyticsTestCase {-- private List<FVP> facetResults;- private Map<String, List<FVP>> results = new HashMap<>();- private Map<String, String> facets = new HashMap<>();- private FVP fvp;- private int fvp_num;-- @Before- protected void initData() {- results = new HashMap<>();- facets = new HashMap<>();- }-- protected void addFacet(String name, String json) {- facets.put(name, json);- facetResults = new ArrayList<>();- results.put(name, facetResults);- fvp_num = 0;- }-- protected void addFacetValue(String value) {- fvp = new FVP(fvp_num++, value, new HashMap<>());- facetResults.add(fvp);- }-- protected void addFacetResult(String expr, Comparable<?> result) {- fvp.expectedResults.put(expr, result);- }-- protected void testGrouping(Map<String, String> expressions) {- try {- testGrouping("grouping", expressions, facets, results);- } catch (Exception e) {- throw new RuntimeException(e);- }- }-- protected void testGrouping(Map<String, String> expressions, boolean sortAscending) {- try {- testGrouping("grouping", expressions, facets, results, sortAscending);- } catch (Exception e) {- throw new RuntimeException(e);- }- }-- protected void testGrouping(- Map<String, String> expressions, String sortExpression, boolean sortAscending) {- try {- testGrouping("grouping", expressions, facets, results, sortExpression, sortAscending);- } catch (Exception e) {- throw new RuntimeException(e);- }- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.javadeleted file mode 100644index 5c216545608..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java+++ /dev/null@@ -1,379 +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.facet;--import java.util.HashMap;-import java.util.Map;-import org.apache.solr.analytics.SolrAnalyticsTestCase;-import org.junit.BeforeClass;-import org.junit.Test;--public class ValueFacetTest extends SolrAnalyticsFacetTestCase {-- @BeforeClass- public static void populate() {- SolrAnalyticsTestCase.populateDocsForAnalyticsTests();- }-- @Test- public void countTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("single", "count(float_f)");- expressions.put("multi", "count(string_sm)");-- // Value Facet "with_missing"- addFacet(- "with_missing", "{ 'type':'value', 'expression':'fill_missing(long_l,\\'No Long\\')' }");-- addFacetValue("1");- addFacetResult("single", 10L);- addFacetResult("multi", 20L);-- addFacetValue("No Long");- addFacetResult("single", 6L);- addFacetResult("multi", 10L);-- testGrouping(expressions, "single", true);- }-- @Test- public void docCountTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("single", "doc_count(date_dt)");- expressions.put("multi", "doc_count(float_fm)");-- // Value Facet "with_missing"- addFacet(- "with_missing",- "{ 'type':'value', 'expression':'fill_missing(string_sm,\\'No Values\\')' }");-- addFacetValue("str1");- addFacetResult("single", 4L);- addFacetResult("multi", 5L);-- addFacetValue("str1_second");- addFacetResult("single", 4L);- addFacetResult("multi", 5L);-- addFacetValue("str2");- addFacetResult("single", 3L);- addFacetResult("multi", 3L);-- addFacetValue("str2_second");- addFacetResult("single", 3L);- addFacetResult("multi", 3L);-- addFacetValue("str3");- addFacetResult("single", 3L);- addFacetResult("multi", 5L);-- addFacetValue("str3_second");- addFacetResult("single", 3L);- addFacetResult("multi", 5L);-- addFacetValue("No Values");- addFacetResult("single", 3L);- addFacetResult("multi", 3L);-- // Value Facet "no_missing"- addFacet("no_missing", "{ 'type':'value', 'expression':'long_l' }");-- addFacetValue("1");- addFacetResult("single", 7L);- addFacetResult("multi", 10L);-- testGrouping(expressions, false);- }-- @Test- public void missingTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("single", "missing(date_dt)");- expressions.put("multi", "missing(float_fm)");-- // Value Facet "with_missing"- addFacet(- "with_missing",- "{ 'type':'value', 'expression':'fill_missing(string_sm,\\'No Values\\')' }");-- addFacetValue("str1");- addFacetResult("single", 1L);- addFacetResult("multi", 0L);-- addFacetValue("str1_second");- addFacetResult("single", 1L);- addFacetResult("multi", 0L);-- addFacetValue("str2");- addFacetResult("single", 2L);- addFacetResult("multi", 2L);-- addFacetValue("str2_second");- addFacetResult("single", 2L);- addFacetResult("multi", 2L);-- addFacetValue("str3");- addFacetResult("single", 2L);- addFacetResult("multi", 0L);-- addFacetValue("str3_second");- addFacetResult("single", 2L);- addFacetResult("multi", 0L);-- addFacetValue("No Values");- addFacetResult("single", 2L);- addFacetResult("multi", 2L);-- // Value Facet "no_missing"- addFacet("no_missing", "{ 'type':'value', 'expression':'long_l' }");-- addFacetValue("1");- addFacetResult("single", 3L);- addFacetResult("multi", 0L);-- testGrouping(expressions, false);- }-- @Test- public void uniqueTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "unique(int_i)");- expressions.put("longs", "unique(long_lm)");- expressions.put("float", "unique(float_f)");- expressions.put("doubles", "unique(double_dm)");- expressions.put("dates", "unique(date_dtm)");- expressions.put("string", "unique(string_s)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 6L);- addFacetResult("longs", 2L);- addFacetResult("float", 2L);- addFacetResult("doubles", 8L);- addFacetResult("dates", 2L);- addFacetResult("string", 3L);-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 5L);- addFacetResult("longs", 2L);- addFacetResult("float", 2L);- addFacetResult("doubles", 8L);- addFacetResult("dates", 2L);- addFacetResult("string", 3L);-- testGrouping(expressions, false);- }-- @Test- public void minTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "min(int_i)");- expressions.put("longs", "min(long_lm)");- expressions.put("float", "min(float_f)");- expressions.put("doubles", "min(double_dm)");- expressions.put("dates", "min(date_dtm)");- expressions.put("string", "min(string_s)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 1);- addFacetResult("longs", 1L);- addFacetResult("float", 1.0F);- addFacetResult("doubles", 1.0);- addFacetResult("dates", "1801-12-31T23:59:59Z");- addFacetResult("string", "str1");-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 1);- addFacetResult("longs", 1L);- addFacetResult("float", 2.0F);- addFacetResult("doubles", 1.0);- addFacetResult("dates", "1802-12-31T23:59:59Z");- addFacetResult("string", "str1");-- testGrouping(expressions, false);- }-- @Test- public void maxTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "max(int_i)");- expressions.put("longs", "max(long_lm)");- expressions.put("float", "max(float_f)");- expressions.put("doubles", "max(double_dm)");- expressions.put("dates", "max(date_dtm)");- expressions.put("string", "max(string_s)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 6);- addFacetResult("longs", 11L);- addFacetResult("float", 4.0F);- addFacetResult("doubles", 14.0);- addFacetResult("dates", "1811-12-31T23:59:59Z");- addFacetResult("string", "str3");-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 5);- addFacetResult("longs", 11L);- addFacetResult("float", 5.0F);- addFacetResult("doubles", 14.0);- addFacetResult("dates", "1812-12-31T23:59:59Z");- addFacetResult("string", "str3");-- testGrouping(expressions, false);- }-- @Test- public void sumTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("single", "sum(float_f)");- expressions.put("multi", "sum(double_dm)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("single", 16.0);- addFacetResult("multi", 90.0);-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("single", 21.0);- addFacetResult("multi", 74.0);-- testGrouping(expressions, false);- }-- @Test- public void meanTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("single", "mean(float_f)");- expressions.put("multi", "mean(double_dm)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("single", 16.0 / 7.0);- addFacetResult("multi", 90.0 / 12.0);-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("single", 21.0 / 6.0);- addFacetResult("multi", 74.0 / 10.0);-- testGrouping(expressions, "multi", true);- }-- @Test- public void medianTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "median(int_i)");- expressions.put("longs", "median(long_lm)");- expressions.put("float", "median(float_f)");- expressions.put("doubles", "median(double_dm)");- expressions.put("dates", "median(date_dtm)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 3.5);- addFacetResult("longs", 6.0);- addFacetResult("float", 1.0);- addFacetResult("doubles", 7.5);- addFacetResult("dates", "1806-12-31T23:59:59Z");-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 3.0);- addFacetResult("longs", 6.0);- addFacetResult("float", 3.5);- addFacetResult("doubles", 7.50);- addFacetResult("dates", "1808-01-01T11:59:59Z");-- testGrouping(expressions, false);- }-- @Test- public void percentileTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "percentile(20,int_i)");- expressions.put("longs", "percentile(80,long_lm)");- expressions.put("float", "percentile(40,float_f)");- expressions.put("doubles", "percentile(50,double_dm)");- expressions.put("dates", "percentile(0,date_dtm)");- expressions.put("string", "percentile(99.99,string_s)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 2);- addFacetResult("longs", 11L);- addFacetResult("float", 1.0F);- addFacetResult("doubles", 11.0);- addFacetResult("dates", "1801-12-31T23:59:59Z");- addFacetResult("string", "str3");-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 2);- addFacetResult("longs", 11L);- addFacetResult("float", 2.0F);- addFacetResult("doubles", 11.0);- addFacetResult("dates", "1802-12-31T23:59:59Z");- addFacetResult("string", "str3");-- testGrouping(expressions, "dates", false);- }-- @Test- public void ordinalTest() throws Exception {- Map<String, String> expressions = new HashMap<>();- expressions.put("int", "ordinal(3,int_i)");- expressions.put("longs", "ordinal(-2,long_lm)");- expressions.put("float", "ordinal(-3,float_f)");- expressions.put("doubles", "ordinal(1,double_dm)");- expressions.put("dates", "ordinal(-1,date_dtm)");- expressions.put("string", "ordinal(4,string_s)");-- // Value Facet "without_missing"- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");-- addFacetValue("1801-12-31T23:59:59Z");- addFacetResult("int", 3);- addFacetResult("longs", 11L);- addFacetResult("float", 4.0F);- addFacetResult("doubles", 1.0);- addFacetResult("dates", "1811-12-31T23:59:59Z");- addFacetResult("string", "str3");-- addFacetValue("1802-12-31T23:59:59Z");- addFacetResult("int", 3);- addFacetResult("longs", 11L);- addFacetResult("float", 5.0F);- addFacetResult("doubles", 1.0);- addFacetResult("dates", "1812-12-31T23:59:59Z");- addFacetResult("string", "str2");-- testGrouping(expressions, "string", false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.javadeleted file mode 100644index 74c2046f91a..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java+++ /dev/null@@ -1,300 +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.function.field;--import java.io.IOException;-import java.time.Instant;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.HashSet;-import java.util.List;-import java.util.Map;-import java.util.Set;-import java.util.function.Predicate;-import org.apache.lucene.index.LeafReaderContext;-import org.apache.lucene.util.Bits;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.ExpressionFactory;-import org.apache.solr.schema.IndexSchema;-import org.apache.solr.search.SolrIndexSearcher;-import org.apache.solr.util.RefCounted;-import org.junit.AfterClass;-import org.junit.BeforeClass;--public class AbstractAnalyticsFieldTest extends SolrTestCaseJ4 {-- private static IndexSchema indexSchema;- private static SolrIndexSearcher searcher;- private static RefCounted<SolrIndexSearcher> ref;-- protected static Map<String, Integer> singleInts;- protected static Map<String, Map<Integer, Integer>> multiInts;- protected static Map<String, Long> singleLongs;- protected static Map<String, Map<Long, Integer>> multiLongs;- protected static Map<String, Float> singleFloats;- protected static Map<String, Map<Float, Integer>> multiFloats;- protected static Map<String, Double> singleDoubles;- protected static Map<String, Map<Double, Integer>> multiDoubles;- protected static Map<String, Long> singleDates;- protected static Map<String, Map<Long, Integer>> multiDates;- protected static Map<String, String> singleStrings;- protected static Map<String, Map<String, Integer>> multiStrings;- protected static Map<String, Boolean> singleBooleans;- protected static Map<String, Map<Boolean, Integer>> multiBooleans;-- private static List<String> missingDocuments;-- @BeforeClass- public static void createSchemaAndFields() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");-- singleInts = new HashMap<>();- multiInts = new HashMap<>();- singleLongs = new HashMap<>();- multiLongs = new HashMap<>();- singleFloats = new HashMap<>();- multiFloats = new HashMap<>();- singleDoubles = new HashMap<>();- multiDoubles = new HashMap<>();- singleDates = new HashMap<>();- multiDates = new HashMap<>();- singleStrings = new HashMap<>();- multiStrings = new HashMap<>();- singleBooleans = new HashMap<>();- multiBooleans = new HashMap<>();-- missingDocuments = new ArrayList<>();-- assertU(adoc("id", "-2"));- missingDocuments.add("-2");- assertU(adoc("id", "5"));- missingDocuments.add("5");- for (int i = -1; i < 5; ++i) {- assertU(- adoc(- "id", "" + i,- "int_i_t", "" + i,- "int_im_t", "" + i,- "int_im_t", "" + (i + 10),- "int_im_t", "" + (i + 10),- "int_im_t", "" + (i + 20),- "int_i_p", "" + i,- "int_im_p", "" + i,- "int_im_p", "" + (i + 10),- "int_im_p", "" + (i + 10),- "int_im_p", "" + (i + 20),- "long_l_t", "" + i,- "long_lm_t", "" + i,- "long_lm_t", "" + (i + 10),- "long_lm_t", "" + (i + 10),- "long_lm_t", "" + (i + 20),- "long_l_p", "" + i,- "long_lm_p", "" + i,- "long_lm_p", "" + (i + 10),- "long_lm_p", "" + (i + 10),- "long_lm_p", "" + (i + 20),- "float_f_t", "" + (i + .75F),- "float_fm_t", "" + (i + .75F),- "float_fm_t", "" + (i + 10.75F),- "float_fm_t", "" + (i + 10.75F),- "float_fm_t", "" + (i + 20.75F),- "float_f_p", "" + (i + .75F),- "float_fm_p", "" + (i + .75F),- "float_fm_p", "" + (i + 10.75F),- "float_fm_p", "" + (i + 10.75F),- "float_fm_p", "" + (i + 20.75F),- "double_d_t", "" + (i + .5),- "double_dm_t", "" + (i + .5),- "double_dm_t", "" + (i + 10.5),- "double_dm_t", "" + (i + 10.5),- "double_dm_t", "" + (i + 20.5),- "double_d_p", "" + (i + .5),- "double_dm_p", "" + (i + .5),- "double_dm_p", "" + (i + 10.5),- "double_dm_p", "" + (i + 10.5),- "double_dm_p", "" + (i + 20.5),- "date_dt_t", (1800 + i) + "-12-31T23:59:59Z",- "date_dtm_t", (1800 + i) + "-12-31T23:59:59Z",- "date_dtm_t", (1800 + i + 10) + "-12-31T23:59:59Z",- "date_dtm_t", (1800 + i + 10) + "-12-31T23:59:59Z",- "date_dtm_t", (1800 + i + 20) + "-12-31T23:59:59Z",- "date_dt_p", (1800 + i) + "-12-31T23:59:59Z",- "date_dtm_p", (1800 + i) + "-12-31T23:59:59Z",- "date_dtm_p", (1800 + i + 10) + "-12-31T23:59:59Z",- "date_dtm_p", (1800 + i + 10) + "-12-31T23:59:59Z",- "date_dtm_p", (1800 + i + 20) + "-12-31T23:59:59Z",- "string_s", "abc" + i,- "string_sm", "abc" + i,- "string_sm", "def" + i,- "string_sm", "def" + i,- "string_sm", "ghi" + i,- "boolean_b", Boolean.toString(i % 3 == 0),- "boolean_bm", "false",- "boolean_bm", "true",- "boolean_bm", "false"));-- singleInts.put("" + i, i);- Map<Integer, Integer> ints = new HashMap<>();- ints.put(i, 1);- ints.put(i + 10, 2);- ints.put(i + 20, 1);- multiInts.put("" + i, ints);-- singleLongs.put("" + i, (long) i);- Map<Long, Integer> longs = new HashMap<>();- longs.put((long) i, 1);- longs.put(i + 10L, 2);- longs.put(i + 20L, 1);- multiLongs.put("" + i, longs);-- singleFloats.put("" + i, i + .75F);- Map<Float, Integer> floats = new HashMap<>();- floats.put(i + .75F, 1);- floats.put(i + 10.75F, 2);- floats.put(i + 20.75F, 1);- multiFloats.put("" + i, floats);-- singleDoubles.put("" + i, i + .5);- Map<Double, Integer> doubles = new HashMap<>();- doubles.put(i + .5, 1);- doubles.put(i + 10.5, 2);- doubles.put(i + 20.5, 1);- multiDoubles.put("" + i, doubles);-- singleDates.put("" + i, Instant.parse((1800 + i) + "-12-31T23:59:59Z").toEpochMilli());- Map<Long, Integer> dates = new HashMap<>();- dates.put(Instant.parse((1800 + i) + "-12-31T23:59:59Z").toEpochMilli(), 1);- dates.put(Instant.parse((1800 + i + 10) + "-12-31T23:59:59Z").toEpochMilli(), 2);- dates.put(Instant.parse((1800 + i + 20) + "-12-31T23:59:59Z").toEpochMilli(), 1);- multiDates.put("" + i, dates);-- singleStrings.put("" + i, "abc" + i);- Map<String, Integer> strings = new HashMap<>();- strings.put("abc" + i, 1);- strings.put("def" + i, 2);- strings.put("ghi" + i, 1);- multiStrings.put("" + i, strings);-- singleBooleans.put("" + i, i % 3 == 0);- Map<Boolean, Integer> booleans = new HashMap<>();- booleans.put(true, 1);- booleans.put(false, 2);- multiBooleans.put("" + i, booleans);- }- assertU(commit());-- ref = h.getCore().getSearcher();- searcher = ref.get();-- indexSchema = h.getCore().getLatestSchema();- }-- protected ExpressionFactory getExpressionFactory() {- ExpressionFactory fact = new ExpressionFactory(indexSchema);- fact.startRequest();- return fact;- }-- @AfterClass- public static void closeSearcher() throws IOException {- if (null != ref) {- ref.decref();- ref = null;- }- indexSchema = null;- searcher = null;- ref = null;- }-- protected <T> void checkSingleFieldValues(- Map<String, T> expected, Map<String, T> found, Set<String> missing) {- expected.forEach(- (id, value) -> {- assertTrue("Field does not contain value for id '" + id + "'.", found.containsKey(id));- assertEquals(value, found.get(id));- });- assertEquals(expected.size(), found.size());-- missingDocuments.forEach(- id ->- assertTrue(- "Field does not have correct information for missing id '" + id + "'.",- missing.contains(id)));- assertEquals(missingDocuments.size(), missing.size());- }-- protected <T> void checkMultiFieldValues(- Map<String, Map<T, Integer>> expected,- Map<String, Map<T, Integer>> found,- Set<String> missing,- boolean deduplicated) {- expected.forEach(- (id, expectedValues) -> {- assertTrue("Field does not contain values for id '" + id + "'.", found.containsKey(id));- Map<T, Integer> foundValues = found.get(id);- expectedValues.forEach(- (value, count) -> {- assertTrue(- "Value '" + value + "' not found for document with id '" + id + "'.",- foundValues.containsKey(value));- if (deduplicated) {- assertEquals(1, foundValues.get(value).intValue());- } else {- assertEquals(count, foundValues.get(value));- }- });- assertEquals(expectedValues.size(), foundValues.size());- });- assertEquals(expected.size(), found.size());-- missingDocuments.forEach(- id ->- assertTrue(- "Field does not have correct information for missing id '" + id + "'.",- missing.contains(id)));- assertEquals(missingDocuments.size(), missing.size());- }-- protected boolean emptyValueFound;-- protected Set<String> collectFieldValues(AnalyticsField testField, Predicate<String> valuesFiller)- throws IOException {- StringField idField = new StringField("id");- Set<String> missing = new HashSet<>();-- List<LeafReaderContext> contexts = searcher.getTopReaderContext().leaves();- for (LeafReaderContext context : contexts) {- testField.doSetNextReader(context);- idField.doSetNextReader(context);- Bits liveDocs = context.reader().getLiveDocs();- for (int doc = 0; doc < context.reader().maxDoc(); doc++) {- if (liveDocs != null && !liveDocs.get(doc)) {- continue;- }- // Add a document to the statistics being generated- testField.collect(doc);- idField.collect(doc);-- String id = idField.getString();- if (!valuesFiller.test(id)) {- missing.add(id);- }- }- }- return missing;- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.javadeleted file mode 100644index bc30953a10a..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java+++ /dev/null@@ -1,77 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class BooleanFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("boolean_b") instanceof BooleanField);- assertTrue(fact.createExpression("boolean_bm") instanceof BooleanMultiField);- }-- @Test- public void singleValuedBooleanTest() throws IOException {- BooleanField valueField = new BooleanField("boolean_b");- Map<String, Boolean> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- boolean value = valueField.getBoolean();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleBooleans, values, missing);- }-- @Test- public void multiValuedBooleanTest() throws IOException {- BooleanMultiField valueField = new BooleanMultiField("boolean_bm");- Map<String, Map<Boolean, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Boolean, Integer> doc = new HashMap<>();- valueField.streamBooleans(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiBooleans, values, missing, true);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.javadeleted file mode 100644index 3108d9a6eca..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java+++ /dev/null@@ -1,121 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class DateFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("date_dt_t") instanceof DateField);- assertTrue(fact.createExpression("date_dt_p") instanceof DateField);- assertTrue(fact.createExpression("date_dtm_t") instanceof DateMultiTrieField);- assertTrue(fact.createExpression("date_dtm_p") instanceof DateMultiPointField);- }-- @Test- public void singleValuedTrieDateTest() throws IOException {- DateField valueField = new DateField("date_dt_t");- Map<String, Long> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- long value = valueField.getLong();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleDates, values, missing);- }-- @Test- public void singleValuedPointDateTest() throws IOException {- DateField valueField = new DateField("date_dt_p");- Map<String, Long> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- long value = valueField.getLong();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleDates, values, missing);- }-- @Test- public void multiValuedTrieDateTest() throws IOException {- DateMultiTrieField valueField = new DateMultiTrieField("date_dtm_t");- Map<String, Map<Long, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Long, Integer> doc = new HashMap<>();- valueField.streamLongs(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiDates, values, missing, true);- }-- @Test- public void multiValuedPointDateTest() throws IOException {- DateMultiPointField valueField = new DateMultiPointField("date_dtm_p");- Map<String, Map<Long, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Long, Integer> doc = new HashMap<>();- valueField.streamLongs(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiDates, values, missing, false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.javadeleted file mode 100644index cd6b190eb82..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java+++ /dev/null@@ -1,121 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class DoubleFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("double_d_t") instanceof DoubleField);- assertTrue(fact.createExpression("double_d_p") instanceof DoubleField);- assertTrue(fact.createExpression("double_dm_t") instanceof DoubleMultiTrieField);- assertTrue(fact.createExpression("double_dm_p") instanceof DoubleMultiPointField);- }-- @Test- public void singleValuedTrieDoubleTest() throws IOException {- DoubleField valueField = new DoubleField("double_d_t");- Map<String, Double> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- double value = valueField.getDouble();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleDoubles, values, missing);- }-- @Test- public void singleValuedPointDoubleTest() throws IOException {- DoubleField valueField = new DoubleField("double_d_p");- Map<String, Double> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- double value = valueField.getDouble();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleDoubles, values, missing);- }-- @Test- public void multiValuedTrieDoubleTest() throws IOException {- DoubleMultiTrieField valueField = new DoubleMultiTrieField("double_dm_t");- Map<String, Map<Double, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Double, Integer> doc = new HashMap<>();- valueField.streamDoubles(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiDoubles, values, missing, true);- }-- @Test- public void multiValuedPointDoubleTest() throws IOException {- DoubleMultiPointField valueField = new DoubleMultiPointField("double_dm_p");- Map<String, Map<Double, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Double, Integer> doc = new HashMap<>();- valueField.streamDoubles(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiDoubles, values, missing, false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.javadeleted file mode 100644index ec5d5c6625f..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java+++ /dev/null@@ -1,121 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class FloatFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("float_f_t") instanceof FloatField);- assertTrue(fact.createExpression("float_f_p") instanceof FloatField);- assertTrue(fact.createExpression("float_fm_t") instanceof FloatMultiTrieField);- assertTrue(fact.createExpression("float_fm_p") instanceof FloatMultiPointField);- }-- @Test- public void singleValuedTrieFloatTest() throws IOException {- FloatField valueField = new FloatField("float_f_t");- Map<String, Float> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- float value = valueField.getFloat();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleFloats, values, missing);- }-- @Test- public void singleValuedPointFloatTest() throws IOException {- FloatField valueField = new FloatField("float_f_p");- Map<String, Float> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- float value = valueField.getFloat();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleFloats, values, missing);- }-- @Test- public void multiValuedTrieFloatTest() throws IOException {- FloatMultiTrieField valueField = new FloatMultiTrieField("float_fm_t");- Map<String, Map<Float, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Float, Integer> doc = new HashMap<>();- valueField.streamFloats(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiFloats, values, missing, true);- }-- @Test- public void multiValuedPointFloatTest() throws IOException {- FloatMultiPointField valueField = new FloatMultiPointField("float_fm_p");- Map<String, Map<Float, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Float, Integer> doc = new HashMap<>();- valueField.streamFloats(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiFloats, values, missing, false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.javadeleted file mode 100644index fbde2e9ea39..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java+++ /dev/null@@ -1,121 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class IntFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("int_i_t") instanceof IntField);- assertTrue(fact.createExpression("int_i_p") instanceof IntField);- assertTrue(fact.createExpression("int_im_t") instanceof IntMultiTrieField);- assertTrue(fact.createExpression("int_im_p") instanceof IntMultiPointField);- }-- @Test- public void singleValuedTrieIntTest() throws IOException {- IntField valueField = new IntField("int_i_t");- Map<String, Integer> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- int value = valueField.getInt();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleInts, values, missing);- }-- @Test- public void singleValuedPointIntTest() throws IOException {- IntField valueField = new IntField("int_i_p");- Map<String, Integer> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- int value = valueField.getInt();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleInts, values, missing);- }-- @Test- public void multiValuedTrieIntTest() throws IOException {- IntMultiTrieField valueField = new IntMultiTrieField("int_im_t");- Map<String, Map<Integer, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Integer, Integer> doc = new HashMap<>();- valueField.streamInts(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiInts, values, missing, true);- }-- @Test- public void multiValuedPointIntTest() throws IOException {- IntMultiPointField valueField = new IntMultiPointField("int_im_p");- Map<String, Map<Integer, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Integer, Integer> doc = new HashMap<>();- valueField.streamInts(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiInts, values, missing, false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.javadeleted file mode 100644index a645b885f20..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java+++ /dev/null@@ -1,121 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class LongFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("long_l_t") instanceof LongField);- assertTrue(fact.createExpression("long_l_p") instanceof LongField);- assertTrue(fact.createExpression("long_lm_t") instanceof LongMultiTrieField);- assertTrue(fact.createExpression("long_lm_p") instanceof LongMultiPointField);- }-- @Test- public void singleValuedTrieLongTest() throws IOException {- LongField valueField = new LongField("long_l_t");- Map<String, Long> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- long value = valueField.getLong();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleLongs, values, missing);- }-- @Test- public void singleValuedPointLongTest() throws IOException {- LongField valueField = new LongField("long_l_p");- Map<String, Long> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- long value = valueField.getLong();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleLongs, values, missing);- }-- @Test- public void multiValuedTrieLongTest() throws IOException {- LongMultiTrieField valueField = new LongMultiTrieField("long_lm_t");- Map<String, Map<Long, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Long, Integer> doc = new HashMap<>();- valueField.streamLongs(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiLongs, values, missing, true);- }-- @Test- public void multiValuedPointLongTest() throws IOException {- LongMultiPointField valueField = new LongMultiPointField("long_lm_p");- Map<String, Map<Long, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<Long, Integer> doc = new HashMap<>();- valueField.streamLongs(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiLongs, values, missing, false);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.javadeleted file mode 100644index da0e77ae2f4..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java+++ /dev/null@@ -1,77 +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.function.field;--import java.io.IOException;-import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import org.apache.solr.analytics.ExpressionFactory;-import org.junit.Test;--public class StringFieldsTest extends AbstractAnalyticsFieldTest {-- @Test- public void expressionFactoryCreationTest() {- ExpressionFactory fact = getExpressionFactory();-- assertTrue(fact.createExpression("string_s") instanceof StringField);- assertTrue(fact.createExpression("string_sm") instanceof StringMultiField);- }-- @Test- public void singleValuedStringTest() throws IOException {- StringField valueField = new StringField("string_s");- Map<String, String> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- String value = valueField.getString();- if (valueField.exists()) {- values.put(id, value);- }- return valueField.exists();- });-- checkSingleFieldValues(singleStrings, values, missing);- }-- @Test- public void multiValuedStringTest() throws IOException {- StringMultiField valueField = new StringMultiField("string_sm");- Map<String, Map<String, Integer>> values = new HashMap<>();-- Set<String> missing =- collectFieldValues(- valueField,- id -> {- Map<String, Integer> doc = new HashMap<>();- valueField.streamStrings(- value -> {- doc.put(value, doc.getOrDefault(value, 0) + 1);- });- if (doc.size() > 0) {- values.put(id, doc);- }- return doc.size() > 0;- });-- checkMultiFieldValues(multiStrings, values, missing, true);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.javadeleted file mode 100644index 310bf191262..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java+++ /dev/null@@ -1,286 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.junit.Test;--public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- val.setValue(-100).setExists(true);- assertEquals(100, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21L).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- val.setValue(-100L).setExists(true);- assertEquals(100L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(21.56F, func.getFloat(), 0.00001);- assertTrue(func.exists());-- val.setValue(-100F).setExists(true);- assertEquals(100F, func.getFloat(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56).setExists(true);- assertEquals(21.56, func.getDouble(), 0.00001);- assertTrue(func.exists());-- val.setValue(-100.1).setExists(true);- assertEquals(100.1, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);- Iterator<Integer> values1 = Arrays.asList(4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4, -10, 50, -74);- Iterator<Integer> values2 = Arrays.asList(4, 10, 50, 74).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4L);- Iterator<Long> values1 = Arrays.asList(4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4L, -10L, 50L, -74L);- Iterator<Long> values2 = Arrays.asList(4L, 10L, 50L, 74L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.3F);- Iterator<Float> values1 = Arrays.asList(4.3F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4.3F, -10F, 50.75F, -74.4446F);- Iterator<Float> values2 = Arrays.asList(4.3F, 10F, 50.75F, 74.4446F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.3);- Iterator<Double> values1 = Arrays.asList(4.3).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4.3, -10, 50.75, -74.4446);- Iterator<Double> values2 = Arrays.asList(4.3, 10.0, 50.75, 74.4446).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.javadeleted file mode 100644index 35efe555112..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java+++ /dev/null@@ -1,162 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class AddFunctionTest extends SolrTestCaseJ4 {-- @Test- public void twoSingleValueParametersTest() {- TestIntValue val1 = new TestIntValue();- TestFloatValue val2 = new TestFloatValue();-- AnalyticsValueStream uncasted =- AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- val1.setExists(false);- val2.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- val1.setValue(30).setExists(true);- val2.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- val1.setValue(30).setExists(true);- val2.setValue(21.56F).setExists(true);- assertEquals(51.56, func.getDouble(), 0.000001);- assertTrue(func.exists());- }-- @Test- public void oneMultiValueParameterTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // No values- val.setValues();- func.getDouble();- assertFalse(func.exists());-- // One value- val.setValues(30L);- assertEquals(30, func.getDouble(), 0.000001);- assertTrue(func.exists());-- // Multiple values- val.setValues(30L, 20L, 55L, 61L);- assertEquals(166, func.getDouble(), 0.000001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream val1 = new TestLongValueStream();- TestDoubleValue val2 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- val1.setValues();- val2.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- val1.setValues(4L, 10023L);- val2.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- val1.setValues(4L, 10023L, 48L);- val2.setValue(21.56F).setExists(true);- Iterator<Double> values = Arrays.asList(25.56, 10044.56, 69.56).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.000001);- });- assertFalse(values.hasNext());- }-- @Test- public void multipleSingleValueParameterTest() {- TestLongValue val1 = new TestLongValue();- TestDoubleValue val2 = new TestDoubleValue();- TestFloatValue val3 = new TestFloatValue();- TestIntValue val4 = new TestIntValue();-- AnalyticsValueStream uncasted =- AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue(30.56).setExists(true);- val3.setExists(false);- val4.setValue(12).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // All exist values, one value- val1.setValue(45L).setExists(true);- val2.setValue(30.56).setExists(true);- val3.setValue(2.5F).setExists(true);- val4.setValue(12).setExists(true);- assertEquals(90.06, func.getDouble(), 0.000001);- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.javadeleted file mode 100644index 341b9419e00..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java+++ /dev/null@@ -1,199 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.LogicFunction.AndFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.junit.Test;--public class AndFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValue val2 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Neither exists- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // One exists- val1.setValue(true).setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Both exist- val1.setValue(false).setExists(true);- val2.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(true).setExists(true);- val2.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(false).setExists(true);- val2.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(true).setExists(true);- val2.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneMultiValueParameterTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // No values- val.setValues();- func.getBoolean();- assertFalse(func.exists());-- // One value- val.setValues(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValues(false);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- // Multiple values- val.setValues(true, true, false, true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValues(true, true, true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValueStream val2 = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values, One value- val1.setValue(false).setExists(true);- val2.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- val1.setExists(false);- val2.setValues(true, false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- val1.setValue(false).setExists(true);- val2.setValues(true, false, true);- Iterator<Boolean> values1 = Arrays.asList(false, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val1.setValue(true).setExists(true);- val2.setValues(true, false, true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multipleSingleValueParameterTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValue val2 = new TestBooleanValue();- TestBooleanValue val3 = new TestBooleanValue();- TestBooleanValue val4 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue(true).setExists(true);- val3.setExists(false);- val4.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // All exist values, one value- val1.setValue(true).setExists(true);- val2.setValue(false).setExists(true);- val3.setValue(true).setExists(true);- val4.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(true).setExists(true);- val2.setValue(true).setExists(true);- val3.setValue(true).setExists(true);- val4.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.javadeleted file mode 100644index 3454d254462..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java+++ /dev/null@@ -1,425 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.StringValue;-import org.junit.Test;--public class BottomFunctionTest extends SolrTestCaseJ4 {-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Neither exists- val.setValues();- func.getInt();- assertFalse(func.exists());-- // One exists- val.setValues(30);- assertEquals(30, func.getInt());- assertTrue(func.exists());-- // Both exist- val.setValues(30, 20, -10, 59);- assertEquals(-10, func.getInt());- assertTrue(func.exists());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Neither exists- val.setValues();- func.getLong();- assertFalse(func.exists());-- // One exists- val.setValues(30L);- assertEquals(30L, func.getLong());- assertTrue(func.exists());-- // Both exist- val.setValues(30L, 20L, -10L, 59L);- assertEquals(-10L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Neither exists- val.setValues();- func.getFloat();- assertFalse(func.exists());-- // One exists- val.setValues(30.0F);- assertEquals(30.0F, func.getFloat(), .000001);- assertTrue(func.exists());-- // Both exist- val.setValues(30.5F, 20.01F, -10.49F, -10.48F);- assertEquals(-10.49F, func.getFloat(), .000001);- assertTrue(func.exists());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- val.setValues();- func.getDouble();- assertFalse(func.exists());-- // One exists- val.setValues(30.0);- assertEquals(30.0, func.getDouble(), .000001);- assertTrue(func.exists());-- // Both exist- val.setValues(30.5, 20.01, -10.49, -10.48);- assertEquals(-10.49, func.getDouble(), .000001);- assertTrue(func.exists());- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- TestDateValueStream val = new TestDateValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Neither exists- val.setValues();- func.getDate();- assertFalse(func.exists());-- // One exists- val.setValues("1950-05-03T10:30:50Z");- assertEquals(- Date.from(Instant.parse("1950-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());-- // Both exist- val.setValues(- "1950-05-03T10:30:50Z",- "2200-01-01T10:00:50Z",- "1800-12-31T11:30:50Z",- "1930-05-020T10:45:50Z");- assertEquals(- Date.from(Instant.parse("1800-12-31T11:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Neither exists- val.setValues();- func.getString();- assertFalse(func.exists());-- // One exists- val.setValues("abc");- assertEquals("abc", func.getString());- assertTrue(func.exists());-- // Both exist- val.setValues("1abcdef", "abc", "def", "1abc");- assertEquals("1abc", func.getString());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueIntTest() {- TestIntValue val1 = new TestIntValue();- TestIntValue val2 = new TestIntValue();- TestIntValue val3 = new TestIntValue();- TestIntValue val4 = new TestIntValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000).setExists(false);- val2.setValue(30).setExists(true);- val3.setValue(-1000).setExists(false);- val4.setValue(12).setExists(true);- assertEquals(12, func.getInt());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45).setExists(true);- val2.setValue(30).setExists(true);- val3.setValue(-2).setExists(true);- val4.setValue(12).setExists(true);- assertEquals(-2, func.getInt());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueLongTest() {- TestLongValue val1 = new TestLongValue();- TestLongValue val2 = new TestLongValue();- TestLongValue val3 = new TestLongValue();- TestLongValue val4 = new TestLongValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000L).setExists(false);- val2.setValue(30L).setExists(true);- val3.setValue(-1000L).setExists(false);- val4.setValue(12L).setExists(true);- assertEquals(12L, func.getLong());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45L).setExists(true);- val2.setValue(30L).setExists(true);- val3.setValue(-2L).setExists(true);- val4.setValue(12L).setExists(true);- assertEquals(-2L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueFloatTest() {- TestFloatValue val1 = new TestFloatValue();- TestFloatValue val2 = new TestFloatValue();- TestFloatValue val3 = new TestFloatValue();- TestFloatValue val4 = new TestFloatValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000.1233F).setExists(false);- val2.setValue(30.34F).setExists(true);- val3.setValue(-1000.3241F).setExists(false);- val4.setValue(12.123F).setExists(true);- assertEquals(12.123F, func.getFloat(), .000001);- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45.43F).setExists(true);- val2.setValue(30.231F).setExists(true);- val3.setValue(-2.33F).setExists(true);- val4.setValue(12.5F).setExists(true);- assertEquals(-2.33F, func.getFloat(), .000001);- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueDoubleTest() {- TestDoubleValue val1 = new TestDoubleValue();- TestDoubleValue val2 = new TestDoubleValue();- TestDoubleValue val3 = new TestDoubleValue();- TestDoubleValue val4 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000.1233).setExists(false);- val2.setValue(30.34).setExists(true);- val3.setValue(-1000.3241).setExists(false);- val4.setValue(12.123).setExists(true);- assertEquals(12.123, func.getDouble(), .000001);- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45.43).setExists(true);- val2.setValue(30.231).setExists(true);- val3.setValue(-2.33).setExists(true);- val4.setValue(12.5).setExists(true);- assertEquals(-2.33, func.getDouble(), .000001);- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueDateTest() throws DateTimeParseException {- TestDateValue val1 = new TestDateValue();- TestDateValue val2 = new TestDateValue();- TestDateValue val3 = new TestDateValue();- TestDateValue val4 = new TestDateValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDate();- assertFalse(func.exists());-- // Some exist- val1.setValue("9999-05-03T10:30:50Z").setExists(false);- val2.setValue("1950-05-03T10:30:50Z").setExists(true);- val3.setValue("0000-05-03T10:30:50Z").setExists(false);- val4.setValue("1850-05-03T10:30:50Z").setExists(true);- assertEquals(- Date.from(Instant.parse("1850-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("2200-05-03T10:30:50Z").setExists(true);- val2.setValue("1950-05-03T10:30:50Z").setExists(true);- val3.setValue("1700-05-03T10:30:50Z").setExists(true);- val4.setValue("1850-05-03T10:30:50Z").setExists(true);- assertEquals(- Date.from(Instant.parse("1700-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- }-- @Test- public void multipleStringValueDateTest() {- TestStringValue val1 = new TestStringValue();- TestStringValue val2 = new TestStringValue();- TestStringValue val3 = new TestStringValue();- TestStringValue val4 = new TestStringValue();-- AnalyticsValueStream uncasted =- BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getString();- assertFalse(func.exists());-- // Some exist- val1.setValue("abc").setExists(true);- val2.setValue("1111").setExists(false);- val3.setValue("asdfads").setExists(true);- val4.setValue("zzzzzzzz").setExists(false);- assertEquals("abc", func.getString());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("abc").setExists(true);- val2.setValue("abc1234").setExists(true);- val3.setValue("asdfads").setExists(true);- val4.setValue("fdgsfg").setExists(true);- assertEquals("abc", func.getString());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.javadeleted file mode 100644index 31355fa9e1f..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java+++ /dev/null@@ -1,187 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.CeilingFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.junit.Test;--public class CeilingFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueFloatParameterTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(22, func.getInt());- assertTrue(func.exists());-- val.setValue(-100.3F).setExists(true);- assertEquals(-100, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleParameterTest() {- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56).setExists(true);- assertEquals(22L, func.getLong());- assertTrue(func.exists());-- val.setValue(-100.3).setExists(true);- assertEquals(-100L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueFloatParameterTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4F);- Iterator<Integer> values1 = Arrays.asList(-4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4F, -10.9999F, 50.00001F, 74.99999F);- Iterator<Integer> values2 = Arrays.asList(4, -10, 51, 75).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleParameterTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);- Iterator<Long> values1 = Arrays.asList(-4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4, -10.9999, 50.000001, 74.99999);- Iterator<Long> values2 = Arrays.asList(4L, -10L, 51L, 75L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void nonDecimalParameterTest() {- AnalyticsValueStream result;- AnalyticsValueStream param;-- param = new TestIntValue();- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValue);- assertEquals(param, result);-- param = new TestIntValueStream();- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValueStream);- assertEquals(param, result);-- param = new TestLongValue();- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValue);- assertEquals(param, result);-- param = new TestLongValueStream();- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValueStream);- assertEquals(param, result);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.javadeleted file mode 100644index fe4e4356786..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java+++ /dev/null@@ -1,341 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.ConcatFunction.SeparatedConcatFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.junit.Test;--public class ConcatFunctionTest extends SolrTestCaseJ4 {-- @Test- public void oneMultiValueParameterUnseparatedTest() {- TestStringValueStream val = new TestStringValueStream();-- AnalyticsValueStream uncasted =- ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // No values- val.setValues();- func.getString();- assertFalse(func.exists());-- // One value- val.setValues("abc");- assertEquals("abc", func.getString());- assertTrue(func.exists());-- // Multiple values- val.setValues("abc", "def", "ghi");- assertEquals("abcdefghi", func.getString());- assertTrue(func.exists());- }-- @Test- public void oneMultiValueParameterSeparatedTest() {- TestStringValueStream val = new TestStringValueStream();- ConstantStringValue sep = new ConstantStringValue("===:---");-- AnalyticsValueStream uncasted =- SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // No values- val.setValues();- func.getString();- assertFalse(func.exists());-- // One value- val.setValues("abc");- assertEquals("abc", func.getString());- assertTrue(func.exists());-- // Multiple values- val.setValues("abc", "def", "ghi");- assertEquals("abc===:---def===:---ghi", func.getString());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueParameterUnseperatedTest() {- TestStringValue val1 = new TestStringValue();- TestStringValueStream val2 = new TestStringValueStream();-- AnalyticsValueStream uncasted =- ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // None exist- val1.setExists(false);- val2.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One exists- val1.setExists(false);- val2.setValues("def");- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val1.setValue("abc").setExists(true);- val2.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Both exist- val1.setValue("abc").setExists(true);- val2.setValues("def", "ghi", "jkl");- Iterator<String> values2 = Arrays.asList("abcdef", "abcghi", "abcjkl").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueParameterSeperatedTest() {- TestStringValue val1 = new TestStringValue();- TestStringValueStream val2 = new TestStringValueStream();- ConstantStringValue sep = new ConstantStringValue("+-;");-- AnalyticsValueStream uncasted =- SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val1, val2});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // None exist- val1.setExists(false);- val2.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One exists- val1.setExists(false);- val2.setValues("def");- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val1.setValue("abc").setExists(true);- val2.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Both exist- val1.setValue("abc").setExists(true);- val2.setValues("def", "ghi", "jkl");- Iterator<String> values2 = Arrays.asList("abc+-;def", "abc+-;ghi", "abc+-;jkl").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueParameterUnseperatedTest() {- TestStringValueStream val1 = new TestStringValueStream();- TestStringValue val2 = new TestStringValue();-- AnalyticsValueStream uncasted =- ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // None exist- val1.setValues();- val2.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One exists- val1.setValues("def");- val2.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val1.setValues();- val2.setValue("abc").setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Both exist- val1.setValues("def", "ghi", "jkl");- val2.setValue("abc").setExists(true);- Iterator<String> values2 = Arrays.asList("defabc", "ghiabc", "jklabc").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueParameterSeperatedTest() {- TestStringValueStream val1 = new TestStringValueStream();- TestStringValue val2 = new TestStringValue();- ConstantStringValue sep = new ConstantStringValue("<");-- AnalyticsValueStream uncasted =- SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val1, val2});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // None exist- val1.setValues();- val2.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One exists- val1.setValues("def");- val2.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val1.setValues();- val2.setValue("abc").setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Both exist- val1.setValues("def", "ghi", "jkl");- val2.setValue("abc").setExists(true);- Iterator<String> values2 = Arrays.asList("def<abc", "ghi<abc", "jkl<abc").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multipleSingleValueParameterUnseperatedTest() {- TestStringValue val1 = new TestStringValue();- TestStringValue val2 = new TestStringValue();- TestStringValue val3 = new TestStringValue();- TestStringValue val4 = new TestStringValue();-- AnalyticsValueStream uncasted =- ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getString();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue("def").setExists(true);- val3.setExists(false);- val4.setValue("jkl").setExists(true);- assertEquals("defjkl", func.getString());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("abc").setExists(true);- val2.setValue("def").setExists(true);- val3.setValue("ghi").setExists(true);- val4.setValue("jkl").setExists(true);- assertEquals("abcdefghijkl", func.getString());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueParameterSeperatedTest() {- TestStringValue val1 = new TestStringValue();- TestStringValue val2 = new TestStringValue();- TestStringValue val3 = new TestStringValue();- TestStringValue val4 = new TestStringValue();- ConstantStringValue sep = new ConstantStringValue("+:-");-- AnalyticsValueStream uncasted =- SeparatedConcatFunction.creatorFunction.apply(- new AnalyticsValueStream[] {sep, val1, val2, val3, val4});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getString();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue("def").setExists(true);- val3.setExists(false);- val4.setValue("jkl").setExists(true);- assertEquals("def+:-jkl", func.getString());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("abc").setExists(true);- val2.setValue("def").setExists(true);- val3.setValue("ghi").setExists(true);- val4.setValue("jkl").setExists(true);- assertEquals("abc+:-def+:-ghi+:-jkl", func.getString());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.javadeleted file mode 100644index 316bbb902a8..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java+++ /dev/null@@ -1,136 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.junit.Test;--public class DateMathFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueParameterTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));-- TestDateValue val = new TestDateValue();-- ConstantStringValue math1 = new ConstantStringValue("+1DAY");- ConstantStringValue math2 = new ConstantStringValue("-1MONTH");- ConstantStringValue math3 = new ConstantStringValue("+11YEARS");-- AnalyticsValueStream uncasted =- DateMathFunction.creatorFunction.apply(- new AnalyticsValueStream[] {val, math1, math2, math3});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue("1800-01-01T10:30:15Z").setExists(true);- assertEquals(date1.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("1920-04-15T18:15:45Z").setExists(true);- assertEquals(date2.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueParamaterTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValueStream val = new TestDateValueStream();-- ConstantStringValue math1 = new ConstantStringValue("+1DAY");- ConstantStringValue math2 = new ConstantStringValue("-1MONTH");- ConstantStringValue math3 = new ConstantStringValue("+11YEARS");-- AnalyticsValueStream uncasted =- DateMathFunction.creatorFunction.apply(- new AnalyticsValueStream[] {val, math1, math2, math3});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues("1800-01-01T10:30:15Z");- Iterator<Date> values1 = List.of(date1).iterator();- func.streamDates(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().toInstant(), value.toInstant());- });- assertFalse(values1.hasNext());- Iterator<Long> times1 = List.of(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times1.hasNext());- assertEquals(times1.next().longValue(), value);- });- assertFalse(times1.hasNext());-- // Multiple values- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");- Iterator<Date> values2 = List.of(date1, date2, date3).iterator();- func.streamDates(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().toInstant(), value.toInstant());- });- assertFalse(values2.hasNext());- Iterator<Long> times2 = List.of(date1.getTime(), date2.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times2.hasNext());- assertEquals(times2.next().longValue(), value);- });- assertFalse(times2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.javadeleted file mode 100644index 0c9d8b273ca..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java+++ /dev/null@@ -1,265 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.junit.Test;--public class DateParseFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueLongTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- TestLongValue val = new TestLongValue();-- AnalyticsValueStream uncasted =- DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(date1.getTime()).setExists(true);- assertEquals(date1.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue(date2.getTime()).setExists(true);- assertEquals(date2.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueStringTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- TestStringValue val = new TestStringValue();-- AnalyticsValueStream uncasted =- DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- // Incorrect Value- val.setValue("1800-01T10:30:15Z").setExists(true);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- val.setValue("1800-01-T::Z").setExists(true);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- val.setValue("1800--01T30:30:15Z").setExists(true);- func.getDate();- assertFalse(func.exists());- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue("1800-01-01T10:30:15Z").setExists(true);- assertEquals(date1.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("1920-04-15T18:15:45Z").setExists(true);- assertEquals(date2.toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueLongTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(date1.getTime());- Iterator<Date> values1 = List.of(date1).iterator();- func.streamDates(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().toInstant(), value.toInstant());- });- assertFalse(values1.hasNext());- Iterator<Long> times1 = List.of(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times1.hasNext());- assertEquals(times1.next().longValue(), value);- });- assertFalse(times1.hasNext());-- // Multiple values- val.setValues(date1.getTime(), date2.getTime(), date3.getTime());- Iterator<Date> values2 = List.of(date1, date2, date3).iterator();- func.streamDates(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().toInstant(), value.toInstant());- });- assertFalse(values2.hasNext());- Iterator<Long> times2 = List.of(date1.getTime(), date2.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times2.hasNext());- assertEquals(times2.next().longValue(), value);- });- assertFalse(times2.hasNext());- }-- @Test- public void multiValueStringTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));- TestStringValueStream val = new TestStringValueStream();-- AnalyticsValueStream uncasted =- DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Incorrect value- val.setValues("10:30:15Z");- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues("01-33T10:30:15Z");- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues("1800-01T30:30:15Z");- func.streamDates(- value -> {- fail("There should be no values to stream");- });- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues("1800-01-01T10:30:15Z");- Iterator<Date> values1 = List.of(date1).iterator();- func.streamDates(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().toInstant(), value.toInstant());- });- assertFalse(values1.hasNext());- Iterator<Long> times1 = List.of(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times1.hasNext());- assertEquals(times1.next().longValue(), value);- });- assertFalse(times1.hasNext());-- // Multiple values- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");- Iterator<Date> values2 = List.of(date1, date2, date3).iterator();- func.streamDates(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().toInstant(), value.toInstant());- });- assertFalse(values2.hasNext());- Iterator<Long> times2 = List.of(date1.getTime(), date2.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(times2.hasNext());- assertEquals(times2.next().longValue(), value);- });- assertFalse(times2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.javadeleted file mode 100644index c069e97abd0..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java+++ /dev/null@@ -1,136 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class DivideFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestIntValue dividend = new TestIntValue();- TestFloatValue divisor = new TestFloatValue();-- AnalyticsValueStream uncasted =- DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- dividend.setExists(false);- divisor.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- dividend.setValue(30).setExists(true);- divisor.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- dividend.setValue(60).setExists(true);- divisor.setValue(23.56F).setExists(true);- assertEquals(2.546689, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream dividend = new TestLongValueStream();- TestDoubleValue divisor = new TestDoubleValue();-- AnalyticsValueStream uncasted =- DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- dividend.setValues();- divisor.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- dividend.setValues(4L, 10023L);- divisor.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- dividend.setValues(20L, 5L, -234L);- divisor.setValue(44.56F).setExists(true);- Iterator<Double> values = Arrays.asList(0.448833, 0.112208, -5.251346).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.00001);- });- assertFalse(values.hasNext());- }-- @Test- public void oneSingleOneMultiValueParameterTest() {- TestDoubleValue dividend = new TestDoubleValue();- TestLongValueStream divisor = new TestLongValueStream();-- AnalyticsValueStream uncasted =- DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- dividend.setValue(21.56F).setExists(true);- divisor.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- dividend.setExists(false);- divisor.setValues(4L, 10023L);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- dividend.setValue(44.56F).setExists(true);- divisor.setValues(20L, 5L, -234L);- Iterator<Double> values = Arrays.asList(2.228, 8.912, -0.190427).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.00001);- });- assertFalse(values.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.javadeleted file mode 100644index 569471ce46b..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java+++ /dev/null@@ -1,580 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.junit.Test;--public class EqualFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueBooleanParameterTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValue val2 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val1.setExists(false);- val2.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val1.setValue(true).setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val1.setValue(false).setExists(true);- val2.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(false).setExists(true);- val2.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueNumericParameterTest() {- TestDoubleValue val1 = new TestDoubleValue();- TestDoubleValue val2 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val1.setExists(false);- val2.setValue(3.3).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val1.setValue(3.3).setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val1.setValue(21.56).setExists(true);- val2.setValue(21.56).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(21.56).setExists(true);- val2.setValue(21.57).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueDateParameterTest() {- TestDateValue val1 = new TestDateValue();- TestDateValue val2 = new TestDateValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val1.setExists(false);- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val1.setValue("1800-01-02T10:20:30Z").setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val1.setValue("1800-01-02T10:20:30Z").setExists(true);- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue("1800-01-02T10:20:30Z").setExists(true);- val2.setValue("1800-01-02T10:20:31Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueStringParameterTest() {- TestStringValue val1 = new TestStringValue();- TestStringValue val2 = new TestStringValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val1.setExists(false);- val2.setValue("abcdefghi").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val1.setValue("abcdefghi").setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val1.setValue("abcdefghi").setExists(true);- val2.setValue("abcdefghi").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue("abcdefghi1").setExists(true);- val2.setValue("abcdefghi2").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueBooleanParameterTest() {- TestBooleanValueStream val1 = new TestBooleanValueStream();- TestBooleanValue val2 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues(true);- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues(false);- val2.setValue(false).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(false, true, true, false, false);- val2.setValue(false).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueBooleanParameterTest() {- TestBooleanValueStream val1 = new TestBooleanValueStream();- TestBooleanValue val2 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val2, val1});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues(true);- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues(false);- val2.setValue(false).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(false, true, true, false, false);- val2.setValue(false).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueNumericParameterTest() {- TestDoubleValueStream val1 = new TestDoubleValueStream();- TestDoubleValue val2 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues(-4.2);- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues(-4.2);- val2.setValue(-4.2).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(4, -10, 4, -74, 4.0001);- val2.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueNumericParameterTest() {- TestDoubleValueStream val1 = new TestDoubleValueStream();- TestDoubleValue val2 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val2, val1});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues(-4.2);- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues(-4.2);- val2.setValue(-4.2).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(4, -10, 4, -74, 4.0001);- val2.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueDateParameterTest() {- TestDateValueStream val1 = new TestDateValueStream();- TestDateValue val2 = new TestDateValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues("1800-01-02T10:20:30Z");- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues("1800-01-02T10:20:30Z");- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1801-01-02T10:20:30Z");- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueDateParameterTest() {- TestDateValueStream val1 = new TestDateValueStream();- TestDateValue val2 = new TestDateValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val2, val1});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues("1800-01-02T10:20:30Z");- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues("1800-01-02T10:20:30Z");- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues(- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "9999-01-02T10:20:30Z");- val2.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueStringParameterTest() {- TestStringValueStream val1 = new TestStringValueStream();- TestStringValue val2 = new TestStringValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue("abcdefghi").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues("abcdefghi");- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues("abcdefghi");- val2.setValue("abcdefghi").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues("abcdefghi", "abcdefghi1", "sbcdefghi", "abcdefghi");- val2.setValue("abcdefghi").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueStringParameterTest() {- TestStringValueStream val1 = new TestStringValueStream();- TestStringValue val2 = new TestStringValue();-- AnalyticsValueStream uncasted =- EqualFunction.creatorFunction.apply(new AnalyticsValueStream[] {val2, val1});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val1.setValues();- val2.setValue("abcdefghi").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val1.setValues("abcdefghi");- val2.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val1.setValues("abcdefghi");- val2.setValue("abcdefghi").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val1.setValues("abcdefghi", "abcdefghi1", "sbcdefghi", "abcdefghi");- val2.setValue("abcdefghi").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ExistsFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ExistsFunctionTest.javadeleted file mode 100644index 33e5adeae19..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ExistsFunctionTest.java+++ /dev/null@@ -1,75 +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.function.mapping;--import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class ExistsFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueParameterTest() {- TestBooleanValue val = new TestBooleanValue();-- AnalyticsValueStream uncasted =- ExistsFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- val.setExists(false);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void multiValueParameterTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- ExistsFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- val.setValues(2, 30.0);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValues();- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValues(21234.65);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValues();- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.javadeleted file mode 100644index e81c1ed2386..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java+++ /dev/null@@ -1,789 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class FillMissingFunctionTest extends SolrTestCaseJ4 {-- @Test- public void castingTest() {- assertTrue(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestBooleanValue(), new TestStringValue()})- instanceof StringValue);-- assertFalse(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestIntValue(), new TestFloatValue()})- instanceof IntValue);-- assertFalse(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestBooleanValue(), new TestStringValueStream()})- instanceof AnalyticsValue);-- assertFalse(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestLongValue(), new TestAnalyticsValue()})- instanceof LongValue);-- assertTrue(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestIntValue(), new TestLongValue()})- instanceof DoubleValue);-- assertFalse(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestDateValue(), new TestStringValue()})- instanceof DateValue);-- assertFalse(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestBooleanValueStream(), new TestStringValue()})- instanceof AnalyticsValue);-- assertTrue(- FillMissingFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestDoubleValue(), new TestIntValueStream()})- instanceof DoubleValueStream);- }-- @Test- public void singleValueBooleanTest() {- TestBooleanValue val = new TestBooleanValue();- TestBooleanValue filler = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val.setValue(true).setExists(true);- filler.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- filler.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(true).setExists(true);- filler.setExists(false);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- filler.setExists(false);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();- TestIntValue filler = new TestIntValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- filler.setValue(234).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(-234).setExists(true);- assertEquals(-234, func.getInt());- assertTrue(func.exists());-- val.setValue(52334).setExists(true);- filler.setExists(false);- assertEquals(52334, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();- TestLongValue filler = new TestLongValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21L).setExists(true);- filler.setValue(234L).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(234L).setExists(true);- assertEquals(234L, func.getLong());- assertTrue(func.exists());-- val.setValue(-52334L).setExists(true);- filler.setExists(false);- assertEquals(-52334L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();- TestFloatValue filler = new TestFloatValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Value exists- val.setValue(-21.324F).setExists(true);- filler.setValue(23423.424F).setExists(true);- assertEquals(-21.324F, func.getFloat(), .00000001);- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(3124123.2F).setExists(true);- assertEquals(3124123.2F, func.getFloat(), .00000001);- assertTrue(func.exists());-- val.setValue(2345.3455F).setExists(true);- filler.setExists(false);- assertEquals(2345.3455F, func.getFloat(), .00000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();- TestDoubleValue filler = new TestDoubleValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(-21.324).setExists(true);- filler.setValue(23423.423342).setExists(true);- assertEquals(-21.324, func.getDouble(), .00000001);- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(3124123.32).setExists(true);- assertEquals(3124123.32, func.getDouble(), .00000001);- assertTrue(func.exists());-- val.setValue(2345.345543).setExists(true);- filler.setExists(false);- assertEquals(2345.345543, func.getDouble(), .00000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1950-02-23T14:54:34Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValue val = new TestDateValue();- TestDateValue filler = new TestDateValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue("1810-12-02T10:30:15Z").setExists(true);- filler.setValue("2023-11-01T20:30:15Z").setExists(true);- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue("1950-02-23T14:54:34Z").setExists(true);- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("2023-11-01T20:30:15Z").setExists(true);- filler.setExists(false);- assertEquals(date3.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueStringTest() {- TestStringValue val = new TestStringValue();- TestStringValue filler = new TestStringValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getString();- assertFalse(func.exists());-- // Value exists- val.setValue("abc123").setExists(true);- filler.setValue("def456").setExists(true);- assertEquals("abc123", func.getString());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue("abc456").setExists(true);- assertEquals("abc456", func.getString());- assertTrue(func.exists());-- val.setValue("def123").setExists(true);- filler.setExists(false);- assertEquals("def123", func.getString());- assertTrue(func.exists());- }-- @Test- public void singleValueObjectTest() {- TestAnalyticsValue val = new TestAnalyticsValue();- TestAnalyticsValue filler = new TestAnalyticsValue();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof AnalyticsValue);- AnalyticsValue func = (AnalyticsValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filler.setExists(false);- func.getObject();- assertFalse(func.exists());-- // Value exists- val.setValue("abc123").setExists(true);- filler.setValue(new Date(123)).setExists(true);- assertEquals("abc123", func.getObject());- assertTrue(func.exists());-- val.setExists(false);- filler.setValue(Boolean.TRUE).setExists(true);- assertEquals(Boolean.TRUE, func.getObject());- assertTrue(func.exists());-- val.setValue(234L).setExists(true);- filler.setExists(false);- assertEquals(234L, func.getObject());- assertTrue(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValueStream val = new TestBooleanValueStream();- TestBooleanValueStream filler = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(true);- filler.setValues(true, false);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(true, false);- Iterator<Boolean> values2 = Arrays.asList(true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues(true, false, true);- filler.setValues();- Iterator<Boolean> values3 = Arrays.asList(true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();- TestIntValueStream filler = new TestIntValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323, -9423);- filler.setValues(-1234, 5433, -73843, 1245144);- Iterator<Integer> values1 = Arrays.asList(323, -9423).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(312423, -12343, -23, 2);- Iterator<Integer> values2 = Arrays.asList(312423, -12343, -23, 2).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(1423, -413543);- filler.setValues();- Iterator<Integer> values3 = Arrays.asList(1423, -413543).iterator();- func.streamInts(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().intValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();- TestLongValueStream filler = new TestLongValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323L, -9423L);- filler.setValues(-1234L, -5433L, -73843L, 1245144L);- Iterator<Long> values1 = Arrays.asList(323L, -9423L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(-312423L, 12343L, 23L, 2L);- Iterator<Long> values2 = Arrays.asList(-312423L, 12343L, 23L, 2L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(1423L, -413543L);- filler.setValues();- Iterator<Long> values3 = Arrays.asList(1423L, -413543L).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();- TestFloatValueStream filler = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323.213F, -9423.5F);- filler.setValues(-1234.9478F, -5433.234F, -73843F, 1245144.2F);- Iterator<Float> values1 = Arrays.asList(323.213F, -9423.5F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .00000001);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(-312423.2F, 12343.234F, 23.582F, 2.23F);- Iterator<Float> values2 = Arrays.asList(-312423.2F, 12343.234F, 23.582F, 2.23F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .00000001);- });- assertFalse(values2.hasNext());-- val.setValues(1423.2303F, -413543F);- filler.setValues();- Iterator<Float> values3 = Arrays.asList(1423.2303F, -413543F).iterator();- func.streamFloats(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .00000001);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();- TestDoubleValueStream filler = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323.213, -9423.5);- filler.setValues(-1234.9478, -5433.234, -73843.0, 1245144.2342);- Iterator<Double> values1 = Arrays.asList(323.213, -9423.5).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .00000001);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(-312423.2, 12343.234823, 23.582, 2.23);- Iterator<Double> values2 = Arrays.asList(-312423.2, 12343.234823, 23.582, 2.23).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .00000001);- });- assertFalse(values2.hasNext());-- val.setValues(1423.23039, -413543.0);- filler.setValues();- Iterator<Double> values3 = Arrays.asList(1423.23039, -413543.0).iterator();- func.streamDoubles(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .00000001);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValueStream val = new TestDateValueStream();- TestDateValueStream filler = new TestDateValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues("1810-12-02T10:30:15Z");- filler.setValues("1931-03-16T18:15:45Z", "2023-11-01T20:30:15Z");- Iterator<Long> values1 = Arrays.asList(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues("1931-03-16T18:15:45Z", "1810-12-02T10:30:15Z");- Iterator<Long> values2 = Arrays.asList(date2.getTime(), date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues("2023-11-01T20:30:15Z", "1931-03-16T18:15:45Z");- filler.setValues();- Iterator<Long> values3 = Arrays.asList(date3.getTime(), date2.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();- TestStringValueStream filler = new TestStringValueStream();-- AnalyticsValueStream uncasted =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- val.setValues();- filler.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues("abc");- filler.setValues("123", "def");- Iterator<String> values1 = Arrays.asList("abc").iterator();- func.streamStrings(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues("def", "12341");- Iterator<String> values2 = Arrays.asList("def", "12341").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues("string1", "another string", "the final and last string");- filler.setValues();- Iterator<String> values3 =- Arrays.asList("string1", "another string", "the final and last string").iterator();- func.streamStrings(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueObjectTest() {- TestAnalyticsValueStream val = new TestAnalyticsValueStream();- TestAnalyticsValueStream filler = new TestAnalyticsValueStream();-- AnalyticsValueStream func =- FillMissingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filler});-- // No values- val.setValues();- filler.setValues();- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues("asdfs");- filler.setValues(new Date(12312), 213123L);- Iterator<Object> values1 = Arrays.<Object>asList("asdfs").iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues();- filler.setValues(3234.42d, "replacement");- Iterator<Object> values2 = Arrays.<Object>asList(3234.42d, "replacement").iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues(new Date(3), "3", 3F);- filler.setValues();- Iterator<Object> values3 = Arrays.<Object>asList(new Date(3), "3", 3F).iterator();- func.streamObjects(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.javadeleted file mode 100644index 1bb79882d93..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java+++ /dev/null@@ -1,1123 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class FilterFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueBooleanTest() {- TestBooleanValue val = new TestBooleanValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val.setValue(true).setExists(true);- filter.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val.setValue(true).setExists(true);- filter.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(true).setExists(true);- filter.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val.setValue(false).setExists(true);- filter.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- filter.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());- }-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getInt();- assertFalse(func.exists());-- val.setValue(32).setExists(true);- filter.setExists(false);- func.getInt();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- val.setValue(-100).setExists(true);- filter.setValue(false).setExists(true);- func.getInt();- assertFalse(func.exists());-- val.setValue(50).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(50, func.getInt());- assertTrue(func.exists());-- val.setValue(5432).setExists(true);- filter.setValue(false).setExists(true);- func.getInt();- assertFalse(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setValue(32L).setExists(true);- filter.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21L).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- val.setValue(-100L).setExists(true);- filter.setValue(false).setExists(true);- func.getLong();- assertFalse(func.exists());-- val.setValue(50L).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(50L, func.getLong());- assertTrue(func.exists());-- val.setValue(3245L).setExists(true);- filter.setValue(false).setExists(true);- func.getLong();- assertFalse(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getFloat();- assertFalse(func.exists());-- val.setValue(32.123F).setExists(true);- filter.setExists(false);- func.getFloat();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getFloat();- assertFalse(func.exists());-- // Value exists- val.setValue(21.453F).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(21.453F, func.getFloat(), .000001);- assertTrue(func.exists());-- val.setValue(-100.123F).setExists(true);- filter.setValue(false).setExists(true);- func.getFloat();- assertFalse(func.exists());-- val.setValue(50.5F).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(50.5F, func.getFloat(), .000001);- assertTrue(func.exists());-- val.setValue(25643.23F).setExists(true);- filter.setValue(false).setExists(true);- func.getFloat();- assertFalse(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getDouble();- assertFalse(func.exists());-- val.setValue(32.123).setExists(true);- filter.setExists(false);- func.getDouble();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(21.453).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(21.453, func.getDouble(), .000001);- assertTrue(func.exists());-- val.setValue(-100.123).setExists(true);- filter.setValue(false).setExists(true);- func.getDouble();- assertFalse(func.exists());-- val.setValue(50.5).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(50.5, func.getDouble(), .000001);- assertTrue(func.exists());-- val.setValue(25643.23).setExists(true);- filter.setValue(false).setExists(true);- func.getDouble();- assertFalse(func.exists());- }-- @Test- public void singleValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValue val = new TestDateValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setValue("1810-12-02T10:30:15Z").setExists(true);- filter.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue("1810-12-02T10:30:15Z").setExists(true);- filter.setValue(true).setExists(true);- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("1931-03-16T18:15:45Z").setExists(true);- filter.setValue(false).setExists(true);- func.getLong();- assertFalse(func.exists());-- val.setValue("2023-11-01T20:30:15Z").setExists(true);- filter.setValue(true).setExists(true);- assertEquals(date3.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("1810-12-02T10:30:15Z").setExists(true);- filter.setValue(false).setExists(true);- func.getLong();- assertFalse(func.exists());- }-- @Test- public void singleValueStringTest() {- TestStringValue val = new TestStringValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getString();- assertFalse(func.exists());-- val.setValue("abc123").setExists(true);- filter.setExists(false);- func.getString();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getString();- assertFalse(func.exists());-- // Value exists- val.setValue("abc").setExists(true);- filter.setValue(true).setExists(true);- assertEquals("abc", func.getString());- assertTrue(func.exists());-- val.setValue("def").setExists(true);- filter.setValue(false).setExists(true);- func.getString();- assertFalse(func.exists());-- val.setValue("123").setExists(true);- filter.setValue(true).setExists(true);- assertEquals("123", func.getString());- assertTrue(func.exists());-- val.setValue("456").setExists(true);- filter.setValue(false).setExists(true);- func.getString();- assertFalse(func.exists());- }-- @Test- public void singleValueObjectTest() {- TestAnalyticsValue val = new TestAnalyticsValue();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof AnalyticsValue);- AnalyticsValue func = (AnalyticsValue) uncasted;-- // Value doesn't exist- val.setExists(false);- filter.setExists(false);- func.getObject();- assertFalse(func.exists());-- val.setValue("1810-12-02T10:30:15Z").setExists(true);- filter.setExists(false);- func.getObject();- assertFalse(func.exists());-- val.setExists(false);- filter.setValue(true).setExists(true);- func.getObject();- assertFalse(func.exists());-- // Value exists- val.setValue(3L).setExists(true);- filter.setValue(true).setExists(true);- assertEquals(3L, func.getObject());- assertTrue(func.exists());-- val.setValue(new Date(2)).setExists(true);- filter.setValue(false).setExists(true);- func.getObject();- assertFalse(func.exists());-- val.setValue("3").setExists(true);- filter.setValue(true).setExists(true);- assertEquals("3", func.getObject());- assertTrue(func.exists());-- val.setValue(new TestAnalyticsValue()).setExists(true);- filter.setValue(false).setExists(true);- func.getObject();- assertFalse(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValueStream val = new TestBooleanValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val.setValues(false, true, false);- filter.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(true);-- filter.setValue(true).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(false, false, true, true);-- filter.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Boolean> values3 = Arrays.asList(false, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- val.setValues(1, 3, 5);- filter.setExists(false);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);-- filter.setValue(true).setExists(true);- Iterator<Integer> values1 = Arrays.asList(-4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Integer> values2 = Arrays.asList(-4).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(4, -10, 50, -74);-- filter.setValue(false).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Integer> values3 = Arrays.asList(4, -10, 50, -74).iterator();- func.streamInts(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().intValue(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues(1L, 3L, 5L);- filter.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4L);-- filter.setValue(true).setExists(true);- Iterator<Long> values1 = Arrays.asList(-4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Long> values2 = Arrays.asList(-4L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(4L, -10L, 50L, -74L);-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Long> values3 = Arrays.asList(4L, -10L, 50L, -74L).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- val.setValues(50.343F, -74.9874F, 2.34233242E+9F);- filter.setExists(false);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.23423F);-- filter.setValue(true).setExists(true);- Iterator<Float> values1 = Arrays.asList(-4.23423F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .0000001);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Float> values2 = Arrays.asList(-4.23423F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .0000001);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(4.3F, -10.134F, 50.343F, -74.9874F);-- filter.setValue(false).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Float> values3 = Arrays.asList(4.3F, -10.134F, 50.343F, -74.9874F).iterator();- func.streamFloats(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .0000001);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- val.setValues(50.343, -74.9874, 2342332342.32);- filter.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.23423);-- filter.setValue(true).setExists(true);- Iterator<Double> values1 = Arrays.asList(-4.23423).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .0000001);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Double> values2 = Arrays.asList(-4.23423).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .0000001);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(4.3, -10.134, 50.343, -74.9874);-- filter.setValue(false).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Double> values3 = Arrays.asList(4.3, -10.134, 50.343, -74.9874).iterator();- func.streamDoubles(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .0000001);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValueStream val = new TestDateValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues("1810-12-02T10:30:15Z", "1850-12-02T20:30:15Z");- filter.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues("1810-12-02T10:30:15Z");-- filter.setValue(true).setExists(true);- Iterator<Long> values1 = Arrays.asList(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Long> values2 = Arrays.asList(date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues("1810-12-02T10:30:15Z", "1931-03-16T18:15:45Z", "2023-11-01T20:30:15Z");-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Long> values3 =- Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream uncasted =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- val.setValues();- filter.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val.setValues("abc", "123", "def", "456");- filter.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues("abcdef");-- filter.setValue(true).setExists(true);- Iterator<String> values1 = Arrays.asList("abcdef").iterator();- func.streamStrings(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<String> values2 = Arrays.asList("abcdef").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues("abc", "123", "def", "456");-- filter.setValue(false).setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<String> values3 = Arrays.asList("abc", "123", "def", "456").iterator();- func.streamStrings(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueObjectTest() {- TestAnalyticsValueStream val = new TestAnalyticsValueStream();- TestBooleanValue filter = new TestBooleanValue();-- AnalyticsValueStream func =- FilterFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, filter});-- // No values- val.setValues();- filter.setExists(false);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- val.setValues(3, "3", new Date(3));- filter.setExists(false);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- filter.setValue(true).setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // One value- Object obj = new TestAnalyticsValueStream();- val.setValues(obj);-- filter.setValue(true).setExists(true);- Iterator<Object> values1 = Arrays.<Object>asList(obj).iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- filter.setValue(false).setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Object> values2 = Arrays.<Object>asList(obj).iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- // Multiple values- val.setValues(3, "3", new Date(3));-- filter.setValue(false).setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- filter.setValue(true).setExists(true);- Iterator<Object> values3 = Arrays.<Object>asList(3, "3", new Date(3)).iterator();- func.streamObjects(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- filter.setValue(false).setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.javadeleted file mode 100644index 22145ef5f30..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java+++ /dev/null@@ -1,187 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.FloorFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.junit.Test;--public class FloorFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueFloatParameterTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- val.setValue(-100.3F).setExists(true);- assertEquals(-101, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleParameterTest() {- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- val.setValue(-100.3).setExists(true);- assertEquals(-101L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueFloatParameterTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4F);- Iterator<Integer> values1 = Arrays.asList(-4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4F, -10.9999F, 50.00001F, 74.99999F);- Iterator<Integer> values2 = Arrays.asList(4, -11, 50, 74).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleParameterTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);- Iterator<Long> values1 = Arrays.asList(-4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4, -10.9999, 50.000001, 74.99999);- Iterator<Long> values2 = Arrays.asList(4L, -11L, 50L, 74L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void nonDecimalParameterTest() {- AnalyticsValueStream result;- AnalyticsValueStream param;-- param = new TestIntValue();- result = FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValue);- assertEquals(param, result);-- param = new TestIntValueStream();- result = FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValueStream);- assertEquals(param, result);-- param = new TestLongValue();- result = FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValue);- assertEquals(param, result);-- param = new TestLongValueStream();- result = FloorFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValueStream);- assertEquals(param, result);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.javadeleted file mode 100644index 93fae174c5b..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java+++ /dev/null@@ -1,321 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.GTEFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class GTEFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue(3.3).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue(3.3).setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue(21.56).setExists(true);- comp.setValue(21.56).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(21.57).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(-21.57).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:31Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1000-01-02T10:20:31Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValueStream comp = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue(-4.2).setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues(-4.2);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue(-4.2).setExists(true);- comp.setValues(-4);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue(4).setExists(true);- comp.setValues(4, -10, 2345, -74, 4.0001);- Iterator<Boolean> values2 = Arrays.asList(true, true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueNumericParameterTest() {- TestDoubleValueStream base = new TestDoubleValueStream();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues(-4.2);- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues(-4.2);- comp.setValue(-4).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(4, -10, 2345, -74, 4.0001);- comp.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValueStream comp = new TestDateValueStream();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues("1800-01-02T10:20:30Z");- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue("1803-01-02T10:20:30Z").setExists(true);- comp.setValues("1800-01-02T10:20:30Z");- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueDateParameterTest() {- TestDateValueStream base = new TestDateValueStream();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- GTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues("1800-01-02T10:20:30Z");- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues("1800-01-02T10:20:30Z");- comp.setValue("1803-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.javadeleted file mode 100644index 6ac044ab930..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java+++ /dev/null@@ -1,321 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.GTFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class GTFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue(3.3).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue(3.3).setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue(21.56).setExists(true);- comp.setValue(21.56).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(21.57).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(-21.57).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:31Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1000-01-02T10:20:31Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValueStream comp = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue(-4.2).setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues(-4.2);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue(-4.2).setExists(true);- comp.setValues(-4);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue(4).setExists(true);- comp.setValues(4, -10, 2345, -74, 4.0001);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueNumericParameterTest() {- TestDoubleValueStream base = new TestDoubleValueStream();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues(-4.2);- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues(-4.2);- comp.setValue(-4).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(4, -10, 2345, -74, 4.0001);- comp.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(false, false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValueStream comp = new TestDateValueStream();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues("1800-01-02T10:20:30Z");- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue("1803-01-02T10:20:30Z").setExists(true);- comp.setValues("1800-01-02T10:20:30Z");- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- Iterator<Boolean> values2 = Arrays.asList(false, true, false, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueDateParameterTest() {- TestDateValueStream base = new TestDateValueStream();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- GTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues("1800-01-02T10:20:30Z");- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues("1800-01-02T10:20:30Z");- comp.setValue("1803-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.javadeleted file mode 100644index 9b1a9fd50a6..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java+++ /dev/null@@ -1,1100 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class IfFunctionTest extends SolrTestCaseJ4 {-- @Test- public void castingTest() {- assertTrue(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestStringValue(), new TestStringValue()- })- instanceof StringValue);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestFloatValue(), new TestDoubleValue()- })- instanceof FloatValueStream);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestDateValue(), new TestLongValue()- })- instanceof DateValueStream);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestAnalyticsValue(), new TestStringValue()- })- instanceof StringValue);-- assertTrue(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestLongValue(), new TestFloatValue()- })- instanceof DoubleValue);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestStringValue(), new TestLongValue()- })- instanceof DateValue);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestStringValue(), new TestStringValue()- })- instanceof BooleanValueStream);-- assertFalse(- IfFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestIntValueStream(), new TestLongValue()- })- instanceof LongValue);- }-- @Test- public void singleValueBooleanTest() {- TestBooleanValue cond = new TestBooleanValue();- TestBooleanValue then = new TestBooleanValue();- TestBooleanValue els = new TestBooleanValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Condition doesn't exist- then.setExists(false);- then.setExists(false);- els.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue(false).setExists(true);- els.setValue(true).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(true).setExists(true);- els.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue(false).setExists(true);- els.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- cond.setValue(true).setExists(true);- then.setValue(true).setExists(true);- els.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(false).setExists(true);- els.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(true).setExists(true);- els.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueIntTest() {- TestBooleanValue cond = new TestBooleanValue();- TestIntValue then = new TestIntValue();- TestIntValue els = new TestIntValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getInt();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue(-234).setExists(true);- els.setValue(765).setExists(true);- func.getInt();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(23423).setExists(true);- func.getInt();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(745).setExists(true);- els.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue(234).setExists(true);- els.setValue(-23423).setExists(true);- assertEquals(234, func.getInt());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(234).setExists(true);- els.setValue(-23423).setExists(true);- assertEquals(-23423, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestBooleanValue cond = new TestBooleanValue();- TestLongValue then = new TestLongValue();- TestLongValue els = new TestLongValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getLong();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue(-234L).setExists(true);- els.setValue(765L).setExists(true);- func.getLong();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(23423L).setExists(true);- func.getLong();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(745L).setExists(true);- els.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue(234L).setExists(true);- els.setValue(-23423L).setExists(true);- assertEquals(234L, func.getLong());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(234L).setExists(true);- els.setValue(-23423L).setExists(true);- assertEquals(-23423L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestBooleanValue cond = new TestBooleanValue();- TestFloatValue then = new TestFloatValue();- TestFloatValue els = new TestFloatValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getFloat();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue(234.7565F).setExists(true);- els.setValue(-234.7565F).setExists(true);- func.getFloat();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(234.7565F).setExists(true);- func.getFloat();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(-23423.234F).setExists(true);- els.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue(234.7565F).setExists(true);- els.setValue(-23423.234F).setExists(true);- assertEquals(234.7565F, func.getFloat(), .0000001);- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(234.7565F).setExists(true);- els.setValue(-23423.234F).setExists(true);- assertEquals(-23423.234F, func.getFloat(), .0000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestBooleanValue cond = new TestBooleanValue();- TestDoubleValue then = new TestDoubleValue();- TestDoubleValue els = new TestDoubleValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getDouble();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue(234.7565).setExists(true);- els.setValue(-234.7565).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(234.7565).setExists(true);- func.getDouble();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(-23423.234).setExists(true);- els.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue(234.7565).setExists(true);- els.setValue(-23423.234).setExists(true);- assertEquals(234.7565, func.getDouble(), .0000001);- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(234.7565).setExists(true);- els.setValue(-23423.234).setExists(true);- assertEquals(-23423.234, func.getDouble(), .0000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1950-02-23T14:54:34Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestBooleanValue cond = new TestBooleanValue();- TestDateValue then = new TestDateValue();- TestDateValue els = new TestDateValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getLong();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue("6723-08-01T23:30:15Z").setExists(true);- els.setValue("2207-11-01T20:30:15Z").setExists(true);- func.getLong();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue("1810-12-02T10:30:15Z").setExists(true);- func.getLong();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue("2023-11-01T20:30:15Z").setExists(true);- els.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue("1810-12-02T10:30:15Z").setExists(true);- els.setValue("2023-11-01T20:30:15Z").setExists(true);- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue("1810-12-02T10:30:15Z").setExists(true);- els.setValue("2023-11-01T20:30:15Z").setExists(true);- assertEquals(date3.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueStringTest() {- TestBooleanValue cond = new TestBooleanValue();- TestStringValue then = new TestStringValue();- TestStringValue els = new TestStringValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getString();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue("if the value is true").setExists(true);- els.setValue("when the value is false").setExists(true);- func.getString();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue("not picked").setExists(true);- func.getString();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue("also not picked").setExists(true);- els.setExists(false);- func.getString();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue("abc123").setExists(true);- els.setValue("def456").setExists(true);- assertEquals("abc123", func.getString());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue("abc123").setExists(true);- els.setValue("def456").setExists(true);- assertEquals("def456", func.getString());- assertTrue(func.exists());- }-- @Test- public void singleValueObjectTest() {- TestBooleanValue cond = new TestBooleanValue();- TestAnalyticsValue then = new TestAnalyticsValue();- TestAnalyticsValue els = new TestAnalyticsValue();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof AnalyticsValue);- AnalyticsValue func = (AnalyticsValue) uncasted;-- // Condition doesn't exist- cond.setExists(false);- then.setExists(false);- els.setExists(false);- func.getObject();- assertFalse(func.exists());-- cond.setExists(false);- then.setValue("if the value is true").setExists(true);- els.setValue(Boolean.FALSE).setExists(true);- func.getObject();- assertFalse(func.exists());-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setExists(false);- els.setValue(123421324L).setExists(true);- func.getObject();- assertFalse(func.exists());-- cond.setValue(false).setExists(true);- then.setValue(1234324.5F).setExists(true);- els.setExists(false);- func.getObject();- assertFalse(func.exists());-- // Value exists- cond.setValue(true).setExists(true);- then.setValue("abc123").setExists(true);- els.setValue(new Date(3214)).setExists(true);- assertEquals("abc123", func.getObject());- assertTrue(func.exists());-- cond.setValue(false).setExists(true);- then.setValue("abc123").setExists(true);- els.setValue(new Date(3214)).setExists(true);- assertEquals(new Date(3214).toInstant(), ((Date) func.getObject()).toInstant());- assertTrue(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValue cond = new TestBooleanValue();- TestBooleanValueStream then = new TestBooleanValueStream();- TestBooleanValueStream els = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(false, true, false);- els.setValues(true, true, true, false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(true, true, true, false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(true, true, true, false);- els.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(true, true, true, false);- els.setValues(false, false, true, false, true);- Iterator<Boolean> values1 = Arrays.asList(true, true, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(true, true, true, false);- els.setValues(false, false, true, false, true);- Iterator<Boolean> values2 = Arrays.asList(false, false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueIntTest() {- TestBooleanValue cond = new TestBooleanValue();- TestIntValueStream then = new TestIntValueStream();- TestIntValueStream els = new TestIntValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(-132, 41543, 563);- els.setValues(0, 1, -2, 3);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(0, 1, -2, 3);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(-132, 41543, 563);- els.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(-132, 41543, 563);- els.setValues(0, 1, -2, 3);- Iterator<Integer> values1 = Arrays.asList(-132, 41543, 563).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(-132, 41543, 563);- els.setValues(0, 1, -2, 3);- Iterator<Integer> values2 = Arrays.asList(0, 1, -2, 3).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueLongTest() {- TestBooleanValue cond = new TestBooleanValue();- TestLongValueStream then = new TestLongValueStream();- TestLongValueStream els = new TestLongValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(-132L, 41543L, 563L);- els.setValues(0L, 1L, -2L, 3L);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(0L, 1L, -2L, 3L);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(-132L, 41543L, 563L);- els.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(-132L, 41543L, 563L);- els.setValues(0L, 1L, -2L, 3L);- Iterator<Long> values1 = Arrays.asList(-132L, 41543L, 563L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(-132L, 41543L, 563L);- els.setValues(0L, 1L, -2L, 3L);- Iterator<Long> values2 = Arrays.asList(0L, 1L, -2L, 3L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueFloatTest() {- TestBooleanValue cond = new TestBooleanValue();- TestFloatValueStream then = new TestFloatValueStream();- TestFloatValueStream els = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(2134.2346F, -234.23F, 20000.0F);- els.setValues(.1111F, -.22222F, .333F);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(.1111F, -.22222F, .333F);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(2134.2346F, -234.23F, 20000.0F);- els.setValues();- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(2134.2346F, -234.23F, 20000.0F);- els.setValues(.1111F, -.22222F, .333F);- Iterator<Float> values1 = Arrays.asList(2134.2346F, -234.23F, 20000.0F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(2134.2346F, -234.23F, 20000.0F);- els.setValues(.1111F, -.22222F, .333F);- Iterator<Float> values2 = Arrays.asList(.1111F, -.22222F, .333F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleTest() {- TestBooleanValue cond = new TestBooleanValue();- TestDoubleValueStream then = new TestDoubleValueStream();- TestDoubleValueStream els = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(2134.2345, -234.23, 20000.0);- els.setValues(.1111, -.22222, .333);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(.1111, -.22222, .333);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(2134.2345, -234.23, 20000.0);- els.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(2134.2345, -234.23, 20000.0);- els.setValues(.1111, -.22222, .333);- Iterator<Double> values1 = Arrays.asList(2134.2345, -234.23, 20000.0).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(2134.2345, -234.23, 20000.0);- els.setValues(.1111, -.22222, .333);- Iterator<Double> values2 = Arrays.asList(.1111, -.22222, .333).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestBooleanValue cond = new TestBooleanValue();- TestDateValueStream then = new TestDateValueStream();- TestDateValueStream els = new TestDateValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues("1810-12-02T10:30:15Z", "2023-11-01T20:30:15Z", "1810-12-02T10:30:15Z");- els.setValues("2023-11-01T20:30:15Z", "1931-03-16T18:15:45Z");- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues("2023-11-01T20:30:15Z", "1931-03-16T18:15:45Z");- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues("1810-12-02T10:30:15Z", "2023-11-01T20:30:15Z", "1810-12-02T10:30:15Z");- els.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues("1810-12-02T10:30:15Z", "2023-11-01T20:30:15Z", "1810-12-02T10:30:15Z");- els.setValues("2023-11-01T20:30:15Z", "1931-03-16T18:15:45Z");- Iterator<Long> values1 =- Arrays.asList(date1.getTime(), date3.getTime(), date1.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues("1810-12-02T10:30:15Z", "2023-11-01T20:30:15Z", "1810-12-02T10:30:15Z");- els.setValues("2023-11-01T20:30:15Z", "1931-03-16T18:15:45Z");- Iterator<Long> values2 = Arrays.asList(date3.getTime(), date2.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueStringTest() {- TestBooleanValue cond = new TestBooleanValue();- TestStringValueStream then = new TestStringValueStream();- TestStringValueStream els = new TestStringValueStream();-- AnalyticsValueStream uncasted =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues("abc123", "abcsdafasd", "third");- els.setValues("this", "is", "a", "sentence");- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues("this", "is", "a", "sentence");- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues("abc123", "abcsdafasd", "third");- els.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues("abc123", "abcsdafasd", "third");- els.setValues("this", "is", "a", "sentence");- Iterator<String> values1 = Arrays.asList("abc123", "abcsdafasd", "third").iterator();- func.streamStrings(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues("abc123", "abcsdafasd", "third");- els.setValues("this", "is", "a", "sentence");- Iterator<String> values2 = Arrays.asList("this", "is", "a", "sentence").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueObjectTest() {- TestBooleanValue cond = new TestBooleanValue();- TestAnalyticsValueStream then = new TestAnalyticsValueStream();- TestAnalyticsValueStream els = new TestAnalyticsValueStream();-- AnalyticsValueStream func =- IfFunction.creatorFunction.apply(new AnalyticsValueStream[] {cond, then, els});-- // No values- cond.setExists(false);- then.setValues();- els.setValues();- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- cond.setExists(false);- then.setValues(new Date(142341), "abcsdafasd", 1234.1324123);- els.setValues(324923.03F, 123, Boolean.TRUE, "if statement");- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Result doesn't exist- cond.setValue(true).setExists(true);- then.setValues();- els.setValues(324923.03F, 123, Boolean.TRUE, "if statement");- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- cond.setValue(false).setExists(true);- then.setValues(new Date(142341), "abcsdafasd", 1234.1324123);- els.setValues();- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Values exist- cond.setValue(true).setExists(true);- then.setValues(new Date(142341), "abcsdafasd", 1234.1324123);- els.setValues(324923.03F, 123, Boolean.TRUE, "if statement");- Iterator<Object> values1 =- Arrays.<Object>asList(new Date(142341), "abcsdafasd", 1234.1324123).iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- cond.setValue(false).setExists(true);- then.setValues(new Date(142341), "abcsdafasd", 1234.1324123);- els.setValues(324923.03F, 123, Boolean.TRUE, "if statement");- Iterator<Object> values2 =- Arrays.<Object>asList(324923.03F, 123, Boolean.TRUE, "if statement").iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.javadeleted file mode 100644index 0a3b7f9d202..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java+++ /dev/null@@ -1,321 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.LTEFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class LTEFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue(3.3).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue(3.3).setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue(21.56).setExists(true);- comp.setValue(21.56).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(21.57).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(-21.57).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:31Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1000-01-02T10:20:31Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValueStream comp = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue(-4.2).setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues(-4.2);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue(-4.2).setExists(true);- comp.setValues(-4);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue(4).setExists(true);- comp.setValues(4, -10, 2345, -74, 4.0001);- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueNumericParameterTest() {- TestDoubleValueStream base = new TestDoubleValueStream();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues(-4.2);- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues(-4.2);- comp.setValue(-4).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(4, -10, 2345, -74, 4.0001);- comp.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(true, true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValueStream comp = new TestDateValueStream();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues("1800-01-02T10:20:30Z");- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue("1803-01-02T10:20:30Z").setExists(true);- comp.setValues("1800-01-02T10:20:30Z");- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- Iterator<Boolean> values2 = Arrays.asList(true, false, true, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueDateParameterTest() {- TestDateValueStream base = new TestDateValueStream();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- LTEFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues("1800-01-02T10:20:30Z");- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues("1800-01-02T10:20:30Z");- comp.setValue("1803-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.javadeleted file mode 100644index 1c83670b996..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java+++ /dev/null@@ -1,321 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.ComparisonFunction.LTFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class LTFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue(3.3).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue(3.3).setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue(21.56).setExists(true);- comp.setValue(21.56).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(21.57).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue(21.56).setExists(true);- comp.setValue(-21.57).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- base.setExists(false);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- base.setExists(false);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.getBoolean();- assertFalse(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1800-01-02T10:20:31Z").setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValue("1000-01-02T10:20:31Z").setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneSingleOneMultiValueNumericParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestDoubleValueStream comp = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue(-4.2).setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues(-4.2);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue(-4.2).setExists(true);- comp.setValues(-4);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue(4).setExists(true);- comp.setValues(4, -10, 2345, -74, 4.0001);- Iterator<Boolean> values2 = Arrays.asList(false, false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueNumericParameterTest() {- TestDoubleValueStream base = new TestDoubleValueStream();- TestDoubleValue comp = new TestDoubleValue();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue(-4.2).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues(-4.2);- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues(-4.2);- comp.setValue(-4).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(4, -10, 2345, -74, 4.0001);- comp.setValue(4).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneSingleOneMultiValueDateParameterTest() {- TestDateValue base = new TestDateValue();- TestDateValueStream comp = new TestDateValueStream();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setExists(false);- comp.setValues("1800-01-02T10:20:30Z");- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValue("1803-01-02T10:20:30Z").setExists(true);- comp.setValues("1800-01-02T10:20:30Z");- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValue("1800-01-02T10:20:30Z").setExists(true);- comp.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- Iterator<Boolean> values2 = Arrays.asList(true, false, true, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void oneMultiOneSingleValueDateParameterTest() {- TestDateValueStream base = new TestDateValueStream();- TestDateValue comp = new TestDateValue();-- AnalyticsValueStream uncasted =- LTFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, comp});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- base.setValues();- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- base.setValues("1800-01-02T10:20:30Z");- comp.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- base.setValues("1800-01-02T10:20:30Z");- comp.setValue("1803-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values1 = Arrays.asList(true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- base.setValues(- "1800-03-02T10:20:30Z",- "1799-01-01T10:20:29Z",- "1800-01-02T10:20:31Z",- "1800-01-02T10:20:30Z",- "1800-01-02T10:20:29Z");- comp.setValue("1800-01-02T10:20:30Z").setExists(true);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.javadeleted file mode 100644index 2c000768438..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java+++ /dev/null@@ -1,210 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class LogFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueParameterTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- LogFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(Math.log(21.56F), func.getDouble(), 0.00001);- assertTrue(func.exists());-- val.setValue(-100F).setExists(true);- assertEquals(Math.log(-100F), func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void multiValueParameterTest() {- TestIntValueStream val = new TestIntValueStream();-- AnalyticsValueStream uncasted =- LogFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(4);- Iterator<Double> values1 = Arrays.asList(Math.log(4)).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .00001);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(2, 103, 502, 743);- Iterator<Double> values2 =- Arrays.asList(Math.log(2), Math.log(103), Math.log(502), Math.log(743)).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .00001);- });- assertFalse(values2.hasNext());- }-- @Test- public void twoSingleValueParametersTest() {- TestIntValue base = new TestIntValue();- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- LogFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, base});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- base.setExists(false);- val.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- base.setValue(30).setExists(true);- val.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- base.setValue(6).setExists(true);- val.setValue(2.56F).setExists(true);- assertEquals(Math.log(2.56F) / Math.log(6), func.getDouble(), 0.0001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream base = new TestLongValueStream();- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- LogFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, base});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- base.setValues();- val.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- base.setValues(4L, 10023L);- val.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- base.setValues(4L, 123L, 2L);- val.setValue(4.56F).setExists(true);- Iterator<Double> values =- Arrays.asList(- Math.log(4.56F) / Math.log(4.0D),- Math.log(4.56F) / Math.log(123.0D),- Math.log(4.56F) / Math.log(2.0D))- .iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.0001);- });- assertFalse(values.hasNext());- }-- @Test- public void oneSingleOneMultiValueParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- LogFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, base});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- base.setValue(21.56F).setExists(true);- val.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- base.setExists(false);- val.setValues(4L, 10023L);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- base.setValue(4.56F).setExists(true);- val.setValues(2L, 50L, 3L);- Iterator<Double> values =- Arrays.asList(- Math.log(2.0D) / Math.log(4.56F),- Math.log(50.0D) / Math.log(4.56F),- Math.log(3.0D) / Math.log(4.56F))- .iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.0001);- });- assertFalse(values.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.javadeleted file mode 100644index 54965049aff..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java+++ /dev/null@@ -1,161 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class MultFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestIntValue val1 = new TestIntValue();- TestFloatValue val2 = new TestFloatValue();-- AnalyticsValueStream uncasted =- MultFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- val1.setExists(false);- val2.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- val1.setValue(30).setExists(true);- val2.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- val1.setValue(30).setExists(true);- val2.setValue(21.56F).setExists(true);- assertEquals(646.8, func.getDouble(), 0.0001);- assertTrue(func.exists());- }-- @Test- public void oneMultiValueParameterTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- MultFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // No values- val.setValues();- func.getDouble();- assertFalse(func.exists());-- // One value- val.setValues(30L);- assertEquals(30, func.getDouble(), 0.00001);- assertTrue(func.exists());-- // Multiple values- val.setValues(30L, 20L, 55L, 61L);- assertEquals(2013000, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream val1 = new TestLongValueStream();- TestDoubleValue val2 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- MultFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- val1.setValues();- val2.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- val1.setValues(4L, 10023L);- val2.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- val1.setValues(4L, 10023L, 48L);- val2.setValue(21.56F).setExists(true);- Iterator<Double> values = Arrays.asList(86.24, 216095.88, 1034.88).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.01);- });- assertFalse(values.hasNext());- }-- @Test- public void multipleSingleValueParameterTest() {- TestLongValue val1 = new TestLongValue();- TestDoubleValue val2 = new TestDoubleValue();- TestFloatValue val3 = new TestFloatValue();- TestIntValue val4 = new TestIntValue();-- AnalyticsValueStream uncasted =- MultFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue(30.56).setExists(true);- val3.setExists(false);- val4.setValue(12).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // All exist values, one value- val1.setValue(45L).setExists(true);- val2.setValue(30.56).setExists(true);- val3.setValue(2.5F).setExists(true);- val4.setValue(12).setExists(true);- assertEquals(41256, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.javadeleted file mode 100644index ff710d8990c..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java+++ /dev/null@@ -1,351 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.junit.Test;--public class NegateFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueBooleanTest() {- TestBooleanValue val = new TestBooleanValue();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- assertEquals(-21, func.getInt());- assertTrue(func.exists());-- val.setValue(-100).setExists(true);- assertEquals(100, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21L).setExists(true);- assertEquals(-21, func.getLong());- assertTrue(func.exists());-- val.setValue(-100L).setExists(true);- assertEquals(100L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(-21.56F, func.getFloat(), 0.00001);- assertTrue(func.exists());-- val.setValue(-100F).setExists(true);- assertEquals(100F, func.getFloat(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56).setExists(true);- assertEquals(-21.56, func.getDouble(), 0.00001);- assertTrue(func.exists());-- val.setValue(-100.1).setExists(true);- assertEquals(100.1, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(true);- Iterator<Boolean> values1 = Arrays.asList(false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(true, false, true, false);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);- Iterator<Integer> values1 = Arrays.asList(4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4, -10, 50, -74);- Iterator<Integer> values2 = Arrays.asList(-4, 10, -50, 74).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4L);- Iterator<Long> values1 = Arrays.asList(4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4L, -10L, 50L, -74L);- Iterator<Long> values2 = Arrays.asList(-4L, 10L, -50L, 74L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.3F);- Iterator<Float> values1 = Arrays.asList(4.3F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4.3F, -10F, 50.75F, -74.4446F);- Iterator<Float> values2 = Arrays.asList(-4.3F, 10F, -50.75F, 74.4446F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- NegateFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4.3);- Iterator<Double> values1 = Arrays.asList(4.3).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4.3, -10, 50.75, -74.4446);- Iterator<Double> values2 = Arrays.asList(-4.3, 10.0, -50.75, 74.4446).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.javadeleted file mode 100644index 3aa96e2aa3f..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java+++ /dev/null@@ -1,199 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.LogicFunction.OrFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.junit.Test;--public class OrFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValue val2 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- OrFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Neither exists- val1.setExists(false);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // One exists- val1.setValue(true).setExists(true);- val2.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Both exist- val1.setValue(false).setExists(true);- val2.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(true).setExists(true);- val2.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(false).setExists(true);- val2.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(true).setExists(true);- val2.setValue(true).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneMultiValueParameterTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- OrFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // No values- val.setValues();- func.getBoolean();- assertFalse(func.exists());-- // One value- val.setValues(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValues(false);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- // Multiple values- val.setValues(false, false, true, false);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValues(false, false, false);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValueStream val2 = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- OrFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values, One value- val1.setValue(false).setExists(true);- val2.setValues();- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- val1.setExists(false);- val2.setValues(true, false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- val1.setValue(false).setExists(true);- val2.setValues(true, false, true);- Iterator<Boolean> values1 = Arrays.asList(true, false, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val1.setValue(true).setExists(true);- val2.setValues(true, false, true);- Iterator<Boolean> values2 = Arrays.asList(true, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multipleSingleValueParameterTest() {- TestBooleanValue val1 = new TestBooleanValue();- TestBooleanValue val2 = new TestBooleanValue();- TestBooleanValue val3 = new TestBooleanValue();- TestBooleanValue val4 = new TestBooleanValue();-- AnalyticsValueStream uncasted =- OrFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- // Some exist- val1.setExists(false);- val2.setValue(true).setExists(true);- val3.setExists(false);- val4.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // All exist values, one value- val1.setValue(false).setExists(true);- val2.setValue(true).setExists(true);- val3.setValue(false).setExists(true);- val4.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val1.setValue(false).setExists(true);- val2.setValue(false).setExists(true);- val3.setValue(false).setExists(true);- val4.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.javadeleted file mode 100644index 74fb9364505..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java+++ /dev/null@@ -1,136 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class PowerFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestIntValue base = new TestIntValue();- TestFloatValue pow = new TestFloatValue();-- AnalyticsValueStream uncasted =- PowerFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, pow});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- base.setExists(false);- pow.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- base.setValue(30).setExists(true);- pow.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- base.setValue(6).setExists(true);- pow.setValue(2.56F).setExists(true);- assertEquals(98.1899, func.getDouble(), 0.0001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream base = new TestLongValueStream();- TestDoubleValue pow = new TestDoubleValue();-- AnalyticsValueStream uncasted =- PowerFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, pow});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- base.setValues();- pow.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- base.setValues(4L, 10023L);- pow.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- base.setValues(4L, 123L, 10L);- pow.setValue(2.5F).setExists(true);- Iterator<Double> values = Arrays.asList(32.0, 167788.7268, 316.2277).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.001);- });- assertFalse(values.hasNext());- }-- @Test- public void oneSingleOneMultiValueParameterTest() {- TestDoubleValue base = new TestDoubleValue();- TestLongValueStream pow = new TestLongValueStream();-- AnalyticsValueStream uncasted =- PowerFunction.creatorFunction.apply(new AnalyticsValueStream[] {base, pow});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- base.setValue(21.56F).setExists(true);- pow.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- base.setExists(false);- pow.setValues(4L, 10023L);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- base.setValue(4.56F).setExists(true);- pow.setValues(2L, 5L, 3L);- Iterator<Double> values = Arrays.asList(20.7936, 1971.6245, 94.8188).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.0001);- });- assertFalse(values.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.javadeleted file mode 100644index 3d157caf4eb..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java+++ /dev/null@@ -1,955 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class RemoveFunctionTest extends SolrTestCaseJ4 {-- @Test- public void castingTest() {- assertTrue(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestBooleanValue(), new TestStringValue()})- instanceof StringValue);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestIntValueStream(), new TestFloatValue()})- instanceof FloatValue);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestLongValueStream(), new TestDateValue()})- instanceof AnalyticsValue);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestLongValue(), new TestAnalyticsValue()})- instanceof StringValue);-- assertTrue(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestIntValue(), new TestLongValue()})- instanceof DoubleValue);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestDateValue(), new TestStringValue()})- instanceof DateValue);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestBooleanValueStream(), new TestStringValue()})- instanceof BooleanValueStream);-- assertFalse(- RemoveFunction.creatorFunction.apply(- new AnalyticsValueStream[] {new TestDoubleValue(), new TestIntValue()})- instanceof LongValue);- }-- @Test- public void singleValueBooleanTest() {- TestBooleanValue val = new TestBooleanValue();- TestBooleanValue remover = new TestBooleanValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // Value exists- val.setValue(true).setExists(true);- remover.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(true).setExists(true);- remover.setValue(true).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val.setValue(false).setExists(true);- remover.setValue(true).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- remover.setValue(false).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- val.setValue(false).setExists(true);- remover.setExists(false);- assertFalse(func.getBoolean());- assertTrue(func.exists());- }-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();- TestIntValue remover = new TestIntValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getInt();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(-234).setExists(true);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- remover.setValue(234).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- val.setValue(-154).setExists(true);- remover.setValue(-154).setExists(true);- func.getInt();- assertFalse(func.exists());-- val.setValue(52334).setExists(true);- remover.setExists(false);- assertEquals(52334, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();- TestLongValue remover = new TestLongValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(234L).setExists(true);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21L).setExists(true);- remover.setValue(234L).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- val.setValue(3421L).setExists(true);- remover.setValue(3421L).setExists(true);- func.getLong();- assertFalse(func.exists());-- val.setValue(-52334L).setExists(true);- remover.setExists(false);- assertEquals(-52334L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();- TestFloatValue remover = new TestFloatValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getFloat();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(3124123.2F).setExists(true);- func.getFloat();- assertFalse(func.exists());-- // Value exists- val.setValue(-21.324F).setExists(true);- remover.setValue(23423.424F).setExists(true);- assertEquals(-21.324F, func.getFloat(), .00000001);- assertTrue(func.exists());-- val.setValue(84353.45F).setExists(true);- remover.setValue(84353.45F).setExists(true);- func.getFloat();- assertFalse(func.exists());-- val.setValue(2345.3455F).setExists(true);- remover.setExists(false);- assertEquals(2345.3455F, func.getFloat(), .00000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();- TestDoubleValue remover = new TestDoubleValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getDouble();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(3124123.32).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // Value exists- val.setValue(-21.324).setExists(true);- remover.setValue(23423.423342).setExists(true);- assertEquals(-21.324, func.getDouble(), .00000001);- assertTrue(func.exists());-- val.setValue(84353.452).setExists(true);- remover.setValue(84353.452).setExists(true);- func.getDouble();- assertFalse(func.exists());-- val.setValue(2345.345543).setExists(true);- remover.setExists(false);- assertEquals(2345.345543, func.getDouble(), .00000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1950-02-23T14:54:34Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValue val = new TestDateValue();- TestDateValue remover = new TestDateValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue("1950-02-23T14:54:34Z").setExists(true);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue("1810-12-02T10:30:15Z").setExists(true);- remover.setValue("2023-11-01T20:30:15Z").setExists(true);- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());-- val.setValue("1950-02-23T14:54:34Z").setExists(true);- remover.setValue("1950-02-23T14:54:34Z").setExists(true);- func.getLong();- assertFalse(func.exists());-- val.setValue("2023-11-01T20:30:15Z").setExists(true);- remover.setExists(false);- assertEquals(date3.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueStringTest() {- TestStringValue val = new TestStringValue();- TestStringValue remover = new TestStringValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getString();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue("abc456").setExists(true);- func.getString();- assertFalse(func.exists());-- // Value exists- val.setValue("abc123").setExists(true);- remover.setValue("def456").setExists(true);- assertEquals("abc123", func.getString());- assertTrue(func.exists());-- val.setValue("this will be removed").setExists(true);- remover.setValue("this will be removed").setExists(true);- func.getString();- assertFalse(func.exists());-- val.setValue("def123").setExists(true);- remover.setExists(false);- assertEquals("def123", func.getString());- assertTrue(func.exists());- }-- @Test- public void singleValueObjectTest() {- TestAnalyticsValue val = new TestAnalyticsValue();- TestAnalyticsValue remover = new TestAnalyticsValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof AnalyticsValue);- AnalyticsValue func = (AnalyticsValue) uncasted;-- // Value doesn't exist- val.setExists(false);- remover.setExists(false);- func.getObject();- assertFalse(func.exists());-- val.setExists(false);- remover.setValue(Boolean.TRUE).setExists(true);- func.getObject();- assertFalse(func.exists());-- // Value exists- val.setValue("abc123").setExists(true);- remover.setValue(new Date(123)).setExists(true);- assertEquals("abc123", func.getObject());- assertTrue(func.exists());-- val.setValue(23423.0d).setExists(true);- remover.setValue(23423.0d).setExists(true);- func.getObject();- assertFalse(func.exists());-- val.setValue(234L).setExists(true);- remover.setExists(false);- assertEquals(234L, func.getObject());- assertTrue(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValueStream val = new TestBooleanValueStream();- TestBooleanValue remover = new TestBooleanValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue(true).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(false, true, false, true, true);- remover.setValue(true).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues(false, true, false, true, true);- remover.setExists(false);- Iterator<Boolean> values2 = Arrays.asList(false, true, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues(false, true, false, true, true);- remover.setValue(false).setExists(true);- Iterator<Boolean> values3 = Arrays.asList(true, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- val.setValues(false, false, false);- remover.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();- TestIntValue remover = new TestIntValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue(324).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(1, 234, -234, 4439, -234, -3245);- remover.setValue(-234).setExists(true);- Iterator<Integer> values1 = Arrays.asList(1, 234, 4439, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues(1, 234, -234, 4439, -234, -3245);- remover.setExists(false);- Iterator<Integer> values2 = Arrays.asList(1, 234, -234, 4439, -234, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(1, 234, -234, 4439, -234, -3245);- remover.setValue(100).setExists(true);- Iterator<Integer> values3 = Arrays.asList(1, 234, -234, 4439, -234, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().intValue(), value);- });- assertFalse(values3.hasNext());-- val.setValues(1, 1);- remover.setValue(1).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();- TestLongValue remover = new TestLongValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue(2323L).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323L, -9423L, -1234L, 23423L, -1234L, -1234L);- remover.setValue(-1234L).setExists(true);- Iterator<Long> values1 = Arrays.asList(323L, -9423L, 23423L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues(323L, -9423L, -1234L, 23423L, -1234L, -1234L);- remover.setExists(false);- Iterator<Long> values2 = Arrays.asList(323L, -9423L, -1234L, 23423L, -1234L, -1234L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(323L, -9423L, -1234L, 23423L, -1234L, -1234L);- remover.setValue(100L).setExists(true);- Iterator<Long> values3 = Arrays.asList(323L, -9423L, -1234L, 23423L, -1234L, -1234L).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());-- val.setValues(10L);- remover.setValue(10L).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();- TestFloatValue remover = new TestFloatValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue(230.32F).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(-1234.9478F, -9423.5F, -1234.9478F, 23423.324F, 942.0F);- remover.setValue(-1234.9478F).setExists(true);- Iterator<Float> values1 = Arrays.asList(-9423.5F, 23423.324F, 942.0F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .00000001);- });- assertFalse(values1.hasNext());-- val.setValues(-1234.9478F, -9423.5F, -1234.9478F, 23423.324F, 942.0F);- remover.setExists(false);- Iterator<Float> values2 =- Arrays.asList(-1234.9478F, -9423.5F, -1234.9478F, 23423.324F, 942.0F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .00000001);- });- assertFalse(values2.hasNext());-- val.setValues(-1234.9478F, -9423.5F, -1234.9478F, 23423.324F, 942.0F);- remover.setValue(23423.584F).setExists(true);- Iterator<Float> values3 =- Arrays.asList(-1234.9478F, -9423.5F, -1234.9478F, 23423.324F, 942.0F).iterator();- func.streamFloats(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .00000001);- });- assertFalse(values3.hasNext());-- val.setValues(23.56F, 23.56F, 23.56F);- remover.setValue(23.56F).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();- TestDoubleValue remover = new TestDoubleValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue(234237.67).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(323.213, -9423.5, 124544.42);- remover.setValue(124544.42).setExists(true);- Iterator<Double> values1 = Arrays.asList(323.213, -9423.5).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .00000001);- });- assertFalse(values1.hasNext());-- val.setValues(323.213, -9423.5, 124544.42);- remover.setExists(false);- Iterator<Double> values2 = Arrays.asList(323.213, -9423.5, 124544.42).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .00000001);- });- assertFalse(values2.hasNext());-- val.setValues(323.213, -9423.5, 124544.42);- remover.setValue(345.34).setExists(true);- Iterator<Double> values3 = Arrays.asList(323.213, -9423.5, 124544.42).iterator();- func.streamDoubles(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .00000001);- });- assertFalse(values1.hasNext());-- val.setValues(3124.96, 3124.96);- remover.setValue(3124.96).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValueStream val = new TestDateValueStream();- TestDateValue remover = new TestDateValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue("1700-12-14").setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- remover.setValue("1931-03-16T18:15:45Z").setExists(true);- Iterator<Long> values1 = Arrays.asList(date1.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- remover.setExists(false);- Iterator<Long> values2 =- Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime(), date2.getTime())- .iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- remover.setValue("1810-12-02T10:30:16Z").setExists(true);- Iterator<Long> values3 =- Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime(), date2.getTime())- .iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());-- val.setValues("1810-12-02T10:30:15Z");- remover.setValue("1810-12-02T10:30:15Z").setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();- TestStringValue remover = new TestStringValue();-- AnalyticsValueStream uncasted =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- val.setValues();- remover.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue("ads").setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues("abc", "123", "456", "abc");- remover.setValue("abc").setExists(true);- Iterator<String> values1 = Arrays.asList("123", "456").iterator();- func.streamStrings(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues("abc", "123", "456", "abc");- remover.setExists(false);- Iterator<String> values2 = Arrays.asList("abc", "123", "456", "abc").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues("string1", "another string", "the final and last string");- remover.setValue("not in values").setExists(true);- Iterator<String> values3 =- Arrays.asList("string1", "another string", "the final and last string").iterator();- func.streamStrings(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- val.setValues("abc123", "abc123", "abc123", "abc123");- remover.setValue("abc123").setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });- }-- @Test- public void multiValueObjectTest() {- TestAnalyticsValueStream val = new TestAnalyticsValueStream();- TestAnalyticsValue remover = new TestAnalyticsValue();-- AnalyticsValueStream func =- RemoveFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, remover});-- // No values- val.setValues();- remover.setExists(false);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- remover.setValue("doesn't matter").setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Values exist- val.setValues("asdfs", new Date(12312), 213123L, new Date(12312));- remover.setValue(new Date(12312)).setExists(true);- Iterator<Object> values1 = Arrays.<Object>asList("asdfs", 213123L).iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- val.setValues("asdfs", new Date(12312), 213123L, new Date(12312));- remover.setExists(false);- Iterator<Object> values2 =- Arrays.<Object>asList("asdfs", new Date(12312), 213123L, new Date(12312)).iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues(new Date(3), "3", 3F);- remover.setValue(new Date(4)).setExists(true);- Iterator<Object> values3 = Arrays.<Object>asList(new Date(3), "3", 3F).iterator();- func.streamObjects(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());-- val.setValues(new Date(4));- remover.setValue(new Date(4)).setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.javadeleted file mode 100644index a6eaa1a1ac0..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java+++ /dev/null@@ -1,1108 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DateValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.FloatValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class ReplaceFunctionTest extends SolrTestCaseJ4 {-- @Test- public void castingTest() {- assertTrue(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValue(), new TestStringValue(), new TestStringValue()- })- instanceof StringValue);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestIntValueStream(), new TestFloatValue(), new TestDoubleValue()- })- instanceof FloatValueStream);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestLongValueStream(), new TestDateValue(), new TestLongValue()- })- instanceof DateValueStream);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestLongValue(), new TestAnalyticsValue(), new TestStringValue()- })- instanceof StringValue);-- assertTrue(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestIntValue(), new TestLongValue(), new TestFloatValue()- })- instanceof DoubleValue);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestDateValue(), new TestStringValue(), new TestLongValue()- })- instanceof DateValue);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestBooleanValueStream(), new TestStringValue(), new TestStringValue()- })- instanceof BooleanValueStream);-- assertFalse(- ReplaceFunction.creatorFunction.apply(- new AnalyticsValueStream[] {- new TestDoubleValue(), new TestIntValue(), new TestLongValue()- })- instanceof LongValue);- }-- @Test- public void singleValueBooleanTest() {- TestBooleanValue val = new TestBooleanValue();- TestBooleanValue comp = new TestBooleanValue();- TestBooleanValue fill = new TestBooleanValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof BooleanValue);- BooleanValue func = (BooleanValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getBoolean();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(false).setExists(true);- fill.setValue(true).setExists(true);- func.getBoolean();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue(true).setExists(true);- comp.setExists(false);- fill.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- // Value exists- val.setValue(true).setExists(true);- comp.setValue(false).setExists(true);- fill.setValue(false).setExists(true);- assertTrue(func.getBoolean());- assertTrue(func.exists());-- val.setValue(true).setExists(true);- comp.setValue(true).setExists(true);- fill.setValue(false).setExists(true);- assertFalse(func.getBoolean());- assertTrue(func.exists());-- val.setValue(false).setExists(true);- comp.setValue(false).setExists(true);- fill.setExists(false);- func.getBoolean();- assertFalse(func.exists());- }-- @Test- public void singleValueIntTest() {- TestIntValue val = new TestIntValue();- TestIntValue comp = new TestIntValue();- TestIntValue fill = new TestIntValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- func.getInt();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(-234).setExists(true);- fill.setValue(765).setExists(true);- func.getInt();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue(745).setExists(true);- comp.setExists(false);- fill.setValue(23423).setExists(true);- assertEquals(745, func.getInt());- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue(21).setExists(true);- comp.setValue(234).setExists(true);-- fill.setValue(23423).setExists(true);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(21, func.getInt());- assertTrue(func.exists());-- // Comp == Val- val.setValue(-154).setExists(true);- comp.setValue(-154).setExists(true);-- fill.setExists(false);- func.getInt();- assertFalse(func.exists());-- fill.setValue(23423).setExists(true);- assertEquals(23423, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueLongTest() {- TestLongValue val = new TestLongValue();- TestLongValue comp = new TestLongValue();- TestLongValue fill = new TestLongValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(234L).setExists(true);- fill.setValue(232584L).setExists(true);- func.getLong();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue(745L).setExists(true);- comp.setExists(false);- fill.setValue(23423L).setExists(true);- assertEquals(745L, func.getLong());- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue(21L).setExists(true);- comp.setValue(234L).setExists(true);-- fill.setValue(23423L).setExists(true);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(21L, func.getLong());- assertTrue(func.exists());-- // Comp == Val- val.setValue(-154L).setExists(true);- comp.setValue(-154L).setExists(true);-- fill.setExists(false);- func.getLong();- assertFalse(func.exists());-- fill.setValue(23423L).setExists(true);- assertEquals(23423L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueFloatTest() {- TestFloatValue val = new TestFloatValue();- TestFloatValue comp = new TestFloatValue();- TestFloatValue fill = new TestFloatValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getFloat();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(3124123.2F).setExists(true);- fill.setValue(-32473.336F).setExists(true);- func.getFloat();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue(-745.234F).setExists(true);- comp.setExists(false);- fill.setValue(23423.324F).setExists(true);- assertEquals(-745.234F, func.getFloat(), .0000001);- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue(3423.304F).setExists(true);- comp.setValue(3423.303F).setExists(true);-- fill.setValue(-23.764F).setExists(true);- assertEquals(3423.304F, func.getFloat(), .0000001);- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(3423.304F, func.getFloat(), .0000001);- assertTrue(func.exists());-- // Comp == Val- val.setValue(-154.45F).setExists(true);- comp.setValue(-154.45F).setExists(true);-- fill.setExists(false);- func.getFloat();- assertFalse(func.exists());-- fill.setValue(4353434.0F).setExists(true);- assertEquals(4353434.0F, func.getFloat(), .0000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleTest() {- TestDoubleValue val = new TestDoubleValue();- TestDoubleValue comp = new TestDoubleValue();- TestDoubleValue fill = new TestDoubleValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getDouble();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(3124123.32).setExists(true);- fill.setValue(-13242.34).setExists(true);- func.getDouble();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue(-745.234).setExists(true);- comp.setExists(false);- fill.setValue(23423.324).setExists(true);- assertEquals(-745.234, func.getDouble(), .0000001);- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue(34923.304).setExists(true);- comp.setValue(34923.303).setExists(true);-- fill.setValue(-23.764).setExists(true);- assertEquals(34923.304, func.getDouble(), .0000001);- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(34923.304, func.getDouble(), .0000001);- assertTrue(func.exists());-- // Comp == Val- val.setValue(-154.45).setExists(true);- comp.setValue(-154.45).setExists(true);-- fill.setExists(false);- func.getDouble();- assertFalse(func.exists());-- fill.setValue(4353434.234).setExists(true);- assertEquals(4353434.234, func.getDouble(), .0000001);- assertTrue(func.exists());- }-- @Test- public void singleValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1950-02-23T14:54:34Z"));-- TestDateValue val = new TestDateValue();- TestDateValue comp = new TestDateValue();- TestDateValue fill = new TestDateValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getLong();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue("1950-02-23T14:54:34Z").setExists(true);- fill.setValue("1350-02-26T14:34:34Z").setExists(true);- func.getLong();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue("1950-02-23T14:54:34Z").setExists(true);- comp.setExists(false);- fill.setValue("1350-02-26T14:34:34Z").setExists(true);- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue("1950-02-23T14:54:34Z").setExists(true);- comp.setValue("1350-02-26T14:34:34Z").setExists(true);-- fill.setValue("2023-11-01T20:30:15Z").setExists(true);- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(date2.getTime(), func.getLong());- assertTrue(func.exists());-- // Comp == Val- val.setValue("2023-11-01T20:30:15Z").setExists(true);- comp.setValue("2023-11-01T20:30:15Z").setExists(true);-- fill.setExists(false);- func.getLong();- assertFalse(func.exists());-- fill.setValue("1810-12-02T10:30:15Z").setExists(true);- assertEquals(date1.getTime(), func.getLong());- assertTrue(func.exists());- }-- @Test- public void singleValueStringTest() {- TestStringValue val = new TestStringValue();- TestStringValue comp = new TestStringValue();- TestStringValue fill = new TestStringValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getString();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue("abc456").setExists(true);- fill.setValue("not touched").setExists(true);- func.getString();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue("abcd").setExists(true);- comp.setExists(false);- fill.setValue("12234").setExists(true);- assertEquals("abcd", func.getString());- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue("original").setExists(true);- comp.setValue("different").setExists(true);-- fill.setValue("anything").setExists(true);- assertEquals("original", func.getString());- assertTrue(func.exists());-- fill.setExists(false);- assertEquals("original", func.getString());- assertTrue(func.exists());-- // Comp == Val- val.setValue("the same").setExists(true);- comp.setValue("the same").setExists(true);-- fill.setExists(false);- func.getString();- assertFalse(func.exists());-- fill.setValue("replacement").setExists(true);- assertEquals("replacement", func.getString());- assertTrue(func.exists());- }-- @Test- public void singleValueObjectTest() {- TestAnalyticsValue val = new TestAnalyticsValue();- TestAnalyticsValue comp = new TestAnalyticsValue();- TestAnalyticsValue fill = new TestAnalyticsValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof AnalyticsValue);- AnalyticsValue func = (AnalyticsValue) uncasted;-- // Value doesn't exist- val.setExists(false);- comp.setExists(false);- fill.setExists(false);- func.getObject();- assertFalse(func.exists());-- val.setExists(false);- comp.setValue(Boolean.TRUE).setExists(true);- fill.setValue("abc").setExists(true);- func.getObject();- assertFalse(func.exists());-- // Comp doesn't exist- val.setValue("abcd").setExists(true);- comp.setExists(false);- fill.setValue(new Date(123321)).setExists(true);- assertEquals("abcd", func.getObject());- assertTrue(func.exists());-- // Value exists- // Comp != Val- val.setValue(new Date(1234)).setExists(true);- comp.setValue(1234).setExists(true);-- fill.setValue("not used").setExists(true);- assertEquals(new Date(1234).toInstant(), ((Date) func.getObject()).toInstant());- assertTrue(func.exists());-- fill.setExists(false);- assertEquals(new Date(1234).toInstant(), ((Date) func.getObject()).toInstant());- assertTrue(func.exists());-- // Comp == Val- val.setValue(2342.324F).setExists(true);- comp.setValue(2342.324F).setExists(true);-- fill.setExists(false);- func.getObject();- assertFalse(func.exists());-- fill.setValue("replacement").setExists(true);- assertEquals("replacement", func.getObject());- assertTrue(func.exists());- }-- @Test- public void multiValueBooleanTest() {- TestBooleanValueStream val = new TestBooleanValueStream();- TestBooleanValue comp = new TestBooleanValue();- TestBooleanValue fill = new TestBooleanValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof BooleanValueStream);- BooleanValueStream func = (BooleanValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue(true).setExists(true);- fill.setValue(false).setExists(true);- func.streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(false, true, false, true, true);- comp.setExists(false);- fill.setValue(true).setExists(true);- Iterator<Boolean> values1 = Arrays.asList(false, true, false, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(false, true, false, true, true);- comp.setValue(true).setExists(true);- fill.setValue(false).setExists(true);- Iterator<Boolean> values2 = Arrays.asList(false, false, false, false, false).iterator();- func.streamBooleans(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues(false, true, false, true, true);- comp.setValue(false).setExists(true);- fill.setExists(false);- Iterator<Boolean> values3 = Arrays.asList(true, true, true).iterator();- func.streamBooleans(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();- TestIntValue comp = new TestIntValue();- TestIntValue fill = new TestIntValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue(324).setExists(true);- fill.setValue(52341).setExists(true);- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(1, 234, -234, 4439, -234, -3245);- comp.setExists(false);- fill.setValue(52135).setExists(true);- Iterator<Integer> values1 = Arrays.asList(1, 234, -234, 4439, -234, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(1, 234, -234, 4439, -234, -3245);- comp.setValue(-234).setExists(true);- fill.setExists(false);- Iterator<Integer> values2 = Arrays.asList(1, 234, 4439, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(1, 234, -234, 4439, -234, -3245);- comp.setValue(4439).setExists(true);- fill.setValue(-1000).setExists(true);- Iterator<Integer> values3 = Arrays.asList(1, 234, -234, -1000, -234, -3245).iterator();- func.streamInts(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().intValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();- TestLongValue comp = new TestLongValue();- TestLongValue fill = new TestLongValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue(2323L).setExists(true);- fill.setValue(-5943L).setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(1L, 234L, -234L, 4439L, -234L, -3245L);- comp.setExists(false);- fill.setValue(52135L).setExists(true);- Iterator<Long> values1 = Arrays.asList(1L, 234L, -234L, 4439L, -234L, -3245L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(1L, 234L, -234L, 4439L, -234L, -3245L);- comp.setValue(-234L).setExists(true);- fill.setExists(false);- Iterator<Long> values2 = Arrays.asList(1L, 234L, 4439L, -3245L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(1L, 234L, -234L, 4439L, -234L, -3245L);- comp.setValue(4439L).setExists(true);- fill.setValue(-1000L).setExists(true);- Iterator<Long> values3 = Arrays.asList(1L, 234L, -234L, -1000L, -234L, -3245L).iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();- TestFloatValue comp = new TestFloatValue();- TestFloatValue fill = new TestFloatValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof FloatValueStream);- FloatValueStream func = (FloatValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue(-230.32F).setExists(true);- fill.setValue(9459.346F).setExists(true);- func.streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(1423.3F, 423.4323F, -2349.2F, -343.43933F, 423.4323F);- comp.setExists(false);- fill.setValue(234.234F).setExists(true);- Iterator<Float> values1 =- Arrays.asList(1423.3F, 423.4323F, -2349.2F, -343.43933F, 423.4323F).iterator();- func.streamFloats(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(1423.3F, 423.4323F, -2349.2F, -343.43933F, 423.4323F);- comp.setValue(423.4323F).setExists(true);- fill.setExists(false);- Iterator<Float> values2 = Arrays.asList(1423.3F, -2349.2F, -343.43933F).iterator();- func.streamFloats(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());-- val.setValues(1423.3F, 423.4323F, -2349.2F, -343.43933F, 423.4323F);- comp.setValue(423.4323F).setExists(true);- fill.setValue(-1000F).setExists(true);- Iterator<Float> values3 =- Arrays.asList(1423.3F, -1000F, -2349.2F, -343.43933F, -1000F).iterator();- func.streamFloats(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .000001);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();- TestDoubleValue comp = new TestDoubleValue();- TestDoubleValue fill = new TestDoubleValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue(234237.67).setExists(true);- fill.setValue(-234.312).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(1423.3, 423.4323, -2349.2, -343.43934, 423.4323);- comp.setExists(false);- fill.setValue(234.234).setExists(true);- Iterator<Double> values1 =- Arrays.asList(1423.3, 423.4323, -2349.2, -343.43934, 423.4323).iterator();- func.streamDoubles(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value, .000001);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(1423.3, 423.4323, -2349.2, -343.43934, 423.4323);- comp.setValue(423.4323).setExists(true);- fill.setExists(false);- Iterator<Double> values2 = Arrays.asList(1423.3, -2349.2, -343.43934).iterator();- func.streamDoubles(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value, .000001);- });- assertFalse(values2.hasNext());-- val.setValues(1423.3, 423.4323, -2349.2, -343.43934, 423.4323);- comp.setValue(423.4323).setExists(true);- fill.setValue(-1000.0).setExists(true);- Iterator<Double> values3 =- Arrays.asList(1423.3, -1000.0, -2349.2, -343.43934, -1000.0).iterator();- func.streamDoubles(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value, .000001);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));-- TestDateValueStream val = new TestDateValueStream();- TestDateValue comp = new TestDateValue();- TestDateValue fill = new TestDateValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof DateValueStream);- DateValueStream func = (DateValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue("1700-12-14").setExists(true);- fill.setValue("3450-04-23").setExists(true);- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- comp.setExists(false);- fill.setValue("1810-12-02T10:30:15Z").setExists(true);- Iterator<Long> values1 =- Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime(), date2.getTime())- .iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- comp.setValue("1931-03-16T18:15:45Z").setExists(true);- fill.setExists(false);- Iterator<Long> values2 = Arrays.asList(date1.getTime(), date3.getTime()).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());-- val.setValues(- "1810-12-02T10:30:15Z",- "1931-03-16T18:15:45Z",- "2023-11-01T20:30:15Z",- "1931-03-16T18:15:45Z");- comp.setValue("1931-03-16T18:15:45Z").setExists(true);- fill.setValue("1810-12-02T10:30:15Z").setExists(true);- Iterator<Long> values3 =- Arrays.asList(date1.getTime(), date1.getTime(), date3.getTime(), date1.getTime())- .iterator();- func.streamLongs(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next().longValue(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();- TestStringValue comp = new TestStringValue();- TestStringValue fill = new TestStringValue();-- AnalyticsValueStream uncasted =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue("ads").setExists(true);- fill.setValue("empty").setExists(true);- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues("abc", "123", "456", "def", "123");- comp.setExists(false);- fill.setValue("won't show up").setExists(true);- Iterator<String> values1 = Arrays.asList("abc", "123", "456", "def", "123").iterator();- func.streamStrings(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues("abc", "123", "456", "def", "123");- comp.setValue("123").setExists(true);- fill.setExists(false);- Iterator<String> values2 = Arrays.asList("abc", "456", "def").iterator();- func.streamStrings(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues("abc", "123", "456", "def", "123");- comp.setValue("456").setExists(true);- fill.setValue("changed").setExists(true);- Iterator<String> values3 = Arrays.asList("abc", "123", "changed", "def", "123").iterator();- func.streamStrings(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-- @Test- public void multiValueObjectTest() {- TestAnalyticsValueStream val = new TestAnalyticsValueStream();- TestAnalyticsValue comp = new TestAnalyticsValue();- TestAnalyticsValue fill = new TestAnalyticsValue();-- AnalyticsValueStream func =- ReplaceFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, comp, fill});-- // No values- val.setValues();- comp.setExists(false);- fill.setExists(false);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- val.setValues();- comp.setValue("doesn't matter").setExists(true);- fill.setValue("won't show up").setExists(true);- func.streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Comp doesn't exist- val.setValues("asdfs", new Date(12312), 213123L, new Date(12312));- comp.setExists(false);- fill.setValue("won't show up").setExists(true);- Iterator<Object> values1 =- Arrays.<Object>asList("asdfs", new Date(12312), 213123L, new Date(12312)).iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Values exist- val.setValues("asdfs", new Date(12312), 213123L, new Date(12312));- comp.setValue("asdfs").setExists(true);- fill.setExists(false);- Iterator<Object> values2 =- Arrays.<Object>asList(new Date(12312), 213123L, new Date(12312)).iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());-- val.setValues("asdfs", new Date(12312), 213123L, new Date(12312));- comp.setValue(new Date(12312)).setExists(true);- fill.setValue(Boolean.FALSE).setExists(true);- Iterator<Object> values3 =- Arrays.<Object>asList("asdfs", Boolean.FALSE, 213123L, Boolean.FALSE).iterator();- func.streamObjects(- value -> {- assertTrue(values3.hasNext());- assertEquals(values3.next(), value);- });- assertFalse(values3.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RoundFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RoundFunctionTest.javadeleted file mode 100644index 1af9ea6685e..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RoundFunctionTest.java+++ /dev/null@@ -1,187 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.RoundFunction;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.IntValueStream;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.LongValueStream;-import org.junit.Test;--public class RoundFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueFloatParameterTest() {- TestFloatValue val = new TestFloatValue();-- AnalyticsValueStream uncasted =- RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56F).setExists(true);- assertEquals(22, func.getInt());- assertTrue(func.exists());-- val.setValue(-100.3F).setExists(true);- assertEquals(-100, func.getInt());- assertTrue(func.exists());- }-- @Test- public void singleValueDoubleParameterTest() {- TestDoubleValue val = new TestDoubleValue();-- AnalyticsValueStream uncasted =- RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Value exists- val.setValue(21.56).setExists(true);- assertEquals(22L, func.getLong());- assertTrue(func.exists());-- val.setValue(-100.3).setExists(true);- assertEquals(-100L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueFloatParameterTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValueStream);- IntValueStream func = (IntValueStream) uncasted;-- // No values- val.setValues();- func.streamInts(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4F);- Iterator<Integer> values1 = Arrays.asList(-4).iterator();- func.streamInts(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().intValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4F, -10.9999F, 50.00001F, 74.99999F, 101.4999F, 105.5F);- Iterator<Integer> values2 = Arrays.asList(4, -11, 50, 75, 101, 106).iterator();- func.streamInts(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().intValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void multiValueDoubleParameterTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValueStream);- LongValueStream func = (LongValueStream) uncasted;-- // No values- val.setValues();- func.streamLongs(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(-4);- Iterator<Long> values1 = Arrays.asList(-4L).iterator();- func.streamLongs(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next().longValue(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(4, -10.9999, 50.000001, 74.99999, 101.4999, 105.5);- Iterator<Long> values2 = Arrays.asList(4L, -11L, 50L, 75L, 101L, 106L).iterator();- func.streamLongs(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next().longValue(), value);- });- assertFalse(values2.hasNext());- }-- @Test- public void nonDecimalParameterTest() {- AnalyticsValueStream result;- AnalyticsValueStream param;-- param = new TestIntValue();- result = RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValue);- assertEquals(param, result);-- param = new TestIntValueStream();- result = RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof IntValueStream);- assertEquals(param, result);-- param = new TestLongValue();- result = RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValue);- assertEquals(param, result);-- param = new TestLongValueStream();- result = RoundFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});- assertTrue(result instanceof LongValueStream);- assertEquals(param, result);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/StringCastFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/StringCastFunctionTest.javadeleted file mode 100644index def48b58ed1..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/StringCastFunctionTest.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.analytics.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.StringValue;-import org.apache.solr.analytics.value.StringValueStream;-import org.junit.Test;--public class StringCastFunctionTest extends SolrTestCaseJ4 {-- @Test- public void singleValueParameterTest() {- TestIntValue val = new TestIntValue();-- AnalyticsValueStream uncasted =- StringCastFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Value doesn't exist- val.setExists(false);- func.getObject();- assertFalse(func.exists());-- // Value exists- val.setValue(21).setExists(true);- assertEquals("21", func.getObject());- assertTrue(func.exists());-- val.setValue(-100).setExists(true);- assertEquals("-100", func.getObject());- assertTrue(func.exists());- }-- @Test- public void multiValueParameterTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- AnalyticsValueStream uncasted =- StringCastFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof StringValueStream);- StringValueStream func = (StringValueStream) uncasted;-- // No values- val.setValues();- func.streamStrings(- value -> {- fail("There should be no values to stream");- });-- // One value- val.setValues(true);- Iterator<String> values1 = Arrays.asList("true").iterator();- func.streamObjects(- value -> {- assertTrue(values1.hasNext());- assertEquals(values1.next(), value);- });- assertFalse(values1.hasNext());-- // Multiple values- val.setValues(true, true, false, false);- Iterator<String> values2 = Arrays.asList("true", "true", "false", "false").iterator();- func.streamObjects(- value -> {- assertTrue(values2.hasNext());- assertEquals(values2.next(), value);- });- assertFalse(values2.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/SubtractFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/SubtractFunctionTest.javadeleted file mode 100644index 0345365a37e..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/SubtractFunctionTest.java+++ /dev/null@@ -1,136 +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.function.mapping;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class SubtractFunctionTest extends SolrTestCaseJ4 {- @Test- public void twoSingleValueParametersTest() {- TestIntValue minuend = new TestIntValue();- TestFloatValue subtrahend = new TestFloatValue();-- AnalyticsValueStream uncasted =- SubtractFunction.creatorFunction.apply(new AnalyticsValueStream[] {minuend, subtrahend});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- minuend.setExists(false);- subtrahend.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // One exists- minuend.setValue(30).setExists(true);- subtrahend.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Both exist- minuend.setValue(60).setExists(true);- subtrahend.setValue(23.56F).setExists(true);- assertEquals(36.44, func.getDouble(), 0.00001);- assertTrue(func.exists());- }-- @Test- public void oneMultiOneSingleValueParameterTest() {- TestLongValueStream minuend = new TestLongValueStream();- TestDoubleValue subtrahend = new TestDoubleValue();-- AnalyticsValueStream uncasted =- SubtractFunction.creatorFunction.apply(new AnalyticsValueStream[] {minuend, subtrahend});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- minuend.setValues();- subtrahend.setValue(21.56F).setExists(true);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- minuend.setValues(4L, 10023L);- subtrahend.setExists(false);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- minuend.setValues(20L, 5L, 234L);- subtrahend.setValue(44.56F).setExists(true);- Iterator<Double> values = Arrays.asList(-24.56, -39.56, 189.44).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.00001);- });- assertFalse(values.hasNext());- }-- @Test- public void oneSingleOneMultiValueParameterTest() {- TestDoubleValue minuend = new TestDoubleValue();- TestLongValueStream subtrahend = new TestLongValueStream();-- AnalyticsValueStream uncasted =- SubtractFunction.creatorFunction.apply(new AnalyticsValueStream[] {minuend, subtrahend});- assertTrue(uncasted instanceof DoubleValueStream);- DoubleValueStream func = (DoubleValueStream) uncasted;-- // No values, One value- minuend.setValue(21.56F).setExists(true);- subtrahend.setValues();- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, no value- minuend.setExists(false);- subtrahend.setValues(4L, 10023L);- func.streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple values, one value- minuend.setValue(44.56F).setExists(true);- subtrahend.setValues(20L, 5L, 234L);- Iterator<Double> values = Arrays.asList(24.56, 39.56, -189.44).iterator();- func.streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, 0.00001);- });- assertFalse(values.hasNext());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/TopFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/TopFunctionTest.javadeleted file mode 100644index 68d9a790219..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/TopFunctionTest.java+++ /dev/null@@ -1,425 +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.function.mapping;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream;-import org.apache.solr.analytics.value.DateValue;-import org.apache.solr.analytics.value.DoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.apache.solr.analytics.value.FloatValue;-import org.apache.solr.analytics.value.IntValue;-import org.apache.solr.analytics.value.LongValue;-import org.apache.solr.analytics.value.StringValue;-import org.junit.Test;--public class TopFunctionTest extends SolrTestCaseJ4 {-- @Test- public void multiValueIntTest() {- TestIntValueStream val = new TestIntValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // Neither exists- val.setValues();- func.getInt();- assertFalse(func.exists());-- // One exists- val.setValues(30);- assertEquals(30, func.getInt());- assertTrue(func.exists());-- // Both exist- val.setValues(30, 20, -10, 59);- assertEquals(59, func.getInt());- assertTrue(func.exists());- }-- @Test- public void multiValueLongTest() {- TestLongValueStream val = new TestLongValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // Neither exists- val.setValues();- func.getLong();- assertFalse(func.exists());-- // One exists- val.setValues(30L);- assertEquals(30L, func.getLong());- assertTrue(func.exists());-- // Both exist- val.setValues(30L, 20L, -10L, 59L);- assertEquals(59L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multiValueFloatTest() {- TestFloatValueStream val = new TestFloatValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // Neither exists- val.setValues();- func.getFloat();- assertFalse(func.exists());-- // One exists- val.setValues(30.0F);- assertEquals(30.0F, func.getFloat(), .000001);- assertTrue(func.exists());-- // Both exist- val.setValues(30.5F, 20.01F, -10.49F, -10.48F);- assertEquals(30.5F, func.getFloat(), .000001);- assertTrue(func.exists());- }-- @Test- public void multiValueDoubleTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // Neither exists- val.setValues();- func.getDouble();- assertFalse(func.exists());-- // One exists- val.setValues(30.0);- assertEquals(30.0, func.getDouble(), .000001);- assertTrue(func.exists());-- // Both exist- val.setValues(30.5, 20.01, -10.49, -10.48);- assertEquals(30.5, func.getDouble(), .000001);- assertTrue(func.exists());- }-- @Test- public void multiValueDateTest() throws DateTimeParseException {- TestDateValueStream val = new TestDateValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // Neither exists- val.setValues();- func.getDate();- assertFalse(func.exists());-- // One exists- val.setValues("1950-05-03T10:30:50Z");- assertEquals(- Date.from(Instant.parse("1950-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());-- // Both exist- val.setValues(- "1950-05-03T10:30:50Z",- "2200-01-01T10:00:50Z",- "1800-12-31T11:30:50Z",- "1930-05-020T10:45:50Z");- assertEquals(- Date.from(Instant.parse("2200-01-01T10:00:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- }-- @Test- public void multiValueStringTest() {- TestStringValueStream val = new TestStringValueStream();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // Neither exists- val.setValues();- func.getString();- assertFalse(func.exists());-- // One exists- val.setValues("abc");- assertEquals("abc", func.getString());- assertTrue(func.exists());-- // Both exist- val.setValues("1abcdef", "abc", "def", "def1", "1abc");- assertEquals("def1", func.getString());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueIntTest() {- TestIntValue val1 = new TestIntValue();- TestIntValue val2 = new TestIntValue();- TestIntValue val3 = new TestIntValue();- TestIntValue val4 = new TestIntValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof IntValue);- IntValue func = (IntValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getInt();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000).setExists(false);- val2.setValue(30).setExists(true);- val3.setValue(-1000).setExists(false);- val4.setValue(12).setExists(true);- assertEquals(30, func.getInt());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45).setExists(true);- val2.setValue(30).setExists(true);- val3.setValue(-2).setExists(true);- val4.setValue(12).setExists(true);- assertEquals(45, func.getInt());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueLongTest() {- TestLongValue val1 = new TestLongValue();- TestLongValue val2 = new TestLongValue();- TestLongValue val3 = new TestLongValue();- TestLongValue val4 = new TestLongValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof LongValue);- LongValue func = (LongValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getLong();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000L).setExists(false);- val2.setValue(30L).setExists(true);- val3.setValue(-1000L).setExists(false);- val4.setValue(12L).setExists(true);- assertEquals(30L, func.getLong());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45L).setExists(true);- val2.setValue(30L).setExists(true);- val3.setValue(-2L).setExists(true);- val4.setValue(12L).setExists(true);- assertEquals(45L, func.getLong());- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueFloatTest() {- TestFloatValue val1 = new TestFloatValue();- TestFloatValue val2 = new TestFloatValue();- TestFloatValue val3 = new TestFloatValue();- TestFloatValue val4 = new TestFloatValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof FloatValue);- FloatValue func = (FloatValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getFloat();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000.1233F).setExists(false);- val2.setValue(30.34F).setExists(true);- val3.setValue(-1000.3241F).setExists(false);- val4.setValue(12.123F).setExists(true);- assertEquals(30.34F, func.getFloat(), .000001);- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45.43F).setExists(true);- val2.setValue(30.231F).setExists(true);- val3.setValue(-2.33F).setExists(true);- val4.setValue(12.5F).setExists(true);- assertEquals(45.43F, func.getFloat(), .000001);- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueDoubleTest() {- TestDoubleValue val1 = new TestDoubleValue();- TestDoubleValue val2 = new TestDoubleValue();- TestDoubleValue val3 = new TestDoubleValue();- TestDoubleValue val4 = new TestDoubleValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DoubleValue);- DoubleValue func = (DoubleValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDouble();- assertFalse(func.exists());-- // Some exist- val1.setValue(1000.1233).setExists(false);- val2.setValue(30.34).setExists(true);- val3.setValue(-1000.3241).setExists(false);- val4.setValue(12.123).setExists(true);- assertEquals(30.34, func.getDouble(), .000001);- assertTrue(func.exists());-- // All exist values, one value- val1.setValue(45.43).setExists(true);- val2.setValue(30.231).setExists(true);- val3.setValue(-2.33).setExists(true);- val4.setValue(12.5).setExists(true);- assertEquals(45.43, func.getDouble(), .000001);- assertTrue(func.exists());- }-- @Test- public void multipleSingleValueDateTest() throws DateTimeParseException {- TestDateValue val1 = new TestDateValue();- TestDateValue val2 = new TestDateValue();- TestDateValue val3 = new TestDateValue();- TestDateValue val4 = new TestDateValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof DateValue);- DateValue func = (DateValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getDate();- assertFalse(func.exists());-- // Some exist- val1.setValue("9999-05-03T10:30:50Z").setExists(false);- val2.setValue("1950-05-03T10:30:50Z").setExists(true);- val3.setValue("0000-05-03T10:30:50Z").setExists(false);- val4.setValue("1850-05-03T10:30:50Z").setExists(true);- assertEquals(- Date.from(Instant.parse("1950-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("2200-05-03T10:30:50Z").setExists(true);- val2.setValue("1950-05-03T10:30:50Z").setExists(true);- val3.setValue("1700-05-03T10:30:50Z").setExists(true);- val4.setValue("1850-05-03T10:30:50Z").setExists(true);- assertEquals(- Date.from(Instant.parse("2200-05-03T10:30:50Z")).toInstant(), func.getDate().toInstant());- assertTrue(func.exists());- }-- @Test- public void multipleStringValueDateTest() {- TestStringValue val1 = new TestStringValue();- TestStringValue val2 = new TestStringValue();- TestStringValue val3 = new TestStringValue();- TestStringValue val4 = new TestStringValue();-- AnalyticsValueStream uncasted =- TopFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});- assertTrue(uncasted instanceof StringValue);- StringValue func = (StringValue) uncasted;-- // None exist- val1.setExists(false);- val2.setExists(false);- val3.setExists(false);- val4.setExists(false);- func.getString();- assertFalse(func.exists());-- // Some exist- val1.setValue("abc").setExists(true);- val2.setValue("1111").setExists(false);- val3.setValue("asdfads").setExists(true);- val4.setValue("zzzzzzzz").setExists(false);- assertEquals("asdfads", func.getString());- assertTrue(func.exists());-- // All exist values, one value- val1.setValue("abc").setExists(true);- val2.setValue("abc1234").setExists(true);- val3.setValue("fdgsfg1").setExists(true);- val4.setValue("fdgsfg").setExists(true);- assertEquals("fdgsfg1", func.getString());- assertTrue(func.exists());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsCloudTest.javadeleted file mode 100644index 1fc397e8701..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsCloudTest.java+++ /dev/null@@ -1,192 +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.legacy;--import java.io.IOException;-import java.util.ArrayList;-import java.util.Collections;-import java.util.HashSet;-import java.util.concurrent.TimeoutException;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.analytics.util.MedianCalculator;-import org.apache.solr.analytics.util.OrdinalCalculator;-import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.request.CollectionAdminRequest;-import org.apache.solr.client.solrj.request.QueryRequest;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.client.solrj.response.QueryResponse;-import org.apache.solr.cloud.SolrCloudTestCase;-import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.response.SolrQueryResponse;-import org.junit.AfterClass;-import org.junit.BeforeClass;--public class LegacyAbstractAnalyticsCloudTest extends SolrCloudTestCase {-- protected static final String COLLECTIONORALIAS = "collection1";- protected static final int TIMEOUT = DEFAULT_TIMEOUT;- protected static final String id = "id";-- @BeforeClass- public static void setupCollection() throws Exception {- configureCluster(4).addConfig("conf", configset("cloud-analytics")).configure();-- CollectionAdminRequest.createCollection(COLLECTIONORALIAS, "conf", 2, 1)- .process(cluster.getSolrClient());- cluster.waitForActiveCollection(COLLECTIONORALIAS, 2, 2);- }-- @AfterClass- public static void teardownCollection() throws Exception {- shutdownCluster();- }-- public void cleanIndex() throws Exception {- new UpdateRequest().deleteByQuery("*:*").commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- protected static final String[] BASEPARMS =- new String[] {"q", "*:*", "indent", "true", "olap", "true", "rows", "0"};-- public static enum VAL_TYPE {- INTEGER("int"),- LONG("long"),- FLOAT("float"),- DOUBLE("double"),- STRING("str"),- DATE("date");-- private VAL_TYPE(final String text) {- this.text = text;- }-- private final String text;-- @Override- public String toString() {- return text;- }- }-- protected NamedList<Object> queryLegacyCloudAnalytics(String[] testParams)- throws SolrServerException, IOException, InterruptedException, TimeoutException {- ModifiableSolrParams params = new ModifiableSolrParams();- params.set("q", "*:*");- params.set("indent", "true");- params.set("olap", "true");- params.set("rows", "0");- for (int i = 0; i + 1 < testParams.length; ) {- params.add(testParams[i++], testParams[i++]);- }- cluster.waitForAllNodes(10);- QueryRequest qreq = new QueryRequest(params);- QueryResponse resp = qreq.process(cluster.getSolrClient(), COLLECTIONORALIAS);- final NamedList<Object> response = resp.getResponse();- assertRequestTimeout(params);- return response;- }-- /** caveat: the given params are modified */- protected void assertRequestTimeout(ModifiableSolrParams params)- throws IOException, InterruptedException, TimeoutException, SolrServerException {- params.set("timeAllowed", 0);- cluster.waitForAllNodes(10);- final QueryResponse maybeTimeout =- new QueryRequest(params).process(cluster.getSolrClient(), COLLECTIONORALIAS);- assertEquals(maybeTimeout.getHeader() + "", 0, maybeTimeout.getStatus());- final Boolean partial =- maybeTimeout- .getHeader()- .getBooleanArg(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY);- assertNotNull("No partial results header returned", partial);- assertTrue(- "The request "- + params- + "was not stopped halfway through, the partial results header was false",- partial);- }-- @SuppressWarnings("unchecked")- protected <T> T getValue(NamedList<Object> response, String infoName, String exprName) {- return (T)- response.findRecursive(AnalyticsResponseHeadings.COMPLETED_OLD_HEADER, infoName, exprName);- }-- public <T extends Number & Comparable<T>> Double calculateNumberStat(- ArrayList<T> list, String stat) {- Double result;- if (stat.equals("median")) {- result = MedianCalculator.getMedian(list);- } else if (stat.equals("mean")) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result = Double.valueOf(d / list.size());- } else if (stat.equals("sum")) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result = Double.valueOf(d);- } else if (stat.equals("sumOfSquares")) {- double d = 0;- for (T element : list) {- d += element.doubleValue() * element.doubleValue();- }- result = Double.valueOf(d);- } else if (stat.equals("stddev")) {- double sum = 0;- double sumSquares = 0;- for (T element : list) {- sum += element.doubleValue();- sumSquares += element.doubleValue() * element.doubleValue();- }- result = Math.sqrt(sumSquares / list.size() - sum * sum / (list.size() * list.size()));- } else {- throw new IllegalArgumentException();- }- return result;- }-- public <T extends Comparable<T>> Object calculateStat(ArrayList<T> list, String stat) {- Object result;- if (stat.contains("perc_")) {- ArrayList<Integer> percs = new ArrayList<>(1);- int ord = (int) Math.ceil(Double.parseDouble(stat.substring(5)) / 100 * list.size()) - 1;- percs.add(ord);- OrdinalCalculator.putOrdinalsInPosition(list, percs);- result = list.get(percs.get(0));- } else if (stat.equals("count")) {- result = Long.valueOf(list.size());- } else if (stat.equals("unique")) {- HashSet<T> set = new HashSet<>();- set.addAll(list);- result = Long.valueOf((long) set.size());- } else if (stat.equals("max")) {- Collections.sort(list);- result = list.get(list.size() - 1);- } else if (stat.equals("min")) {- Collections.sort(list);- result = list.get(0);- } else {- result = null;- }- return result;- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.javadeleted file mode 100644index fbb978beb4c..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java+++ /dev/null@@ -1,263 +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.legacy;--import java.io.ByteArrayInputStream;-import java.io.FileNotFoundException;-import java.io.IOException;-import java.io.InputStream;-import java.lang.invoke.MethodHandles;-import java.nio.charset.StandardCharsets;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Collections;-import java.util.HashMap;-import java.util.HashSet;-import java.util.Scanner;-import java.util.stream.Stream;-import javax.xml.parsers.DocumentBuilder;-import javax.xml.parsers.DocumentBuilderFactory;-import javax.xml.parsers.ParserConfigurationException;-import javax.xml.xpath.XPathConstants;-import javax.xml.xpath.XPathExpressionException;-import javax.xml.xpath.XPathFactory;-import org.apache.lucene.util.IOUtils;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.analytics.util.MedianCalculator;-import org.apache.solr.analytics.util.OrdinalCalculator;-import org.apache.solr.request.SolrQueryRequest;-import org.junit.AfterClass;-import org.junit.BeforeClass;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;-import org.w3c.dom.Document;-import org.xml.sax.InputSource;-import org.xml.sax.SAXException;--public class LegacyAbstractAnalyticsTest extends SolrTestCaseJ4 {- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());-- protected static final String[] BASEPARMS =- new String[] {"q", "*:*", "indent", "true", "olap", "true", "rows", "0"};- protected static final HashMap<String, Object> defaults = new HashMap<>();-- public static enum VAL_TYPE {- INTEGER("int"),- LONG("long"),- FLOAT("float"),- DOUBLE("double"),- STRING("str"),- DATE("date");-- private VAL_TYPE(final String text) {- this.text = text;- }-- private final String text;-- @Override- public String toString() {- return text;- }- }-- private static Document doc;- private static XPathFactory xPathFact;-- private static String rawResponse;-- @BeforeClass- public static void beforeClassAbstractAnalysis() {- xPathFact = XPathFactory.newInstance();- }-- @AfterClass- public static void afterClassAbstractAnalysis() {- xPathFact = null;- doc = null;- rawResponse = null;- defaults.clear();- }-- public static void setResponse(String response)- throws ParserConfigurationException, IOException, SAXException {- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();- factory.setNamespaceAware(true); // never forget this!- DocumentBuilder builder = factory.newDocumentBuilder();- doc =- builder.parse(- new InputSource(new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8))));- rawResponse = response;- }-- protected String getRawResponse() {- return rawResponse;- }-- public Object getStatResult(String section, String name, VAL_TYPE type)- throws XPathExpressionException {-- // Construct the XPath expression. The form better not change or all these will fail.- StringBuilder sb =- new StringBuilder(- "/response/lst[@name='"- + AnalyticsResponseHeadings.COMPLETED_OLD_HEADER- + "']/lst[@name='")- .append(section)- .append("']");-- // This is a little fragile in that it demands the elements have the same name as type, i.e.- // when looking for a- // VAL_TYPE.DOUBLE, the element in question is <double name="blah">47.0</double>.- sb.append("/").append(type.toString()).append("[@name='").append(name).append("']");- String val =- xPathFact.newXPath().compile(sb.toString()).evaluate(doc, XPathConstants.STRING).toString();- try {- switch (type) {- case INTEGER:- return Integer.parseInt(val);- case DOUBLE:- return Double.parseDouble(val);- case FLOAT:- return Float.parseFloat(val);- case LONG:- return Long.parseLong(val);- case STRING:- assertTrue(rawResponse, val != null && val.length() > 0);- return val;- case DATE:- assertTrue(rawResponse, val != null && val.length() > 0);- return val;- }- } catch (Exception e) {- log.error("Caught exception in getStatResult", e);- fail("Caught exception in getStatResult, xPath = " + sb + " \nraw data: " + rawResponse);- }- fail("Unknown type used in getStatResult");- return null; // Really can't get here, but the compiler thinks we can!- }-- public <T extends Number & Comparable<T>> Double calculateNumberStat(- ArrayList<T> list, String stat) {- Double result;- if (stat.equals("median")) {- result = MedianCalculator.getMedian(list);- } else if (stat.equals("mean")) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result = Double.valueOf(d / list.size());- } else if (stat.equals("sum")) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result = Double.valueOf(d);- } else if (stat.equals("sumOfSquares")) {- double d = 0;- for (T element : list) {- d += element.doubleValue() * element.doubleValue();- }- result = Double.valueOf(d);- } else if (stat.equals("stddev")) {- double sum = 0;- double sumSquares = 0;- for (T element : list) {- sum += element.doubleValue();- sumSquares += element.doubleValue() * element.doubleValue();- }- result = Math.sqrt(sumSquares / list.size() - sum * sum / (list.size() * list.size()));- } else {- throw new IllegalArgumentException();- }- return result;- }-- public <T extends Comparable<T>> Object calculateStat(ArrayList<T> list, String stat) {- Object result;- if (stat.contains("perc_")) {- ArrayList<Integer> percs = new ArrayList<>(1);- int ord = (int) Math.ceil(Double.parseDouble(stat.substring(5)) / 100 * list.size()) - 1;- percs.add(ord);- OrdinalCalculator.putOrdinalsInPosition(list, percs);- result = list.get(percs.get(0));- } else if (stat.equals("count")) {- result = Long.valueOf(list.size());- } else if (stat.equals("unique")) {- HashSet<T> set = new HashSet<>();- set.addAll(list);- result = Long.valueOf((long) set.size());- } else if (stat.equals("max")) {- Collections.sort(list);- result = list.get(list.size() - 1);- } else if (stat.equals("min")) {- Collections.sort(list);- result = list.get(0);- } else {- result = null;- }- return result;- }-- @SuppressWarnings("unchecked")- public <T extends Comparable<T>> Long calculateMissing(ArrayList<T> list, String type) {- T def = (T) defaults.get(type);- long miss = 0;- for (T element : list) {- if (element.compareTo(def) == 0) {- miss++;- }- }- return Long.valueOf(miss);- }-- public static SolrQueryRequest request(String... args) {- return SolrTestCaseJ4.req(- Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new));- }-- public static SolrQueryRequest request(String[] args, String... additional) {- return SolrTestCaseJ4.req(- Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new),- additional);- }-- public static String[] fileToStringArr(Class<?> clazz, String fileName)- throws FileNotFoundException {- InputStream in = clazz.getResourceAsStream("/solr/analytics/legacy/" + fileName);- if (in == null) throw new FileNotFoundException("Resource not found: " + fileName);- Scanner file = new Scanner(in, StandardCharsets.UTF_8);- try {- ArrayList<String> strList = new ArrayList<>();- while (file.hasNextLine()) {- String line = file.nextLine();- line = line.trim();- if (line.isEmpty() || line.startsWith("#")) {- continue;- }- String[] param = line.split("=");- strList.add(param[0]);- strList.add(param[1]);- }- return strList.toArray(new String[0]);- } finally {- IOUtils.closeWhileHandlingException(file, in);- }- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetCloudTest.javadeleted file mode 100644index 0c809b4f7cd..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetCloudTest.java+++ /dev/null@@ -1,570 +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.legacy;--import java.util.ArrayList;-import java.util.List;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.common.util.NamedList;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyNoFacetCloudTest extends LegacyAbstractAnalyticsCloudTest {- public static final int INT = 71;- public static final int LONG = 36;- public static final int FLOAT = 93;- public static final int DOUBLE = 49;- public static final int DATE = 12;- public static final int STRING = 28;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<Integer> intTestStart;- static long intMissing = 0;-- // LONG- static ArrayList<Long> longTestStart;- static long longMissing = 0;-- // FLOAT- static ArrayList<Float> floatTestStart;- static long floatMissing = 0;-- // DOUBLE- static ArrayList<Double> doubleTestStart;- static long doubleMissing = 0;-- // DATE- static ArrayList<String> dateTestStart;- static long dateMissing = 0;-- // STR- static ArrayList<String> stringTestStart;- static long stringMissing = 0;-- @BeforeClass- public static void populate() throws Exception {- intTestStart = new ArrayList<>();- longTestStart = new ArrayList<>();- floatTestStart = new ArrayList<>();- doubleTestStart = new ArrayList<>();- dateTestStart = new ArrayList<>();- stringTestStart = new ArrayList<>();- intMissing = 0;- longMissing = 0;- doubleMissing = 0;- floatMissing = 0;- dateMissing = 0;- stringMissing = 0;-- UpdateRequest req = new UpdateRequest();- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- String dt = (1800 + j % DATE) + "-12-31T23:59:59Z";- String s = "str" + (j % STRING);- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);-- if (i != 0) {- fields.add("int_id");- fields.add("" + i);- intTestStart.add(i);- } else intMissing++;-- if (l != 0l) {- fields.add("long_ld");- fields.add("" + l);- longTestStart.add(l);- } else longMissing++;-- if (f != 0.0f) {- fields.add("float_fd");- fields.add("" + f);- floatTestStart.add(f);- } else floatMissing++;-- if (d != 0.0d) {- fields.add("double_dd");- fields.add("" + d);- doubleTestStart.add(d);- } else doubleMissing++;-- if ((j % DATE) != 0) {- fields.add("date_dtd");- fields.add(dt);- dateTestStart.add(dt);- } else dateMissing++;-- if ((j % STRING) != 0) {- fields.add("string_sd");- fields.add(s);- stringTestStart.add(s);- } else stringMissing++;-- req.add(fields.toArray(new String[0]));- }- req.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- @Test- public void sumTest() throws Exception {- String[] params =- new String[] {- "o.sr.s.int_id", "sum(int_id)",- "o.sr.s.long_ld", "sum(long_ld)",- "o.sr.s.float_fd", "sum(float_fd)",- "o.sr.s.double_dd", "sum(double_dd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Double intResult = getValue(response, "sr", "int_id");- Double intTest = calculateNumberStat(intTestStart, "sum");- assertEquals(responseStr, intResult, intTest);-- // Long- Double longResult = getValue(response, "sr", "long_ld");- Double longTest = calculateNumberStat(longTestStart, "sum");- assertEquals(responseStr, longResult, longTest);-- // Float- Double floatResult = getValue(response, "sr", "float_fd");- Double floatTest = calculateNumberStat(floatTestStart, "sum");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Double doubleResult = getValue(response, "sr", "double_dd");- Double doubleTest = calculateNumberStat(doubleTestStart, "sum");- assertEquals(responseStr, doubleResult, doubleTest);- }-- @Test- public void meanTest() throws Exception {- String[] params =- new String[] {- "o.mr.s.int_id", "mean(int_id)",- "o.mr.s.long_ld", "mean(long_ld)",- "o.mr.s.float_fd", "mean(float_fd)",- "o.mr.s.double_dd", "mean(double_dd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Double intResult = getValue(response, "mr", "int_id");- Double intTest = calculateNumberStat(intTestStart, "mean");- assertEquals(responseStr, intResult, intTest);-- // Long- Double longResult = getValue(response, "mr", "long_ld");- Double longTest = calculateNumberStat(longTestStart, "mean");- assertEquals(responseStr, longResult, longTest);-- // Float- Double floatResult = getValue(response, "mr", "float_fd");- Double floatTest = calculateNumberStat(floatTestStart, "mean");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Double doubleResult = getValue(response, "mr", "double_dd");- Double doubleTest = calculateNumberStat(doubleTestStart, "mean");- assertEquals(responseStr, doubleResult, doubleTest);- }-- @Test- public void stddevTest() throws Exception {- String[] params =- new String[] {- "o.str.s.int_id", "stddev(int_id)",- "o.str.s.long_ld", "stddev(long_ld)",- "o.str.s.float_fd", "stddev(float_fd)",- "o.str.s.double_dd", "stddev(double_dd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Double intResult = getValue(response, "str", "int_id");- Double intTest = calculateNumberStat(intTestStart, "stddev");- assertEquals(responseStr, intResult, intTest, 0.00000000001);-- // Long- Double longResult = getValue(response, "str", "long_ld");- Double longTest = calculateNumberStat(longTestStart, "stddev");- assertEquals(responseStr, longResult, longTest, 0.00000000001);-- // Float- Double floatResult = getValue(response, "str", "float_fd");- Double floatTest = calculateNumberStat(floatTestStart, "stddev");- assertEquals(responseStr, floatResult, floatTest, 0.00000000001);-- // Double- Double doubleResult = getValue(response, "str", "double_dd");- Double doubleTest = calculateNumberStat(doubleTestStart, "stddev");- assertEquals(responseStr, doubleResult, doubleTest, 0.00000000001);- }-- @Test- public void medianTest() throws Exception {- String[] params =- new String[] {- "o.medr.s.int_id", "median(int_id)",- "o.medr.s.long_ld", "median(long_ld)",- "o.medr.s.float_fd", "median(float_fd)",- "o.medr.s.double_dd", "median(double_dd)",- "o.medr.s.date_dtd", "median(date_dtd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Double intResult = getValue(response, "medr", "int_id");- Double intTest = calculateNumberStat(intTestStart, "median");- assertEquals(responseStr, intResult, intTest);-- // Long- Double longResult = getValue(response, "medr", "long_ld");- Double longTest = calculateNumberStat(longTestStart, "median");- assertEquals(responseStr, longResult, longTest);-- // Float- Double floatResult = getValue(response, "medr", "float_fd");- Double floatTest = calculateNumberStat(floatTestStart, "median");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Double doubleResult = getValue(response, "medr", "double_dd");- Double doubleTest = calculateNumberStat(doubleTestStart, "median");- assertEquals(responseStr, doubleResult, doubleTest);-- // TODO: Add test for date median- }-- @Test- public void perc20Test() throws Exception {- String[] params =- new String[] {- "o.p2r.s.int_id", "percentile(20,int_id)",- "o.p2r.s.long_ld", "percentile(20,long_ld)",- "o.p2r.s.float_fd", "percentile(20,float_fd)",- "o.p2r.s.double_dd", "percentile(20,double_dd)",- "o.p2r.s.date_dtd", "string(percentile(20,date_dtd))",- "o.p2r.s.string_sd", "percentile(20,string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int 20- Integer intResult = getValue(response, "p2r", "int_id");- Integer intTest = (Integer) calculateStat(intTestStart, "perc_20");- assertEquals(responseStr, intResult, intTest);-- // Long 20- Long longResult = getValue(response, "p2r", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "perc_20");- assertEquals(responseStr, longResult, longTest);-- // Float 20- Float floatResult = getValue(response, "p2r", "float_fd");- Float floatTest = (Float) calculateStat(floatTestStart, "perc_20");- assertEquals(responseStr, floatResult, floatTest);-- // Double 20- Double doubleResult = getValue(response, "p2r", "double_dd");- Double doubleTest = (Double) calculateStat(doubleTestStart, "perc_20");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date 20- String dateResult = getValue(response, "p2r", "date_dtd");- String dateTest = (String) calculateStat(dateTestStart, "perc_20");- assertEquals(responseStr, dateResult, dateTest);-- // String 20- String stringResult = getValue(response, "p2r", "string_sd");- String stringTest = (String) calculateStat(stringTestStart, "perc_20");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void perc60Test() throws Exception {- String[] params =- new String[] {- "o.p6r.s.int_id", "percentile(60,int_id)",- "o.p6r.s.long_ld", "percentile(60,long_ld)",- "o.p6r.s.float_fd", "percentile(60,float_fd)",- "o.p6r.s.double_dd", "percentile(60,double_dd)",- "o.p6r.s.date_dtd", "string(percentile(60,date_dtd))",- "o.p6r.s.string_sd", "percentile(60,string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int 60- Integer intResult = getValue(response, "p6r", "int_id");- Integer intTest = (Integer) calculateStat(intTestStart, "perc_60");- assertEquals(responseStr, intResult, intTest);-- // Long 60- Long longResult = getValue(response, "p6r", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "perc_60");- assertEquals(responseStr, longResult, longTest);-- // Float 60- Float floatResult = getValue(response, "p6r", "float_fd");- Float floatTest = (Float) calculateStat(floatTestStart, "perc_60");- assertEquals(responseStr, floatResult, floatTest);-- // Double 60- Double doubleResult = getValue(response, "p6r", "double_dd");- Double doubleTest = (Double) calculateStat(doubleTestStart, "perc_60");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date 60- String dateResult = getValue(response, "p6r", "date_dtd");- String dateTest = (String) calculateStat(dateTestStart, "perc_60");- assertEquals(responseStr, dateResult, dateTest);-- // String 60- String stringResult = getValue(response, "p6r", "string_sd");- String stringTest = (String) calculateStat(stringTestStart, "perc_60");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void minTest() throws Exception {- String[] params =- new String[] {- "o.mir.s.int_id", "min(int_id)",- "o.mir.s.long_ld", "min(long_ld)",- "o.mir.s.float_fd", "min(float_fd)",- "o.mir.s.double_dd", "min(double_dd)",- "o.mir.s.date_dtd", "string(min(date_dtd))",- "o.mir.s.string_sd", "min(string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Integer intResult = getValue(response, "mir", "int_id");- Integer intTest = (Integer) calculateStat(intTestStart, "min");- assertEquals(responseStr, intResult, intTest);-- // Long- Long longResult = getValue(response, "mir", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "min");- assertEquals(responseStr, longResult, longTest);-- // Float- Float floatResult = getValue(response, "mir", "float_fd");- Float floatTest = (Float) calculateStat(floatTestStart, "min");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Double doubleResult = getValue(response, "mir", "double_dd");- Double doubleTest = (Double) calculateStat(doubleTestStart, "min");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date- String dateResult = getValue(response, "mir", "date_dtd");- String dateTest = (String) calculateStat(dateTestStart, "min");- assertEquals(responseStr, dateResult, dateTest);-- // String- String stringResult = getValue(response, "mir", "string_sd");- String stringTest = (String) calculateStat(stringTestStart, "min");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void maxTest() throws Exception {- String[] params =- new String[] {- "o.mar.s.int_id", "max(int_id)",- "o.mar.s.long_ld", "max(long_ld)",- "o.mar.s.float_fd", "max(float_fd)",- "o.mar.s.double_dd", "max(double_dd)",- "o.mar.s.date_dtd", "string(max(date_dtd))",- "o.mar.s.string_sd", "max(string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Integer intResult = getValue(response, "mar", "int_id");- Integer intTest = (Integer) calculateStat(intTestStart, "max");- assertEquals(responseStr, intResult, intTest);-- // Long- Long longResult = getValue(response, "mar", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "max");- assertEquals(responseStr, longResult, longTest);-- // Float- Float floatResult = getValue(response, "mar", "float_fd");- Float floatTest = (Float) calculateStat(floatTestStart, "max");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Double doubleResult = getValue(response, "mar", "double_dd");- Double doubleTest = (Double) calculateStat(doubleTestStart, "max");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date- String dateResult = getValue(response, "mar", "date_dtd");- String dateTest = (String) calculateStat(dateTestStart, "max");- assertEquals(responseStr, dateResult, dateTest);-- // String- String stringResult = getValue(response, "mar", "string_sd");- String stringTest = (String) calculateStat(stringTestStart, "max");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void uniqueTest() throws Exception {- String[] params =- new String[] {- "o.ur.s.int_id", "unique(int_id)",- "o.ur.s.long_ld", "unique(long_ld)",- "o.ur.s.float_fd", "unique(float_fd)",- "o.ur.s.double_dd", "unique(double_dd)",- "o.ur.s.date_dtd", "unique(date_dtd)",- "o.ur.s.string_sd", "unique(string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Long intResult = getValue(response, "ur", "int_id");- Long intTest = (Long) calculateStat(intTestStart, "unique");- assertEquals(responseStr, intResult, intTest);-- // Long- Long longResult = getValue(response, "ur", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "unique");- assertEquals(responseStr, longResult, longTest);-- // Float- Long floatResult = getValue(response, "ur", "float_fd");- Long floatTest = (Long) calculateStat(floatTestStart, "unique");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Long doubleResult = getValue(response, "ur", "double_dd");- Long doubleTest = (Long) calculateStat(doubleTestStart, "unique");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date- Long dateResult = getValue(response, "ur", "date_dtd");- Long dateTest = (Long) calculateStat(dateTestStart, "unique");- assertEquals(responseStr, dateResult, dateTest);-- // String- Long stringResult = getValue(response, "ur", "string_sd");- Long stringTest = (Long) calculateStat(stringTestStart, "unique");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void countTest() throws Exception {- String[] params =- new String[] {- "o.cr.s.int_id", "count(int_id)",- "o.cr.s.long_ld", "count(long_ld)",- "o.cr.s.float_fd", "count(float_fd)",- "o.cr.s.double_dd", "count(double_dd)",- "o.cr.s.date_dtd", "count(date_dtd)",- "o.cr.s.string_sd", "count(string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- Long intResult = getValue(response, "cr", "int_id");- Long intTest = (Long) calculateStat(intTestStart, "count");- assertEquals(responseStr, intResult, intTest);-- // Long- Long longResult = getValue(response, "cr", "long_ld");- Long longTest = (Long) calculateStat(longTestStart, "count");- assertEquals(responseStr, longResult, longTest);-- // Float- Long floatResult = getValue(response, "cr", "float_fd");- Long floatTest = (Long) calculateStat(floatTestStart, "count");- assertEquals(responseStr, floatResult, floatTest);-- // Double- Long doubleResult = getValue(response, "cr", "double_dd");- Long doubleTest = (Long) calculateStat(doubleTestStart, "count");- assertEquals(responseStr, doubleResult, doubleTest);-- // Date- Long dateResult = getValue(response, "cr", "date_dtd");- Long dateTest = (Long) calculateStat(dateTestStart, "count");- assertEquals(responseStr, dateResult, dateTest);-- // String- Long stringResult = getValue(response, "cr", "string_sd");- Long stringTest = (Long) calculateStat(stringTestStart, "count");- assertEquals(responseStr, stringResult, stringTest);- }-- @Test- public void missingDefaultTest() throws Exception {- String[] params =- new String[] {- "o.misr.s.int_id", "missing(int_id)",- "o.misr.s.long_ld", "missing(long_ld)",- "o.misr.s.float_fd", "missing(float_fd)",- "o.misr.s.double_dd", "missing(double_dd)",- "o.misr.s.date_dtd", "missing(date_dtd)",- "o.misr.s.string_sd", "missing(string_sd)"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int- long intResult = getValue(response, "misr", "int_id");- assertEquals(responseStr, intMissing, intResult);-- // Long- long longResult = getValue(response, "misr", "long_ld");- assertEquals(responseStr, longMissing, longResult);-- // Float- long floatResult = getValue(response, "misr", "float_fd");- assertEquals(responseStr, floatMissing, floatResult);-- // Double- long doubleResult = getValue(response, "misr", "double_dd");- assertEquals(responseStr, doubleMissing, doubleResult);-- // Date- long dateResult = getValue(response, "misr", "date_dtd");- assertEquals(responseStr, dateMissing, dateResult);-- // String- long stringResult = getValue(response, "misr", "string_sd");- assertEquals(responseStr, stringMissing, stringResult);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetTest.javadeleted file mode 100644index f7ae8f1c437..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyNoFacetTest.java+++ /dev/null@@ -1,459 +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.legacy;--import java.util.ArrayList;-import java.util.List;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyNoFacetTest extends LegacyAbstractAnalyticsTest {- static String fileName = "noFacets.txt";-- public static final int INT = 71;- public static final int LONG = 36;- public static final int FLOAT = 93;- public static final int DOUBLE = 49;- public static final int DATE = 12;- public static final int STRING = 28;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<Integer> intTestStart;- static long intMissing = 0;-- // LONG- static ArrayList<Long> longTestStart;- static long longMissing = 0;-- // FLOAT- static ArrayList<Float> floatTestStart;- static long floatMissing = 0;-- // DOUBLE- static ArrayList<Double> doubleTestStart;- static long doubleMissing = 0;-- // DATE- static ArrayList<String> dateTestStart;- static long dateMissing = 0;-- // STR- static ArrayList<String> stringTestStart;- static long stringMissing = 0;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");- defaults.put("int_id", 0);- defaults.put("long_ld", 0L);- defaults.put("float_fd", (float) 0);- defaults.put("double_dd", (double) 0);- defaults.put("date_dtd", "1800-12-31T23:59:59Z");- defaults.put("string_sd", "str0");-- intTestStart = new ArrayList<>();- intMissing = 0;- longTestStart = new ArrayList<>();- longMissing = 0;- floatTestStart = new ArrayList<>();- floatMissing = 0;- doubleTestStart = new ArrayList<>();- doubleMissing = 0;- dateTestStart = new ArrayList<>();- dateMissing = 0;- stringTestStart = new ArrayList<>();- stringMissing = 0;-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- String dt = (1800 + j % DATE) + "-12-31T23:59:59Z";- String s = "str" + (j % STRING);- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);-- if (i != 0) {- fields.add("int_id");- fields.add("" + i);- intTestStart.add(i);- } else intMissing++;-- if (l != 0l) {- fields.add("long_ld");- fields.add("" + l);- longTestStart.add(l);- } else longMissing++;-- if (f != 0.0f) {- fields.add("float_fd");- fields.add("" + f);- floatTestStart.add(f);- } else floatMissing++;-- if (d != 0.0d) {- fields.add("double_dd");- fields.add("" + d);- doubleTestStart.add(d);- } else doubleMissing++;-- if ((j % DATE) != 0) {- fields.add("date_dtd");- fields.add(dt);- dateTestStart.add(dt);- } else dateMissing++;-- if ((j % STRING) != 0) {- fields.add("string_sd");- fields.add(s);- stringTestStart.add(s);- } else stringMissing++;-- assertU(adoc(fields.toArray(new String[0])));-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());-- // Sort ascending tests- setResponse(h.query(request(fileToStringArr(LegacyNoFacetTest.class, fileName))));- }-- @Test- public void sumTest() throws Exception {- // Int- Double intResult = (Double) getStatResult("sr", "int_id", VAL_TYPE.DOUBLE);- Double intTest = calculateNumberStat(intTestStart, "sum");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Double longResult = (Double) getStatResult("sr", "long_ld", VAL_TYPE.DOUBLE);- Double longTest = calculateNumberStat(longTestStart, "sum");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Double floatResult = (Double) getStatResult("sr", "float_fd", VAL_TYPE.DOUBLE);- Double floatTest = calculateNumberStat(floatTestStart, "sum");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Double doubleResult = (Double) getStatResult("sr", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = calculateNumberStat(doubleTestStart, "sum");- assertEquals(getRawResponse(), doubleResult, doubleTest);- }-- @Test- public void meanTest() throws Exception {- // Int- Double intResult = (Double) getStatResult("mr", "int_id", VAL_TYPE.DOUBLE);- Double intTest = calculateNumberStat(intTestStart, "mean");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Double longResult = (Double) getStatResult("mr", "long_ld", VAL_TYPE.DOUBLE);- Double longTest = calculateNumberStat(longTestStart, "mean");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Double floatResult = (Double) getStatResult("mr", "float_fd", VAL_TYPE.DOUBLE);- Double floatTest = calculateNumberStat(floatTestStart, "mean");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Double doubleResult = (Double) getStatResult("mr", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = calculateNumberStat(doubleTestStart, "mean");- assertEquals(getRawResponse(), doubleResult, doubleTest);- }-- @Test- public void stddevTest() throws Exception {- // Int- Double intResult = (Double) getStatResult("str", "int_id", VAL_TYPE.DOUBLE);- Double intTest = calculateNumberStat(intTestStart, "stddev");- assertEquals(getRawResponse(), intResult, intTest, 0.00000000001);-- // Long- Double longResult = (Double) getStatResult("str", "long_ld", VAL_TYPE.DOUBLE);- Double longTest = calculateNumberStat(longTestStart, "stddev");- assertEquals(getRawResponse(), longResult, longTest, 0.00000000001);-- // Float- Double floatResult = (Double) getStatResult("str", "float_fd", VAL_TYPE.DOUBLE);- Double floatTest = calculateNumberStat(floatTestStart, "stddev");- assertEquals(getRawResponse(), floatResult, floatTest, 0.00000000001);-- // Double- Double doubleResult = (Double) getStatResult("str", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = calculateNumberStat(doubleTestStart, "stddev");- assertEquals(getRawResponse(), doubleResult, doubleTest, 0.00000000001);- }-- @Test- public void medianTest() throws Exception {- // Int- Double intResult = (Double) getStatResult("medr", "int_id", VAL_TYPE.DOUBLE);- Double intTest = calculateNumberStat(intTestStart, "median");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Double longResult = (Double) getStatResult("medr", "long_ld", VAL_TYPE.DOUBLE);- Double longTest = calculateNumberStat(longTestStart, "median");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Double floatResult = (Double) getStatResult("medr", "float_fd", VAL_TYPE.DOUBLE);- Double floatTest = calculateNumberStat(floatTestStart, "median");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Double doubleResult = (Double) getStatResult("medr", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = calculateNumberStat(doubleTestStart, "median");- assertEquals(getRawResponse(), doubleResult, doubleTest);- }-- @Test- public void perc20Test() throws Exception {- // Int 20- Integer intResult = (Integer) getStatResult("p2r", "int_id", VAL_TYPE.INTEGER);- Integer intTest = (Integer) calculateStat(intTestStart, "perc_20");- assertEquals(getRawResponse(), intResult, intTest);-- // Long 20- Long longResult = (Long) getStatResult("p2r", "long_ld", VAL_TYPE.LONG);- Long longTest = (Long) calculateStat(longTestStart, "perc_20");- assertEquals(getRawResponse(), longResult, longTest);-- // Float 20- Float floatResult = (Float) getStatResult("p2r", "float_fd", VAL_TYPE.FLOAT);- Float floatTest = (Float) calculateStat(floatTestStart, "perc_20");- // assertEquals(getRawResponse(), floatResult,floatTest);-- // Double 20- Double doubleResult = (Double) getStatResult("p2r", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = (Double) calculateStat(doubleTestStart, "perc_20");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date 20- String dateResult = (String) getStatResult("p2r", "date_dtd", VAL_TYPE.DATE);- String dateTest = (String) calculateStat(dateTestStart, "perc_20");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String 20- String stringResult = (String) getStatResult("p2r", "string_sd", VAL_TYPE.STRING);- String stringTest = (String) calculateStat(stringTestStart, "perc_20");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void perc60Test() throws Exception {- // Int 60- Integer intResult = (Integer) getStatResult("p6r", "int_id", VAL_TYPE.INTEGER);- Integer intTest = (Integer) calculateStat(intTestStart, "perc_60");- assertEquals(getRawResponse(), intResult, intTest);-- // Long 60- Long longResult = (Long) getStatResult("p6r", "long_ld", VAL_TYPE.LONG);- Long longTest = (Long) calculateStat(longTestStart, "perc_60");- assertEquals(getRawResponse(), longResult, longTest);-- // Float 60- Float floatResult = (Float) getStatResult("p6r", "float_fd", VAL_TYPE.FLOAT);- Float floatTest = (Float) calculateStat(floatTestStart, "perc_60");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double 60- Double doubleResult = (Double) getStatResult("p6r", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = (Double) calculateStat(doubleTestStart, "perc_60");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date 60- String dateResult = (String) getStatResult("p6r", "date_dtd", VAL_TYPE.DATE);- String dateTest = (String) calculateStat(dateTestStart, "perc_60");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String 60- String stringResult = (String) getStatResult("p6r", "string_sd", VAL_TYPE.STRING);- String stringTest = (String) calculateStat(stringTestStart, "perc_60");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void minTest() throws Exception {- // Int- Integer intResult = ((Integer) getStatResult("mir", "int_id", VAL_TYPE.INTEGER));- Integer intTest = (Integer) calculateStat(intTestStart, "min");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Long longResult = ((Long) getStatResult("mir", "long_ld", VAL_TYPE.LONG));- Long longTest = (Long) calculateStat(longTestStart, "min");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Float floatResult = ((Float) getStatResult("mir", "float_fd", VAL_TYPE.FLOAT));- Float floatTest = (Float) calculateStat(floatTestStart, "min");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Double doubleResult = (Double) getStatResult("mir", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = (Double) calculateStat(doubleTestStart, "min");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date- String dateResult = (String) getStatResult("mir", "date_dtd", VAL_TYPE.DATE);- String dateTest = (String) calculateStat(dateTestStart, "min");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String- String stringResult = (String) getStatResult("mir", "string_sd", VAL_TYPE.STRING);- String stringTest = (String) calculateStat(stringTestStart, "min");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void maxTest() throws Exception {- // Int- Integer intResult = ((Integer) getStatResult("mar", "int_id", VAL_TYPE.INTEGER));- Integer intTest = (Integer) calculateStat(intTestStart, "max");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Long longResult = ((Long) getStatResult("mar", "long_ld", VAL_TYPE.LONG));- Long longTest = (Long) calculateStat(longTestStart, "max");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Float floatResult = ((Float) getStatResult("mar", "float_fd", VAL_TYPE.FLOAT));- Float floatTest = (Float) calculateStat(floatTestStart, "max");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Double doubleResult = (Double) getStatResult("mar", "double_dd", VAL_TYPE.DOUBLE);- Double doubleTest = (Double) calculateStat(doubleTestStart, "max");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date- String dateResult = (String) getStatResult("mar", "date_dtd", VAL_TYPE.DATE);- String dateTest = (String) calculateStat(dateTestStart, "max");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String- String stringResult = (String) getStatResult("mar", "string_sd", VAL_TYPE.STRING);- String stringTest = (String) calculateStat(stringTestStart, "max");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void uniqueTest() throws Exception {- // Int- Long intResult = (Long) getStatResult("ur", "int_id", VAL_TYPE.LONG);- Long intTest = (Long) calculateStat(intTestStart, "unique");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Long longResult = (Long) getStatResult("ur", "long_ld", VAL_TYPE.LONG);- Long longTest = (Long) calculateStat(longTestStart, "unique");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Long floatResult = (Long) getStatResult("ur", "float_fd", VAL_TYPE.LONG);- Long floatTest = (Long) calculateStat(floatTestStart, "unique");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Long doubleResult = (Long) getStatResult("ur", "double_dd", VAL_TYPE.LONG);- Long doubleTest = (Long) calculateStat(doubleTestStart, "unique");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date- Long dateResult = (Long) getStatResult("ur", "date_dtd", VAL_TYPE.LONG);- Long dateTest = (Long) calculateStat(dateTestStart, "unique");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String- Long stringResult = (Long) getStatResult("ur", "string_sd", VAL_TYPE.LONG);- Long stringTest = (Long) calculateStat(stringTestStart, "unique");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void countTest() throws Exception {- // Int- Long intResult = (Long) getStatResult("cr", "int_id", VAL_TYPE.LONG);- Long intTest = (Long) calculateStat(intTestStart, "count");- assertEquals(getRawResponse(), intResult, intTest);-- // Long- Long longResult = (Long) getStatResult("cr", "long_ld", VAL_TYPE.LONG);- Long longTest = (Long) calculateStat(longTestStart, "count");- assertEquals(getRawResponse(), longResult, longTest);-- // Float- Long floatResult = (Long) getStatResult("cr", "float_fd", VAL_TYPE.LONG);- Long floatTest = (Long) calculateStat(floatTestStart, "count");- assertEquals(getRawResponse(), floatResult, floatTest);-- // Double- Long doubleResult = (Long) getStatResult("cr", "double_dd", VAL_TYPE.LONG);- Long doubleTest = (Long) calculateStat(doubleTestStart, "count");- assertEquals(getRawResponse(), doubleResult, doubleTest);-- // Date- Long dateResult = (Long) getStatResult("cr", "date_dtd", VAL_TYPE.LONG);- Long dateTest = (Long) calculateStat(dateTestStart, "count");- assertEquals(getRawResponse(), dateResult, dateTest);-- // String- Long stringResult = (Long) getStatResult("cr", "string_sd", VAL_TYPE.LONG);- Long stringTest = (Long) calculateStat(stringTestStart, "count");- assertEquals(getRawResponse(), stringResult, stringTest);- }-- @Test- public void missingDefaultTest() throws Exception {- // Int- long intResult = (Long) getStatResult("misr", "int_id", VAL_TYPE.LONG);- assertEquals(getRawResponse(), intMissing, intResult);-- // Long- long longResult = (Long) getStatResult("misr", "long_ld", VAL_TYPE.LONG);- assertEquals(getRawResponse(), longMissing, longResult);-- // Float- long floatResult = (Long) getStatResult("misr", "float_fd", VAL_TYPE.LONG);- assertEquals(getRawResponse(), floatMissing, floatResult);-- // Double- long doubleResult = (Long) getStatResult("misr", "double_dd", VAL_TYPE.LONG);- assertEquals(getRawResponse(), doubleMissing, doubleResult);-- // Date- long dateResult = (Long) getStatResult("misr", "date_dtd", VAL_TYPE.LONG);- assertEquals(getRawResponse(), dateMissing, dateResult);-- // String- long stringResult = (Long) getStatResult("misr", "string_sd", VAL_TYPE.LONG);- assertEquals(getRawResponse(), stringMissing, stringResult);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.javadeleted file mode 100644index 3ef90232559..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.java+++ /dev/null@@ -1,223 +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.legacy.expression;--import java.time.Instant;-import java.util.Date;-import org.apache.solr.analytics.legacy.LegacyAbstractAnalyticsTest;-import org.apache.solr.util.DateMathParser;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyExpressionTest extends LegacyAbstractAnalyticsTest {- private static final String fileName = "expressions.txt";-- private static final int INT = 71;- private static final int LONG = 36;- private static final int FLOAT = 93;- private static final int DOUBLE = 49;- private static final int DATE = 12;- private static final int STRING = 28;- private static final int NUM_LOOPS = 100;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- String dt = (1800 + j % DATE) + "-12-31T23:59:59Z";- String s = "str" + (j % STRING);- assertU(- adoc(- "id",- "1000" + j,- "int_id",- "" + i,- "long_ld",- "" + l,- "float_fd",- "" + f,- "double_dd",- "" + d,- "date_dtd",- dt,- "string_sd",- s));-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());-- setResponse(h.query(request(fileToStringArr(LegacyExpressionTest.class, fileName))));- }-- @Test- public void addTest() throws Exception {- double sumResult = (Double) getStatResult("ar", "sum", VAL_TYPE.DOUBLE);- double uniqueResult = ((Long) getStatResult("ar", "unique", VAL_TYPE.LONG)).doubleValue();- double result = (Double) getStatResult("ar", "su", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), sumResult + uniqueResult, result, 0.0);-- double meanResult = (Double) getStatResult("ar", "mean", VAL_TYPE.DOUBLE);- double medianResult = (Double) getStatResult("ar", "median", VAL_TYPE.DOUBLE);- double countResult = ((Long) getStatResult("ar", "count", VAL_TYPE.LONG)).doubleValue();- result = (Double) getStatResult("ar", "mcm", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), meanResult + countResult + medianResult, result, 0.0);- }-- @Test- public void multiplyTest() throws Exception {- double sumResult = (Double) getStatResult("mr", "sum", VAL_TYPE.DOUBLE);- double uniqueResult = ((Long) getStatResult("mr", "unique", VAL_TYPE.LONG)).doubleValue();- double result = (Double) getStatResult("mr", "su", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), sumResult * uniqueResult, result, 0.0);-- double meanResult = (Double) getStatResult("mr", "mean", VAL_TYPE.DOUBLE);- double medianResult = (Double) getStatResult("mr", "median", VAL_TYPE.DOUBLE);- double countResult = ((Long) getStatResult("mr", "count", VAL_TYPE.LONG)).doubleValue();- result = (Double) getStatResult("mr", "mcm", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), meanResult * countResult * medianResult, result, 0.0);- }-- @Test- public void divideTest() throws Exception {- double sumResult = (Double) getStatResult("dr", "sum", VAL_TYPE.DOUBLE);- double uniqueResult = ((Long) getStatResult("dr", "unique", VAL_TYPE.LONG)).doubleValue();- double result = (Double) getStatResult("dr", "su", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), sumResult / uniqueResult, result, 0.0);-- double meanResult = (Double) getStatResult("dr", "mean", VAL_TYPE.DOUBLE);- double countResult = ((Long) getStatResult("dr", "count", VAL_TYPE.LONG)).doubleValue();- result = (Double) getStatResult("dr", "mc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), meanResult / countResult, result, 0.0);- }-- @Test- public void powerTest() throws Exception {- double sumResult = (Double) getStatResult("pr", "sum", VAL_TYPE.DOUBLE);- double uniqueResult = ((Long) getStatResult("pr", "unique", VAL_TYPE.LONG)).doubleValue();- double result = (Double) getStatResult("pr", "su", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), Math.pow(sumResult, uniqueResult), result, 0.0);-- double meanResult = (Double) getStatResult("pr", "mean", VAL_TYPE.DOUBLE);- double countResult = ((Long) getStatResult("pr", "count", VAL_TYPE.LONG)).doubleValue();- result = (Double) getStatResult("pr", "mc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), Math.pow(meanResult, countResult), result, 0.0);- }-- @Test- public void negateTest() throws Exception {- double sumResult = (Double) getStatResult("nr", "sum", VAL_TYPE.DOUBLE);- double result = (Double) getStatResult("nr", "s", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), -1 * sumResult, result, 0.0);-- long countResult = ((Long) getStatResult("nr", "count", VAL_TYPE.LONG));- long lresult = (Long) getStatResult("nr", "c", VAL_TYPE.LONG);- assertEquals(getRawResponse(), -1 * countResult, lresult);- }-- @Test- public void absoluteValueTest() throws Exception {- double sumResult = (Double) getStatResult("avr", "sum", VAL_TYPE.DOUBLE);- double result = (Double) getStatResult("avr", "s", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), sumResult, result, 0.0);-- long countResult = ((Long) getStatResult("avr", "count", VAL_TYPE.LONG));- long lresult = (Long) getStatResult("avr", "c", VAL_TYPE.LONG);- assertEquals(getRawResponse(), countResult, lresult);- }-- @Test- public void constantNumberTest() throws Exception {- int result = (Integer) getStatResult("cnr", "c8", VAL_TYPE.INTEGER);- assertEquals(getRawResponse(), 8, result);-- double dresult = (Double) getStatResult("cnr", "c10", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), 10.0, dresult, 0.0);- }-- @Test- public void dateMathTest() throws Exception {- String math = (String) getStatResult("dmr", "cme", VAL_TYPE.STRING);- DateMathParser dateMathParser = new DateMathParser();- dateMathParser.setNow(- new Date(- Instant.parse((String) getStatResult("dmr", "median", VAL_TYPE.DATE)).toEpochMilli()));- String dateMath = (String) getStatResult("dmr", "dmme", VAL_TYPE.DATE);- assertEquals(- getRawResponse(),- new Date(Instant.parse(dateMath).toEpochMilli()).toInstant(),- dateMathParser.parseMath(math).toInstant());-- math = (String) getStatResult("dmr", "cma", VAL_TYPE.STRING);- dateMathParser = new DateMathParser();- dateMathParser.setNow(- new Date(- Instant.parse((String) getStatResult("dmr", "max", VAL_TYPE.DATE)).toEpochMilli()));- dateMath = (String) getStatResult("dmr", "dmma", VAL_TYPE.DATE);- assertEquals(- getRawResponse(),- new Date(Instant.parse(dateMath).toEpochMilli()).toInstant(),- dateMathParser.parseMath(math).toInstant());- }-- @Test- public void constantDateTest() throws Exception {- String date = (String) getStatResult("cdr", "cd1", VAL_TYPE.DATE);- String str = (String) getStatResult("cdr", "cs1", VAL_TYPE.STRING);- assertEquals(getRawResponse(), date, str);-- date = (String) getStatResult("cdr", "cd2", VAL_TYPE.DATE);- str = (String) getStatResult("cdr", "cs2", VAL_TYPE.STRING);- assertEquals(getRawResponse(), date, str);- }-- @Test- public void constantStringTest() throws Exception {- String str = (String) getStatResult("csr", "cs1", VAL_TYPE.STRING);- assertEquals(getRawResponse(), str, "this is the first");-- str = (String) getStatResult("csr", "cs2", VAL_TYPE.STRING);- assertEquals(getRawResponse(), str, "this is the second");-- str = (String) getStatResult("csr", "cs3", VAL_TYPE.STRING);- assertEquals(getRawResponse(), str, "this is the third");- }-- @Test- public void concatenateTest() throws Exception {- StringBuilder builder = new StringBuilder();- builder.append((String) getStatResult("cr", "csmin", VAL_TYPE.STRING));- builder.append((String) getStatResult("cr", "min", VAL_TYPE.STRING));- String concat = (String) getStatResult("cr", "ccmin", VAL_TYPE.STRING);- assertEquals(getRawResponse(), concat, builder.toString());-- builder.setLength(0);- builder.append((String) getStatResult("cr", "csmax", VAL_TYPE.STRING));- builder.append((String) getStatResult("cr", "max", VAL_TYPE.STRING));- concat = (String) getStatResult("cr", "ccmax", VAL_TYPE.STRING);- assertEquals(getRawResponse(), concat, builder.toString());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.javadeleted file mode 100644index 0b99df0a402..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.java+++ /dev/null@@ -1,270 +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.legacy.expression;--import org.apache.solr.analytics.legacy.LegacyAbstractAnalyticsTest;-import org.apache.solr.analytics.legacy.facet.LegacyAbstractAnalyticsFacetTest;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyFunctionTest extends LegacyAbstractAnalyticsTest {- static String fileName = "functions.txt";-- public static final int INT = 71;- public static final int LONG = 36;- public static final int FLOAT = 93;- public static final int DOUBLE = 49;- public static final int DATE = 12;- public static final int STRING = 28;- public static final int NUM_LOOPS = 100;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT + 1;- long l = j % LONG + 1L;- float f = j % FLOAT + 1;- double d = j % DOUBLE + 1;- double d0 = j % DOUBLE;- String dt = (1800 + j % DATE) + "-06-30T23:59:59Z";- String s = "str" + (j % STRING);-- double add_if = (double) i + f;- double add_ldf = (double) l + d + f;- double mult_if = (double) i * f;- double mult_ldf = (double) l * d * f;- double div_if = (double) i / f;- double div_ld = (double) l / d;- double pow_if = Math.pow(i, f);- double pow_ld = Math.pow((double) l, d);- int neg_i = i * -1;- long neg_l = l * -1;- String dm_2y = (1802 + j % DATE) + "-06-30T23:59:59Z";- String dm_2m = (1800 + j % DATE) + "-08-30T23:59:59Z";- String concat_first = "this is the first" + s;- String concat_second = "this is the second" + s;-- assertU(- adoc(- LegacyAbstractAnalyticsFacetTest.filter(- "id",- "1000" + j,- "int_id",- "" + i,- "long_ld",- "" + l,- "float_fd",- "" + f,- "double_dd",- "" + d,- "date_dtd",- dt,- "string_sd",- s,- "add_if_dd",- "" + add_if,- "add_ldf_dd",- "" + add_ldf,- "mult_if_dd",- "" + mult_if,- "mult_ldf_dd",- "" + mult_ldf,- "div_if_dd",- "" + div_if,- "div_ld_dd",- "" + div_ld,- "pow_if_dd",- "" + pow_if,- "pow_ld_dd",- "" + pow_ld,- "neg_id",- "" + neg_i,- "neg_ld",- "" + neg_l,- "const_8_dd",- "8",- "const_10_dd",- "10",- "dm_2y_dtd",- dm_2y,- "dm_2m_dtd",- dm_2m,- "const_00_dtd",- "1800-06-30T23:59:59Z",- "const_04_dtd",- "1804-06-30T23:59:59Z",- "const_first_sd",- "this is the first",- "const_second_sd",- "this is the second",- "concat_first_sd",- concat_first,- "concat_second_sd",- concat_second,- "miss_dd",- "" + d0)));-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());-- setResponse(h.query(request(fileToStringArr(LegacyFunctionTest.class, fileName))));- }-- @Test- public void addTest() throws Exception {- double result = (Double) getStatResult("ar", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("ar", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- // TODO checfk why asserted 2times- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("ar", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("ar", "meanc", VAL_TYPE.DOUBLE);- assertEquals(result, calculated, 0.0);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void multiplyTest() throws Exception {- double result = (Double) getStatResult("mr", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("mr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("mr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("mr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void divideTest() throws Exception {- Double result = (Double) getStatResult("dr", "sum", VAL_TYPE.DOUBLE);- Double calculated = (Double) getStatResult("dr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("dr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("dr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void powerTest() throws Exception {- double result = (Double) getStatResult("pr", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("pr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("pr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("pr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void negateTest() throws Exception {- double result = (Double) getStatResult("nr", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("nr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("nr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("nr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void absoluteValueTest() throws Exception {- double result = (Double) getStatResult("avr", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("avr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("avr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("avr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void constantNumberTest() throws Exception {- double result = (Double) getStatResult("cnr", "sum", VAL_TYPE.DOUBLE);- double calculated = (Double) getStatResult("cnr", "sumc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- assertEquals(getRawResponse(), result, calculated, 0.0);-- result = (Double) getStatResult("cnr", "mean", VAL_TYPE.DOUBLE);- calculated = (Double) getStatResult("cnr", "meanc", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), result, calculated, 0.0);- assertEquals(getRawResponse(), result, calculated, 0.0);- }-- @Test- public void dateMathTest() throws Exception {- String result = (String) getStatResult("dmr", "median", VAL_TYPE.DATE);- String calculated = (String) getStatResult("dmr", "medianc", VAL_TYPE.DATE);- assertEquals(getRawResponse(), result, calculated);-- result = (String) getStatResult("dmr", "max", VAL_TYPE.DATE);- calculated = (String) getStatResult("dmr", "maxc", VAL_TYPE.DATE);- assertEquals(getRawResponse(), result, calculated);- }-- @Test- public void constantDateTest() throws Exception {- String result = (String) getStatResult("cdr", "median", VAL_TYPE.DATE);- String calculated = (String) getStatResult("cdr", "medianc", VAL_TYPE.DATE);- assertEquals(getRawResponse(), result, calculated);- assertEquals(getRawResponse(), result, calculated);-- result = (String) getStatResult("cdr", "max", VAL_TYPE.DATE);- calculated = (String) getStatResult("cdr", "maxc", VAL_TYPE.DATE);- assertEquals(getRawResponse(), result, calculated);- }-- @Test- public void constantStringTest() throws Exception {- String result = (String) getStatResult("csr", "min", VAL_TYPE.STRING);- String calculated = (String) getStatResult("csr", "minc", VAL_TYPE.STRING);- assertEquals(getRawResponse(), result, calculated);-- result = (String) getStatResult("csr", "max", VAL_TYPE.STRING);- calculated = (String) getStatResult("csr", "maxc", VAL_TYPE.STRING);- assertEquals(getRawResponse(), result, calculated);- }-- @Test- public void concatenateTest() throws Exception {- String result = (String) getStatResult("cr", "min", VAL_TYPE.STRING);- String calculated = (String) getStatResult("cr", "minc", VAL_TYPE.STRING);- assertEquals(getRawResponse(), result, calculated);-- result = (String) getStatResult("cr", "max", VAL_TYPE.STRING);- calculated = (String) getStatResult("cr", "maxc", VAL_TYPE.STRING);- assertEquals(getRawResponse(), result, calculated);- }-- @Test- public void missingTest() throws Exception {- double min = (Double) getStatResult("ms", "min", VAL_TYPE.DOUBLE);- double max = (Double) getStatResult("ms", "max", VAL_TYPE.DOUBLE);- assertEquals(getRawResponse(), 48.0d, max, 0.0);- assertEquals(getRawResponse(), 1.0d, min, 0.0);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetCloudTest.javadeleted file mode 100644index e8eda3546bf..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetCloudTest.java+++ /dev/null@@ -1,208 +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.legacy.facet;--import java.util.ArrayList;-import java.util.Collection;-import java.util.Collections;-import java.util.HashMap;-import java.util.HashSet;-import java.util.List;-import org.apache.solr.analytics.legacy.LegacyAbstractAnalyticsCloudTest;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.analytics.util.MedianCalculator;-import org.apache.solr.analytics.util.OrdinalCalculator;-import org.apache.solr.common.util.NamedList;-import org.junit.AfterClass;--public class LegacyAbstractAnalyticsFacetCloudTest extends LegacyAbstractAnalyticsCloudTest {- protected static final HashMap<String, Object> defaults = new HashMap<>();-- protected String latestType = "";-- @AfterClass- public static void afterClassAbstractAnalysis() {- defaults.clear();- }-- @SuppressWarnings("unchecked")- protected <T> ArrayList<T> getValueList(- NamedList<Object> response,- String infoName,- String facetType,- String facetName,- String exprName,- boolean includeMissing) {- NamedList<NamedList<Object>> facetList =- (NamedList<NamedList<Object>>)- response.findRecursive(- AnalyticsResponseHeadings.COMPLETED_OLD_HEADER, infoName, facetType, facetName);-- ArrayList<T> results = new ArrayList<>();- facetList.forEach(- (name, expressions) -> {- if (!includeMissing && !name.equals("(MISSING)")) {- T result = (T) expressions.get(exprName);- if (result != null) results.add(result);- }- });- return results;- }-- protected boolean responseContainsFacetValue(- NamedList<Object> response,- String infoName,- String facetType,- String facetName,- String facetValue) {- return null- != response.findRecursive(- AnalyticsResponseHeadings.COMPLETED_OLD_HEADER,- infoName,- facetType,- facetName,- facetValue);- }-- public static void increment(List<Long> list, int idx) {- Long i = list.remove(idx);- list.add(idx, i + 1);- }-- protected void setLatestType(String latestType) {- this.latestType = latestType;- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public <T extends Number & Comparable<T>> ArrayList calculateFacetedNumberStat(- ArrayList<ArrayList<T>> lists, String stat) {- ArrayList result;- if (stat.equals("median")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- result.add(MedianCalculator.getMedian(list));- }- } else if (stat.equals("mean")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result.add(d / list.size());- }- } else if (stat.equals("sum")) {- result = new ArrayList<Double>();- for (Collection<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result.add(d);- }- } else if (stat.equals("sumOfSquares")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue() * element.doubleValue();- }- result.add(d);- }- } else if (stat.equals("stddev")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double sum = 0;- double sumSquares = 0;- for (T element : list) {- sum += element.doubleValue();- sumSquares += element.doubleValue() * element.doubleValue();- }- String res =- Double.toString(- Math.sqrt(sumSquares / list.size() - sum * sum / (list.size() * list.size())));- result.add(Double.parseDouble(res));- }- } else {- throw new IllegalArgumentException();- }- return result;- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public <T extends Comparable<T>> ArrayList calculateFacetedStat(- ArrayList<ArrayList<T>> lists, String stat) {- ArrayList result;- if (stat.contains("perc_")) {- result = new ArrayList<T>();- for (List<T> list : lists) {- if (list.size() == 0) continue;- int ord = (int) Math.ceil(Double.parseDouble(stat.substring(5)) / 100 * list.size()) - 1;- ArrayList<Integer> percs = new ArrayList<>(1);- percs.add(ord);- OrdinalCalculator.putOrdinalsInPosition(list, percs);- result.add(list.get(ord));- }- } else if (stat.equals("count")) {- result = new ArrayList<Long>();- for (List<T> list : lists) {- result.add((long) list.size());- }- } else if (stat.equals("missing")) {- result = new ArrayList<Long>();- for (ArrayList<T> list : lists) {- result.add(calculateMissing(list, latestType));- }- } else if (stat.equals("unique")) {- result = new ArrayList<Long>();- for (List<T> list : lists) {- HashSet<T> set = new HashSet<>();- set.addAll(list);- result.add((long) set.size());- }- } else if (stat.equals("max")) {- result = new ArrayList<T>();- for (List<T> list : lists) {- if (list.size() == 0) continue;- Collections.sort(list);- result.add(list.get(list.size() - 1));- }- } else if (stat.equals("min")) {- result = new ArrayList<T>();- for (List<T> list : lists) {- if (list.size() == 0) continue;- Collections.sort(list);- result.add(list.get(0));- }- } else {- result = null;- }- return result;- }-- @SuppressWarnings("unchecked")- public <T extends Comparable<T>> Long calculateMissing(ArrayList<T> list, String type) {- T def = (T) defaults.get(type);- long miss = 0;- for (T element : list) {- if (element.compareTo(def) == 0) {- miss++;- }- }- return Long.valueOf(miss);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.javadeleted file mode 100644index 17dbc293d0f..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java+++ /dev/null@@ -1,357 +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.legacy.facet;--import java.io.ByteArrayInputStream;-import java.io.FileNotFoundException;-import java.io.IOException;-import java.io.InputStream;-import java.nio.charset.StandardCharsets;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Collection;-import java.util.Collections;-import java.util.HashMap;-import java.util.HashSet;-import java.util.List;-import java.util.Scanner;-import java.util.stream.Stream;-import javax.xml.parsers.DocumentBuilder;-import javax.xml.parsers.DocumentBuilderFactory;-import javax.xml.parsers.ParserConfigurationException;-import javax.xml.xpath.XPathConstants;-import javax.xml.xpath.XPathExpressionException;-import javax.xml.xpath.XPathFactory;-import org.apache.lucene.util.IOUtils;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.util.AnalyticsResponseHeadings;-import org.apache.solr.analytics.util.MedianCalculator;-import org.apache.solr.analytics.util.OrdinalCalculator;-import org.apache.solr.request.SolrQueryRequest;-import org.junit.AfterClass;-import org.junit.BeforeClass;-import org.w3c.dom.Document;-import org.w3c.dom.Node;-import org.w3c.dom.NodeList;-import org.xml.sax.InputSource;-import org.xml.sax.SAXException;--public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {- protected static final HashMap<String, Object> defaults = new HashMap<>();-- protected String latestType = "";-- private static Document doc;- private static XPathFactory xPathFact;- private static String rawResponse;-- @BeforeClass- public static void beforeClassAbstractAnalysis() {- xPathFact = XPathFactory.newInstance();- }-- @AfterClass- public static void afterClassAbstractAnalysis() {- xPathFact = null;- doc = null;- rawResponse = null;- defaults.clear();- }-- protected static void setResponse(String response)- throws ParserConfigurationException, IOException, SAXException {- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();- factory.setNamespaceAware(true); // never forget this!- DocumentBuilder builder = factory.newDocumentBuilder();- doc =- builder.parse(- new InputSource(new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8))));- rawResponse = response;- }-- protected String getRawResponse() {- return rawResponse;- }-- protected Node getNode(String xPath) throws XPathExpressionException {- return (Node) xPathFact.newXPath().compile(xPath).evaluate(doc, XPathConstants.NODE);- }-- private NodeList getNodes(String n1, String n2, String n3, String element, String n4)- throws XPathExpressionException {- // Construct the XPath expression. The form better not change or all these will fail.- StringBuilder sb =- new StringBuilder(- "/response/lst[@name='"- + AnalyticsResponseHeadings.COMPLETED_OLD_HEADER- + "']/lst[@name='")- .append(n1)- .append("']");- sb.append("/lst[@name='").append(n2).append("']");- sb.append("/lst[@name='").append(n3).append("']");- sb.append("/lst[@name!='(MISSING)']");- sb.append("//").append(element).append("[@name='").append(n4).append("']");- return (NodeList)- xPathFact.newXPath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);- }-- protected ArrayList<String> getStringList(- String n1, String n2, String n3, String element, String n4) throws XPathExpressionException {- ArrayList<String> ret = new ArrayList<>();- NodeList nodes = getNodes(n1, n2, n3, element, n4);- for (int idx = 0; idx < nodes.getLength(); ++idx) {- ret.add(nodes.item(idx).getTextContent());- }- return ret;- }-- protected ArrayList<Integer> getIntegerList(- String n1, String n2, String n3, String element, String n4) throws XPathExpressionException {- ArrayList<Integer> ret = new ArrayList<>();- NodeList nodes = getNodes(n1, n2, n3, element, n4);- for (int idx = 0; idx < nodes.getLength(); ++idx) {- ret.add(Integer.parseInt(nodes.item(idx).getTextContent()));- }- return ret;- }-- protected ArrayList<Long> getLongList(String n1, String n2, String n3, String element, String n4)- throws XPathExpressionException {- ArrayList<Long> ret = new ArrayList<>();- NodeList nodes = getNodes(n1, n2, n3, element, n4);- for (int idx = 0; idx < nodes.getLength(); ++idx) {- ret.add(Long.parseLong(nodes.item(idx).getTextContent()));- }- return ret;- }-- protected ArrayList<Float> getFloatList(- String n1, String n2, String n3, String element, String n4) throws XPathExpressionException {- ArrayList<Float> ret = new ArrayList<>();- NodeList nodes = getNodes(n1, n2, n3, element, n4);- for (int idx = 0; idx < nodes.getLength(); ++idx) {- ret.add(Float.parseFloat(nodes.item(idx).getTextContent()));- }- return ret;- }-- protected ArrayList<Double> getDoubleList(- String n1, String n2, String n3, String element, String n4) throws XPathExpressionException {- ArrayList<Double> ret = new ArrayList<>();- NodeList nodes = getNodes(n1, n2, n3, element, n4);- for (int idx = 0; idx < nodes.getLength(); ++idx) {- ret.add(Double.parseDouble(nodes.item(idx).getTextContent()));- }- return ret;- }-- public static void increment(List<Long> list, int idx) {- Long i = list.remove(idx);- list.add(idx, i + 1);- }-- public static String[] filter(String... args) {- List<String> l = new ArrayList<>();- for (int i = 0; i < args.length; i += 2) {- if (args[i + 1].equals("0")- || args[i + 1].equals("0.0")- || args[i + 1].equals("1800-12-31T23:59:59Z")- || args[i + 1].equals("str0")- || args[i + 1].equals("this is the firststr0")- || args[i + 1].equals("this is the secondstr0")) {- continue;- }- l.add(args[i]);- l.add(args[i + 1]);- }- return l.toArray(new String[0]);- }-- protected void setLatestType(String latestType) {- this.latestType = latestType;- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public <T extends Number & Comparable<T>> ArrayList calculateNumberStat(- ArrayList<ArrayList<T>> lists, String stat) {- ArrayList result;- if (stat.equals("median")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- result.add(MedianCalculator.getMedian(list));- }- } else if (stat.equals("mean")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result.add(d / list.size());- }- } else if (stat.equals("sum")) {- result = new ArrayList<Double>();- for (Collection<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue();- }- result.add(d);- }- } else if (stat.equals("sumOfSquares")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double d = 0;- for (T element : list) {- d += element.doubleValue() * element.doubleValue();- }- result.add(d);- }- } else if (stat.equals("stddev")) {- result = new ArrayList<Double>();- for (List<T> list : lists) {- double sum = 0;- double sumSquares = 0;- for (T element : list) {- sum += element.doubleValue();- sumSquares += element.doubleValue() * element.doubleValue();- }- String res =- Double.toString(- Math.sqrt(sumSquares / list.size() - sum * sum / (list.size() * list.size())));- result.add(Double.parseDouble(res));- }- } else {- throw new IllegalArgumentException();- }- return result;- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public <T extends Comparable<T>> ArrayList calculateStat(- ArrayList<ArrayList<T>> lists, String stat) {- ArrayList result;- if (stat.contains("perc_")) {- result = new ArrayList<T>();- for (List<T> list : lists) {- if (list.size() == 0) continue;- int ord = (int) Math.ceil(Double.parseDouble(stat.substring(5)) / 100 * list.size()) - 1;- ArrayList<Integer> percs = new ArrayList<>(1);- percs.add(ord);- OrdinalCalculator.putOrdinalsInPosition(list, percs);- result.add(list.get(ord));- }- } else if (stat.equals("count")) {- result = new ArrayList<Long>();- for (List<T> list : lists) {- // if( list.size() == 0) continue;- result.add((long) list.size());- }- } else if (stat.equals("missing")) {- result = new ArrayList<Long>();- for (ArrayList<T> list : lists) {- if (list.size() == 0) continue;- result.add(calculateMissing(list, latestType));- }- } else if (stat.equals("unique")) {- result = new ArrayList<Long>();- for (List<T> list : lists) {- HashSet<T> set = new HashSet<>(list);- result.add((long) set.size());- }- } else if (stat.equals("max")) {- result = new ArrayList<T>();- for (List<T> list : lists) {- if (list.size() == 0) continue;- Collections.sort(list);- result.add(list.get(list.size() - 1));- }- } else if (stat.equals("min")) {- result = new ArrayList<T>();- for (List list : lists) {- if (list.size() == 0) continue;- Collections.sort(list);- result.add(list.get(0));- }- } else {- result = null;- }- return result;- }-- @SuppressWarnings("unchecked")- public <T extends Comparable<T>> Long calculateMissing(ArrayList<T> list, String type) {- T def = (T) defaults.get(type);- long miss = 0;- for (T element : list) {- if (element.compareTo(def) == 0) {- miss++;- }- }- return Long.valueOf(miss);- }-- public static SolrQueryRequest request(String... args) {- return SolrTestCaseJ4.req(- Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new));- }-- private static final String[] BASEPARMS =- new String[] {"q", "*:*", "indent", "true", "olap", "true", "rows", "0"};-- public static String[] fileToStringArr(Class<?> clazz, String fileName)- throws FileNotFoundException {- InputStream in = clazz.getResourceAsStream("/solr/analytics/legacy/" + fileName);- if (in == null) throw new FileNotFoundException("Resource not found: " + fileName);- Scanner file = new Scanner(in, StandardCharsets.UTF_8);- try {- ArrayList<String> strList = new ArrayList<>();- while (file.hasNextLine()) {- String line = file.nextLine();- if (line.length() < 2) {- continue;- }- int commentStart = line.indexOf("//");- if (commentStart >= 0) {- line = line.substring(0, commentStart);- }- String[] param = line.split("=");- if (param.length != 2) {- continue;- }- strList.add(param[0]);- strList.add(param[1]);- }- return strList.toArray(new String[0]);- } finally {- IOUtils.closeWhileHandlingException(file, in);- }- }-- protected void removeNodes(String xPath, List<Double> string) throws XPathExpressionException {- NodeList missingNodes = getNodes(xPath);- List<Double> result = new ArrayList<>();- for (int idx = 0; idx < missingNodes.getLength(); ++idx) {- result.add(Double.parseDouble(missingNodes.item(idx).getTextContent()));- }- string.removeAll(result);- }-- protected NodeList getNodes(String xPath) throws XPathExpressionException {- return (NodeList) xPathFact.newXPath().compile(xPath).evaluate(doc, XPathConstants.NODESET);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFacetSortingTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFacetSortingTest.javadeleted file mode 100644index 7e02c08aaf5..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFacetSortingTest.java+++ /dev/null@@ -1,54 +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.legacy.facet;--import org.apache.solr.analytics.legacy.LegacyAbstractAnalyticsTest;-import org.apache.solr.analytics.legacy.expression.LegacyExpressionTest;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyFacetSortingTest extends LegacyAbstractAnalyticsTest {- private static String fileName = "facetSorting.txt";-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- // The data set below is so generated that in bucket corresponding fieldFacet B, double_dd- // column has null values- // and in bucket C corresponding to fieldFacet C has null values for column long_ld.- // FieldFaceting occurs on string_sd field- assertU(adoc("id", "1001", "string_sd", "A", "double_dd", "" + 3, "long_ld", "" + 1));- assertU(adoc("id", "1002", "string_sd", "A", "double_dd", "" + 25, "long_ld", "" + 2));- assertU(adoc("id", "1003", "string_sd", "B", "long_ld", "" + 3));- assertU(adoc("id", "1004", "string_sd", "B", "long_ld", "" + 4));- assertU(adoc("id", "1005", "string_sd", "C", "double_dd", "" + 17));-- assertU(commit());- String response = h.query(request(fileToStringArr(LegacyExpressionTest.class, fileName)));- setResponse(response);- }-- @Test- public void addTest() throws Exception {- Double minResult = (Double) getStatResult("ar", "min", VAL_TYPE.DOUBLE);- Long maxResult = (Long) getStatResult("ar", "max", VAL_TYPE.LONG);- assertEquals(Double.valueOf(minResult), Double.valueOf(3.0));- assertEquals(Long.valueOf(maxResult), Long.valueOf(4));- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetCloudTest.javadeleted file mode 100644index 9a8802b5729..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetCloudTest.java+++ /dev/null@@ -1,1444 +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.legacy.facet;--import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import java.util.ArrayList;-import java.util.Collections;-import java.util.List;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.common.util.NamedList;-import org.junit.BeforeClass;-import org.junit.Test;--@ThreadLeakLingering(linger = 0)-public class LegacyFieldFacetCloudTest extends LegacyAbstractAnalyticsFacetCloudTest {- public static final int INT = 71;- public static final int LONG = 36;- public static final int LONGM = 50;- public static final int FLOAT = 73;- public static final int FLOATM = 84;- public static final int DOUBLE = 49;- public static final int DATE = 12;- public static final int DATEM = 30;- public static final int STRING = 29;- public static final int STRINGM = 41;- public static final int NUM_LOOPS = 100;-- // INT- private static ArrayList<ArrayList<Integer>> intDateTestStart;- private static ArrayList<Long> intDateTestMissing;- private static ArrayList<ArrayList<Integer>> intStringTestStart;- private static ArrayList<Long> intStringTestMissing;-- // LONG- private static ArrayList<ArrayList<Long>> longDateTestStart;- private static ArrayList<Long> longDateTestMissing;- private static ArrayList<ArrayList<Long>> longStringTestStart;- private static ArrayList<Long> longStringTestMissing;-- // FLOAT- private static ArrayList<ArrayList<Float>> floatDateTestStart;- private static ArrayList<Long> floatDateTestMissing;- private static ArrayList<ArrayList<Float>> floatStringTestStart;- private static ArrayList<Long> floatStringTestMissing;-- // DOUBLE- private static ArrayList<ArrayList<Double>> doubleDateTestStart;- private static ArrayList<Long> doubleDateTestMissing;- private static ArrayList<ArrayList<Double>> doubleStringTestStart;- private static ArrayList<Long> doubleStringTestMissing;-- // DATE- private static ArrayList<ArrayList<String>> dateIntTestStart;- private static ArrayList<Long> dateIntTestMissing;- private static ArrayList<ArrayList<String>> dateLongTestStart;- private static ArrayList<Long> dateLongTestMissing;-- // String- private static ArrayList<ArrayList<String>> stringIntTestStart;- private static ArrayList<Long> stringIntTestMissing;- private static ArrayList<ArrayList<String>> stringLongTestStart;- private static ArrayList<Long> stringLongTestMissing;-- // Multi-Valued- private static ArrayList<ArrayList<Integer>> multiLongTestStart;- private static ArrayList<Long> multiLongTestMissing;- private static ArrayList<ArrayList<Integer>> multiStringTestStart;- private static ArrayList<Long> multiStringTestMissing;- private static ArrayList<ArrayList<Integer>> multiDateTestStart;- private static ArrayList<Long> multiDateTestMissing;-- @BeforeClass- public static void beforeTest() throws Exception {-- // INT- intDateTestStart = new ArrayList<>();- intDateTestMissing = new ArrayList<>();- intStringTestStart = new ArrayList<>();- intStringTestMissing = new ArrayList<>();-- // LONG- longDateTestStart = new ArrayList<>();- longDateTestMissing = new ArrayList<>();- longStringTestStart = new ArrayList<>();- longStringTestMissing = new ArrayList<>();-- // FLOAT- floatDateTestStart = new ArrayList<>();- floatDateTestMissing = new ArrayList<>();- floatStringTestStart = new ArrayList<>();- floatStringTestMissing = new ArrayList<>();-- // DOUBLE- doubleDateTestStart = new ArrayList<>();- doubleDateTestMissing = new ArrayList<>();- doubleStringTestStart = new ArrayList<>();- doubleStringTestMissing = new ArrayList<>();-- // DATE- dateIntTestStart = new ArrayList<>();- dateIntTestMissing = new ArrayList<>();- dateLongTestStart = new ArrayList<>();- dateLongTestMissing = new ArrayList<>();-- // String- stringIntTestStart = new ArrayList<>();- stringIntTestMissing = new ArrayList<>();- stringLongTestStart = new ArrayList<>();- stringLongTestMissing = new ArrayList<>();-- // Multi-Valued- multiLongTestStart = new ArrayList<>();- multiLongTestMissing = new ArrayList<>();- multiStringTestStart = new ArrayList<>();- multiStringTestMissing = new ArrayList<>();- multiDateTestStart = new ArrayList<>();- multiDateTestMissing = new ArrayList<>();-- boolean multiCanHaveDuplicates = Boolean.getBoolean(NUMERIC_POINTS_SYSPROP);-- UpdateRequest req = new UpdateRequest();- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- long lm = j % LONGM;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int dtm = j % DATEM;- int s = j % STRING;- int sm = j % STRINGM;-- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);-- if (i != 0) {- fields.add("int_id");- fields.add("" + i);- }- if (l != 0l) {- fields.add("long_ld");- fields.add("" + l);- fields.add("long_ldm");- fields.add("" + l);- }- if (lm != 0l) {- fields.add("long_ldm");- fields.add("" + lm);- }- if (f != 0.0f) {- fields.add("float_fd");- fields.add("" + f);- }- if (d != 0.0d) {- fields.add("double_dd");- fields.add("" + d);- }- if (dt != 0) {- fields.add("date_dtd");- fields.add((1800 + dt) + "-12-31T23:59:59Z");- fields.add("date_dtdm");- fields.add((1800 + dt) + "-12-31T23:59:59Z");- }- if (dtm != 0) {- fields.add("date_dtdm");- fields.add((1800 + dtm) + "-12-31T23:59:59Z");- }- if (s != 0) {- fields.add("string_sd");- fields.add("str" + s);- fields.add("string_sdm");- fields.add("str" + s);- }- if (sm != 0) {- fields.add("string_sdm");- fields.add("str" + sm);- }- req.add(fields.toArray(new String[0]));-- if (dt != 0) {- // Dates- if (j - DATE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- intDateTestMissing.add(0l);- } else {- intDateTestMissing.add(1l);- }- intDateTestStart.add(list1);- ArrayList<Long> list2 = new ArrayList<>();- if (l != 0l) {- list2.add(l);- longDateTestMissing.add(0l);- } else {- longDateTestMissing.add(1l);- }- longDateTestStart.add(list2);- ArrayList<Float> list3 = new ArrayList<>();- if (f != 0.0f) {- list3.add(f);- floatDateTestMissing.add(0l);- } else {- floatDateTestMissing.add(1l);- }- floatDateTestStart.add(list3);- ArrayList<Double> list4 = new ArrayList<>();- if (d != 0.0d) {- list4.add(d);- doubleDateTestMissing.add(0l);- } else {- doubleDateTestMissing.add(1l);- }- doubleDateTestStart.add(list4);- ArrayList<Integer> list5 = new ArrayList<>();- if (i != 0) {- list5.add(i);- multiDateTestMissing.add(0l);- } else {- multiDateTestMissing.add(1l);- }- multiDateTestStart.add(list5);- } else {- if (i != 0) intDateTestStart.get(dt - 1).add(i);- else increment(intDateTestMissing, dt - 1);- if (l != 0l) longDateTestStart.get(dt - 1).add(l);- else increment(longDateTestMissing, dt - 1);- if (f != 0.0f) floatDateTestStart.get(dt - 1).add(f);- else increment(floatDateTestMissing, dt - 1);- if (d != 0.0d) doubleDateTestStart.get(dt - 1).add(d);- else increment(doubleDateTestMissing, dt - 1);- if (i != 0) multiDateTestStart.get(dt - 1).add(i);- else increment(multiDateTestMissing, dt - 1);- }- }-- if (dtm != 0) {- if (j - DATEM < 0 && dtm != dt) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiDateTestMissing.add(0l);- } else {- multiDateTestMissing.add(1l);- }- multiDateTestStart.add(list1);- } else if (dtm != dt || multiCanHaveDuplicates) {- if (i != 0) multiDateTestStart.get(dtm - 1).add(i);- else increment(multiDateTestMissing, dtm - 1);- }- }-- if (s != 0) {- // Strings- if (j - STRING < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- intStringTestMissing.add(0l);- } else {- intStringTestMissing.add(1l);- }- intStringTestStart.add(list1);- ArrayList<Long> list2 = new ArrayList<>();- if (l != 0l) {- list2.add(l);- longStringTestMissing.add(0l);- } else {- longStringTestMissing.add(1l);- }- longStringTestStart.add(list2);- ArrayList<Float> list3 = new ArrayList<>();- if (f != 0.0f) {- list3.add(f);- floatStringTestMissing.add(0l);- } else {- floatStringTestMissing.add(1l);- }- floatStringTestStart.add(list3);- ArrayList<Double> list4 = new ArrayList<>();- if (d != 0.0d) {- list4.add(d);- doubleStringTestMissing.add(0l);- } else {- doubleStringTestMissing.add(1l);- }- doubleStringTestStart.add(list4);- ArrayList<Integer> list5 = new ArrayList<>();- if (i != 0) {- list5.add(i);- multiStringTestMissing.add(0l);- } else {- multiStringTestMissing.add(1l);- }- multiStringTestStart.add(list5);- } else {- if (i != 0) intStringTestStart.get(s - 1).add(i);- else increment(intStringTestMissing, s - 1);- if (l != 0l) longStringTestStart.get(s - 1).add(l);- else increment(longStringTestMissing, s - 1);- if (f != 0.0f) floatStringTestStart.get(s - 1).add(f);- else increment(floatStringTestMissing, s - 1);- if (d != 0.0d) doubleStringTestStart.get(s - 1).add(d);- else increment(doubleStringTestMissing, s - 1);- if (i != 0) multiStringTestStart.get(s - 1).add(i);- else increment(multiStringTestMissing, s - 1);- }- }-- // Strings- if (sm != 0) {- if (j - STRINGM < 0 && sm != s) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiStringTestMissing.add(0l);- } else {- multiStringTestMissing.add(1l);- }- multiStringTestStart.add(list1);- } else if (sm != s) {- if (i != 0) multiStringTestStart.get(sm - 1).add(i);- else increment(multiStringTestMissing, sm - 1);- }- }-- // Int- if (i != 0) {- if (j - INT < 0) {- ArrayList<String> list1 = new ArrayList<>();- if (dt != 0) {- list1.add((1800 + dt) + "-12-31T23:59:59Z");- dateIntTestMissing.add(0l);- } else {- dateIntTestMissing.add(1l);- }- dateIntTestStart.add(list1);- ArrayList<String> list2 = new ArrayList<>();- if (s != 0) {- list2.add("str" + s);- stringIntTestMissing.add(0l);- } else {- stringIntTestMissing.add(1l);- }- stringIntTestStart.add(list2);- } else {- if (dt != 0) dateIntTestStart.get(i - 1).add((1800 + dt) + "-12-31T23:59:59Z");- else increment(dateIntTestMissing, i - 1);- if (s != 0) stringIntTestStart.get(i - 1).add("str" + s);- else increment(stringIntTestMissing, i - 1);- }- }-- // Long- if (l != 0) {- if (j - LONG < 0) {- ArrayList<String> list1 = new ArrayList<>();- if (dt != 0) {- list1.add((1800 + dt) + "-12-31T23:59:59Z");- dateLongTestMissing.add(0l);- } else {- dateLongTestMissing.add(1l);- }- dateLongTestStart.add(list1);- ArrayList<String> list2 = new ArrayList<>();- if (s != 0) {- list2.add("str" + s);- stringLongTestMissing.add(0l);- } else {- stringLongTestMissing.add(1l);- }- stringLongTestStart.add(list2);- ArrayList<Integer> list3 = new ArrayList<>();- if (i != 0) {- list3.add(i);- multiLongTestMissing.add(0l);- } else {- multiLongTestMissing.add(1l);- }- multiLongTestStart.add(list3);- } else {- if (dt != 0) dateLongTestStart.get((int) l - 1).add((1800 + dt) + "-12-31T23:59:59Z");- else increment(dateLongTestMissing, (int) l - 1);- if (s != 0) stringLongTestStart.get((int) l - 1).add("str" + s);- else increment(stringLongTestMissing, (int) l - 1);- if (i != 0) multiLongTestStart.get((int) l - 1).add(i);- else increment(multiLongTestMissing, (int) l - 1);- }- }-- // Long- if (lm != 0) {- if (j - LONGM < 0 && lm != l) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiLongTestMissing.add(0l);- } else {- multiLongTestMissing.add(1l);- }- multiLongTestStart.add(list1);- } else if (lm != l || multiCanHaveDuplicates) {- if (i != 0) multiLongTestStart.get((int) lm - 1).add(i);- else increment(multiLongTestMissing, (int) lm - 1);- }- }- }-- req.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- @SuppressWarnings("unchecked")- @Test- public void sumTest() throws Exception {- String[] params =- new String[] {- "o.sum.s.int", "sum(int_id)",- "o.sum.s.long", "sum(long_ld)",- "o.sum.s.float", "sum(float_fd)",- "o.sum.s.double", "sum(double_dd)",- "o.sum.ff", "string_sd",- "o.sum.ff", "date_dtd"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Double> intDate =- getValueList(response, "sum", "fieldFacets", "date_dtd", "int", false);- ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "sum");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getValueList(response, "sum", "fieldFacets", "string_sd", "int", false);- ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "sum");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getValueList(response, "sum", "fieldFacets", "date_dtd", "long", false);- ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "sum");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getValueList(response, "sum", "fieldFacets", "string_sd", "long", false);- ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "sum");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getValueList(response, "sum", "fieldFacets", "date_dtd", "float", false);- ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "sum");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getValueList(response, "sum", "fieldFacets", "string_sd", "float", false);- ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "sum");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "sum", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "sum");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "sum", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest = calculateFacetedNumberStat(doubleStringTestStart, "sum");- assertEqualsList(responseStr, doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void meanTest() throws Exception {- String[] params =- new String[] {- "o.mean.s.int", "mean(int_id)",- "o.mean.s.long", "mean(long_ld)",- "o.mean.s.float", "mean(float_fd)",- "o.mean.s.double", "mean(double_dd)",- "o.mean.ff", "string_sd",- "o.mean.ff", "date_dtd"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Double> intDate =- getValueList(response, "mean", "fieldFacets", "date_dtd", "int", false);- ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "mean");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getValueList(response, "mean", "fieldFacets", "string_sd", "int", false);- ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "mean");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getValueList(response, "mean", "fieldFacets", "date_dtd", "long", false);- ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "mean");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getValueList(response, "mean", "fieldFacets", "string_sd", "long", false);- ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "mean");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getValueList(response, "mean", "fieldFacets", "date_dtd", "float", false);- ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "mean");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getValueList(response, "mean", "fieldFacets", "string_sd", "float", false);- ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "mean");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "mean", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "mean");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "mean", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest = calculateFacetedNumberStat(doubleStringTestStart, "mean");- assertEqualsList(responseStr, doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void stddevFacetAscTest() throws Exception {- String[] params =- new String[] {- "o.stddev.s.int", "stddev(int_id)",- "o.stddev.s.long", "stddev(long_ld)",- "o.stddev.s.float", "stddev(float_fd)",- "o.stddev.s.double", "stddev(double_dd)",- "o.stddev.ff", "string_sd",- "o.stddev.ff", "date_dtd"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);-- // Int Date- ArrayList<Double> intDate =- getValueList(response, "stddev", "fieldFacets", "date_dtd", "int", false);- ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "stddev");- checkStddevs(response, intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getValueList(response, "stddev", "fieldFacets", "string_sd", "int", false);- ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "stddev");- checkStddevs(response, intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getValueList(response, "stddev", "fieldFacets", "date_dtd", "long", false);- ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "stddev");- checkStddevs(response, longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getValueList(response, "stddev", "fieldFacets", "string_sd", "long", false);- ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "stddev");- checkStddevs(response, longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getValueList(response, "stddev", "fieldFacets", "date_dtd", "float", false);- ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "stddev");- checkStddevs(response, floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getValueList(response, "stddev", "fieldFacets", "string_sd", "float", false);- ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "stddev");- checkStddevs(response, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "stddev", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "stddev");- checkStddevs(response, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "stddev", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- calculateFacetedNumberStat(doubleStringTestStart, "stddev");- checkStddevs(response, doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void medianFacetAscTest() throws Exception {- String[] params =- new String[] {- "o.median.s.int", "median(int_id)",- "o.median.s.long", "median(long_ld)",- "o.median.s.float", "median(float_fd)",- "o.median.s.double", "median(double_dd)",- "o.median.ff", "string_sd",- "o.median.ff", "date_dtd"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Double> intDate =- getValueList(response, "median", "fieldFacets", "date_dtd", "int", false);- ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "median");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getValueList(response, "median", "fieldFacets", "string_sd", "int", false);- ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "median");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getValueList(response, "median", "fieldFacets", "date_dtd", "long", false);- ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "median");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getValueList(response, "median", "fieldFacets", "string_sd", "long", false);- ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "median");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getValueList(response, "median", "fieldFacets", "date_dtd", "float", false);- ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "median");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getValueList(response, "median", "fieldFacets", "string_sd", "float", false);- ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "median");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "median", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "median");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "median", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- calculateFacetedNumberStat(doubleStringTestStart, "median");- assertEqualsList(responseStr, doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void perc20Test() throws Exception {- String[] params =- new String[] {- "o.percentile_20n.s.int", "percentile(20,int_id)",- "o.percentile_20n.s.long", "percentile(20,long_ld)",- "o.percentile_20n.s.float", "percentile(20,float_fd)",- "o.percentile_20n.s.double", "percentile(20,double_dd)",- "o.percentile_20n.ff", "string_sd",- "o.percentile_20n.ff", "date_dtd",- "o.percentile_20.s.str", "percentile(20,string_sd)",- "o.percentile_20.s.date", "string(percentile(20,date_dtd))",- "o.percentile_20.ff", "int_id",- "o.percentile_20.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Integer> intDate =- getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "int", false);- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateFacetedStat(intDateTestStart, "perc_20");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Integer> intString =- getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "int", false);- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateFacetedStat(intStringTestStart, "perc_20");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest =- (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "perc_20");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "perc_20");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "float", false);- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateFacetedStat(floatDateTestStart, "perc_20");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "float", false);- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateFacetedStat(floatStringTestStart, "perc_20");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateFacetedStat(doubleDateTestStart, "perc_20");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateFacetedStat(doubleStringTestStart, "perc_20");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt =- getValueList(response, "percentile_20", "fieldFacets", "int_id", "date", false);- ArrayList<String> dateIntTest =- (ArrayList<String>) calculateFacetedStat(dateIntTestStart, "perc_20");- assertEqualsList(responseStr, dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString =- getValueList(response, "percentile_20", "fieldFacets", "long_ld", "date", false);- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateFacetedStat(dateLongTestStart, "perc_20");- assertEqualsList(responseStr, dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt =- getValueList(response, "percentile_20", "fieldFacets", "int_id", "str", false);- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateFacetedStat(stringIntTestStart, "perc_20");- assertEqualsList(responseStr, stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong =- getValueList(response, "percentile_20", "fieldFacets", "long_ld", "str", false);- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateFacetedStat(stringLongTestStart, "perc_20");- assertEqualsList(responseStr, stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void perc60Test() throws Exception {- String[] params =- new String[] {- "o.percentile_60n.s.int", "percentile(60,int_id)",- "o.percentile_60n.s.long", "percentile(60,long_ld)",- "o.percentile_60n.s.float", "percentile(60,float_fd)",- "o.percentile_60n.s.double", "percentile(60,double_dd)",- "o.percentile_60n.ff", "string_sd",- "o.percentile_60n.ff", "date_dtd",- "o.percentile_60.s.str", "percentile(60,string_sd)",- "o.percentile_60.s.date", "string(percentile(60,date_dtd))",- "o.percentile_60.ff", "int_id",- "o.percentile_60.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Integer> intDate =- getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "int", false);- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateFacetedStat(intDateTestStart, "perc_60");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Integer> intString =- getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "int", false);- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateFacetedStat(intStringTestStart, "perc_60");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest =- (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "perc_60");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "perc_60");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "float", false);- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateFacetedStat(floatDateTestStart, "perc_60");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "float", false);- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateFacetedStat(floatStringTestStart, "perc_60");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateFacetedStat(doubleDateTestStart, "perc_60");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateFacetedStat(doubleStringTestStart, "perc_60");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt =- getValueList(response, "percentile_60", "fieldFacets", "int_id", "date", false);- ArrayList<String> dateIntTest =- (ArrayList<String>) calculateFacetedStat(dateIntTestStart, "perc_60");- assertEqualsList(responseStr, dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString =- getValueList(response, "percentile_60", "fieldFacets", "long_ld", "date", false);- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateFacetedStat(dateLongTestStart, "perc_60");- assertEqualsList(responseStr, dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt =- getValueList(response, "percentile_60", "fieldFacets", "int_id", "str", false);- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateFacetedStat(stringIntTestStart, "perc_60");- assertEqualsList(responseStr, stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong =- getValueList(response, "percentile_60", "fieldFacets", "long_ld", "str", false);- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateFacetedStat(stringLongTestStart, "perc_60");- assertEqualsList(responseStr, stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void minTest() throws Exception {- String[] params =- new String[] {- "o.minn.s.int", "min(int_id)",- "o.minn.s.long", "min(long_ld)",- "o.minn.s.float", "min(float_fd)",- "o.minn.s.double", "min(double_dd)",- "o.minn.ff", "string_sd",- "o.minn.ff", "date_dtd",- "o.min.s.str", "min(string_sd)",- "o.min.s.date", "string(min(date_dtd))",- "o.min.ff", "int_id",- "o.min.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Integer> intDate =- getValueList(response, "minn", "fieldFacets", "date_dtd", "int", false);- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateFacetedStat(intDateTestStart, "min");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Integer> intString =- getValueList(response, "minn", "fieldFacets", "string_sd", "int", false);- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateFacetedStat(intStringTestStart, "min");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "minn", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "min");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getValueList(response, "minn", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "min");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getValueList(response, "minn", "fieldFacets", "date_dtd", "float", false);- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateFacetedStat(floatDateTestStart, "min");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getValueList(response, "minn", "fieldFacets", "string_sd", "float", false);- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateFacetedStat(floatStringTestStart, "min");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "minn", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateFacetedStat(doubleDateTestStart, "min");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getValueList(response, "minn", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateFacetedStat(doubleStringTestStart, "min");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt =- getValueList(response, "min", "fieldFacets", "int_id", "date", false);- ArrayList<String> dateIntTest =- (ArrayList<String>) calculateFacetedStat(dateIntTestStart, "min");- assertEqualsList(responseStr, dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString =- getValueList(response, "min", "fieldFacets", "long_ld", "date", false);- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateFacetedStat(dateLongTestStart, "min");- assertEqualsList(responseStr, dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt =- getValueList(response, "min", "fieldFacets", "int_id", "str", false);- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateFacetedStat(stringIntTestStart, "min");- assertEqualsList(responseStr, stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong =- getValueList(response, "min", "fieldFacets", "long_ld", "str", false);- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateFacetedStat(stringLongTestStart, "min");- assertEqualsList(responseStr, stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void maxTest() throws Exception {- String[] params =- new String[] {- "o.maxn.s.int", "max(int_id)",- "o.maxn.s.long", "max(long_ld)",- "o.maxn.s.float", "max(float_fd)",- "o.maxn.s.double", "max(double_dd)",- "o.maxn.ff", "string_sd",- "o.maxn.ff", "date_dtd",- "o.max.s.str", "max(string_sd)",- "o.max.s.date", "string(max(date_dtd))",- "o.max.ff", "int_id",- "o.max.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Integer> intDate =- getValueList(response, "maxn", "fieldFacets", "date_dtd", "int", false);- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateFacetedStat(intDateTestStart, "max");- assertEqualsList(responseStr, intDate, intDateTest);-- // Int String- ArrayList<Integer> intString =- getValueList(response, "maxn", "fieldFacets", "string_sd", "int", false);- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateFacetedStat(intStringTestStart, "max");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "maxn", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "max");- assertEqualsList(responseStr, longDate, longDateTest);-- // Long String- ArrayList<Long> longString =- getValueList(response, "maxn", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "max");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getValueList(response, "maxn", "fieldFacets", "date_dtd", "float", false);- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateFacetedStat(floatDateTestStart, "max");- assertEqualsList(responseStr, floatDate, floatDateTest);-- // Float String- ArrayList<Float> floatString =- getValueList(response, "maxn", "fieldFacets", "string_sd", "float", false);- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateFacetedStat(floatStringTestStart, "max");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getValueList(response, "maxn", "fieldFacets", "date_dtd", "double", false);- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateFacetedStat(doubleDateTestStart, "max");- assertEqualsList(responseStr, doubleDate, doubleDateTest);-- // Double String- ArrayList<Double> doubleString =- getValueList(response, "maxn", "fieldFacets", "string_sd", "double", false);- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateFacetedStat(doubleStringTestStart, "max");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // String Int- ArrayList<String> stringInt =- getValueList(response, "max", "fieldFacets", "int_id", "str", false);- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateFacetedStat(stringIntTestStart, "max");- assertEqualsList(responseStr, stringInt, stringIntTest);-- // String Long- ArrayList<String> stringLong =- getValueList(response, "max", "fieldFacets", "long_ld", "str", false);- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateFacetedStat(stringLongTestStart, "max");- assertEqualsList(responseStr, stringLong, stringLongTest);-- // Date Int- ArrayList<String> dateInt =- getValueList(response, "max", "fieldFacets", "int_id", "date", false);- ArrayList<String> dateIntTest =- (ArrayList<String>) calculateFacetedStat(dateIntTestStart, "max");- assertEqualsList(responseStr, dateInt, dateIntTest);-- // Date Long- ArrayList<String> dateString =- getValueList(response, "max", "fieldFacets", "long_ld", "date", false);- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateFacetedStat(dateLongTestStart, "max");- assertEqualsList(responseStr, dateString, dateLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void uniqueTest() throws Exception {- String[] params =- new String[] {- "o.uniquen.s.int", "unique(int_id)",- "o.uniquen.s.long", "unique(long_ld)",- "o.uniquen.s.float", "unique(float_fd)",- "o.uniquen.s.double", "unique(double_dd)",- "o.uniquen.ff", "string_sd",- "o.uniquen.ff", "date_dtd",- "o.unique.s.str", "unique(string_sd)",- "o.unique.s.date", "unique(date_dtd)",- "o.unique.ff", "int_id",- "o.unique.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Long> intDate =- getValueList(response, "uniquen", "fieldFacets", "date_dtd", "int", false);- ArrayList<Long> intDateTest =- (ArrayList<Long>) calculateFacetedStat(intDateTestStart, "unique");- assertEqualsList(responseStr, intDate, intDateTest);- // Int String- ArrayList<Long> intString =- getValueList(response, "uniquen", "fieldFacets", "string_sd", "int", false);- ArrayList<Long> intStringTest =- (ArrayList<Long>) calculateFacetedStat(intStringTestStart, "unique");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "uniquen", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest =- (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "unique");- assertEqualsList(responseStr, longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getValueList(response, "uniquen", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "unique");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Long> floatDate =- getValueList(response, "uniquen", "fieldFacets", "date_dtd", "float", false);- ArrayList<Long> floatDateTest =- (ArrayList<Long>) calculateFacetedStat(floatDateTestStart, "unique");- assertEqualsList(responseStr, floatDate, floatDateTest);- // Float String- ArrayList<Long> floatString =- getValueList(response, "uniquen", "fieldFacets", "string_sd", "float", false);- ArrayList<Long> floatStringTest =- (ArrayList<Long>) calculateFacetedStat(floatStringTestStart, "unique");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Long> doubleDate =- getValueList(response, "uniquen", "fieldFacets", "date_dtd", "double", false);- ArrayList<Long> doubleDateTest =- (ArrayList<Long>) calculateFacetedStat(doubleDateTestStart, "unique");- assertEqualsList(responseStr, doubleDate, doubleDateTest);- // Double String- ArrayList<Long> doubleString =- getValueList(response, "uniquen", "fieldFacets", "string_sd", "double", false);- ArrayList<Long> doubleStringTest =- (ArrayList<Long>) calculateFacetedStat(doubleStringTestStart, "unique");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // Date Int- ArrayList<Long> dateInt =- getValueList(response, "unique", "fieldFacets", "int_id", "date", false);- ArrayList<Long> dateIntTest =- (ArrayList<Long>) calculateFacetedStat(dateIntTestStart, "unique");- assertEqualsList(responseStr, dateInt, dateIntTest);- // Date Long- ArrayList<Long> dateString =- getValueList(response, "unique", "fieldFacets", "long_ld", "date", false);- ArrayList<Long> dateLongTest =- (ArrayList<Long>) calculateFacetedStat(dateLongTestStart, "unique");- assertEqualsList(responseStr, dateString, dateLongTest);-- // String Int- ArrayList<Long> stringInt =- getValueList(response, "unique", "fieldFacets", "int_id", "str", false);- ArrayList<Long> stringIntTest =- (ArrayList<Long>) calculateFacetedStat(stringIntTestStart, "unique");- assertEqualsList(responseStr, stringInt, stringIntTest);- // String Long- ArrayList<Long> stringLong =- getValueList(response, "unique", "fieldFacets", "long_ld", "str", false);- ArrayList<Long> stringLongTest =- (ArrayList<Long>) calculateFacetedStat(stringLongTestStart, "unique");- assertEqualsList(responseStr, stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void countTest() throws Exception {- String[] params =- new String[] {- "o.countn.s.int", "count(int_id)",- "o.countn.s.long", "count(long_ld)",- "o.countn.s.float", "count(float_fd)",- "o.countn.s.double", "count(double_dd)",- "o.countn.ff", "string_sd",- "o.countn.ff", "date_dtd",- "o.count.s.str", "count(string_sd)",- "o.count.s.date", "count(date_dtd)",- "o.count.ff", "int_id",- "o.count.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Long> intDate =- getValueList(response, "countn", "fieldFacets", "date_dtd", "int", false);- ArrayList<Long> intDateTest = (ArrayList<Long>) calculateFacetedStat(intDateTestStart, "count");- assertEqualsList(responseStr, intDate, intDateTest);-- // Int String- ArrayList<Long> intString =- getValueList(response, "countn", "fieldFacets", "string_sd", "int", false);- ArrayList<Long> intStringTest =- (ArrayList<Long>) calculateFacetedStat(intStringTestStart, "count");- assertEqualsList(responseStr, intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "countn", "fieldFacets", "date_dtd", "long", false);- ArrayList<Long> longDateTest =- (ArrayList<Long>) calculateFacetedStat(longDateTestStart, "count");- assertEqualsList(responseStr, longDate, longDateTest);-- // Long String- ArrayList<Long> longString =- getValueList(response, "countn", "fieldFacets", "string_sd", "long", false);- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateFacetedStat(longStringTestStart, "count");- assertEqualsList(responseStr, longString, longStringTest);-- // Float Date- ArrayList<Long> floatDate =- getValueList(response, "countn", "fieldFacets", "date_dtd", "float", false);- ArrayList<Long> floatDateTest =- (ArrayList<Long>) calculateFacetedStat(floatDateTestStart, "count");- assertEqualsList(responseStr, floatDate, floatDateTest);-- // Float String- ArrayList<Long> floatString =- getValueList(response, "countn", "fieldFacets", "string_sd", "float", false);- ArrayList<Long> floatStringTest =- (ArrayList<Long>) calculateFacetedStat(floatStringTestStart, "count");- assertEqualsList(responseStr, floatString, floatStringTest);-- // Double Date- ArrayList<Long> doubleDate =- getValueList(response, "countn", "fieldFacets", "date_dtd", "double", false);- ArrayList<Long> doubleDateTest =- (ArrayList<Long>) calculateFacetedStat(doubleDateTestStart, "count");- assertEqualsList(responseStr, doubleDate, doubleDateTest);-- // Double String- ArrayList<Long> doubleString =- getValueList(response, "countn", "fieldFacets", "string_sd", "double", false);- ArrayList<Long> doubleStringTest =- (ArrayList<Long>) calculateFacetedStat(doubleStringTestStart, "count");- assertEqualsList(responseStr, doubleString, doubleStringTest);-- // Date Int- ArrayList<Long> dateInt =- getValueList(response, "count", "fieldFacets", "int_id", "date", false);- ArrayList<Long> dateIntTest = (ArrayList<Long>) calculateFacetedStat(dateIntTestStart, "count");- assertEqualsList(responseStr, dateIntTest, dateInt);-- // Date Long- ArrayList<Long> dateLong =- getValueList(response, "count", "fieldFacets", "long_ld", "date", false);- ArrayList<Long> dateLongTest =- (ArrayList<Long>) calculateFacetedStat(dateLongTestStart, "count");- assertEqualsList(responseStr, dateLong, dateLongTest);-- // String Int- ArrayList<Long> stringInt =- getValueList(response, "count", "fieldFacets", "int_id", "str", false);- ArrayList<Long> stringIntTest =- (ArrayList<Long>) calculateFacetedStat(stringIntTestStart, "count");- assertEqualsList(responseStr, stringInt, stringIntTest);-- // String Long- ArrayList<Long> stringLong =- getValueList(response, "count", "fieldFacets", "long_ld", "str", false);- ArrayList<Long> stringLongTest =- (ArrayList<Long>) calculateFacetedStat(stringLongTestStart, "count");- assertEqualsList(responseStr, stringLong, stringLongTest);- }-- @Test- public void missingTest() throws Exception {- String[] params =- new String[] {- "o.missingn.s.int", "missing(int_id)",- "o.missingn.s.long", "missing(long_ld)",- "o.missingn.s.float", "missing(float_fd)",- "o.missingn.s.double", "missing(double_dd)",- "o.missingn.ff", "string_sd",- "o.missingn.ff", "date_dtd",- "o.missing.s.str", "missing(string_sd)",- "o.missing.s.date", "missing(date_dtd)",- "o.missing.ff", "int_id",- "o.missing.ff", "long_ld"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Date- ArrayList<Long> intDate =- getValueList(response, "missingn", "fieldFacets", "date_dtd", "int", false);- setLatestType("int");- assertEqualsList(responseStr, intDateTestMissing, intDate);-- // Int String- ArrayList<Long> intString =- getValueList(response, "missingn", "fieldFacets", "string_sd", "int", false);- assertEqualsList(responseStr, intStringTestMissing, intString);-- // Long Date- ArrayList<Long> longDate =- getValueList(response, "missingn", "fieldFacets", "date_dtd", "long", false);- setLatestType("long");- assertEqualsList(responseStr, longDateTestMissing, longDate);-- // Long String- ArrayList<Long> longString =- getValueList(response, "missingn", "fieldFacets", "string_sd", "long", false);- assertEqualsList(responseStr, longStringTestMissing, longString);-- // Float Date- ArrayList<Long> floatDate =- getValueList(response, "missingn", "fieldFacets", "date_dtd", "float", false);- setLatestType("float");- assertEqualsList(responseStr, floatDateTestMissing, floatDate);-- // Float String- ArrayList<Long> floatString =- getValueList(response, "missingn", "fieldFacets", "string_sd", "float", false);- assertEqualsList(responseStr, floatStringTestMissing, floatString);-- // Double Date- ArrayList<Long> doubleDate =- getValueList(response, "missingn", "fieldFacets", "date_dtd", "double", false);- setLatestType("double");- assertEqualsList(responseStr, doubleDateTestMissing, doubleDate);-- // Double String- ArrayList<Long> doubleString =- getValueList(response, "missingn", "fieldFacets", "string_sd", "double", false);- assertEqualsList(responseStr, doubleStringTestMissing, doubleString);-- // Date Int- ArrayList<Long> dateInt =- getValueList(response, "missing", "fieldFacets", "int_id", "date", false);- setLatestType("date");- assertEqualsList(responseStr, dateIntTestMissing, dateInt);-- // Date Long- ArrayList<Long> dateLong =- getValueList(response, "missing", "fieldFacets", "long_ld", "date", false);- assertEqualsList(responseStr, dateLongTestMissing, dateLong);-- // String Int- ArrayList<Long> stringInt =- getValueList(response, "missing", "fieldFacets", "int_id", "str", false);- setLatestType("string");- assertEqualsList(responseStr, stringIntTestMissing, stringInt);-- // String Long- ArrayList<Long> stringLong =- getValueList(response, "missing", "fieldFacets", "long_ld", "str", false);- assertEqualsList(responseStr, stringLongTestMissing, stringLong);- }-- @SuppressWarnings("unchecked")- @Test- public void multiValueTest() throws Exception {- String[] params =- new String[] {- "o.multivalued.s.mean", "mean(int_id)",- "o.multivalued.ff", "long_ldm",- "o.multivalued.ff", "string_sdm",- "o.multivalued.ff", "date_dtdm"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Long- ArrayList<Double> lon =- getValueList(response, "multivalued", "fieldFacets", "long_ldm", "mean", false);- ArrayList<Double> longTest = calculateFacetedNumberStat(multiLongTestStart, "mean");- assertEqualsList(responseStr, lon, longTest);- // Date- ArrayList<Double> date =- getValueList(response, "multivalued", "fieldFacets", "date_dtdm", "mean", false);- ArrayList<Double> dateTest = calculateFacetedNumberStat(multiDateTestStart, "mean");- assertEqualsList(responseStr, date, dateTest);- // String- ArrayList<Double> string =- getValueList(response, "multivalued", "fieldFacets", "string_sdm", "mean", false);- ArrayList<Double> stringTest = calculateFacetedNumberStat(multiStringTestStart, "mean");- assertEqualsList(responseStr, string, stringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void missingFacetTest() throws Exception {- String[] params =- new String[] {- "o.missingf.s.mean", "mean(int_id)",- "o.missingf.ff", "date_dtd",- "o.missingf.ff", "string_sd",- "o.missingf.ff.string_sd.sm", "true",- "o.missingf.ff", "date_dtdm",- "o.missingf.ff.date_dtdm.sm", "true"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // int MultiDate- assertTrue(- responseStr,- responseContainsFacetValue(response, "missingf", "fieldFacets", "date_dtdm", "(MISSING)"));- ArrayList<Double> string =- getValueList(response, "missingf", "fieldFacets", "date_dtdm", "mean", false);- ArrayList<Double> stringTest = calculateFacetedNumberStat(multiDateTestStart, "mean");- assertEqualsList(responseStr, string, stringTest);-- // Int String- assertTrue(- responseStr,- responseContainsFacetValue(response, "missingf", "fieldFacets", "string_sd", "(MISSING)"));- assertFalse(- responseStr,- responseContainsFacetValue(response, "missingf", "fieldFacets", "string_sd", "str0"));- ArrayList<Double> intString =- getValueList(response, "missingf", "fieldFacets", "string_sd", "mean", false);- ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "mean");- assertEqualsList(responseStr, intString, intStringTest);-- // Int Date- ArrayList<Double> intDate =- getValueList(response, "missingf", "fieldFacets", "date_dtd", "mean", false);- ArrayList<ArrayList<Double>> intDateMissingTestStart =- (ArrayList<ArrayList<Double>>) intDateTestStart.clone();- ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateMissingTestStart, "mean");- assertEqualsList(responseStr, intDate, intDateTest);- }-- private void checkStddevs(- NamedList<Object> response, ArrayList<Double> list1, ArrayList<Double> list2) {- Collections.sort(list1);- Collections.sort(list2);- for (int i = 0; i < list2.size(); i++) {- if ((Math.abs(list1.get(i) - list2.get(i)) < .00000000001) == false) {- assertEquals(response.toString(), list1.get(i), list2.get(i), 0.00000000001);- }- }- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public static void assertEqualsList(- String mes,- ArrayList<? extends Comparable> actual,- ArrayList<? extends Comparable> expected) {- Collections.sort(actual);- Collections.sort(expected);- assertEquals(mes, actual, expected);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasCloudTest.javadeleted file mode 100644index d0002ad5ad8..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasCloudTest.java+++ /dev/null@@ -1,260 +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.legacy.facet;--import java.util.ArrayList;-import java.util.Collection;-import java.util.Collections;-import java.util.List;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.common.util.NamedList;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyFieldFacetExtrasCloudTest extends LegacyAbstractAnalyticsFacetCloudTest {- public static final int INT = 21;- public static final int LONG = 22;- public static final int FLOAT = 23;- public static final int DOUBLE = 24;- public static final int DATE = 25;- public static final int STRING = 26;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<ArrayList<Integer>> intLongTestStart;- static ArrayList<ArrayList<Integer>> intFloatTestStart;- static ArrayList<ArrayList<Integer>> intDoubleTestStart;- static ArrayList<ArrayList<Integer>> intStringTestStart;-- @BeforeClass- public static void beforeTest() throws Exception {-- // INT- intLongTestStart = new ArrayList<>();- intFloatTestStart = new ArrayList<>();- intDoubleTestStart = new ArrayList<>();- intStringTestStart = new ArrayList<>();-- UpdateRequest req = new UpdateRequest();-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;-- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);- fields.add("int_id");- fields.add("" + i);- fields.add("long_ld");- fields.add("" + l);- fields.add("float_fd");- fields.add("" + f);- fields.add("double_dd");- fields.add("" + d);- fields.add("date_dtd");- fields.add((1800 + dt) + "-12-31T23:59:59.999Z");- fields.add("string_sd");- fields.add("abc" + s);- req.add(fields.toArray(new String[0]));-- // Long- if (j - LONG < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intLongTestStart.add(list1);- } else {- intLongTestStart.get((int) l).add(i);- }- // String- if (j - FLOAT < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intFloatTestStart.add(list1);- } else {- intFloatTestStart.get((int) f).add(i);- }- // String- if (j - DOUBLE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDoubleTestStart.add(list1);- } else {- intDoubleTestStart.get((int) d).add(i);- }- // String- if (j - STRING < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intStringTestStart.add(list1);- } else {- intStringTestStart.get(s).add(i);- }- }-- req.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- @Test- public void limitTest() throws Exception {- String[] params =- new String[] {- "o.lr.s.mean", "mean(int_id)",- "o.lr.s.median", "median(int_id)",- "o.lr.s.count", "count(int_id)",- "o.lr.s.percentile_20", "percentile(20,int_id)",- "o.lr.ff.long_ld", "long_ld",- "o.lr.ff.long_ld.ss", "mean",- "o.lr.ff.long_ld.sd", "asc",- "o.lr.ff.long_ld.limit", "5",- "o.lr.ff.float_fd", "float_fd",- "o.lr.ff.float_fd.ss", "median",- "o.lr.ff.float_fd.sd", "desc",- "o.lr.ff.float_fd.limit", "3",- "o.lr.ff.double_dd", "double_dd",- "o.lr.ff.double_dd.ss", "count",- "o.lr.ff.double_dd.sd", "asc",- "o.lr.ff.double_dd.limit", "7",- "o.lr.ff.string_sd", "string_sd",- "o.lr.ff.string_sd.ss", "percentile_20",- "o.lr.ff.string_sd.sd", "desc",- "o.lr.ff.string_sd.limit", "1"- };-- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- Collection<Double> lon = getValueList(response, "lr", "fieldFacets", "long_ld", "mean", false);- assertEquals(responseStr, lon.size(), 5);- Collection<Double> flo =- getValueList(response, "lr", "fieldFacets", "float_fd", "median", false);- assertEquals(responseStr, flo.size(), 3);- Collection<Long> doub =- getValueList(response, "lr", "fieldFacets", "double_dd", "count", false);- assertEquals(responseStr, doub.size(), 7);- Collection<Integer> string =- getValueList(response, "lr", "fieldFacets", "string_sd", "percentile_20", false);- assertEquals(responseStr, string.size(), 1);- }-- @Test- public void offsetTest() throws Exception {- String[] params =- new String[] {- "o.offAll.s.mean", "mean(int_id)",- "o.offAll.ff", "long_ld",- "o.offAll.ff.long_ld.ss", "mean",- "o.offAll.ff.long_ld.sd", "asc",- "o.offAll.ff.long_ld.limit", "7",- "o.off0.s.mean", "mean(int_id)",- "o.off0.ff", "long_ld",- "o.off0.ff.long_ld.ss", "mean",- "o.off0.ff.long_ld.sd", "asc",- "o.off0.ff.long_ld.limit", "2",- "o.off0.ff.long_ld.offset", "0",- "o.off1.s.mean", "mean(int_id)",- "o.off1.ff", "long_ld",- "o.off1.ff.long_ld.ss", "mean",- "o.off1.ff.long_ld.sd", "asc",- "o.off1.ff.long_ld.limit", "2",- "o.off1.ff.long_ld.offset", "2",- "o.off2.s.mean", "mean(int_id)",- "o.off2.ff", "long_ld",- "o.off2.ff.long_ld.ss", "mean",- "o.off2.ff.long_ld.sd", "asc",- "o.off2.ff.long_ld.limit", "3",- "o.off2.ff.long_ld.offset", "4"- };-- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- Collection<Double> lon;-- List<Double> all = new ArrayList<>();- lon = getValueList(response, "off0", "fieldFacets", "long_ld", "mean", false);- assertEquals(responseStr, lon.size(), 2);- assertArrayEquals(new Double[] {1.5, 2.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getValueList(response, "off1", "fieldFacets", "long_ld", "mean", false);- assertEquals(responseStr, lon.size(), 2);- assertArrayEquals(new Double[] {3.0, 4.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getValueList(response, "off2", "fieldFacets", "long_ld", "mean", false);- assertEquals(responseStr, lon.size(), 3);- assertArrayEquals(new Double[] {5.0, 5.75, 6.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getValueList(response, "offAll", "fieldFacets", "long_ld", "mean", false);- assertEquals(responseStr, lon.size(), 7);- assertArrayEquals(all.toArray(new Double[0]), lon.toArray(new Double[0]));- }-- @SuppressWarnings("unchecked")- @Test- public void sortTest() throws Exception {- String[] params =- new String[] {- "o.sr.s.mean", "mean(int_id)",- "o.sr.s.median", "median(int_id)",- "o.sr.s.count", "count(int_id)",- "o.sr.s.percentile_20", "percentile(20,int_id)",- "o.sr.ff", "long_ld",- "o.sr.ff.long_ld.ss", "mean",- "o.sr.ff.long_ld.sd", "asc",- "o.sr.ff", "float_fd",- "o.sr.ff.float_fd.ss", "median",- "o.sr.ff.float_fd.sd", "desc",- "o.sr.ff", "double_dd",- "o.sr.ff.double_dd.ss", "count",- "o.sr.ff.double_dd.sd", "asc",- "o.sr.ff", "string_sd",- "o.sr.ff.string_sd.ss", "percentile_20",- "o.sr.ff.string_sd.sd", "desc"- };-- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- List<Double> lon = getValueList(response, "sr", "fieldFacets", "long_ld", "mean", false);- List<Double> longTest = calculateFacetedNumberStat(intLongTestStart, "mean");- Collections.sort(longTest);- assertEquals(responseStr, longTest, lon);-- List<Double> flo = getValueList(response, "sr", "fieldFacets", "float_fd", "median", false);- List<Double> floatTest = calculateFacetedNumberStat(intFloatTestStart, "median");- floatTest.sort(Collections.reverseOrder());- assertEquals(responseStr, floatTest, flo);-- List<Long> doub = getValueList(response, "sr", "fieldFacets", "double_dd", "count", false);- List<Long> doubleTest = (List<Long>) calculateFacetedStat(intDoubleTestStart, "count");- Collections.sort(doubleTest);- assertEquals(responseStr, doubleTest, doub);-- List<Integer> string =- getValueList(response, "sr", "fieldFacets", "string_sd", "percentile_20", false);- List<Integer> stringTest = (List<Integer>) calculateFacetedStat(intStringTestStart, "perc_20");- stringTest.sort(Collections.reverseOrder());- assertEquals(responseStr, stringTest, string);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasTest.javadeleted file mode 100644index f22921a4c44..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetExtrasTest.java+++ /dev/null@@ -1,182 +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.legacy.facet;--import java.util.ArrayList;-import java.util.Collection;-import java.util.Collections;-import java.util.List;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyFieldFacetExtrasTest extends LegacyAbstractAnalyticsFacetTest {- static String fileName = "fieldFacetExtras.txt";-- public static final int INT = 21;- public static final int LONG = 22;- public static final int FLOAT = 23;- public static final int DOUBLE = 24;- public static final int DATE = 25;- public static final int STRING = 26;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<ArrayList<Integer>> intLongTestStart;- static ArrayList<ArrayList<Integer>> intFloatTestStart;- static ArrayList<ArrayList<Integer>> intDoubleTestStart;- static ArrayList<ArrayList<Integer>> intStringTestStart;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- // INT- intLongTestStart = new ArrayList<>();- intFloatTestStart = new ArrayList<>();- intDoubleTestStart = new ArrayList<>();- intStringTestStart = new ArrayList<>();-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;- assertU(- adoc(- "id",- "1000" + j,- "int_id",- "" + i,- "long_ld",- "" + l,- "float_fd",- "" + f,- "double_dd",- "" + d,- "date_dtd",- (1800 + dt) + "-12-31T23:59:59.999Z",- "string_sd",- "abc" + s));- // Long- if (j - LONG < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intLongTestStart.add(list1);- } else {- intLongTestStart.get((int) l).add(i);- }- // String- if (j - FLOAT < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intFloatTestStart.add(list1);- } else {- intFloatTestStart.get((int) f).add(i);- }- // String- if (j - DOUBLE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDoubleTestStart.add(list1);- } else {- intDoubleTestStart.get((int) d).add(i);- }- // String- if (j - STRING < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intStringTestStart.add(list1);- } else {- intStringTestStart.get(s).add(i);- }-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());- setResponse(h.query(request(fileToStringArr(LegacyFieldFacetExtrasTest.class, fileName))));- }-- @Test- public void limitTest() throws Exception {-- Collection<Double> lon = getDoubleList("lr", "fieldFacets", "long_ld", "double", "mean");- assertEquals(getRawResponse(), lon.size(), 5);- Collection<Double> flo = getDoubleList("lr", "fieldFacets", "float_fd", "double", "median");- assertEquals(getRawResponse(), flo.size(), 3);- Collection<Long> doub = getLongList("lr", "fieldFacets", "double_dd", "long", "count");- assertEquals(getRawResponse(), doub.size(), 7);- Collection<Integer> string =- getIntegerList("lr", "fieldFacets", "string_sd", "int", "percentile_20");- assertEquals(getRawResponse(), string.size(), 1);- }-- @Test- public void offsetTest() throws Exception {-- Collection<Double> lon;-- List<Double> all = new ArrayList<>();- lon = getDoubleList("off0", "fieldFacets", "long_ld", "double", "mean");- assertEquals(getRawResponse(), lon.size(), 2);- assertArrayEquals(new Double[] {1.5, 2.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getDoubleList("off1", "fieldFacets", "long_ld", "double", "mean");- assertEquals(getRawResponse(), lon.size(), 2);- assertArrayEquals(new Double[] {3.0, 4.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getDoubleList("off2", "fieldFacets", "long_ld", "double", "mean");- assertEquals(getRawResponse(), lon.size(), 3);- assertArrayEquals(new Double[] {5.0, 5.75, 6.0}, lon.toArray(new Double[0]));- all.addAll(lon);-- lon = getDoubleList("offAll", "fieldFacets", "long_ld", "double", "mean");- assertEquals(getRawResponse(), lon.size(), 7);- assertArrayEquals(all.toArray(new Double[0]), lon.toArray(new Double[0]));- }-- @SuppressWarnings("unchecked")- @Test- public void sortTest() throws Exception {- List<Double> lon = getDoubleList("sr", "fieldFacets", "long_ld", "double", "mean");- List<Double> longTest = calculateNumberStat(intLongTestStart, "mean");- Collections.sort(longTest);- assertEquals(getRawResponse(), longTest, lon);-- List<Double> flo = getDoubleList("sr", "fieldFacets", "float_fd", "double", "median");- List<Double> floatTest = calculateNumberStat(intFloatTestStart, "median");- floatTest.sort(Collections.reverseOrder());- assertEquals(getRawResponse(), floatTest, flo);-- List<Long> doub = getLongList("sr", "fieldFacets", "double_dd", "long", "count");- List<Long> doubleTest = (List<Long>) calculateStat(intDoubleTestStart, "count");- Collections.sort(doubleTest);- assertEquals(getRawResponse(), doubleTest, doub);-- List<Integer> string = getIntegerList("sr", "fieldFacets", "string_sd", "int", "percentile_20");- List<Integer> stringTest = (List<Integer>) calculateStat(intStringTestStart, "perc_20");- stringTest.sort(Collections.reverseOrder());- assertEquals(getRawResponse(), stringTest, string);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetTest.javadeleted file mode 100644index 7b08517638e..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyFieldFacetTest.java+++ /dev/null@@ -1,1234 +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.legacy.facet;--import java.util.ArrayList;-import java.util.Collections;-import java.util.List;-import org.apache.solr.common.params.CommonParams;-import org.apache.solr.request.SolrQueryRequest;-import org.apache.solr.response.SolrQueryResponse;-import org.junit.BeforeClass;-import org.junit.Test;-import org.w3c.dom.Node;--public class LegacyFieldFacetTest extends LegacyAbstractAnalyticsFacetTest {- static String fileName = "fieldFacets.txt";-- public static final int INT = 71;- public static final int LONG = 36;- public static final int LONGM = 50;- public static final int FLOAT = 73;- public static final int FLOATM = 84;- public static final int DOUBLE = 49;- public static final int DATE = 12;- public static final int DATEM = 30;- public static final int STRING = 28;- public static final int STRINGM = 40;- public static final int NUM_LOOPS = 100;-- // INT- private static ArrayList<ArrayList<Integer>> intDateTestStart;- private static ArrayList<Long> intDateTestMissing;- private static ArrayList<ArrayList<Integer>> intStringTestStart;- private static ArrayList<Long> intStringTestMissing;-- // LONG- private static ArrayList<ArrayList<Long>> longDateTestStart;- private static ArrayList<Long> longDateTestMissing;- private static ArrayList<ArrayList<Long>> longStringTestStart;- private static ArrayList<Long> longStringTestMissing;-- // FLOAT- private static ArrayList<ArrayList<Float>> floatDateTestStart;- private static ArrayList<Long> floatDateTestMissing;- private static ArrayList<ArrayList<Float>> floatStringTestStart;- private static ArrayList<Long> floatStringTestMissing;-- // DOUBLE- private static ArrayList<ArrayList<Double>> doubleDateTestStart;- private static ArrayList<Long> doubleDateTestMissing;- private static ArrayList<ArrayList<Double>> doubleStringTestStart;- private static ArrayList<Long> doubleStringTestMissing;-- // DATE- private static ArrayList<ArrayList<String>> dateIntTestStart;- private static ArrayList<Long> dateIntTestMissing;- private static ArrayList<ArrayList<String>> dateLongTestStart;- private static ArrayList<Long> dateLongTestMissing;-- // String- private static ArrayList<ArrayList<String>> stringIntTestStart;- private static ArrayList<Long> stringIntTestMissing;- private static ArrayList<ArrayList<String>> stringLongTestStart;- private static ArrayList<Long> stringLongTestMissing;-- // Multi-Valued- private static ArrayList<ArrayList<Integer>> multiLongTestStart;- private static ArrayList<Long> multiLongTestMissing;- private static ArrayList<ArrayList<Integer>> multiStringTestStart;- private static ArrayList<Long> multiStringTestMissing;- private static ArrayList<ArrayList<Integer>> multiDateTestStart;- private static ArrayList<Long> multiDateTestMissing;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- defaults.put("int", 0);- defaults.put("long", 0L);- defaults.put("float", (float) 0);- defaults.put("double", (double) 0);- defaults.put("date", "1800-12-31T23:59:59Z");- defaults.put("string", "str0");-- // INT- intDateTestStart = new ArrayList<>();- intDateTestMissing = new ArrayList<>();- intStringTestStart = new ArrayList<>();- intStringTestMissing = new ArrayList<>();-- // LONG- longDateTestStart = new ArrayList<>();- longDateTestMissing = new ArrayList<>();- longStringTestStart = new ArrayList<>();- longStringTestMissing = new ArrayList<>();-- // FLOAT- floatDateTestStart = new ArrayList<>();- floatDateTestMissing = new ArrayList<>();- floatStringTestStart = new ArrayList<>();- floatStringTestMissing = new ArrayList<>();-- // DOUBLE- doubleDateTestStart = new ArrayList<>();- doubleDateTestMissing = new ArrayList<>();- doubleStringTestStart = new ArrayList<>();- doubleStringTestMissing = new ArrayList<>();-- // DATE- dateIntTestStart = new ArrayList<>();- dateIntTestMissing = new ArrayList<>();- dateLongTestStart = new ArrayList<>();- dateLongTestMissing = new ArrayList<>();-- // String- stringIntTestStart = new ArrayList<>();- stringIntTestMissing = new ArrayList<>();- stringLongTestStart = new ArrayList<>();- stringLongTestMissing = new ArrayList<>();-- // Multi-Valued- multiLongTestStart = new ArrayList<>();- multiLongTestMissing = new ArrayList<>();- multiStringTestStart = new ArrayList<>();- multiStringTestMissing = new ArrayList<>();- multiDateTestStart = new ArrayList<>();- multiDateTestMissing = new ArrayList<>();-- boolean multiCanHaveDuplicates = Boolean.getBoolean(NUMERIC_POINTS_SYSPROP);-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- long lm = j % LONGM;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int dtm = j % DATEM;- int s = j % STRING;- int sm = j % STRINGM;-- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);-- if (i != 0) {- fields.add("int_id");- fields.add("" + i);- }- if (l != 0l) {- fields.add("long_ld");- fields.add("" + l);- fields.add("long_ldm");- fields.add("" + l);- }- if (lm != 0l) {- fields.add("long_ldm");- fields.add("" + lm);- }- if (f != 0.0f) {- fields.add("float_fd");- fields.add("" + f);- }- if (d != 0.0d) {- fields.add("double_dd");- fields.add("" + d);- }- if (dt != 0) {- fields.add("date_dtd");- fields.add((1800 + dt) + "-12-31T23:59:59Z");- fields.add("date_dtdm");- fields.add((1800 + dt) + "-12-31T23:59:59Z");- }- if (dtm != 0) {- fields.add("date_dtdm");- fields.add((1800 + dtm) + "-12-31T23:59:59Z");- }- if (s != 0) {- fields.add("string_sd");- fields.add("str" + s);- fields.add("string_sdm");- fields.add("str" + s);- }- if (sm != 0) {- fields.add("string_sdm");- fields.add("str" + sm);- }- assertU(adoc(fields.toArray(new String[0])));-- if (dt != 0) {- // Dates- if (j - DATE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- intDateTestMissing.add(0l);- } else {- intDateTestMissing.add(1l);- }- intDateTestStart.add(list1);- ArrayList<Long> list2 = new ArrayList<>();- if (l != 0l) {- list2.add(l);- longDateTestMissing.add(0l);- } else {- longDateTestMissing.add(1l);- }- longDateTestStart.add(list2);- ArrayList<Float> list3 = new ArrayList<>();- if (f != 0.0f) {- list3.add(f);- floatDateTestMissing.add(0l);- } else {- floatDateTestMissing.add(1l);- }- floatDateTestStart.add(list3);- ArrayList<Double> list4 = new ArrayList<>();- if (d != 0.0d) {- list4.add(d);- doubleDateTestMissing.add(0l);- } else {- doubleDateTestMissing.add(1l);- }- doubleDateTestStart.add(list4);- ArrayList<Integer> list5 = new ArrayList<>();- if (i != 0) {- list5.add(i);- multiDateTestMissing.add(0l);- } else {- multiDateTestMissing.add(1l);- }- multiDateTestStart.add(list5);- } else {- if (i != 0) intDateTestStart.get(dt - 1).add(i);- else increment(intDateTestMissing, dt - 1);- if (l != 0l) longDateTestStart.get(dt - 1).add(l);- else increment(longDateTestMissing, dt - 1);- if (f != 0.0f) floatDateTestStart.get(dt - 1).add(f);- else increment(floatDateTestMissing, dt - 1);- if (d != 0.0d) doubleDateTestStart.get(dt - 1).add(d);- else increment(doubleDateTestMissing, dt - 1);- if (i != 0) multiDateTestStart.get(dt - 1).add(i);- else increment(multiDateTestMissing, dt - 1);- }- }-- if (dtm != 0) {- if (j - DATEM < 0 && dtm != dt) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiDateTestMissing.add(0l);- } else {- multiDateTestMissing.add(1l);- }- multiDateTestStart.add(list1);- } else if (dtm != dt || multiCanHaveDuplicates) {- if (i != 0) multiDateTestStart.get(dtm - 1).add(i);- else increment(multiDateTestMissing, dtm - 1);- }- }-- if (s != 0) {- // Strings- if (j - STRING < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- intStringTestMissing.add(0l);- } else {- intStringTestMissing.add(1l);- }- intStringTestStart.add(list1);- ArrayList<Long> list2 = new ArrayList<>();- if (l != 0l) {- list2.add(l);- longStringTestMissing.add(0l);- } else {- longStringTestMissing.add(1l);- }- longStringTestStart.add(list2);- ArrayList<Float> list3 = new ArrayList<>();- if (f != 0.0f) {- list3.add(f);- floatStringTestMissing.add(0l);- } else {- floatStringTestMissing.add(1l);- }- floatStringTestStart.add(list3);- ArrayList<Double> list4 = new ArrayList<>();- if (d != 0.0d) {- list4.add(d);- doubleStringTestMissing.add(0l);- } else {- doubleStringTestMissing.add(1l);- }- doubleStringTestStart.add(list4);- ArrayList<Integer> list5 = new ArrayList<>();- if (i != 0) {- list5.add(i);- multiStringTestMissing.add(0l);- } else {- multiStringTestMissing.add(1l);- }- multiStringTestStart.add(list5);- } else {- if (i != 0) intStringTestStart.get(s - 1).add(i);- else increment(intStringTestMissing, s - 1);- if (l != 0l) longStringTestStart.get(s - 1).add(l);- else increment(longStringTestMissing, s - 1);- if (f != 0.0f) floatStringTestStart.get(s - 1).add(f);- else increment(floatStringTestMissing, s - 1);- if (d != 0.0d) doubleStringTestStart.get(s - 1).add(d);- else increment(doubleStringTestMissing, s - 1);- if (i != 0) multiStringTestStart.get(s - 1).add(i);- else increment(multiStringTestMissing, s - 1);- }- }-- // Strings- if (sm != 0) {- if (j - STRINGM < 0 && sm != s) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiStringTestMissing.add(0l);- } else {- multiStringTestMissing.add(1l);- }- multiStringTestStart.add(list1);- } else if (sm != s) {- if (i != 0) multiStringTestStart.get(sm - 1).add(i);- else increment(multiStringTestMissing, sm - 1);- }- }-- // Int- if (i != 0) {- if (j - INT < 0) {- ArrayList<String> list1 = new ArrayList<>();- if (dt != 0) {- list1.add((1800 + dt) + "-12-31T23:59:59Z");- dateIntTestMissing.add(0l);- } else {- dateIntTestMissing.add(1l);- }- dateIntTestStart.add(list1);- ArrayList<String> list2 = new ArrayList<>();- if (s != 0) {- list2.add("str" + s);- stringIntTestMissing.add(0l);- } else {- stringIntTestMissing.add(1l);- }- stringIntTestStart.add(list2);- } else {- if (dt != 0) dateIntTestStart.get(i - 1).add((1800 + dt) + "-12-31T23:59:59Z");- else increment(dateIntTestMissing, i - 1);- if (s != 0) stringIntTestStart.get(i - 1).add("str" + s);- else increment(stringIntTestMissing, i - 1);- }- }-- // Long- if (l != 0) {- if (j - LONG < 0) {- ArrayList<String> list1 = new ArrayList<>();- if (dt != 0) {- list1.add((1800 + dt) + "-12-31T23:59:59Z");- dateLongTestMissing.add(0l);- } else {- dateLongTestMissing.add(1l);- }- dateLongTestStart.add(list1);- ArrayList<String> list2 = new ArrayList<>();- if (s != 0) {- list2.add("str" + s);- stringLongTestMissing.add(0l);- } else {- stringLongTestMissing.add(1l);- }- stringLongTestStart.add(list2);- ArrayList<Integer> list3 = new ArrayList<>();- if (i != 0) {- list3.add(i);- multiLongTestMissing.add(0l);- } else {- multiLongTestMissing.add(1l);- }- multiLongTestStart.add(list3);- } else {- if (dt != 0) dateLongTestStart.get((int) l - 1).add((1800 + dt) + "-12-31T23:59:59Z");- else increment(dateLongTestMissing, (int) l - 1);- if (s != 0) stringLongTestStart.get((int) l - 1).add("str" + s);- else increment(stringLongTestMissing, (int) l - 1);- if (i != 0) multiLongTestStart.get((int) l - 1).add(i);- else increment(multiLongTestMissing, (int) l - 1);- }- }-- // Long- if (lm != 0) {- if (j - LONGM < 0 && lm != l) {- ArrayList<Integer> list1 = new ArrayList<>();- if (i != 0) {- list1.add(i);- multiLongTestMissing.add(0l);- } else {- multiLongTestMissing.add(1l);- }- multiLongTestStart.add(list1);- } else if (lm != l || multiCanHaveDuplicates) {- if (i != 0) multiLongTestStart.get((int) lm - 1).add(i);- else increment(multiLongTestMissing, (int) lm - 1);- }- }-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());- String[] reqFacetParamas = fileToStringArr(LegacyFieldFacetTest.class, fileName);- String[] reqParamas = new String[reqFacetParamas.length + 2];- System.arraycopy(reqFacetParamas, 0, reqParamas, 0, reqFacetParamas.length);- reqParamas[reqFacetParamas.length] = "solr";- reqParamas[reqFacetParamas.length + 1] = "asc";- setResponse(h.query(request(reqFacetParamas)));- }-- @Test- public void timeAllowedTest() throws Exception {- String query =- "int_id: [0 TO "- + random().nextInt(INT)- + "] AND long_ld: [0 TO "- + random().nextInt(LONG)- + "]";- try (SolrQueryRequest req =- req(- fileToStringArr(LegacyFieldFacetTest.class, fileName),- "q",- query,- "timeAllowed",- "0",- "cache",- "false")) {- SolrQueryResponse resp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);-- assertEquals(resp.getResponseHeader().toString(), 0, resp.getResponseHeader().get("status"));- Boolean partialResults =- resp.getResponseHeader()- .getBooleanArg(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY);- assertNotNull(- "No partial results header returned: " + resp.getResponseHeader().toString(),- partialResults);- assertTrue(- "The request was not stopped halfway through, the partial results header was false",- partialResults);- }- }-- @SuppressWarnings("unchecked")- @Test- public void sumTest() throws Exception {- // Int Date- ArrayList<Double> intDate = getDoubleList("sum", "fieldFacets", "date_dtd", "double", "int");- ArrayList<Double> intDateTest = calculateNumberStat(intDateTestStart, "sum");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Double> intString = getDoubleList("sum", "fieldFacets", "string_sd", "double", "int");- ArrayList<Double> intStringTest = calculateNumberStat(intStringTestStart, "sum");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Double> longDate = getDoubleList("sum", "fieldFacets", "date_dtd", "double", "long");- ArrayList<Double> longDateTest = calculateNumberStat(longDateTestStart, "sum");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getDoubleList("sum", "fieldFacets", "string_sd", "double", "long");- ArrayList<Double> longStringTest = calculateNumberStat(longStringTestStart, "sum");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getDoubleList("sum", "fieldFacets", "date_dtd", "double", "float");- ArrayList<Double> floatDateTest = calculateNumberStat(floatDateTestStart, "sum");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getDoubleList("sum", "fieldFacets", "string_sd", "double", "float");- ArrayList<Double> floatStringTest = calculateNumberStat(floatStringTestStart, "sum");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("sum", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest = calculateNumberStat(doubleDateTestStart, "sum");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("sum", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest = calculateNumberStat(doubleStringTestStart, "sum");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void meanTest() throws Exception {- // Int Date- ArrayList<Double> intDate = getDoubleList("mean", "fieldFacets", "date_dtd", "double", "int");- ArrayList<Double> intDateTest = calculateNumberStat(intDateTestStart, "mean");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getDoubleList("mean", "fieldFacets", "string_sd", "double", "int");- ArrayList<Double> intStringTest = calculateNumberStat(intStringTestStart, "mean");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Double> longDate = getDoubleList("mean", "fieldFacets", "date_dtd", "double", "long");- ArrayList<Double> longDateTest = calculateNumberStat(longDateTestStart, "mean");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getDoubleList("mean", "fieldFacets", "string_sd", "double", "long");- ArrayList<Double> longStringTest = calculateNumberStat(longStringTestStart, "mean");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getDoubleList("mean", "fieldFacets", "date_dtd", "double", "float");- ArrayList<Double> floatDateTest = calculateNumberStat(floatDateTestStart, "mean");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getDoubleList("mean", "fieldFacets", "string_sd", "double", "float");- ArrayList<Double> floatStringTest = calculateNumberStat(floatStringTestStart, "mean");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("mean", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest = calculateNumberStat(doubleDateTestStart, "mean");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("mean", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest = calculateNumberStat(doubleStringTestStart, "mean");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void stddevFacetAscTest() throws Exception {- // Int Date- ArrayList<Double> intDate = getDoubleList("stddev", "fieldFacets", "date_dtd", "double", "int");- ArrayList<Double> intDateTest = calculateNumberStat(intDateTestStart, "stddev");- checkStddevs(intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getDoubleList("stddev", "fieldFacets", "string_sd", "double", "int");- ArrayList<Double> intStringTest = calculateNumberStat(intStringTestStart, "stddev");- checkStddevs(intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getDoubleList("stddev", "fieldFacets", "date_dtd", "double", "long");- ArrayList<Double> longDateTest = calculateNumberStat(longDateTestStart, "stddev");- checkStddevs(longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getDoubleList("stddev", "fieldFacets", "string_sd", "double", "long");- ArrayList<Double> longStringTest = calculateNumberStat(longStringTestStart, "stddev");- checkStddevs(longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getDoubleList("stddev", "fieldFacets", "date_dtd", "double", "float");- ArrayList<Double> floatDateTest = calculateNumberStat(floatDateTestStart, "stddev");- checkStddevs(floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getDoubleList("stddev", "fieldFacets", "string_sd", "double", "float");- ArrayList<Double> floatStringTest = calculateNumberStat(floatStringTestStart, "stddev");- checkStddevs(floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("stddev", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest = calculateNumberStat(doubleDateTestStart, "stddev");- checkStddevs(doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("stddev", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest = calculateNumberStat(doubleStringTestStart, "stddev");- checkStddevs(doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void medianFacetAscTest() throws Exception {- // Int Date- ArrayList<Double> intDate = getDoubleList("median", "fieldFacets", "date_dtd", "double", "int");- ArrayList<Double> intDateTest = calculateNumberStat(intDateTestStart, "median");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Double> intString =- getDoubleList("median", "fieldFacets", "string_sd", "double", "int");- ArrayList<Double> intStringTest = calculateNumberStat(intStringTestStart, "median");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Double> longDate =- getDoubleList("median", "fieldFacets", "date_dtd", "double", "long");- ArrayList<Double> longDateTest = calculateNumberStat(longDateTestStart, "median");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Double> longString =- getDoubleList("median", "fieldFacets", "string_sd", "double", "long");- ArrayList<Double> longStringTest = calculateNumberStat(longStringTestStart, "median");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Double> floatDate =- getDoubleList("median", "fieldFacets", "date_dtd", "double", "float");- ArrayList<Double> floatDateTest = calculateNumberStat(floatDateTestStart, "median");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Double> floatString =- getDoubleList("median", "fieldFacets", "string_sd", "double", "float");- ArrayList<Double> floatStringTest = calculateNumberStat(floatStringTestStart, "median");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("median", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest = calculateNumberStat(doubleDateTestStart, "median");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("median", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest = calculateNumberStat(doubleStringTestStart, "median");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void perc20Test() throws Exception {- // Int Date- ArrayList<Integer> intDate =- getIntegerList("percentile_20n", "fieldFacets", "date_dtd", "int", "int");- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateStat(intDateTestStart, "perc_20");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Integer> intString =- getIntegerList("percentile_20n", "fieldFacets", "string_sd", "int", "int");- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateStat(intStringTestStart, "perc_20");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getLongList("percentile_20n", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "perc_20");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getLongList("percentile_20n", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateStat(longStringTestStart, "perc_20");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getFloatList("percentile_20n", "fieldFacets", "date_dtd", "float", "float");- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateStat(floatDateTestStart, "perc_20");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getFloatList("percentile_20n", "fieldFacets", "string_sd", "float", "float");- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateStat(floatStringTestStart, "perc_20");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("percentile_20n", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateStat(doubleDateTestStart, "perc_20");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("percentile_20n", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateStat(doubleStringTestStart, "perc_20");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt =- getStringList("percentile_20", "fieldFacets", "int_id", "date", "date");- ArrayList<String> dateIntTest = (ArrayList<String>) calculateStat(dateIntTestStart, "perc_20");- assertEqualsList(getRawResponse(), dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString =- getStringList("percentile_20", "fieldFacets", "long_ld", "date", "date");- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateStat(dateLongTestStart, "perc_20");- assertEqualsList(getRawResponse(), dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt =- getStringList("percentile_20", "fieldFacets", "int_id", "str", "str");- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateStat(stringIntTestStart, "perc_20");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong =- getStringList("percentile_20", "fieldFacets", "long_ld", "str", "str");- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateStat(stringLongTestStart, "perc_20");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void perc60Test() throws Exception {- // Int Date- ArrayList<Integer> intDate =- getIntegerList("percentile_60n", "fieldFacets", "date_dtd", "int", "int");- ArrayList<Integer> intDateTest =- (ArrayList<Integer>) calculateStat(intDateTestStart, "perc_60");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Integer> intString =- getIntegerList("percentile_60n", "fieldFacets", "string_sd", "int", "int");- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateStat(intStringTestStart, "perc_60");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate =- getLongList("percentile_60n", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "perc_60");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Long> longString =- getLongList("percentile_60n", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest =- (ArrayList<Long>) calculateStat(longStringTestStart, "perc_60");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate =- getFloatList("percentile_60n", "fieldFacets", "date_dtd", "float", "float");- ArrayList<Float> floatDateTest =- (ArrayList<Float>) calculateStat(floatDateTestStart, "perc_60");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getFloatList("percentile_60n", "fieldFacets", "string_sd", "float", "float");- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateStat(floatStringTestStart, "perc_60");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("percentile_60n", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateStat(doubleDateTestStart, "perc_60");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("percentile_60n", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateStat(doubleStringTestStart, "perc_60");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt =- getStringList("percentile_60", "fieldFacets", "int_id", "date", "date");- ArrayList<String> dateIntTest = (ArrayList<String>) calculateStat(dateIntTestStart, "perc_60");- assertEqualsList(getRawResponse(), dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString =- getStringList("percentile_60", "fieldFacets", "long_ld", "date", "date");- ArrayList<String> dateLongTest =- (ArrayList<String>) calculateStat(dateLongTestStart, "perc_60");- assertEqualsList(getRawResponse(), dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt =- getStringList("percentile_60", "fieldFacets", "int_id", "str", "str");- ArrayList<String> stringIntTest =- (ArrayList<String>) calculateStat(stringIntTestStart, "perc_60");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong =- getStringList("percentile_60", "fieldFacets", "long_ld", "str", "str");- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateStat(stringLongTestStart, "perc_60");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void minTest() throws Exception {- // Int Date- ArrayList<Integer> intDate = getIntegerList("minn", "fieldFacets", "date_dtd", "int", "int");- ArrayList<Integer> intDateTest = (ArrayList<Integer>) calculateStat(intDateTestStart, "min");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Integer> intString = getIntegerList("minn", "fieldFacets", "string_sd", "int", "int");- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateStat(intStringTestStart, "min");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate = getLongList("minn", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "min");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Long> longString = getLongList("minn", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest = (ArrayList<Long>) calculateStat(longStringTestStart, "min");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate = getFloatList("minn", "fieldFacets", "date_dtd", "float", "float");- ArrayList<Float> floatDateTest = (ArrayList<Float>) calculateStat(floatDateTestStart, "min");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Float> floatString =- getFloatList("minn", "fieldFacets", "string_sd", "float", "float");- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateStat(floatStringTestStart, "min");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("minn", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateStat(doubleDateTestStart, "min");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Double> doubleString =- getDoubleList("minn", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateStat(doubleStringTestStart, "min");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // Date Int- ArrayList<String> dateInt = getStringList("min", "fieldFacets", "int_id", "date", "date");- ArrayList<String> dateIntTest = (ArrayList<String>) calculateStat(dateIntTestStart, "min");- assertEqualsList(getRawResponse(), dateInt, dateIntTest);- // Date Long- ArrayList<String> dateString = getStringList("min", "fieldFacets", "long_ld", "date", "date");- ArrayList<String> dateLongTest = (ArrayList<String>) calculateStat(dateLongTestStart, "min");- assertEqualsList(getRawResponse(), dateString, dateLongTest);-- // String Int- ArrayList<String> stringInt = getStringList("min", "fieldFacets", "int_id", "str", "str");- ArrayList<String> stringIntTest = (ArrayList<String>) calculateStat(stringIntTestStart, "min");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);- // String Long- ArrayList<String> stringLong = getStringList("min", "fieldFacets", "long_ld", "str", "str");- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateStat(stringLongTestStart, "min");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void maxTest() throws Exception {- // Int Date- ArrayList<Integer> intDate = getIntegerList("maxn", "fieldFacets", "date_dtd", "int", "int");- ArrayList<Integer> intDateTest = (ArrayList<Integer>) calculateStat(intDateTestStart, "max");- assertEqualsList(getRawResponse(), intDate, intDateTest);-- // Int String- ArrayList<Integer> intString = getIntegerList("maxn", "fieldFacets", "string_sd", "int", "int");- ArrayList<Integer> intStringTest =- (ArrayList<Integer>) calculateStat(intStringTestStart, "max");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate = getLongList("maxn", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "max");- assertEqualsList(getRawResponse(), longDate, longDateTest);-- // Long String- ArrayList<Long> longString = getLongList("maxn", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest = (ArrayList<Long>) calculateStat(longStringTestStart, "max");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Float> floatDate = getFloatList("maxn", "fieldFacets", "date_dtd", "float", "float");- ArrayList<Float> floatDateTest = (ArrayList<Float>) calculateStat(floatDateTestStart, "max");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);-- // Float String- ArrayList<Float> floatString =- getFloatList("maxn", "fieldFacets", "string_sd", "float", "float");- ArrayList<Float> floatStringTest =- (ArrayList<Float>) calculateStat(floatStringTestStart, "max");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Double> doubleDate =- getDoubleList("maxn", "fieldFacets", "date_dtd", "double", "double");- ArrayList<Double> doubleDateTest =- (ArrayList<Double>) calculateStat(doubleDateTestStart, "max");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);-- // Double String- ArrayList<Double> doubleString =- getDoubleList("maxn", "fieldFacets", "string_sd", "double", "double");- ArrayList<Double> doubleStringTest =- (ArrayList<Double>) calculateStat(doubleStringTestStart, "max");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // String Int- ArrayList<String> stringInt = getStringList("max", "fieldFacets", "int_id", "str", "str");- ArrayList<String> stringIntTest = (ArrayList<String>) calculateStat(stringIntTestStart, "max");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);-- // String Long- ArrayList<String> stringLong = getStringList("max", "fieldFacets", "long_ld", "str", "str");- ArrayList<String> stringLongTest =- (ArrayList<String>) calculateStat(stringLongTestStart, "max");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);-- // Date Int- ArrayList<String> dateInt = getStringList("max", "fieldFacets", "int_id", "date", "date");- ArrayList<String> dateIntTest = (ArrayList<String>) calculateStat(dateIntTestStart, "max");- assertEqualsList(getRawResponse(), dateInt, dateIntTest);-- // Date Long- ArrayList<String> dateString = getStringList("max", "fieldFacets", "long_ld", "date", "date");- ArrayList<String> dateLongTest = (ArrayList<String>) calculateStat(dateLongTestStart, "max");- assertEqualsList(getRawResponse(), dateString, dateLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void uniqueTest() throws Exception {- // Int Date- ArrayList<Long> intDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "int");- ArrayList<Long> intDateTest = (ArrayList<Long>) calculateStat(intDateTestStart, "unique");- assertEqualsList(getRawResponse(), intDate, intDateTest);- // Int String- ArrayList<Long> intString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "int");- ArrayList<Long> intStringTest = (ArrayList<Long>) calculateStat(intStringTestStart, "unique");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "unique");- assertEqualsList(getRawResponse(), longDate, longDateTest);- // Long String- ArrayList<Long> longString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest = (ArrayList<Long>) calculateStat(longStringTestStart, "unique");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Long> floatDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "float");- ArrayList<Long> floatDateTest = (ArrayList<Long>) calculateStat(floatDateTestStart, "unique");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);- // Float String- ArrayList<Long> floatString =- getLongList("uniquen", "fieldFacets", "string_sd", "long", "float");- ArrayList<Long> floatStringTest =- (ArrayList<Long>) calculateStat(floatStringTestStart, "unique");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Long> doubleDate =- getLongList("uniquen", "fieldFacets", "date_dtd", "long", "double");- ArrayList<Long> doubleDateTest = (ArrayList<Long>) calculateStat(doubleDateTestStart, "unique");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);- // Double String- ArrayList<Long> doubleString =- getLongList("uniquen", "fieldFacets", "string_sd", "long", "double");- ArrayList<Long> doubleStringTest =- (ArrayList<Long>) calculateStat(doubleStringTestStart, "unique");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // Date Int- ArrayList<Long> dateInt = getLongList("unique", "fieldFacets", "int_id", "long", "date");- ArrayList<Long> dateIntTest = (ArrayList<Long>) calculateStat(dateIntTestStart, "unique");- assertEqualsList(getRawResponse(), dateInt, dateIntTest);- // Date Long- ArrayList<Long> dateString = getLongList("unique", "fieldFacets", "long_ld", "long", "date");- ArrayList<Long> dateLongTest = (ArrayList<Long>) calculateStat(dateLongTestStart, "unique");- assertEqualsList(getRawResponse(), dateString, dateLongTest);-- // String Int- ArrayList<Long> stringInt = getLongList("unique", "fieldFacets", "int_id", "long", "str");- ArrayList<Long> stringIntTest = (ArrayList<Long>) calculateStat(stringIntTestStart, "unique");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);- // String Long- ArrayList<Long> stringLong = getLongList("unique", "fieldFacets", "long_ld", "long", "str");- ArrayList<Long> stringLongTest = (ArrayList<Long>) calculateStat(stringLongTestStart, "unique");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);- }-- @SuppressWarnings("unchecked")- @Test- public void countTest() throws Exception {- // Int Date- ArrayList<Long> intDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "int");- ArrayList<Long> intDateTest = (ArrayList<Long>) calculateStat(intDateTestStart, "count");- assertEqualsList(getRawResponse(), intDate, intDateTest);-- // Int String- ArrayList<Long> intString = getLongList("countn", "fieldFacets", "string_sd", "long", "int");- ArrayList<Long> intStringTest = (ArrayList<Long>) calculateStat(intStringTestStart, "count");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Long Date- ArrayList<Long> longDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "long");- ArrayList<Long> longDateTest = (ArrayList<Long>) calculateStat(longDateTestStart, "count");- assertEqualsList(getRawResponse(), longDate, longDateTest);-- // Long String- ArrayList<Long> longString = getLongList("countn", "fieldFacets", "string_sd", "long", "long");- ArrayList<Long> longStringTest = (ArrayList<Long>) calculateStat(longStringTestStart, "count");- assertEqualsList(getRawResponse(), longString, longStringTest);-- // Float Date- ArrayList<Long> floatDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "float");- ArrayList<Long> floatDateTest = (ArrayList<Long>) calculateStat(floatDateTestStart, "count");- assertEqualsList(getRawResponse(), floatDate, floatDateTest);-- // Float String- ArrayList<Long> floatString =- getLongList("countn", "fieldFacets", "string_sd", "long", "float");- ArrayList<Long> floatStringTest =- (ArrayList<Long>) calculateStat(floatStringTestStart, "count");- assertEqualsList(getRawResponse(), floatString, floatStringTest);-- // Double Date- ArrayList<Long> doubleDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "double");- ArrayList<Long> doubleDateTest = (ArrayList<Long>) calculateStat(doubleDateTestStart, "count");- assertEqualsList(getRawResponse(), doubleDate, doubleDateTest);-- // Double String- ArrayList<Long> doubleString =- getLongList("countn", "fieldFacets", "string_sd", "long", "double");- ArrayList<Long> doubleStringTest =- (ArrayList<Long>) calculateStat(doubleStringTestStart, "count");- assertEqualsList(getRawResponse(), doubleString, doubleStringTest);-- // Date Int- ArrayList<Long> dateInt = getLongList("count", "fieldFacets", "int_id", "long", "date");- ArrayList<Long> dateIntTest = (ArrayList<Long>) calculateStat(dateIntTestStart, "count");- assertEqualsList(getRawResponse(), dateIntTest, dateInt);-- // Date Long- ArrayList<Long> dateLong = getLongList("count", "fieldFacets", "long_ld", "long", "date");- ArrayList<Long> dateLongTest = (ArrayList<Long>) calculateStat(dateLongTestStart, "count");- assertEqualsList(getRawResponse(), dateLong, dateLongTest);-- // String Int- ArrayList<Long> stringInt = getLongList("count", "fieldFacets", "int_id", "long", "str");- ArrayList<Long> stringIntTest = (ArrayList<Long>) calculateStat(stringIntTestStart, "count");- assertEqualsList(getRawResponse(), stringInt, stringIntTest);-- // String Long- ArrayList<Long> stringLong = getLongList("count", "fieldFacets", "long_ld", "long", "str");- ArrayList<Long> stringLongTest = (ArrayList<Long>) calculateStat(stringLongTestStart, "count");- assertEqualsList(getRawResponse(), stringLong, stringLongTest);- }-- @Test- public void missingTest() throws Exception {- // Int Date- ArrayList<Long> intDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "int");- setLatestType("int");- assertEqualsList(getRawResponse(), intDateTestMissing, intDate);-- // Int String- ArrayList<Long> intString = getLongList("missingn", "fieldFacets", "string_sd", "long", "int");- assertEqualsList(getRawResponse(), intStringTestMissing, intString);-- // Long Date- ArrayList<Long> longDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "long");- setLatestType("long");- assertEqualsList(getRawResponse(), longDateTestMissing, longDate);-- // Long String- ArrayList<Long> longString =- getLongList("missingn", "fieldFacets", "string_sd", "long", "long");- assertEqualsList(getRawResponse(), longStringTestMissing, longString);-- // Float Date- ArrayList<Long> floatDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "float");- setLatestType("float");- assertEqualsList(getRawResponse(), floatDateTestMissing, floatDate);-- // Float String- ArrayList<Long> floatString =- getLongList("missingn", "fieldFacets", "string_sd", "long", "float");- assertEqualsList(getRawResponse(), floatStringTestMissing, floatString);-- // Double Date- ArrayList<Long> doubleDate =- getLongList("missingn", "fieldFacets", "date_dtd", "long", "double");- setLatestType("double");- assertEqualsList(getRawResponse(), doubleDateTestMissing, doubleDate);-- // Double String- ArrayList<Long> doubleString =- getLongList("missingn", "fieldFacets", "string_sd", "long", "double");- assertEqualsList(getRawResponse(), doubleStringTestMissing, doubleString);-- // Date Int- ArrayList<Long> dateInt = getLongList("missing", "fieldFacets", "int_id", "long", "date");- setLatestType("date");- assertEqualsList(getRawResponse(), dateIntTestMissing, dateInt);-- // Date Long- ArrayList<Long> dateLong = getLongList("missing", "fieldFacets", "long_ld", "long", "date");- assertEqualsList(getRawResponse(), dateLongTestMissing, dateLong);-- // String Int- ArrayList<Long> stringInt = getLongList("missing", "fieldFacets", "int_id", "long", "str");- setLatestType("string");- assertEqualsList(getRawResponse(), stringIntTestMissing, stringInt);-- // String Long- ArrayList<Long> stringLong = getLongList("missing", "fieldFacets", "long_ld", "long", "str");- assertEqualsList(getRawResponse(), stringLongTestMissing, stringLong);- }-- @SuppressWarnings("unchecked")- @Test- public void multiValueTest() throws Exception {- // Long- ArrayList<Double> lon =- getDoubleList("multivalued", "fieldFacets", "long_ldm", "double", "mean");- ArrayList<Double> longTest = calculateNumberStat(multiLongTestStart, "mean");- assertEqualsList(getRawResponse(), lon, longTest);- // Date- ArrayList<Double> date =- getDoubleList("multivalued", "fieldFacets", "date_dtdm", "double", "mean");- ArrayList<Double> dateTest = calculateNumberStat(multiDateTestStart, "mean");- assertEqualsList(getRawResponse(), date, dateTest);- // String- ArrayList<Double> string =- getDoubleList("multivalued", "fieldFacets", "string_sdm", "double", "mean");- ArrayList<Double> stringTest = calculateNumberStat(multiStringTestStart, "mean");- assertEqualsList(getRawResponse(), string, stringTest);- }-- @SuppressWarnings("unchecked")- @Test- public void missingFacetTest() throws Exception {- // int MultiDate- String xPath =- "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='date_dtdm']/lst[@name='(MISSING)']";- Node missingNodeXPath = getNode(xPath);- assertNotNull(getRawResponse(), missingNodeXPath);-- ArrayList<Double> string =- getDoubleList("missingf", "fieldFacets", "date_dtdm", "double", "mean");- // super.removeNodes(xPath, string);- ArrayList<Double> stringTest = calculateNumberStat(multiDateTestStart, "mean");- assertEqualsList(getRawResponse(), string, stringTest);-- // Int String- xPath =- "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='string_sd']/lst[@name='(MISSING)']";- missingNodeXPath = getNode(xPath);- String missingNodeXPathStr = xPath;- assertNotNull(getRawResponse(), missingNodeXPath);-- xPath =- "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='string_sd']/lst[@name='str0']";- assertNull(getRawResponse(), getNode(xPath));-- ArrayList<Double> intString =- getDoubleList("missingf", "fieldFacets", "string_sd", "double", "mean");- // removeNodes(missingNodeXPathStr, intString);- ArrayList<Double> intStringTest = calculateNumberStat(intStringTestStart, "mean");- assertEqualsList(getRawResponse(), intString, intStringTest);-- // Int Date- ArrayList<Double> intDate =- getDoubleList("missingf", "fieldFacets", "date_dtd", "double", "mean");- ArrayList<ArrayList<Double>> intDateMissingTestStart =- (ArrayList<ArrayList<Double>>) intDateTestStart.clone();- ArrayList<Double> intDateTest = calculateNumberStat(intDateMissingTestStart, "mean");- assertEqualsList(getRawResponse(), intDate, intDateTest);- }-- private void checkStddevs(ArrayList<Double> list1, ArrayList<Double> list2) {- Collections.sort(list1);- Collections.sort(list2);- for (int i = 0; i < list1.size(); i++) {- if ((Math.abs(list1.get(i) - list2.get(i)) < .00000000001) == false) {- assertEquals(getRawResponse(), list1.get(i), list2.get(i), 0.00000000001);- }- }- }-- @SuppressWarnings({"unchecked", "rawtypes"})- public static void assertEqualsList(- String mes,- ArrayList<? extends Comparable> actual,- ArrayList<? extends Comparable> expected) {- Collections.sort(actual);- Collections.sort(expected);- assertEquals(mes, actual, expected);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetCloudTest.javadeleted file mode 100644index 99e7ac11187..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetCloudTest.java+++ /dev/null@@ -1,173 +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.legacy.facet;--import java.util.ArrayList;-import java.util.List;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.common.util.NamedList;-import org.junit.After;-import org.junit.Before;-import org.junit.Test;--public class LegacyQueryFacetCloudTest extends LegacyAbstractAnalyticsFacetCloudTest {- private static final int INT = 71;- private static final int LONG = 36;- private static final int FLOAT = 93;- private static final int DOUBLE = 49;- private static final int DATE = 12;- private static final int STRING = 7;- private static final int NUM_LOOPS = 100;-- private static final ArrayList<ArrayList<Integer>> int1TestStart = new ArrayList<>();- private static final ArrayList<ArrayList<Integer>> int2TestStart = new ArrayList<>();- private static final ArrayList<ArrayList<Long>> longTestStart = new ArrayList<>();- private static final ArrayList<ArrayList<Float>> floatTestStart = new ArrayList<>();-- @After- public void afterTest() throws Exception {- int1TestStart.clear();- int2TestStart.clear();- longTestStart.clear();- floatTestStart.clear();- }-- @Before- public void beforeTest() throws Exception {-- // INT- int1TestStart.add(new ArrayList<>());- int2TestStart.add(new ArrayList<>());-- // LONG- longTestStart.add(new ArrayList<>());- longTestStart.add(new ArrayList<>());-- // FLOAT- floatTestStart.add(new ArrayList<>());- floatTestStart.add(new ArrayList<>());- floatTestStart.add(new ArrayList<>());-- UpdateRequest req = new UpdateRequest();-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;-- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);- fields.add("int_id");- fields.add("" + i);- fields.add("long_ld");- fields.add("" + l);- fields.add("float_fd");- fields.add("" + f);- fields.add("double_dd");- fields.add("" + d);- fields.add("date_dtd");- fields.add((1000 + dt) + "-01-01T23:59:59Z");- fields.add("string_sd");- fields.add("abc" + s);- req.add(fields.toArray(new String[0]));-- if (f <= 50) {- int1TestStart.get(0).add(i);- }- if (f <= 30) {- int2TestStart.get(0).add(i);- }- if (s == 1) {- longTestStart.get(0).add(l);- }- if (s == 2) {- longTestStart.get(1).add(l);- }- if (l >= 30) {- floatTestStart.get(0).add(f);- }- if (d <= 50) {- floatTestStart.get(1).add(f);- }- if (l >= 20) {- floatTestStart.get(2).add(f);- }- }-- req.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- @SuppressWarnings("unchecked")- @Test- public void queryTest() throws Exception {- String[] params =- new String[] {- "o.ir.s.sum", "sum(int_id)",- "o.ir.s.mean", "mean(int_id)",- "o.ir.s.median", "median(int_id)",- "o.ir.s.percentile_8", "percentile(8,int_id)",- "o.ir.qf", "float1",- "o.ir.qf.float1.q", "float_fd:[* TO 50]",- "o.ir.qf", "float2",- "o.ir.qf.float2.q", "float_fd:[* TO 30]",- "o.lr.s.sum", "sum(long_ld)",- "o.lr.s.mean", "mean(long_ld)",- "o.lr.s.median", "median(long_ld)",- "o.lr.s.percentile_8", "percentile(8,long_ld)",- "o.lr.qf", "string",- "o.lr.qf.string.q", "string_sd:abc1",- "o.lr.qf.string.q", "string_sd:abc2",- "o.fr.s.sum", "sum(float_fd)",- "o.fr.s.mean", "mean(float_fd)",- "o.fr.s.median", "median(float_fd)",- "o.fr.s.percentile_8", "percentile(8,float_fd)",- "o.fr.qf", "lad",- "o.fr.qf.lad.q", "long_ld:[20 TO *]",- "o.fr.qf.lad.q", "long_ld:[30 TO *]",- "o.fr.qf.lad.q", "double_dd:[* TO 50]"- };-- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int One- ArrayList<Double> int1 = getValueList(response, "ir", "queryFacets", "float1", "sum", false);- ArrayList<Double> int1Test = calculateFacetedNumberStat(int1TestStart, "sum");- assertEquals(responseStr, int1, int1Test);- // Int Two- ArrayList<Integer> int2 =- getValueList(response, "ir", "queryFacets", "float2", "percentile_8", false);- ArrayList<Integer> int2Test =- (ArrayList<Integer>) calculateFacetedStat(int2TestStart, "perc_8");- assertEquals(responseStr, int2, int2Test);-- // Long- ArrayList<Double> long1 =- getValueList(response, "lr", "queryFacets", "string", "median", false);- ArrayList<Double> long1Test = calculateFacetedNumberStat(longTestStart, "median");- assertEquals(responseStr, long1, long1Test);-- // Float- ArrayList<Double> float1 = getValueList(response, "fr", "queryFacets", "lad", "mean", false);- ArrayList<Double> float1Test = calculateFacetedNumberStat(floatTestStart, "mean");- assertEquals(responseStr, float1, float1Test);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetTest.javadeleted file mode 100644index d665638ec9a..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyQueryFacetTest.java+++ /dev/null@@ -1,135 +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.legacy.facet;--import java.util.ArrayList;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyQueryFacetTest extends LegacyAbstractAnalyticsFacetTest {- static String fileName = "queryFacets.txt";-- public final int INT = 71;- public final int LONG = 36;- public final int FLOAT = 93;- public final int DOUBLE = 49;- public final int DATE = 12;- public final int STRING = 28;- public final int NUM_LOOPS = 100;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- }-- @SuppressWarnings("unchecked")- @Test- public void queryTest() throws Exception {- h.update("<delete><query>*:*</query></delete>");- // INT- ArrayList<ArrayList<Integer>> int1TestStart = new ArrayList<>();- int1TestStart.add(new ArrayList<>());- ArrayList<ArrayList<Integer>> int2TestStart = new ArrayList<>();- int2TestStart.add(new ArrayList<>());-- // LONG- ArrayList<ArrayList<Long>> longTestStart = new ArrayList<>();- longTestStart.add(new ArrayList<>());- longTestStart.add(new ArrayList<>());-- // FLOAT- ArrayList<ArrayList<Float>> floatTestStart = new ArrayList<>();- floatTestStart.add(new ArrayList<>());- floatTestStart.add(new ArrayList<>());- floatTestStart.add(new ArrayList<>());-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;- assertU(- adoc(- "id",- "1000" + j,- "int_id",- "" + i,- "long_ld",- "" + l,- "float_fd",- "" + f,- "double_dd",- "" + d,- "date_dtd",- (1800 + dt) + "-12-31T23:59:59.999Z",- "string_sd",- "abc" + Integer.toString(s).charAt(0)));-- if (f <= 50) {- int1TestStart.get(0).add(i);- }- if (f <= 30) {- int2TestStart.get(0).add(i);- }- if (Integer.toString(s).charAt(0) == '1') {- longTestStart.get(0).add(l);- }- if (Integer.toString(s).charAt(0) == '2') {- longTestStart.get(1).add(l);- }- if (l >= 30) {- floatTestStart.get(0).add(f);- }- if (d <= 50) {- floatTestStart.get(1).add(f);- }- if (l >= 20) {- floatTestStart.get(2).add(f);- }-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());-- // Query ascending tests- setResponse(h.query(request(fileToStringArr(LegacyQueryFacetTest.class, fileName))));-- // Int One- ArrayList<Double> int1 = getDoubleList("ir", "queryFacets", "float1", "double", "sum");- ArrayList<Double> int1Test = calculateNumberStat(int1TestStart, "sum");- assertEquals(getRawResponse(), int1, int1Test);- // Int Two- ArrayList<Integer> int2 = getIntegerList("ir", "queryFacets", "float2", "int", "percentile_8");- ArrayList<Integer> int2Test = (ArrayList<Integer>) calculateStat(int2TestStart, "perc_8");- assertEquals(getRawResponse(), int2, int2Test);-- // Long- ArrayList<Double> long1 = getDoubleList("lr", "queryFacets", "string", "double", "median");- ArrayList<Double> long1Test = calculateNumberStat(longTestStart, "median");- assertEquals(getRawResponse(), long1, long1Test);-- // Float- ArrayList<Double> float1 = getDoubleList("fr", "queryFacets", "lad", "double", "mean");- ArrayList<Double> float1Test = calculateNumberStat(floatTestStart, "mean");- assertEquals(getRawResponse(), float1, float1Test);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetCloudTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetCloudTest.javadeleted file mode 100644index 2596e591b52..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetCloudTest.java+++ /dev/null@@ -1,653 +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.legacy.facet;--import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import java.util.ArrayList;-import java.util.List;-import org.apache.solr.client.solrj.request.UpdateRequest;-import org.apache.solr.common.util.NamedList;-import org.junit.Before;-import org.junit.Test;--@ThreadLeakLingering(linger = 0)-public class LegacyRangeFacetCloudTest extends LegacyAbstractAnalyticsFacetCloudTest {- public static final int INT = 71;- public static final int LONG = 36;- public static final int FLOAT = 93;- public static final int DOUBLE = 48;- public static final int DATE = 52;- public static final int STRING = 28;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<ArrayList<Integer>> intLongTestStart;- static ArrayList<ArrayList<Integer>> intDoubleTestStart;- static ArrayList<ArrayList<Integer>> intDateTestStart;-- // FLOAT- static ArrayList<ArrayList<Float>> floatLongTestStart;- static ArrayList<ArrayList<Float>> floatDoubleTestStart;- static ArrayList<ArrayList<Float>> floatDateTestStart;-- @Before- public void beforeTest() throws Exception {-- // INT- intLongTestStart = new ArrayList<>();- intDoubleTestStart = new ArrayList<>();- intDateTestStart = new ArrayList<>();-- // FLOAT- floatLongTestStart = new ArrayList<>();- floatDoubleTestStart = new ArrayList<>();- floatDateTestStart = new ArrayList<>();-- UpdateRequest req = new UpdateRequest();-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;-- List<String> fields = new ArrayList<>();- fields.add("id");- fields.add("1000" + j);- fields.add("int_id");- fields.add("" + i);- fields.add("long_ld");- fields.add("" + l);- fields.add("float_fd");- fields.add("" + f);- fields.add("double_dd");- fields.add("" + d);- fields.add("date_dtd");- fields.add((1000 + dt) + "-01-01T23:59:59Z");- fields.add("string_sd");- fields.add("abc" + s);- req.add(fields.toArray(new String[0]));-- // Longs- if (j - LONG < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intLongTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatLongTestStart.add(list2);- } else {- intLongTestStart.get((int) l).add(i);- floatLongTestStart.get((int) l).add(f);- }- // Doubles- if (j - DOUBLE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDoubleTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatDoubleTestStart.add(list2);- } else {- intDoubleTestStart.get((int) d).add(i);- floatDoubleTestStart.get((int) d).add(f);- }- // Dates- if (j - DATE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDateTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatDateTestStart.add(list2);- } else {- intDateTestStart.get(dt).add(i);- floatDateTestStart.get(dt).add(f);- }- }-- req.commit(cluster.getSolrClient(), COLLECTIONORALIAS);- }-- @SuppressWarnings("unchecked")- @Test- public void rangeTest() throws Exception {- String[] params =- new String[] {- "o.ri.s.sum", "sum(int_id)",- "o.ri.s.mean", "mean(int_id)",- "o.ri.s.median", "median(int_id)",- "o.ri.s.count", "count(int_id)",- "o.ri.rf", "long_ld",- "o.ri.rf.long_ld.st", "5",- "o.ri.rf.long_ld.e", "30",- "o.ri.rf.long_ld.g", "5",- "o.ri.rf.long_ld.ib", "lower",- "o.ri.rf.long_ld.or", "all",- "o.ri.rf", "double_dd",- "o.ri.rf.double_dd.st", "3",- "o.ri.rf.double_dd.e", "39",- "o.ri.rf.double_dd.g", "7",- "o.ri.rf.double_dd.ib", "upper",- "o.ri.rf.double_dd.ib", "outer",- "o.ri.rf.double_dd.or", "all",- "o.ri.rf", "date_dtd",- "o.ri.rf.date_dtd.st", "1007-01-01T23:59:59Z",- "o.ri.rf.date_dtd.e", "1044-01-01T23:59:59Z",- "o.ri.rf.date_dtd.g", "+7YEARS",- "o.ri.rf.date_dtd.ib", "lower",- "o.ri.rf.date_dtd.ib", "edge",- "o.ri.rf.date_dtd.ib", "outer",- "o.ri.rf.date_dtd.or", "all",- "o.rf.s.sum", "sum(float_fd)",- "o.rf.s.mean", "mean(float_fd)",- "o.rf.s.median", "median(float_fd)",- "o.rf.s.count", "count(float_fd)",- "o.rf.rf", "long_ld",- "o.rf.rf.long_ld.st", "0",- "o.rf.rf.long_ld.e", "29",- "o.rf.rf.long_ld.g", "4",- "o.rf.rf.long_ld.ib", "all",- "o.rf.rf.long_ld.or", "all",- "o.rf.rf", "double_dd",- "o.rf.rf.double_dd.st", "4",- "o.rf.rf.double_dd.e", "47",- "o.rf.rf.double_dd.g", "11",- "o.rf.rf.double_dd.ib", "edge",- "o.rf.rf.double_dd.or", "all",- "o.rf.rf", "date_dtd",- "o.rf.rf.date_dtd.st", "1004-01-01T23:59:59Z",- "o.rf.rf.date_dtd.e", "1046-01-01T23:59:59Z",- "o.rf.rf.date_dtd.g", "+5YEARS",- "o.rf.rf.date_dtd.ib", "upper",- "o.rf.rf.date_dtd.ib", "edge",- "o.rf.rf.date_dtd.or", "all"- };-- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Long- ArrayList<Long> intLong =- getValueList(response, "ri", "rangeFacets", "long_ld", "count", false);- ArrayList<Long> intLongTest =- calculateFacetedStat(- transformLists(intLongTestStart, 5, 30, 5, false, true, false, false, false), "count");- assertEquals(responseStr, intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble =- getValueList(response, "ri", "rangeFacets", "double_dd", "mean", false);- ArrayList<Double> intDoubleTest =- calculateFacetedNumberStat(- transformLists(intDoubleTestStart, 3, 39, 7, false, false, true, false, true), "mean");- assertEquals(responseStr, intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate =- getValueList(response, "ri", "rangeFacets", "date_dtd", "count", false);- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(intDateTestStart, 7, 44, 7, false, true, false, true, true),- "count");- assertEquals(responseStr, intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong =- getValueList(response, "rf", "rangeFacets", "long_ld", "median", false);- ArrayList<Double> floatLongTest =- calculateFacetedNumberStat(- transformLists(floatLongTestStart, 0, 29, 4, false, true, true, true, true), "median");- assertEquals(responseStr, floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble =- getValueList(response, "rf", "rangeFacets", "double_dd", "count", false);- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(floatDoubleTestStart, 4, 47, 11, false, false, false, true, false),- "count");- assertEquals(responseStr, floatDouble, floatDoubleTest);- }-- @SuppressWarnings("unchecked")- @Test- public void hardendRangeTest() throws Exception {- String[] params =- new String[] {- "o.hi.s.sum", "sum(int_id)",- "o.hi.s.mean", "mean(int_id)",- "o.hi.s.median", "median(int_id)",- "o.hi.s.count", "count(int_id)",- "o.hi.rf", "long_ld",- "o.hi.rf.long_ld.st", "5",- "o.hi.rf.long_ld.e", "30",- "o.hi.rf.long_ld.g", "5",- "o.hi.rf.long_ld.he", "true",- "o.hi.rf.long_ld.ib", "lower",- "o.hi.rf.long_ld.or", "all",- "o.hi.rf", "double_dd",- "o.hi.rf.double_dd.st", "3",- "o.hi.rf.double_dd.e", "39",- "o.hi.rf.double_dd.g", "7",- "o.hi.rf.double_dd.he", "true",- "o.hi.rf.double_dd.ib", "upper",- "o.hi.rf.double_dd.ib", "outer",- "o.hi.rf.double_dd.or", "all",- "o.hi.rf", "date_dtd",- "o.hi.rf.date_dtd.st", "1007-01-01T23:59:59Z",- "o.hi.rf.date_dtd.e", "1044-01-01T23:59:59Z",- "o.hi.rf.date_dtd.g", "+7YEARS",- "o.hi.rf.date_dtd.he", "true",- "o.hi.rf.date_dtd.ib", "lower",- "o.hi.rf.date_dtd.ib", "edge",- "o.hi.rf.date_dtd.ib", "outer",- "o.hi.rf.date_dtd.or", "all",- "o.hf.s.sum", "sum(float_fd)",- "o.hf.s.mean", "mean(float_fd)",- "o.hf.s.median", "median(float_fd)",- "o.hf.s.count", "count(float_fd)",- "o.hf.rf", "long_ld",- "o.hf.rf.long_ld.st", "0",- "o.hf.rf.long_ld.e", "29",- "o.hf.rf.long_ld.g", "4",- "o.hf.rf.long_ld.he", "true",- "o.hf.rf.long_ld.ib", "all",- "o.hf.rf.long_ld.or", "all",- "o.hf.rf", "double_dd",- "o.hf.rf.double_dd.st", "4",- "o.hf.rf.double_dd.e", "47",- "o.hf.rf.double_dd.g", "11",- "o.hf.rf.double_dd.he", "true",- "o.hf.rf.double_dd.ib", "edge",- "o.hf.rf.double_dd.or", "all",- "o.hf.rf", "date_dtd",- "o.hf.rf.date_dtd.st", "1004-01-01T23:59:59Z",- "o.hf.rf.date_dtd.e", "1046-01-01T23:59:59Z",- "o.hf.rf.date_dtd.g", "+5YEARS",- "o.hf.rf.date_dtd.he", "true",- "o.hf.rf.date_dtd.ib", "upper",- "o.hf.rf.date_dtd.ib", "edge",- "o.hf.rf.date_dtd.or", "all"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Long- ArrayList<Double> intLong =- getValueList(response, "hi", "rangeFacets", "long_ld", "sum", false);- ArrayList<Double> intLongTest =- calculateFacetedNumberStat(- transformLists(intLongTestStart, 5, 30, 5, true, true, false, false, false), "sum");- assertEquals(responseStr, intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble =- getValueList(response, "hi", "rangeFacets", "double_dd", "mean", false);- ArrayList<Double> intDoubleTest =- calculateFacetedNumberStat(- transformLists(intDoubleTestStart, 3, 39, 7, true, false, true, false, true), "mean");- assertEquals(responseStr, intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate =- getValueList(response, "hi", "rangeFacets", "date_dtd", "count", false);- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(intDateTestStart, 7, 44, 7, true, true, false, true, true), "count");- assertEquals(responseStr, intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong =- getValueList(response, "hf", "rangeFacets", "long_ld", "median", false);- ArrayList<Double> floatLongTest =- calculateFacetedNumberStat(- transformLists(floatLongTestStart, 0, 29, 4, true, true, true, true, true), "median");- assertEquals(responseStr, floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble =- getValueList(response, "hf", "rangeFacets", "double_dd", "count", false);- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(floatDoubleTestStart, 4, 47, 11, true, false, false, true, false),- "count");- assertEquals(responseStr, floatDouble, floatDoubleTest);- }-- @SuppressWarnings("unchecked")- @Test- public void multiGapTest() throws Exception {- String[] params =- new String[] {- "o.mi.s.sum", "sum(int_id)",- "o.mi.s.mean", "mean(int_id)",- "o.mi.s.median", "median(int_id)",- "o.mi.s.count", "count(int_id)",- "o.mi.rf", "long_ld",- "o.mi.rf.long_ld.st", "5",- "o.mi.rf.long_ld.e", "30",- "o.mi.rf.long_ld.g", "4,2,6,3",- "o.mi.rf.long_ld.ib", "lower",- "o.mi.rf.long_ld.or", "all",- "o.mi.rf", "double_dd",- "o.mi.rf.double_dd.st", "3",- "o.mi.rf.double_dd.e", "39",- "o.mi.rf.double_dd.g", "3,1,7",- "o.mi.rf.double_dd.ib", "upper",- "o.mi.rf.double_dd.ib", "outer",- "o.mi.rf.double_dd.or", "all",- "o.mi.rf", "date_dtd",- "o.mi.rf.date_dtd.st", "1007-01-01T23:59:59Z",- "o.mi.rf.date_dtd.e", "1044-01-01T23:59:59Z",- "o.mi.rf.date_dtd.g", "+2YEARS,+7YEARS",- "o.mi.rf.date_dtd.ib", "lower",- "o.mi.rf.date_dtd.ib", "edge",- "o.mi.rf.date_dtd.ib", "outer",- "o.mi.rf.date_dtd.or", "all",- "o.mf.s.sum", "sum(float_fd)",- "o.mf.s.mean", "mean(float_fd)",- "o.mf.s.median", "median(float_fd)",- "o.mf.s.count", "count(float_fd)",- "o.mf.rf", "long_ld",- "o.mf.rf.long_ld.st", "0",- "o.mf.rf.long_ld.e", "29",- "o.mf.rf.long_ld.g", "1,4",- "o.mf.rf.long_ld.ib", "all",- "o.mf.rf.long_ld.or", "all",- "o.mf.rf", "double_dd",- "o.mf.rf.double_dd.st", "4",- "o.mf.rf.double_dd.e", "47",- "o.mf.rf.double_dd.g", "2,3,11",- "o.mf.rf.double_dd.ib", "edge",- "o.mf.rf.double_dd.or", "all",- "o.mf.rf", "date_dtd",- "o.mf.rf.date_dtd.st", "1004-01-01T23:59:59Z",- "o.mf.rf.date_dtd.e", "1046-01-01T23:59:59Z",- "o.mf.rf.date_dtd.g", "+4YEARS,+5YEARS",- "o.mf.rf.date_dtd.ib", "upper",- "o.mf.rf.date_dtd.ib", "edge",- "o.mf.rf.date_dtd.or", "all"- };- NamedList<Object> response = queryLegacyCloudAnalytics(params);- String responseStr = response.toString();-- // Int Long- ArrayList<Double> intLong =- getValueList(response, "mi", "rangeFacets", "long_ld", "sum", false);- ArrayList<Double> intLongTest =- calculateFacetedNumberStat(- transformLists(intLongTestStart, 5, 30, "4,2,6,3", false, true, false, false, false),- "sum");- assertEquals(responseStr, intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble =- getValueList(response, "mi", "rangeFacets", "double_dd", "mean", false);- ArrayList<Double> intDoubleTest =- calculateFacetedNumberStat(- transformLists(intDoubleTestStart, 3, 39, "3,1,7", false, false, true, false, true),- "mean");- assertEquals(responseStr, intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate =- getValueList(response, "mi", "rangeFacets", "date_dtd", "count", false);- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(intDateTestStart, 7, 44, "2,7", false, true, false, true, true),- "count");- assertEquals(responseStr, intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong =- getValueList(response, "mf", "rangeFacets", "long_ld", "median", false);- ArrayList<Double> floatLongTest =- calculateFacetedNumberStat(- transformLists(floatLongTestStart, 0, 29, "1,4", false, true, true, true, true),- "median");- ;- assertEquals(responseStr, floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble =- getValueList(response, "mf", "rangeFacets", "double_dd", "count", false);- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateFacetedStat(- transformLists(- floatDoubleTestStart, 4, 47, "2,3,11", false, false, false, true, false),- "count");- assertEquals(responseStr, floatDouble, floatDoubleTest);- }-- private <T> ArrayList<ArrayList<T>> transformLists(- ArrayList<ArrayList<T>> listsStart,- int start,- int end,- int gap,- boolean hardend,- boolean incLow,- boolean incUp,- boolean incEdge,- boolean incOut) {- int off = (end - start) % gap;- if (!hardend && off > 0) {- end += gap - off;- }-- ArrayList<ArrayList<T>> lists = new ArrayList<>();- ArrayList<T> between = new ArrayList<>();- if (incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else if (incLow && !incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- } else if (!incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- }-- if (incEdge && !incLow && start >= 0) {- lists.get(0).addAll(listsStart.get(start));- between.addAll(listsStart.get(start));- }- if (incEdge && !incUp && end < listsStart.size()) {- lists.get(lists.size() - 1).addAll(listsStart.get(end));- between.addAll(listsStart.get(end));- }- ArrayList<T> before = new ArrayList<>();- ArrayList<T> after = new ArrayList<>();- if (incOut || !(incLow || incEdge)) {- for (int i = 0; i <= start; i++) {- before.addAll(listsStart.get(i));- }- } else {- for (int i = 0; i < start; i++) {- before.addAll(listsStart.get(i));- }- }- if (incOut || !(incUp || incEdge)) {- for (int i = end; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- } else {- for (int i = end + 1; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- }- lists.add(before);- lists.add(after);- lists.add(between);- return lists;- }-- private <T> ArrayList<ArrayList<T>> transformLists(- ArrayList<ArrayList<T>> listsStart,- int start,- int end,- String gapString,- boolean hardend,- boolean incLow,- boolean incUp,- boolean incEdge,- boolean incOut) {- String[] stringGaps = gapString.split(",");- int[] gaps = new int[stringGaps.length];- for (int i = 0; i < gaps.length; i++) {- gaps[i] = Integer.parseInt(stringGaps[i]);- }- int bigGap = 0;- int last = gaps[gaps.length - 1];- for (int i = 0; i < gaps.length - 1; i++) {- bigGap += gaps[i];- }- int off = (end - start - bigGap) % last;- if (!hardend && off > 0) {- end += last - off;- }-- ArrayList<ArrayList<T>> lists = new ArrayList<>();- ArrayList<T> between = new ArrayList<>();- int gap = 0;- int gapCounter = 0;- if (incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else if (incLow && !incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- } else if (!incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- }-- if (incEdge && !incLow && start >= 0) {- lists.get(0).addAll(listsStart.get(start));- between.addAll(listsStart.get(start));- }- if (incEdge && !incUp && end < listsStart.size()) {- lists.get(lists.size() - 1).addAll(listsStart.get(end));- between.addAll(listsStart.get(end));- }- ArrayList<T> before = new ArrayList<>();- ArrayList<T> after = new ArrayList<>();- if (incOut || !(incLow || incEdge)) {- for (int i = 0; i <= start; i++) {- before.addAll(listsStart.get(i));- }- } else {- for (int i = 0; i < start; i++) {- before.addAll(listsStart.get(i));- }- }- if (incOut || !(incUp || incEdge)) {- for (int i = end; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- } else {- for (int i = end + 1; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- }- lists.add(before);- lists.add(after);- lists.add(between);- return lists;- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetTest.javadeleted file mode 100644index 8214eaa19de..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyRangeFacetTest.java+++ /dev/null@@ -1,471 +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.legacy.facet;--import java.util.ArrayList;-import org.junit.BeforeClass;-import org.junit.Test;--public class LegacyRangeFacetTest extends LegacyAbstractAnalyticsFacetTest {- static String fileName = "rangeFacets.txt";-- public static final int INT = 71;- public static final int LONG = 36;- public static final int FLOAT = 93;- public static final int DOUBLE = 48;- public static final int DATE = 52;- public static final int STRING = 28;- public static final int NUM_LOOPS = 100;-- // INT- static ArrayList<ArrayList<Integer>> intLongTestStart;- static ArrayList<ArrayList<Integer>> intDoubleTestStart;- static ArrayList<ArrayList<Integer>> intDateTestStart;-- // FLOAT- static ArrayList<ArrayList<Float>> floatLongTestStart;- static ArrayList<ArrayList<Float>> floatDoubleTestStart;- static ArrayList<ArrayList<Float>> floatDateTestStart;-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- h.update("<delete><query>*:*</query></delete>");-- // INT- intLongTestStart = new ArrayList<>();- intDoubleTestStart = new ArrayList<>();- intDateTestStart = new ArrayList<>();-- // FLOAT- floatLongTestStart = new ArrayList<>();- floatDoubleTestStart = new ArrayList<>();- floatDateTestStart = new ArrayList<>();-- for (int j = 0; j < NUM_LOOPS; ++j) {- int i = j % INT;- long l = j % LONG;- float f = j % FLOAT;- double d = j % DOUBLE;- int dt = j % DATE;- int s = j % STRING;- assertU(- adoc(- "id",- "1000" + j,- "int_id",- "" + i,- "long_ld",- "" + l,- "float_fd",- "" + f,- "double_dd",- "" + d,- "date_dtd",- (1000 + dt) + "-01-01T23:59:59Z",- "string_sd",- "abc" + s));- // Longs- if (j - LONG < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intLongTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatLongTestStart.add(list2);- } else {- intLongTestStart.get((int) l).add(i);- floatLongTestStart.get((int) l).add(f);- }- // Doubles- if (j - DOUBLE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDoubleTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatDoubleTestStart.add(list2);- } else {- intDoubleTestStart.get((int) d).add(i);- floatDoubleTestStart.get((int) d).add(f);- }- // Dates- if (j - DATE < 0) {- ArrayList<Integer> list1 = new ArrayList<>();- list1.add(i);- intDateTestStart.add(list1);- ArrayList<Float> list2 = new ArrayList<>();- list2.add(f);- floatDateTestStart.add(list2);- } else {- intDateTestStart.get(dt).add(i);- floatDateTestStart.get(dt).add(f);- }-- if (usually()) {- assertU(commit()); // to have several segments- }- }-- assertU(commit());-- setResponse(h.query(request(fileToStringArr(LegacyRangeFacetTest.class, fileName))));- }-- @SuppressWarnings("unchecked")- @Test- public void rangeTest() throws Exception {-- // Int Long- ArrayList<Long> intLong = getLongList("ri", "rangeFacets", "long_ld", "long", "count");- ArrayList<Long> intLongTest =- calculateStat(- transformLists(intLongTestStart, 5, 30, 5, false, true, false, false, false), "count");- assertEquals(getRawResponse(), intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble = getDoubleList("ri", "rangeFacets", "double_dd", "double", "mean");- ArrayList<Double> intDoubleTest =- calculateNumberStat(- transformLists(intDoubleTestStart, 3, 39, 7, false, false, true, false, true), "mean");- assertEquals(getRawResponse(), intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate = getLongList("ri", "rangeFacets", "date_dtd", "long", "count");- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateStat(- transformLists(intDateTestStart, 7, 44, 7, false, true, false, true, true),- "count");- assertEquals(getRawResponse(), intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong = getDoubleList("rf", "rangeFacets", "long_ld", "double", "median");- ArrayList<Double> floatLongTest =- calculateNumberStat(- transformLists(floatLongTestStart, 0, 29, 4, false, true, true, true, true), "median");- assertEquals(getRawResponse(), floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble = getLongList("rf", "rangeFacets", "double_dd", "long", "count");- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateStat(- transformLists(floatDoubleTestStart, 4, 47, 11, false, false, false, true, false),- "count");- assertEquals(getRawResponse(), floatDouble, floatDoubleTest);- }-- @SuppressWarnings("unchecked")- @Test- public void hardendRangeTest() throws Exception {- // Int Long- ArrayList<Double> intLong = getDoubleList("hi", "rangeFacets", "long_ld", "double", "sum");- ArrayList<Double> intLongTest =- calculateNumberStat(- transformLists(intLongTestStart, 5, 30, 5, true, true, false, false, false), "sum");- assertEquals(getRawResponse(), intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble = getDoubleList("hi", "rangeFacets", "double_dd", "double", "mean");- ArrayList<Double> intDoubleTest =- calculateNumberStat(- transformLists(intDoubleTestStart, 3, 39, 7, true, false, true, false, true), "mean");- assertEquals(getRawResponse(), intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate = getLongList("hi", "rangeFacets", "date_dtd", "long", "count");- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateStat(- transformLists(intDateTestStart, 7, 44, 7, true, true, false, true, true), "count");- assertEquals(getRawResponse(), intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong = getDoubleList("hf", "rangeFacets", "long_ld", "double", "median");- ArrayList<Double> floatLongTest =- calculateNumberStat(- transformLists(floatLongTestStart, 0, 29, 4, true, true, true, true, true), "median");- assertEquals(getRawResponse(), floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble = getLongList("hf", "rangeFacets", "double_dd", "long", "count");- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateStat(- transformLists(floatDoubleTestStart, 4, 47, 11, true, false, false, true, false),- "count");- assertEquals(getRawResponse(), floatDouble, floatDoubleTest);- }-- @SuppressWarnings("unchecked")- @Test- public void multiGapTest() throws Exception {- // Int Long- ArrayList<Double> intLong = getDoubleList("mi", "rangeFacets", "long_ld", "double", "sum");- ArrayList<Double> intLongTest =- calculateNumberStat(- transformLists(intLongTestStart, 5, 30, "4,2,6,3", false, true, false, false, false),- "sum");- assertEquals(getRawResponse(), intLong, intLongTest);- // Int Double- ArrayList<Double> intDouble = getDoubleList("mi", "rangeFacets", "double_dd", "double", "mean");- ArrayList<Double> intDoubleTest =- calculateNumberStat(- transformLists(intDoubleTestStart, 3, 39, "3,1,7", false, false, true, false, true),- "mean");- assertEquals(getRawResponse(), intDouble, intDoubleTest);- // Int Date- ArrayList<Long> intDate = getLongList("mi", "rangeFacets", "date_dtd", "long", "count");- ArrayList<Long> intDateTest =- (ArrayList<Long>)- calculateStat(- transformLists(intDateTestStart, 7, 44, "2,7", false, true, false, true, true),- "count");- assertEquals(getRawResponse(), intDate, intDateTest);-- // Float Long- ArrayList<Double> floatLong = getDoubleList("mf", "rangeFacets", "long_ld", "double", "median");- ArrayList<Double> floatLongTest =- calculateNumberStat(- transformLists(floatLongTestStart, 0, 29, "1,4", false, true, true, true, true),- "median");- ;- assertEquals(getRawResponse(), floatLong, floatLongTest);- // Float Double- ArrayList<Long> floatDouble = getLongList("mf", "rangeFacets", "double_dd", "long", "count");- ArrayList<Long> floatDoubleTest =- (ArrayList<Long>)- calculateStat(- transformLists(- floatDoubleTestStart, 4, 47, "2,3,11", false, false, false, true, false),- "count");- assertEquals(getRawResponse(), floatDouble, floatDoubleTest);- }-- private <T> ArrayList<ArrayList<T>> transformLists(- ArrayList<ArrayList<T>> listsStart,- int start,- int end,- int gap,- boolean hardend,- boolean incLow,- boolean incUp,- boolean incEdge,- boolean incOut) {- int off = (end - start) % gap;- if (!hardend && off > 0) {- end += gap - off;- }-- ArrayList<ArrayList<T>> lists = new ArrayList<>();- ArrayList<T> between = new ArrayList<>();- if (incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else if (incLow && !incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- } else if (!incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- }-- if (incEdge && !incLow && start >= 0) {- lists.get(0).addAll(listsStart.get(start));- between.addAll(listsStart.get(start));- }- if (incEdge && !incUp && end < listsStart.size()) {- lists.get(lists.size() - 1).addAll(listsStart.get(end));- between.addAll(listsStart.get(end));- }- ArrayList<T> before = new ArrayList<>();- ArrayList<T> after = new ArrayList<>();- if (incOut || !(incLow || incEdge)) {- for (int i = 0; i <= start; i++) {- before.addAll(listsStart.get(i));- }- } else {- for (int i = 0; i < start; i++) {- before.addAll(listsStart.get(i));- }- }- if (incOut || !(incUp || incEdge)) {- for (int i = end; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- } else {- for (int i = end + 1; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- }- lists.add(before);- lists.add(after);- lists.add(between);- return lists;- }-- private <T> ArrayList<ArrayList<T>> transformLists(- ArrayList<ArrayList<T>> listsStart,- int start,- int end,- String gapString,- boolean hardend,- boolean incLow,- boolean incUp,- boolean incEdge,- boolean incOut) {- String[] stringGaps = gapString.split(",");- int[] gaps = new int[stringGaps.length];- for (int i = 0; i < gaps.length; i++) {- gaps[i] = Integer.parseInt(stringGaps[i]);- }- int bigGap = 0;- int last = gaps[gaps.length - 1];- for (int i = 0; i < gaps.length - 1; i++) {- bigGap += gaps[i];- }- int off = (end - start - bigGap) % last;- if (!hardend && off > 0) {- end += last - off;- }-- ArrayList<ArrayList<T>> lists = new ArrayList<>();- ArrayList<T> between = new ArrayList<>();- int gap = 0;- int gapCounter = 0;- if (incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else if (incLow && !incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- } else if (!incLow && incUp) {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j <= i + gap && j <= end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i <= end; i++) {- between.addAll(listsStart.get(i));- }- } else {- for (int i = start; i < end && i < listsStart.size(); i += gap) {- if (gapCounter < gaps.length) {- gap = gaps[gapCounter++];- }- ArrayList<T> list = new ArrayList<>();- for (int j = i + 1; j < i + gap && j < end && j < listsStart.size(); j++) {- list.addAll(listsStart.get(j));- }- lists.add(list);- }- for (int i = start + 1; i < listsStart.size() && i < end; i++) {- between.addAll(listsStart.get(i));- }- }-- if (incEdge && !incLow && start >= 0) {- lists.get(0).addAll(listsStart.get(start));- between.addAll(listsStart.get(start));- }- if (incEdge && !incUp && end < listsStart.size()) {- lists.get(lists.size() - 1).addAll(listsStart.get(end));- between.addAll(listsStart.get(end));- }- ArrayList<T> before = new ArrayList<>();- ArrayList<T> after = new ArrayList<>();- if (incOut || !(incLow || incEdge)) {- for (int i = 0; i <= start; i++) {- before.addAll(listsStart.get(i));- }- } else {- for (int i = 0; i < start; i++) {- before.addAll(listsStart.get(i));- }- }- if (incOut || !(incUp || incEdge)) {- for (int i = end; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- } else {- for (int i = end + 1; i < listsStart.size(); i++) {- after.addAll(listsStart.get(i));- }- }- lists.add(before);- lists.add(after);- lists.add(between);- return lists;- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/util/OldAnalyticsRequestConverterUnitTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/util/OldAnalyticsRequestConverterUnitTest.javadeleted file mode 100644index 2fe0876cee1..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/util/OldAnalyticsRequestConverterUnitTest.java+++ /dev/null@@ -1,73 +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.util;--import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsExpressionSortRequest;-import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRequest;-import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsValueFacetRequest;--import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsFacetRequest;-import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRangeFacetRequest;-import org.apache.solr.analytics.legacy.facet.LegacyAbstractAnalyticsFacetTest;-import org.apache.solr.common.params.SolrParams;-import org.junit.BeforeClass;-import org.junit.Test;--@ThreadLeakLingering(linger = 10)-public class OldAnalyticsRequestConverterUnitTest extends LegacyAbstractAnalyticsFacetTest {- String fileName = "facetWithDottedFields.txt";-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-analytics.xml", "schema-analytics.xml");- }-- @Test- public void testConvertFieldFacetWithDottedField() throws Exception {- SolrParams params =- request(fileToStringArr(OldAnalyticsRequestConverterUnitTest.class, fileName)).getParams();- AnalyticsRequest request = OldAnalyticsRequestConverter.convert(params);- final AnalyticsValueFacetRequest analyticsValueFacetRequest =- (AnalyticsValueFacetRequest) request.groupings.get("df1").facets.get("long.dotfield");- assertNotNull("Sort param should be parsed for dotted field", analyticsValueFacetRequest.sort);- final AnalyticsExpressionSortRequest analyticsExpressionSortRequest =- (AnalyticsExpressionSortRequest) analyticsValueFacetRequest.sort.criteria.get(0);- assertEquals(- "Sort param expression should be parsed for dotted field",- "mean",- analyticsExpressionSortRequest.expression);- assertEquals(- "Sort param direction should be parsed for dotted field",- "asc",- analyticsExpressionSortRequest.direction);- }-- @Test- public void testConvertRangeFacetWithDottedField() throws Exception {- SolrParams params =- request(fileToStringArr(OldAnalyticsRequestConverterUnitTest.class, fileName)).getParams();- AnalyticsRequest request = OldAnalyticsRequestConverter.convert(params);-- final AnalyticsFacetRequest analyticsFacetRequest =- request.groupings.get("df2").facets.get("long.dotfield");- assertNotNull("Range facet param should be parsed for dotted field", analyticsFacetRequest);- assertEquals("30", ((AnalyticsRangeFacetRequest) analyticsFacetRequest).end);- assertTrue(((AnalyticsRangeFacetRequest) analyticsFacetRequest).hardend);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingAnalyticsValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingAnalyticsValueTest.javadeleted file mode 100644index b04ac5e39c6..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingAnalyticsValueTest.java+++ /dev/null@@ -1,56 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestAnalyticsValue;-import org.junit.Test;--public class CastingAnalyticsValueTest extends SolrTestCaseJ4 {-- @Test- public void objectStreamCastingTest() {- TestAnalyticsValue val = new TestAnalyticsValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("Object").setExists(true);- Iterator<Object> values = List.<Object>of("Object").iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestAnalyticsValue();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueStreamTest.javadeleted file mode 100644index 234cda56960..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueStreamTest.java+++ /dev/null@@ -1,81 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;-import org.junit.Test;--public class CastingBooleanValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void stringStreamCastingTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(false, true, false);- Iterator<String> values = Arrays.asList("false", "true", "false").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestBooleanValueStream val = new TestBooleanValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(false, true, false);- Iterator<Object> values =- Arrays.<Object>asList(Boolean.FALSE, Boolean.TRUE, Boolean.FALSE).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestBooleanValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueTest.javadeleted file mode 100644index b0c1d5f8785..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingBooleanValueTest.java+++ /dev/null@@ -1,155 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;-import org.apache.solr.analytics.value.constant.ConstantBooleanValue;-import org.junit.Test;--public class CastingBooleanValueTest extends SolrTestCaseJ4 {-- @Test- public void stringCastingTest() {- TestBooleanValue val = new TestBooleanValue();-- val.setValue(false).setExists(true);- assertEquals("false", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());-- val.setValue(true).setExists(true);- assertEquals("true", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() {- TestBooleanValue val = new TestBooleanValue();-- val.setValue(false).setExists(true);- assertEquals(Boolean.FALSE, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue(true).setExists(true);- assertEquals(Boolean.TRUE, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void booleanStreamCastingTest() {- TestBooleanValue val = new TestBooleanValue();-- // No values- val.setExists(false);- ((BooleanValueStream) val)- .streamBooleans(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(false).setExists(true);- Iterator<Boolean> values = List.of(false).iterator();- ((BooleanValueStream) val)- .streamBooleans(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestBooleanValue val = new TestBooleanValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(false).setExists(true);- Iterator<String> values = List.of("false").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestBooleanValue val = new TestBooleanValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(false).setExists(true);- Iterator<Object> values = List.<Object>of(Boolean.FALSE).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestBooleanValue val = new TestBooleanValue(ExpressionType.CONST);- val.setValue(true).setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantBooleanValue);- assertTrue(((ConstantBooleanValue) conv).getBoolean());-- val = new TestBooleanValue(ExpressionType.FIELD);- val.setValue(true).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestBooleanValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue(true).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestBooleanValue(ExpressionType.REDUCTION);- val.setValue(true).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestBooleanValue(ExpressionType.REDUCED_MAPPING);- val.setValue(true).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueStreamTest.javadeleted file mode 100644index 40566091956..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueStreamTest.java+++ /dev/null@@ -1,115 +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;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Arrays;-import java.util.Date;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;-import org.junit.Test;--public class CastingDateValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void dateStreamCastingTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));- TestDateValueStream val = new TestDateValueStream();-- // No values- val.setValues();- ((DateValueStream) val)- .streamDates(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");- Iterator<Date> values = Arrays.asList(date1, date2, date3).iterator();- ((DateValueStream) val)- .streamDates(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().toInstant(), value.toInstant());- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestDateValueStream val = new TestDateValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");- Iterator<String> values =- Arrays.asList("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z")- .iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() throws DateTimeParseException {- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));- TestDateValueStream val = new TestDateValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");- Iterator<Object> values = Arrays.<Object>asList(date1, date2, date3).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestDateValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueTest.javadeleted file mode 100644index cc77d7ac7f5..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDateValueTest.java+++ /dev/null@@ -1,165 +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;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;-import org.apache.solr.analytics.value.constant.ConstantDateValue;-import org.junit.Test;--public class CastingDateValueTest extends SolrTestCaseJ4 {-- @Test- public void dateCastingTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- TestDateValue val = new TestDateValue();-- val.setValue("1800-01-01T10:30:15Z").setExists(true);- assertEquals(date.toInstant(), ((DateValue) val).getDate().toInstant());- assertTrue(((DateValue) val).exists());- }-- @Test- public void stringCastingTest() {- TestDateValue val = new TestDateValue();-- val.setValue("1800-01-01T10:30:15Z").setExists(true);- assertEquals("1800-01-01T10:30:15Z", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- TestDateValue val = new TestDateValue();-- val.setValue("1800-01-01T10:30:15Z").setExists(true);- assertEquals(date.toInstant(), ((Date) ((AnalyticsValue) val).getObject()).toInstant());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void dateStreamCastingTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- TestDateValue val = new TestDateValue();-- // No values- val.setExists(false);- ((DateValueStream) val)- .streamDates(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("1800-01-01T10:30:15Z").setExists(true);- Iterator<Date> values = List.of(date).iterator();- ((DateValueStream) val)- .streamDates(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().toInstant(), value.toInstant());- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestDateValue val = new TestDateValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("1800-01-01T10:30:15Z").setExists(true);- Iterator<String> values = List.of("1800-01-01T10:30:15Z").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- TestDateValue val = new TestDateValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("1800-01-01T10:30:15Z").setExists(true);- Iterator<Object> values = List.<Object>of(date).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));-- TestDateValue val = new TestDateValue(ExpressionType.CONST);- val.setValue("1800-01-01T10:30:15Z").setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantDateValue);- assertEquals(date.toInstant(), ((ConstantDateValue) conv).getDate().toInstant());-- val = new TestDateValue(ExpressionType.FIELD);- val.setValue("1800-01-01T10:30:15Z").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDateValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue("1800-01-01T10:30:15Z").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDateValue(ExpressionType.REDUCTION);- val.setValue("1800-01-01T10:30:15Z").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDateValue(ExpressionType.REDUCED_MAPPING);- val.setValue("1800-01-01T10:30:15Z").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueStreamTest.javadeleted file mode 100644index a5fc2d9daa4..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueStreamTest.java+++ /dev/null@@ -1,80 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;-import org.junit.Test;--public class CastingDoubleValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void stringStreamCastingTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20.0, -3.32, 42.5);- Iterator<String> values = Arrays.asList("20.0", "-3.32", "42.5").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestDoubleValueStream val = new TestDoubleValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20.0, -3.32, 42.5);- Iterator<Object> values = Arrays.<Object>asList(20.0, -3.32, 42.5).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestDoubleValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueTest.javadeleted file mode 100644index d945e0502d6..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingDoubleValueTest.java+++ /dev/null@@ -1,155 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;-import org.apache.solr.analytics.value.constant.ConstantDoubleValue;-import org.junit.Test;--public class CastingDoubleValueTest extends SolrTestCaseJ4 {-- @Test- public void stringCastingTest() {- TestDoubleValue val = new TestDoubleValue();-- val.setValue(20.0).setExists(true);- assertEquals("20.0", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());-- val.setValue(1234.0).setExists(true);- assertEquals("1234.0", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() {- TestDoubleValue val = new TestDoubleValue();-- val.setValue(20.0).setExists(true);- assertEquals(20.0d, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue(1234.0).setExists(true);- assertEquals(1234.0d, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void doubleStreamCastingTest() {- TestDoubleValue val = new TestDoubleValue();-- // No values- val.setExists(false);- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20.0).setExists(true);- Iterator<Double> values = List.of(20.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestDoubleValue val = new TestDoubleValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20.0).setExists(true);- Iterator<String> values = List.of("20.0").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestDoubleValue val = new TestDoubleValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20.0).setExists(true);- Iterator<Object> values = List.<Object>of(20.0d).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestDoubleValue val = new TestDoubleValue(ExpressionType.CONST);- val.setValue(12354.234).setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantDoubleValue);- assertEquals(12354.234, ((ConstantDoubleValue) conv).getDouble(), .0000001);-- val = new TestDoubleValue(ExpressionType.FIELD);- val.setValue(12354.234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDoubleValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue(12354.234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDoubleValue(ExpressionType.REDUCTION);- val.setValue(12354.234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestDoubleValue(ExpressionType.REDUCED_MAPPING);- val.setValue(12354.234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueStreamTest.javadeleted file mode 100644index 916ea101968..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueStreamTest.java+++ /dev/null@@ -1,104 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;-import org.junit.Test;--public class CastingFloatValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void doubleStreamCastingTest() {- TestFloatValueStream val = new TestFloatValueStream();-- // No values- val.setValues();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20F, -3.32F, 42.5F);- Iterator<Double> values = Arrays.asList(20.0, -3.32, 42.5).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestFloatValueStream val = new TestFloatValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20F, -3.32F, 42.5F);- Iterator<String> values = Arrays.asList("20.0", "-3.32", "42.5").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestFloatValueStream val = new TestFloatValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20F, -3.32F, 42.5F);- Iterator<Object> values = Arrays.<Object>asList(20F, -3.32F, 42.5F).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestFloatValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueTest.javadeleted file mode 100644index 36c10f8616b..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingFloatValueTest.java+++ /dev/null@@ -1,192 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;-import org.apache.solr.analytics.value.constant.ConstantFloatValue;-import org.junit.Test;--public class CastingFloatValueTest extends SolrTestCaseJ4 {-- @Test- public void doubleCastingTest() {- TestFloatValue val = new TestFloatValue();-- val.setValue(20F).setExists(true);- assertEquals(20.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());-- val.setValue(1234F).setExists(true);- assertEquals(1234.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());- }-- @Test- public void stringCastingTest() {- TestFloatValue val = new TestFloatValue();-- val.setValue(20F).setExists(true);- assertEquals("20.0", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());-- val.setValue(1234F).setExists(true);- assertEquals("1234.0", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() {- TestFloatValue val = new TestFloatValue();-- val.setValue(20F).setExists(true);- assertEquals(20F, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue(1234F).setExists(true);- assertEquals(1234F, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void floatStreamCastingTest() {- TestFloatValue val = new TestFloatValue();-- // No values- val.setExists(false);- ((FloatValueStream) val)- .streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20F).setExists(true);- Iterator<Float> values = List.of(20F).iterator();- ((FloatValueStream) val)- .streamFloats(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void doubleStreamCastingTest() {- TestFloatValue val = new TestFloatValue();-- // No values- val.setExists(false);- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20F).setExists(true);- Iterator<Double> values = List.of(20.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestFloatValue val = new TestFloatValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20F).setExists(true);- Iterator<String> values = List.of("20.0").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestFloatValue val = new TestFloatValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20F).setExists(true);- Iterator<Object> values = List.<Object>of(20F).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestFloatValue val = new TestFloatValue(ExpressionType.CONST);- val.setValue(12354.234F).setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantFloatValue);- assertEquals(12354.234F, ((ConstantFloatValue) conv).getFloat(), .0000001);-- val = new TestFloatValue(ExpressionType.FIELD);- val.setValue(12354.234F).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestFloatValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue(12354.234F).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestFloatValue(ExpressionType.REDUCTION);- val.setValue(12354.234F).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestFloatValue(ExpressionType.REDUCED_MAPPING);- val.setValue(12354.234F).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueStreamTest.javadeleted file mode 100644index 1a4869df6c6..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueStreamTest.java+++ /dev/null@@ -1,152 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;-import org.junit.Test;--public class CastingIntValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void longStreamCastingTest() {- TestIntValueStream val = new TestIntValueStream();-- // No values- val.setValues();- ((LongValueStream) val)- .streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20, -3, 42);- Iterator<Long> values = Arrays.asList(20L, -3L, 42L).iterator();- ((LongValueStream) val)- .streamLongs(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().longValue(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void floatStreamCastingTest() {- TestIntValueStream val = new TestIntValueStream();-- // No values- val.setValues();- ((FloatValueStream) val)- .streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20, -3, 42);- Iterator<Float> values = Arrays.asList(20F, -3F, 42F).iterator();- ((FloatValueStream) val)- .streamFloats(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void doubleStreamCastingTest() {- TestIntValueStream val = new TestIntValueStream();-- // No values- val.setValues();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20, -3, 42);- Iterator<Double> values = Arrays.asList(20.0, -3.0, 42.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestIntValueStream val = new TestIntValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20, -3, 42);- Iterator<String> values = Arrays.asList("20", "-3", "42").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestIntValueStream val = new TestIntValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20, -3, 42);- Iterator<Object> values = Arrays.<Object>asList(20, -3, 42).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestIntValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueTest.javadeleted file mode 100644index db03dc8a1b4..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingIntValueTest.java+++ /dev/null@@ -1,266 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.constant.ConstantIntValue;-import org.junit.Test;--public class CastingIntValueTest extends SolrTestCaseJ4 {-- @Test- public void longCastingTest() {- TestIntValue val = new TestIntValue();-- val.setValue(20).setExists(true);- assertEquals(20L, ((LongValue) val).getLong());- assertTrue(((LongValue) val).exists());-- val.setValue(1234).setExists(true);- assertEquals(1234L, ((LongValue) val).getLong());- assertTrue(((LongValue) val).exists());- }-- @Test- public void floatCastingTest() {- TestIntValue val = new TestIntValue();-- val.setValue(20).setExists(true);- assertEquals(20F, ((FloatValue) val).getFloat(), .00001);- assertTrue(((FloatValue) val).exists());-- val.setValue(1234).setExists(true);- assertEquals(1234F, ((FloatValue) val).getFloat(), .00001);- assertTrue(((FloatValue) val).exists());- }-- @Test- public void doubleCastingTest() {- TestIntValue val = new TestIntValue();-- val.setValue(20).setExists(true);- assertEquals(20.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());-- val.setValue(1234).setExists(true);- assertEquals(1234.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());- }-- @Test- public void stringCastingTest() {- TestIntValue val = new TestIntValue();-- val.setValue(20).setExists(true);- assertEquals("20", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());-- val.setValue(1234).setExists(true);- assertEquals("1234", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() {- TestIntValue val = new TestIntValue();-- val.setValue(20).setExists(true);- assertEquals(20, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue(1234).setExists(true);- assertEquals(1234, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void intStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((IntValueStream) val)- .streamInts(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<Integer> values = List.of(20).iterator();- ((IntValueStream) val)- .streamInts(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().intValue(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void longStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((LongValueStream) val)- .streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<Long> values = List.of(20L).iterator();- ((LongValueStream) val)- .streamLongs(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().longValue(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void floatStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((FloatValueStream) val)- .streamFloats(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<Float> values = List.of(20F).iterator();- ((FloatValueStream) val)- .streamFloats(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void doubleStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<Double> values = List.of(20.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<String> values = List.of("20").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestIntValue val = new TestIntValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20).setExists(true);- Iterator<Object> values = List.<Object>of(20).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestIntValue val = new TestIntValue(ExpressionType.CONST);- val.setValue(1234).setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantIntValue);- assertEquals(1234, ((ConstantIntValue) conv).getInt());-- val = new TestIntValue(ExpressionType.FIELD);- val.setValue(1234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestIntValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue(1234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestIntValue(ExpressionType.REDUCTION);- val.setValue(1234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestIntValue(ExpressionType.REDUCED_MAPPING);- val.setValue(1234).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueStreamTest.javadeleted file mode 100644index 6595c9564e9..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueStreamTest.java+++ /dev/null@@ -1,104 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;-import org.junit.Test;--public class CastingLongValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void doubleStreamCastingTest() {- TestLongValueStream val = new TestLongValueStream();-- // No values- val.setValues();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20L, -3L, 42L);- Iterator<Double> values = Arrays.asList(20.0, -3.0, 42.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestLongValueStream val = new TestLongValueStream();-- // No values- val.setValues();- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20L, -3L, 42L);- Iterator<String> values = Arrays.asList("20", "-3", "42").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestLongValueStream val = new TestLongValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues(20L, -3L, 42L);- Iterator<Object> values = Arrays.<Object>asList(20L, -3L, 42L).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestLongValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueTest.javadeleted file mode 100644index 07fd5fda2c5..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingLongValueTest.java+++ /dev/null@@ -1,192 +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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;-import org.apache.solr.analytics.value.constant.ConstantLongValue;-import org.junit.Test;--public class CastingLongValueTest extends SolrTestCaseJ4 {-- @Test- public void doubleCastingTest() {- TestLongValue val = new TestLongValue();-- val.setValue(20L).setExists(true);- assertEquals(20.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());-- val.setValue(1234L).setExists(true);- assertEquals(1234.0, ((DoubleValue) val).getDouble(), .00001);- assertTrue(((DoubleValue) val).exists());- }-- @Test- public void stringCastingTest() {- TestLongValue val = new TestLongValue();-- val.setValue(20L).setExists(true);- assertEquals("20", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());-- val.setValue(1234L).setExists(true);- assertEquals("1234", ((StringValue) val).getString());- assertTrue(((StringValue) val).exists());- }-- @Test- public void objectCastingTest() {- TestLongValue val = new TestLongValue();-- val.setValue(20L).setExists(true);- assertEquals(20L, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue(1234L).setExists(true);- assertEquals(1234L, ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void longStreamCastingTest() {- TestLongValue val = new TestLongValue();-- // No values- val.setExists(false);- ((LongValueStream) val)- .streamLongs(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20L).setExists(true);- Iterator<Long> values = List.of(20L).iterator();- ((LongValueStream) val)- .streamLongs(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next().longValue(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void doubleStreamCastingTest() {- TestLongValue val = new TestLongValue();-- // No values- val.setExists(false);- ((DoubleValueStream) val)- .streamDoubles(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20L).setExists(true);- Iterator<Double> values = List.of(20.0).iterator();- ((DoubleValueStream) val)- .streamDoubles(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value, .00001);- });- assertFalse(values.hasNext());- }-- @Test- public void stringStreamCastingTest() {- TestLongValue val = new TestLongValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20L).setExists(true);- Iterator<String> values = List.of("20").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestLongValue val = new TestLongValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue(20L).setExists(true);- Iterator<Object> values = List.<Object>of(20L).iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestLongValue val = new TestLongValue(ExpressionType.CONST);- val.setValue(12341L).setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantLongValue);- assertEquals(12341L, ((ConstantLongValue) conv).getLong());-- val = new TestLongValue(ExpressionType.FIELD);- val.setValue(12341L).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestLongValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue(12341L).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestLongValue(ExpressionType.REDUCTION);- val.setValue(12341L).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestLongValue(ExpressionType.REDUCED_MAPPING);- val.setValue(12341L).setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueStreamTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueStreamTest.javadeleted file mode 100644index 744ab96febb..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueStreamTest.java+++ /dev/null@@ -1,56 +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;--import java.util.Arrays;-import java.util.Iterator;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;-import org.junit.Test;--public class CastingStringValueStreamTest extends SolrTestCaseJ4 {-- @Test- public void objectStreamCastingTest() {- TestStringValueStream val = new TestStringValueStream();-- // No values- val.setValues();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValues("abc", "def", "ghi");- Iterator<Object> values = Arrays.<Object>asList("abc", "def", "ghi").iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new TestStringValueStream();- assertSame(val, val.convertToConstant());- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueTest.javadeleted file mode 100644index 66bce7df991..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/CastingStringValueTest.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;--import java.util.Iterator;-import java.util.List;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.AnalyticsValueStream.ExpressionType;-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.junit.Test;--public class CastingStringValueTest extends SolrTestCaseJ4 {-- @Test- public void objectCastingTest() {- TestStringValue val = new TestStringValue();-- val.setValue("string 1").setExists(true);- assertEquals("string 1", ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());-- val.setValue("abc").setExists(true);- assertEquals("abc", ((AnalyticsValue) val).getObject());- assertTrue(((AnalyticsValue) val).exists());- }-- @Test- public void stringStreamCastingTest() {- TestStringValue val = new TestStringValue();-- // No values- val.setExists(false);- ((StringValueStream) val)- .streamStrings(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("abcd").setExists(true);- Iterator<String> values = List.of("abcd").iterator();- ((StringValueStream) val)- .streamStrings(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void objectStreamCastingTest() {- TestStringValue val = new TestStringValue();-- // No values- val.setExists(false);- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- fail("There should be no values to stream");- });-- // Multiple Values- val.setValue("abcd").setExists(true);- Iterator<Object> values = List.<Object>of("abcd").iterator();- ((AnalyticsValueStream) val)- .streamObjects(- value -> {- assertTrue(values.hasNext());- assertEquals(values.next(), value);- });- assertFalse(values.hasNext());- }-- @Test- public void constantConversionTest() {- TestStringValue val = new TestStringValue(ExpressionType.CONST);- val.setValue("asd23n23").setExists(true);- AnalyticsValueStream conv = val.convertToConstant();- assertTrue(conv instanceof ConstantStringValue);- assertEquals("asd23n23", ((ConstantStringValue) conv).getString());-- val = new TestStringValue(ExpressionType.FIELD);- val.setValue("asd23n23").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestStringValue(ExpressionType.UNREDUCED_MAPPING);- val.setValue("asd23n23").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestStringValue(ExpressionType.REDUCTION);- val.setValue("asd23n23").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);-- val = new TestStringValue(ExpressionType.REDUCED_MAPPING);- val.setValue("asd23n23").setExists(true);- conv = val.convertToConstant();- assertSame(val, conv);- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/ConstantValueTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/ConstantValueTest.javadeleted file mode 100644index 85e40b7c1e5..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/ConstantValueTest.java+++ /dev/null@@ -1,396 +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;--import java.time.Instant;-import java.time.format.DateTimeParseException;-import java.util.Date;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;-import org.apache.solr.analytics.value.constant.ConstantBooleanValue;-import org.apache.solr.analytics.value.constant.ConstantDateValue;-import org.apache.solr.analytics.value.constant.ConstantDoubleValue;-import org.apache.solr.analytics.value.constant.ConstantFloatValue;-import org.apache.solr.analytics.value.constant.ConstantIntValue;-import org.apache.solr.analytics.value.constant.ConstantLongValue;-import org.apache.solr.analytics.value.constant.ConstantStringValue;-import org.apache.solr.analytics.value.constant.ConstantValue;-import org.junit.Test;--public class ConstantValueTest extends SolrTestCaseJ4 {-- @Test- public void constantParsingTest() throws DateTimeParseException {- // Int- AnalyticsValueStream uncasted = ConstantValue.creatorFunction.apply("1234");- assertTrue(uncasted instanceof ConstantIntValue);- assertEquals(1234, ((ConstantIntValue) uncasted).getInt());-- // Long- uncasted = ConstantValue.creatorFunction.apply("1234123412341234");- assertTrue(uncasted instanceof ConstantLongValue);- assertEquals(1234123412341234L, ((ConstantLongValue) uncasted).getLong());-- // Floats cannot currently be implicitly created-- // Double- uncasted = ConstantValue.creatorFunction.apply("12341234.12341234");- assertTrue(uncasted instanceof ConstantDoubleValue);- assertEquals(12341234.12341234, ((ConstantDoubleValue) uncasted).getDouble(), 0);-- // String- uncasted = ConstantValue.creatorFunction.apply("'abcdef'");- assertTrue(uncasted instanceof ConstantStringValue);- assertEquals("abcdef", ((ConstantStringValue) uncasted).getString());-- uncasted = ConstantValue.creatorFunction.apply("\"abcdef\"");- assertTrue(uncasted instanceof ConstantStringValue);- assertEquals("abcdef", ((ConstantStringValue) uncasted).getString());-- // Date- uncasted = ConstantValue.creatorFunction.apply("1800-01-01T10:30:15.33Z");- assertTrue(uncasted instanceof ConstantDateValue);- assertEquals(- Instant.parse("1800-01-01T10:30:15.33Z"),- ((ConstantDateValue) uncasted).getDate().toInstant());- }-- @Test- public void constantConversionTest() {- AnalyticsValueStream val = new ConstantBooleanValue(true);- assertSame(val, val.convertToConstant());-- val = new ConstantIntValue(123);- assertSame(val, val.convertToConstant());-- val = new ConstantLongValue(123L);- assertSame(val, val.convertToConstant());-- val = new ConstantFloatValue(123F);- assertSame(val, val.convertToConstant());-- val = new ConstantDoubleValue(123.0);- assertSame(val, val.convertToConstant());-- val = new ConstantDateValue(123L);- assertSame(val, val.convertToConstant());-- val = new ConstantStringValue("123");- assertSame(val, val.convertToConstant());- }-- @Test- public void constantBooleanTest() {- ConstantBooleanValue val = new ConstantBooleanValue(true);-- assertTrue(val.exists());- assertTrue(val.getBoolean());- assertEquals("true", val.getString());- assertEquals(Boolean.TRUE, val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamBooleans(- value -> {- assertTrue(value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("true", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(Boolean.TRUE, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });-- val = new ConstantBooleanValue(false);-- assertTrue(val.exists());- assertFalse(val.getBoolean());- assertEquals("false", val.getString());- assertEquals(Boolean.FALSE, val.getObject());-- counter.setValue(0);- val.streamBooleans(- value -> {- assertFalse(value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("false", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(Boolean.FALSE, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantIntTest() {- ConstantIntValue val = new ConstantIntValue(24);-- assertTrue(val.exists());- assertEquals(24, val.getInt());- assertEquals(24L, val.getLong());- assertEquals(24F, val.getFloat(), .00001);- assertEquals(24.0, val.getDouble(), .00001);- assertEquals("24", val.getString());- assertEquals(24, val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamInts(- value -> {- assertEquals(24, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamLongs(- value -> {- assertEquals(24L, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamFloats(- value -> {- assertEquals(24F, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamDoubles(- value -> {- assertEquals(24.0, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("24", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(24, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantLongTest() {- ConstantLongValue val = new ConstantLongValue(24L);-- assertTrue(val.exists());- assertEquals(24L, val.getLong());- assertEquals(24.0, val.getDouble(), .00001);- assertEquals("24", val.getString());- assertEquals(24L, val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamLongs(- value -> {- assertEquals(24L, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamDoubles(- value -> {- assertEquals(24.0, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("24", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(24L, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantFloatTest() {- ConstantFloatValue val = new ConstantFloatValue(24F);-- assertTrue(val.exists());- assertEquals(24F, val.getFloat(), .00001);- assertEquals(24.0, val.getDouble(), .00001);- assertEquals("24.0", val.getString());- assertEquals(24F, val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamFloats(- value -> {- assertEquals(24F, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamDoubles(- value -> {- assertEquals(24.0, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("24.0", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(24F, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantDoubleTest() {- ConstantDoubleValue val = new ConstantDoubleValue(24.0);-- assertTrue(val.exists());- assertEquals(24.0, val.getDouble(), .00001);- assertEquals("24.0", val.getString());- assertEquals(24.0, val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamDoubles(- value -> {- assertEquals(24.0, value, .00001);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("24.0", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(24.0, value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantDateTest() throws DateTimeParseException {- Date date = Date.from(Instant.parse("1800-01-01T10:30:15Z"));- ConstantDateValue val = new ConstantDateValue(date.getTime());-- assertTrue(val.exists());- assertEquals(date.getTime(), val.getLong());- assertEquals(date.toInstant(), val.getDate().toInstant());- assertEquals("1800-01-01T10:30:15Z", val.getString());- assertEquals(date.toInstant(), ((Date) val.getObject()).toInstant());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamLongs(- value -> {- assertEquals(date.getTime(), value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamDates(- value -> {- assertEquals(date.toInstant(), value.toInstant());- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("1800-01-01T10:30:15Z", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals(date.toInstant(), ((Date) value).toInstant());- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-- @Test- public void constantStringTest() {- ConstantStringValue val = new ConstantStringValue("abcdef");-- assertTrue(val.exists());- assertEquals("abcdef", val.getString());- assertEquals("abcdef", val.getObject());-- TestIntValue counter = new TestIntValue();- counter.setValue(0);- val.streamStrings(- value -> {- assertEquals("abcdef", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- counter.setValue(0);- val.streamObjects(- value -> {- assertEquals("abcdef", value);- assertEquals(0, counter.getInt());- counter.setValue(1);- });- }-}diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/FillableTestValue.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/value/FillableTestValue.javadeleted file mode 100644index dab95e64eb4..00000000000--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/value/FillableTestValue.java+++ /dev/null@@ -1,737 +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;--import java.time.Instant;-import java.time.format.DateTimeParseException;-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.util.function.BooleanConsumer;-import org.apache.solr.analytics.util.function.FloatConsumer;-import org.apache.solr.analytics.value.AnalyticsValue.AbstractAnalyticsValue;-import org.apache.solr.analytics.value.AnalyticsValueStream.AbstractAnalyticsValueStream;-import org.apache.solr.analytics.value.BooleanValue.AbstractBooleanValue;-import org.apache.solr.analytics.value.BooleanValueStream.AbstractBooleanValueStream;-import org.apache.solr.analytics.value.DateValue.AbstractDateValue;-import org.apache.solr.analytics.value.DateValueStream.AbstractDateValueStream;-import org.apache.solr.analytics.value.DoubleValue.AbstractDoubleValue;-import org.apache.solr.analytics.value.DoubleValueStream.AbstractDoubleValueStream;-import org.apache.solr.analytics.value.FloatValue.AbstractFloatValue;-import org.apache.solr.analytics.value.FloatValueStream.AbstractFloatValueStream;-import org.apache.solr.analytics.value.IntValue.AbstractIntValue;-import org.apache.solr.analytics.value.IntValueStream.AbstractIntValueStream;-import org.apache.solr.analytics.value.LongValue.AbstractLongValue;-import org.apache.solr.analytics.value.LongValueStream.AbstractLongValueStream;-import org.apache.solr.analytics.value.StringValue.AbstractStringValue;-import org.apache.solr.analytics.value.StringValueStream.AbstractStringValueStream;--public class FillableTestValue {- public static class TestAnalyticsValue extends AbstractAnalyticsValue {- private final ExpressionType expressionType;-- private Object value;- private boolean exists;-- public TestAnalyticsValue() {- this(ExpressionType.CONST);- }-- public TestAnalyticsValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestAnalyticsValue setValue(Object value) {- this.value = value;- return this;- }-- public TestAnalyticsValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public Object getObject() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_analytics_value";- }-- @Override- public String getExpressionStr() {- return "test_analytics_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestAnalyticsValueStream extends AbstractAnalyticsValueStream {- private final ExpressionType expressionType;-- private Object[] values;-- public TestAnalyticsValueStream() {- this(ExpressionType.CONST);- }-- public TestAnalyticsValueStream(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestAnalyticsValueStream setValues(Object... values) {- this.values = values;- return this;- }-- @Override- public void streamObjects(Consumer<Object> cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_analytics_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_analytics_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestIntValue extends AbstractIntValue {- private final ExpressionType expressionType;-- private int value;- private boolean exists;-- public TestIntValue() {- this(ExpressionType.CONST);- }-- public TestIntValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestIntValue setValue(int value) {- this.value = value;- return this;- }-- public TestIntValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public int getInt() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_int_value";- }-- @Override- public String getExpressionStr() {- return "test_int_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestIntValueStream extends AbstractIntValueStream {- private int[] values;-- public TestIntValueStream() {- this.values = new int[0];- }-- public TestIntValueStream setValues(int... values) {- this.values = values;- return this;- }-- @Override- public void streamInts(IntConsumer cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_int_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_int_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestLongValue extends AbstractLongValue {- private final ExpressionType expressionType;-- private long value;- private boolean exists;-- public TestLongValue() {- this(ExpressionType.CONST);- }-- public TestLongValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestLongValue setValue(long value) {- this.value = value;- return this;- }-- public TestLongValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public long getLong() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_long_value";- }-- @Override- public String getExpressionStr() {- return "test_long_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestLongValueStream extends AbstractLongValueStream {- private long[] values;-- public TestLongValueStream() {- this.values = new long[0];- }-- public TestLongValueStream setValues(long... values) {- this.values = values;- return this;- }-- @Override- public void streamLongs(LongConsumer cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_long_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_long_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestFloatValue extends AbstractFloatValue {- private final ExpressionType expressionType;-- private float value;- private boolean exists;-- public TestFloatValue() {- this(ExpressionType.CONST);- }-- public TestFloatValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestFloatValue setValue(float value) {- this.value = value;- return this;- }-- public TestFloatValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public float getFloat() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_float_value";- }-- @Override- public String getExpressionStr() {- return "test_float_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestFloatValueStream extends AbstractFloatValueStream {- private float[] values;-- public TestFloatValueStream() {- this.values = new float[0];- }-- public TestFloatValueStream setValues(float... values) {- this.values = values;- return this;- }-- @Override- public void streamFloats(FloatConsumer cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_float_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_float_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestDoubleValue extends AbstractDoubleValue {- private final ExpressionType expressionType;-- private double value;- private boolean exists;-- public TestDoubleValue() {- this(ExpressionType.CONST);- }-- public TestDoubleValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestDoubleValue setValue(double value) {- this.value = value;- return this;- }-- public TestDoubleValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public double getDouble() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_double_value";- }-- @Override- public String getExpressionStr() {- return "test_double_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestDoubleValueStream extends AbstractDoubleValueStream {- private double[] values;-- public TestDoubleValueStream() {- this.values = new double[0];- }-- public TestDoubleValueStream setValues(double... values) {- this.values = values;- return this;- }-- @Override- public void streamDoubles(DoubleConsumer cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_double_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_double_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestBooleanValue extends AbstractBooleanValue {- private final ExpressionType expressionType;-- private boolean value;- private boolean exists;-- public TestBooleanValue() {- this(ExpressionType.CONST);- }-- public TestBooleanValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestBooleanValue setValue(boolean value) {- this.value = value;- return this;- }-- public TestBooleanValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public boolean getBoolean() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_boolean_value";- }-- @Override- public String getExpressionStr() {- return "test_boolean_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestBooleanValueStream extends AbstractBooleanValueStream {- private boolean[] values;-- public TestBooleanValueStream() {- this.values = new boolean[0];- }-- public TestBooleanValueStream setValues(boolean... values) {- this.values = values;- return this;- }-- @Override- public void streamBooleans(BooleanConsumer cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_boolean_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_boolean_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestDateValue extends AbstractDateValue {- private final ExpressionType expressionType;-- private long value;- private boolean exists;-- public TestDateValue() {- this(ExpressionType.CONST);- }-- public TestDateValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestDateValue setValue(String value) {- try {- this.value = Instant.parse(value).toEpochMilli();- } catch (DateTimeParseException e) {- this.value = 0;- }- return this;- }-- public TestDateValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public long getLong() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_date_value";- }-- @Override- public String getExpressionStr() {- return "test_date_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestDateValueStream extends AbstractDateValueStream {- private String[] values;-- public TestDateValueStream() {- this.values = new String[0];- }-- public TestDateValueStream setValues(String... values) {- this.values = values;- return this;- }-- @Override- public void streamLongs(LongConsumer cons) {- for (int i = 0; i < values.length; ++i) {- try {- cons.accept(Instant.parse(values[i]).toEpochMilli());- } catch (DateTimeParseException e) {- }- }- }-- @Override- public String getName() {- return "test_date_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_date_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-- public static class TestStringValue extends AbstractStringValue {- private final ExpressionType expressionType;-- private String value;- private boolean exists;-- public TestStringValue() {- this(ExpressionType.CONST);- }-- public TestStringValue(ExpressionType expressionType) {- this.expressionType = expressionType;- }-- public TestStringValue setValue(String value) {- this.value = value;- return this;- }-- public TestStringValue setExists(boolean exists) {- this.exists = exists;- return this;- }-- @Override- public String getString() {- return value;- }-- @Override- public boolean exists() {- return exists;- }-- @Override- public String getName() {- return "test_string_value";- }-- @Override- public String getExpressionStr() {- return "test_string_value";- }-- @Override- public ExpressionType getExpressionType() {- return expressionType;- }- }-- public static class TestStringValueStream extends AbstractStringValueStream {- private String[] values;-- public TestStringValueStream() {- this.values = new String[0];- }-- public TestStringValueStream setValues(String... values) {- this.values = values;- return this;- }-- @Override- public void streamStrings(Consumer<String> cons) {- for (int i = 0; i < values.length; ++i) {- cons.accept(values[i]);- }- }-- @Override- public String getName() {- return "test_string_value_stream";- }-- @Override- public String getExpressionStr() {- return "test_string_value_stream";- }-- @Override- public ExpressionType getExpressionType() {- return ExpressionType.UNREDUCED_MAPPING;- }- }-}diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adocindex 5de1e855031..5006d6eab8e 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc@@ -80,6 +80,7 @@ Unless the `-DzkHost` or `-DzkRun` are specified at startup time, this section i== Solr.xml Parameters+[#the-solr-element]=== The <solr> ElementThere are no attributes that you can specify in the `<solr>` tag, which is the root element of `solr.xml`.diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adocindex 08bf0d27f31..07dba65dff3 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc@@ -242,7 +242,6 @@ They are called in the order listed.Apart from default components, Solr ships with a number of additional - very useful - components.They do need to defined and referenced in `solrconfig.xml` to be actually used.-* `AnalyticsComponent`, described in the section xref:query-guide:analytics.adoc[] (Deprecated).* `ClusteringComponent`, described in the section xref:query-guide:result-clustering.adoc[].* `PhrasesIdentificationComponent`, used to identify & score "phrases" found in the input string, based on shingles in indexed fields, described in the {solr-javadocs}/core/org/apache/solr/handler/component/PhrasesIdentificationComponent.html[PhrasesIdentificationComponent] javadocs.* `QueryElevationComponent`, described in the section xref:query-guide:query-elevation-component.adoc[].diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adocindex d64bcaed646..75ce4974118 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc@@ -156,6 +156,7 @@ If this section is not defined, the following default configuration is used whic</metrics>----+[#the-metrics-reporters-element]=== The <metrics> <reporters> ElementReporters consume the metrics data generated by Solr.diff --git a/solr/solr-ref-guide/modules/query-guide/pages/analytics-expression-sources.adoc b/solr/solr-ref-guide/modules/query-guide/pages/analytics-expression-sources.adocdeleted file mode 100644index 7b535d558e9..00000000000--- a/solr/solr-ref-guide/modules/query-guide/pages/analytics-expression-sources.adoc+++ /dev/null@@ -1,95 +0,0 @@-= Analytics Expression Sources-// 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.--Expression sources are the source of the data being aggregated in xref:analytics.adoc#expressions[analytics expressions].--WARNING: The analytics component is deprecated. We recommend looking into similar functionality found in xref:json-facet-api.adoc[JSON Facet API]. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.--These sources can be either Solr fields indexed with docValues, or constants.--== Supported Field Types--The following xref:indexing-guide:field-types-included-with-solr.adoc[Solr field types] are supported.-Fields of these types can be either multi-valued and single-valued.--All fields used in analytics expressions *must* have xref:indexing-guide:docvalues.adoc[] enabled.---// Since Trie* fields are deprecated as of 7.0, we should consider removing Trie* fields from this list...--[horizontal]-String::- StrField-Boolean::- BoolField-Integer::- TrieIntField +- IntPointField-Long::- TrieLongField +- LongPointField-Float::- TrieFloatField +- FloatPointField-Double::- TrieDoubleField +- DoublePointField-Date::- TrieDateField +- DatePointField--.Multi-valued Field De-duplication-[WARNING]-====-All multi-valued field types, except for PointFields, are de-duplicated, meaning duplicate values for the same field are removed during indexing.-In order to save duplicates, you must use PointField types.-====--== Constants--Constants can be included in expressions to use along side fields and functions.-The available constants are shown below.-Constants do not need to be surrounded by any function to define them, they can be used exactly like fields in an expression.--=== Strings--There are two possible ways of specifying constant strings, as shown below.--* Surrounded by double quotes, inside the quotes both `"` and `\` must be escaped with a `\` character.-+-`"Inside of 'double' \\ \"quotes\""` => `Inside of 'double' \ "quotes"`-* Surrounded by single quotes, inside the quotes both `'` and `\` must be escaped with a `\` character.-+-`'Inside of "single" \\ \'quotes\''` => `Inside of "double" \ 'quotes'`--=== Dates--Dates can be specified in the same way as they are in Solr queries.-Just use ISO-8601 format.-For more information, refer to xref:indexing-guide:date-formatting-math.adoc[].--* `2017-07-17T19:35:08Z`--=== Numeric--Any non-decimal number will be read as an integer, or as a long if it is too large for an integer.-All decimal numbers will be read as doubles.--* `-123421`: Integer-* `800000000000`: Long-* `230.34`: Doublediff --git a/solr/solr-ref-guide/modules/query-guide/pages/analytics-mapping-functions.adoc b/solr/solr-ref-guide/modules/query-guide/pages/analytics-mapping-functions.adocdeleted file mode 100644index 8c0c867aeb1..00000000000--- a/solr/solr-ref-guide/modules/query-guide/pages/analytics-mapping-functions.adoc+++ /dev/null@@ -1,363 +0,0 @@-= Analytics Mapping Functions-// 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.--Mapping functions map values for each Solr Document or Reduction.--WARNING: The analytics component is deprecated. We recommend looking into similar functionality found in xref:json-facet-api.adoc[JSON Facet API]. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.--Below is a list of all mapping functions provided by the Analytics Component.-These mappings can be chained together to implement more complex functionality.--== Numeric Functions--=== Negation-Negates the result of a numeric expression.--`neg(<_Numeric_ T>)` => `<T>`::- * `neg(10.53)` => `-10.53`- * `neg([1, -4])` => `[-1, 4]`--=== Absolute Value-Returns the absolute value of the numeric expression.--`abs(< _Numeric_ T >)` => `< T >`::- * `abs(-10.53)` => `10.53`- * `abs([1, -4])` => `[1, 4]`--[[analytics-round]]-=== Round-Rounds the numeric expression to the nearest `Integer` or `Long` value.--`round(< _Float_ >)` => `< _Int_ >`::-`round(< _Double_ >)` => `< _Long_ >`::- * `round(-1.5)` => `-1`- * `round([1.75, 100.34])` => `[2, 100]`--=== Ceiling-Rounds the numeric expression to the nearest `Integer` or `Long` value that is greater than or equal to the original value.--`ceil(< _Float_ >)` => `< _Int_ >`::-`ceil(< _Double_ >)` => `< _Long_ >`::- * `ceil(5.01)` => `5`- * `ceil([-4.999, 6.99])` => `[-4, 7]`--[[analytics-floor]]-=== Floor-Rounds the numeric expression to the nearest `Integer` or `Long` value that is less than or equal to the original value.--`floor(< _Float_ >)` => `< _Int_ >`::-`floor(< _Double_ >)` => `< _Long_ >`::- * `floor(5.75)` => `5`- * `floor([-4.001, 6.01])` => `[-5, 6]`--=== Addition-Adds the values of the numeric expressions.--`add(< _Multi Double_ >)` => `< _Single Double_ >`::- * `add([1, -4])` => `-3.0`-`add(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `add(3.5, [1, -4])` => `[4.5, -0.5]`-`add(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `add([1, -4], 3.5)` => `[4.5, -0.5]`-`add(< _Single Double_ >, ...)` => `< _Single Double_ >`::- * `add(3.5, 100, -27.6)` => `75.9`--=== Subtraction-Subtracts the values of the numeric expressions.--`sub(< _Single Double_ >, < _Single Double_ >)` => `< _Single Double_ >`::- * `sub(3.5, 100)` => `-76.5`-`sub(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `sub(3.5, [1, -4])` => `[2.5, 7.5]`-`sub(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `sub([1, -4], 3.5)` => `[-2.5, -7.5]`--=== Multiplication-Multiplies the values of the numeric expressions.--`mult(< _Multi Double_ >)` => `< _Single Double_ >`::- * `mult([1, -4])` => `-4.0`-`mult(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `mult(3.5, [1, -4])` => `[3.5, -16.0]`-`mult(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `mult([1, -4], 3.5)` => `[3.5, 16.0]`-`mult(< _Single Double_ >, ...)` => `< _Single Double_ >`::- * `mult(3.5, 100, -27.6)` => `-9660`--=== Division-Divides the values of the numeric expressions.--`div(< _Single Double_ >, < _Single Double_ >)` => `< _Single Double_ >`::- * `div(3.5, 100)` => `.035`-`div(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `div(3.5, [1, -4])` => `[3.5, -0.875]`-`div(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `div([1, -4], 25)` => `[0.04, -0.16]`--=== Power-Takes one numeric expression to the power of another.--*NOTE:* The square root function `sqrt(< _Double_ >)` can be used as shorthand for `pow(< _Double_ >, .5)`--`pow(< _Single Double_ >, < _Single Double_ >)` => `< _Single Double_ >`::- * `pow(2, 4)` => `16.0`-`pow(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `pow(16, [-1, 0])` => `[0.0625, 1]`-`pow(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `pow([1, 16], .25)` => `[1.0, 2.0]`--=== Logarithm-Takes one logarithm of numeric expressions, with an optional second numeric expression as the base.-If only one expression is given, the natural log is used.--`log(< _Double_ >)` => `< _Double_ >`::- * `log(5)` => `1.6094...`- * `log([1.0, 100.34])` => `[0.0, 4.6085...]`-`log(< _Single Double_ >, < _Single Double_ >)` => `< _Single Double_ >`::- * `log(2, 4)` => `0.5`-`log(< _Single Double_ >, < _Multi Double_ >)` => `< _Multi Double_ >`::- * `log(16, [2, 4])` => `[4, 2]`-`log(< _Multi Double_ >, < _Single Double_ >)` => `< _Multi Double_ >`::- * `log([81, 3], 9)` => `[2.0, 0.5]`--== Logic--[[analytics-logic-neg]]-=== Negation-Negates the result of a boolean expression.--`neg(< _Bool_ >)` => `< _Bool_>`::- * `neg(F)` => `T`- * `neg([F, T])` => `[T, F]`--[[analytics-and]]-=== And-ANDs the values of the boolean expressions.--`and(< _Multi Bool_ >)` => `< _Single Bool_ >`::- * `and([T, F, T])` => `F`-`and(< _Single Bool_ >, < _Multi Bool_ >)` => `< _Multi Bool_ >`::- * `and(F, [T, T])` => `[F, F]`-`and(< _Multi Bool_ >, < _Single Bool_ >)` => `< _Multi Bool_ >`::- * `and([F, T], T)` => `[F, T]`-`and(< _Single Bool_ >, ...)` => `< _Single Bool_ >`::- * `and(T, T, T)` => `T`--[[analytics-or]]-=== Or-ORs the values of the boolean expressions.--`or(< _Multi Bool_ >)` => `< _Single Bool_ >`::- * `or([T, F, T])` => `T`-`or(< _Single Bool_ >, < _Multi Bool_ >)` => `< _Multi Bool_ >`::- * `or(F, [F, T])` => `[F, T]`-`or(< _Multi Bool_ >, < _Single Bool_ >)` => `< _Multi Bool_ >`::- * `or([F, T], T)` => `[T, T]`-`or(< _Single Bool_ >, ...)` => `< _Single Bool_ >`::- * `or(F, F, F)` => `F`--==== Exists-Checks whether any value(s) exist for the expression.--`exists( T )` => `< _Single Bool_ >`::- * `exists([1, 2, 3])` => `T`- * `exists([])` => `F`- * `exists(_empty_)` => `F`- * `exists('abc')` => `T`--== Comparison--=== Equality-Checks whether two expressions' values are equal.-The parameters must be the same type, after implicit casting.--`equal(< _Single_ T >, < _Single_ T >)` => `< _Single Bool_ >`::- * `equal(F, F)` => `T`-`equal(< _Single_ T >, < _Multi_ T >)` => `< _Multi Bool_ >`::- * `equal("a", ["a", "ab"])` => `[T, F]`-`equal(< _Multi_ T >, < _Single_ T >)` => `< _Multi Bool_ >`::- * `equal([1.5, -3.0], -3)` => `[F, T]`--=== Greater Than-Checks whether a numeric or `Date` expression's values are greater than another expression's values.-The parameters must be the same type, after implicit casting.--`gt(< _Single Numeric/Date_ T >, < _Single_ T >)` => `< _Single Bool_ >`::- * `gt(1800-01-02, 1799-12-20)` => `F`-`gt(< _Single Numeric/Date_ T >, < _Multi_ T >)` => `< _Multi Bool_ >`::- * `gt(30.756, [30, 100])` => `[F, T]`-`gt(< _Multi Numeric/Date_ T >, < _Single_ T >)` => `< _Multi Bool_ >`::- * `gt([30, 75.6], 30)` => `[F, T]`--=== Greater Than or Equals-Checks whether a numeric or `Date` expression's values are greater than or equal to another expression's values.-The parameters must be the same type, after implicit casting.--`gte(< _Single Numeric/Date_ T >, < _Single_ T >)` => `< _Single Bool_ >`::- * `gte(1800-01-02, 1799-12-20)` => `F`-`gte(< _Single Numeric/Date_ T >, < _Multi_ T >)` => `< _Multi Bool_ >`::- * `gte(30.756, [30, 100])` => `[F, T]`-`gte(< _Multi Numeric/Date_ T >, < _Single_ T >)` => `< _Multi Bool_ >`::- * `gte([30, 75.6], 30)` => `[T, T]`--=== Less Than-Checks whether a numeric or `Date` expression's values are less than another expression's values.-The parameters must be the same type, after implicit casting.--`lt(< _Single Numeric/Date_ T >, < _Single_ T >)` => `< _Single Bool_ >`::- * `lt(1800-01-02, 1799-12-20)` => `T`-`lt(< _Single Numeric/Date_ T >, < _Multi_ T >)` => `< _Multi Bool_ >`::- * `lt(30.756, [30, 100])` => `[T, F]`-`lt(< _Multi Numeric/Date_ T >, < _Single_ T >)` => `< _Multi Bool_ >`::- * `lt([30, 75.6], 30)` => `[F, F]`--=== Less Than or Equals-Checks whether a numeric or `Date` expression's values are less than or equal to another expression's values.-The parameters must be the same type, after implicit casting.--`lte(< _Single Numeric/Date_ T >, < _Single_ T >)` => `< _Single Bool_ >`::- * `lte(1800-01-02, 1799-12-20)` => `T`-`lte(< _Single Numeric/Date_ T >, < _Multi_ T >)` => `< _Multi Bool_ >`::- * `lte(30.756, [30, 100])` => `[T, F]`-`lte(< _Multi Numeric/Date_ T >, < _Single_ T >)` => `< _Multi Bool_ >`::- * `lte([30, 75.6], 30)` => `[T, F]`--[[analytics-top]]-=== Top-Returns the maximum of the numeric, `Date` or `String` expression(s)' values.-The parameters must be the same type, after implicit casting.-(Currently the only type not compatible is `Boolean`, which will be converted to a `String` implicitly in order to compile the expression)--`top(< _Multi_ T >)` => `< _Single_ T >`::- * `top([30, 400, -10, 0])` => `400`-`top(< _Single_ T >, ...)` => `< _Single_ T >`::- * `top("a", 1, "d")` => `"d"`--=== Bottom-Returns the minimum of the numeric, `Date` or `String` expression(s)' values.-The parameters must be the same type, after implicit casting.-(Currently the only type not compatible is `Boolean`, which will be converted to a `String` implicitly in order to compile the expression)--`bottom(< _Multi_ T >)` => `< _Single_ T >`::- * `bottom([30, 400, -10, 0])` => `-10`-`bottom(< _Single_ T >, ...)` => `< _Single_ T >`::- * `bottom("a", 1, "d")` => `"1"`--== Conditional--[[analytics-if]]-=== If-Returns the value(s) of the `THEN` or `ELSE` expressions depending on whether the boolean conditional expression's value is `true` or `false`.-The `THEN` and `ELSE` expressions must be of the same type and cardinality after implicit casting is done.--`if(< _Single Bool_>, < T >, < T >)` => `< T >`::- * `if(true, "abc", [1,2])` => `["abc"]`- * `if(false, "abc", 123)` => `"123"`--=== Replace-Replace all values from the 1^st^ expression that are equal to the value of the 2^nd^ expression with the value of the 3^rd^ expression.-All parameters must be the same type after implicit casting is done.--`replace(< T >, < _Single_ T >, < _Single_ T >)` => `< T >`::- * `replace([1,3], 3, "4")` => `["1", "4"]`- * `replace("abc", "abc", 18)` => `"18"`- * `replace("abc", 1, "def")` => `"abc"`--=== Fill Missing-If the 1^st^ expression does not have values, fill it with the values for the 2^nd^ expression.-Both expressions must be of the same type and cardinality after implicit casting is done.--`fill_missing(< T >, < T >)` => `< T >`::- * `fill_missing([], 3)` => `[3]`- * `fill_missing(_empty_, "abc")` => `"abc"`- * `fill_missing("abc", [1])` => `["abc"]`--=== Remove-Remove all occurrences of the 2^nd^ expression's value from the values of the 1^st^ expression.-Both expressions must be of the same type after implicit casting is done.--`remove(< T >, < _Single_ T >)` => `< T >`::- * `remove([1,2,3,2], 2)` => `[1, 3]`- * `remove("1", 1)` => `_empty_`- * `remove(1, "abc")` => `"1"`--=== Filter-Return the values of the 1^st^ expression if the value of the 2^nd^ expression is `true`, otherwise return no values.--`filter(< T >, < _Single Boolean_ >)` => `< T >`::- * `filter([1,2,3], true)` => `[1,2,3]`- * `filter([1,2,3], false)` => `[]`- * `filter("abc", false)` => `_empty_`- * `filter("abc", true)` => `1`--== Date--=== Date Parse-Explicitly converts the values of a `String` or `Long` expression into `Dates`.--`date(< _String_ >)` => `< _Date_ >`::- * `date('1800-01-02')` => `1800-01-02T​00:00:00Z`- * `date(['1800-01-02', '2016-05-23'])` => `[1800-01-02T..., 2016-05-23T...]`-`date(< _Long_ >)` => `< _Date_ >`::- * `date(1232343246648)` => `2009-01-19T​05:34:06Z`- * `date([1232343246648, 223234324664])` => `[2009-01-19T..., 1977-01-27T...]`--[[analytics-date-math]]-=== Date Math-Compute the given date math strings for the values of a `Date` expression.-The date math strings *must* be xref:analytics-expression-sources.adoc#strings[constant].--`date_math(< _Date_ >, < _Constant String_ >...)` => `< _Date_ >`::- * `date_math(1800-04-15, '+1DAY', '-1MONTH')` => `1800-03-16`- * `date_math([1800-04-15,2016-05-24], '+1DAY', '-1MONTH')` => `[1800-03-16, 2016-04-25]`--== String--=== Explicit Casting-Explicitly casts the expression to a `String` expression.--`string(< _String_ >)` => `< _String_ >`::- * `string(1)` => `'1'`- * `string([1.5, -2.0])` => `['1.5', '-2.0']`--=== Concatenation-Concatenations the values of the `String` expression(s) together.--`concat(< _Multi String_ >)` => `< _Single String_ >`::- * `concat(['a','b','c'])` => `'abc'`-`concat(< _Single String_ >, < _Multi String_ >)` => `< _Multi String_ >`::- * `concat(1, ['a','b','c'])` => `['1a','1b','1c']`-`concat(< _Multi String_ >, < _Single String_ >)` => `< _Multi String_ >`::- * `concat(['a','b','c'], 1)` => `['a1','b1','c1']`-`concat(< _Single String_ >...)` => `< _Single String_ >`::- * `concat('a','b','c')` => `'abc'`- * `concat('a',_empty_,'c')` => `'ac'` +- _Empty values are ignored_--=== Separated Concatenation-Concatenations the values of the `String` expression(s) together using the given xref:analytics-expression-sources.adoc#strings[constant string] value as a separator.--`concat_sep(< _Constant String_ >, < _Multi String_ >)` => `< _Single String_ >`::- * `concat_sep('-', ['a','b'])` => `'a-b'`-`concat_sep(< _Constant String_ >, < _Single String_ >, < _Multi String_ >)` => `< _Multi String_ >`::- * `concat_sep(2,1,['a','b'])` => `['12a','12b']`-`concat_sep(< _Constant String_ >, < _Multi String_ >, < _Single String_ >)` => `< _Multi String_ >`::- * `concat_sep(2,['a','b'],1)` => `['a21','b21']`- * `concat_sep('-','a',2,3)` => `'a-2-3'`- * `concat_sep(';','a',_empty_,'c')` => `'a;c'` +-_Empty values are ignored_diff --git a/solr/solr-ref-guide/modules/query-guide/pages/analytics-reduction-functions.adoc b/solr/solr-ref-guide/modules/query-guide/pages/analytics-reduction-functions.adocdeleted file mode 100644index 946cbd4bea5..00000000000--- a/solr/solr-ref-guide/modules/query-guide/pages/analytics-reduction-functions.adoc+++ /dev/null@@ -1,128 +0,0 @@-= Analytics Reduction Functions-:toclevels: 2-// 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.--Reduction functions reduce the values of xref:analytics-expression-sources.adoc[sources>]-and/or unreduced xref:analytics-mapping-functions.adoc[mapping functions]-for every Solr Document to a single value.--WARNING: The analytics component is deprecated. We recommend looking into similar functionality found in xref:json-facet-api.adoc[JSON Facet API]. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.--Below is a list of all reduction functions provided by the Analytics Component.-These can be combined using mapping functions to implement more complex functionality.--== Counting Reductions--=== Count-The number of existing values for an expression.-For single-valued expressions, this is equivalent to `docCount`.-If no expression is given, the number of matching documents is returned.--`count()` => `< _Single Long_ >`--`count(< T >)` => `< _Single Long_ >`--=== Doc Count-The number of documents for which an expression has existing values.-For single-valued expressions, this is equivalent to `count`.-If no expression is given, the number of matching documents is returned.--`doc_count()` => `< _Single Long_ >`--`doc_count(< T >)` => `< _Single Long_ >`--=== Missing-The number of documents for which an expression has no existing value.--`missing(< T >)` => `< _Single Long_ >`--[[analytics-unique]]-=== Unique-The number of unique values for an expression.-This function accepts `Numeric`, `Date` and `String` expressions.--`unique(< T >)` => `< _Single Long_ >`--== Math Reductions--=== Sum-Returns the sum of all values for the expression.--`sum(< _Double_ >)` => `< _Single Double_ >`--=== Variance-Returns the variance of all values for the expression.--`variance(< _Double_ >)` => `< _Single Double_ >`--=== Standard Deviation-Returns the standard deviation of all values for the expression.--`stddev(< _Double_ >)` => `< _Single Double_ >`--=== Mean-Returns the arithmetic mean of all values for the expression.--`mean(< _Double_ >)` => `< _Single Double_ >`--=== Weighted Mean-Returns the arithmetic mean of all values for the second expression weighted by the values of the first expression.--`wmean(< _Double_ >, < _Double_ >)` => `< _Single Double_ >`--NOTE: The expressions must satisfy the rules for `mult` function parameters.--== Ordering Reductions--=== Minimum-Returns the minimum value for the expression.-This function accepts `Numeric`, `Date` and `String` expressions.--`min(< T >)` => `< _Single_ T >`--=== Maximum-Returns the maximum value for the expression.-This function accepts `Numeric`, `Date` and `String` expressions.--`max(< T >)` => `< _Single_ T >`--=== Median-Returns the median of all values for the expression.-This function accepts `Numeric` and `Date` expressions.--`median(< T >)` => `< _Single_ T >`--=== Percentile-Calculates the given percentile of all values for the expression.-This function accepts `Numeric`, `Date` and `String` expressions for the 2^nd^ parameter.--The percentile, given as the 1^st^ parameter, must be a xref:analytics-expression-sources.adoc#numeric[constant double] between [0, 100).--`percentile(<Constant Double>, < T >)` => `< _Single_ T >`--=== Ordinal-Calculates the given ordinal of all values for the expression.-This function accepts `Numeric`, `Date` and `String` expressions for the 2^nd^ parameter.-The ordinal, given as the 1^st^ parameter, must be a xref:analytics-expression-sources.adoc#numeric[constant integer].-*0 is not accepted as an ordinal value.*--If the ordinal is positive, the returned value will be the _n_^th^ smallest value.--If the ordinal is negative, the returned value will be the _n_^th^ largest value.--`ordinal(<Constant Int>, < T >)` => `< _Single_ T >`diff --git a/solr/solr-ref-guide/modules/query-guide/pages/analytics.adoc b/solr/solr-ref-guide/modules/query-guide/pages/analytics.adocdeleted file mode 100644index 5369bed8807..00000000000--- a/solr/solr-ref-guide/modules/query-guide/pages/analytics.adoc+++ /dev/null@@ -1,967 +0,0 @@-= Analytics Component-:page-children: analytics-expression-sources, analytics-mapping-functions, analytics-reduction-functions-:toclevels: 2-// 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.--The Analytics Component allows users to calculate complex statistical aggregations over result sets.--WARNING: The analytics component is deprecated. We recommend looking into similar functionality found in xref:json-facet-api.adoc[JSON Facet API]. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.--The component enables interacting with data in a variety of ways, both through a diverse set of analytics functions as well as powerful faceting functionality.-The standard facets are supported within the analytics component with additions that leverage its analytical capabilities.--== Module--This is provided via the `analytics` xref:configuration-guide:solr-modules.adoc[Solr Module] that needs to be enabled before use.--== Analytics Configuration--Since the Analytics framework is a _search component_, it must be declared as such and added to the search handler.--For distributed analytics requests over cloud collections, the component uses the `AnalyticsHandler` strictly for inter-shard communication.-The Analytics Handler should not be used by users to submit analytics requests.--Next you need to register the request handler and search component.-Add the following lines to `solrconfig.xml`, near the defintions for other request handlers:--[source,xml]-.solrconfig.xml------<!-- To handle user requests -->-<searchComponent name="analytics" class="org.apache.solr.handler.component.AnalyticsComponent" />--<requestHandler name="/select" class="solr.SearchHandler">- <arr name="last-components">- <str>analytics</str>- </arr>-</requestHandler>--<!-- For inter-shard communication during distributed requests -->-<requestHandler name="/analytics" class="org.apache.solr.handler.AnalyticsHandler" />-------For these changes to take effect, restart Solr or reload the core or collection.--== Request Syntax--An Analytics request is passed to Solr with the parameter `analytics` in a request sent to the-xref:configuration-guide:requesthandlers-searchcomponents.adoc#search-handlers[search handler].-Since the analytics request is sent inside of a search handler request, it will compute results based on the result set determined by the search handler.--For example, this curl command encodes and POSTs a simple analytics request to the search handler:--[source,bash]------$ curl --data-binary 'analytics={- "expressions" : {- "revenue" : "sum(mult(price,quantity))"- }- }'- http://localhost:8983/solr/sales/select?q=*:*&wt=json&rows=0-------There are 3 main parts of any analytics request:--Expressions::-A list of calculations to perform over the entire result set.-Expressions aggregate the search results into a single value to return.-This list is entirely independent of the expressions defined in each of the groupings.-Find out more about them in the section <<Expressions>>.--Functions::-One or more <<variable-functions, Variable Functions>> to be used throughout the rest of the request.-These are essentially lambda functions and can be combined in a number of ways.-These functions for the expressions defined in `expressions` as well as `groupings`.--Groupings::-The list of <<groupings-and-facets, Groupings>> to calculate in addition to the expressions.-Groupings hold a set of facets and a list of expressions to compute over those facets.-The expressions defined in a grouping are only calculated over the facets defined in that grouping.--[NOTE]-.Optional Parameters-Either the `expressions` or the `groupings` parameter must be present in the request, or else there will be no analytics to compute.-The `functions` parameter is always optional.--[source,json]-.Example Analytics Request------{- "functions": {- "sale()": "mult(price,quantity)"- },- "expressions" : {- "max_sale" : "max(sale())",- "med_sale" : "median(sale())"- },- "groupings" : {- "sales" : {- "expressions" : {- "stddev_sale" : "stddev(sale())",- "min_price" : "min(price)",- "max_quantity" : "max(quantity)"- },- "facets" : {- "category" : {- "type" : "value",- "expression" : "fill_missing(category, 'No Category')",- "sort" : {- "criteria" : [- {- "type" : "expression",- "expression" : "min_price",- "direction" : "ascending"- },- {- "type" : "facetvalue",- "direction" : "descending"- }- ],- "limit" : 10- }- },- "temps" : {- "type" : "query",- "queries" : {- "hot" : "temp:[90 TO *]",- "cold" : "temp:[* TO 50]"- }- }- }- }- }-}-------== Expressions--Expressions are the way to request pieces of information from the analytics component.-These are the statistical expressions that you want computed and returned in your response.--=== Constructing an Expression--==== Expression Components--An expression is built using fields, constants, mapping functions and reduction functions.-The ways that these can be defined are described below.--Sources::-* Constants: The values defined in the expression.-The supported constant types are described in the section xref:analytics-expression-sources.adoc#constants[Constants].--* Fields: Solr fields that are read from the index.-The supported fields are listed in the section xref:analytics-expression-sources.adoc#supported-field-types[Supported Field Types].--Mapping Functions::-Mapping functions map values for each Solr Document or Reduction.-The provided mapping functions are detailed in the xref:analytics-mapping-functions.adoc[].--* Unreduced Mapping: Mapping a Field with another Field or Constant returns a value for every Solr Document.-Unreduced mapping functions can take fields, constants as well as other unreduced mapping functions as input.--* Reduced Mapping: Mapping a Reduction Function with another Reduction Function or Constant returns a single value.--Reduction Functions::-Functions that reduce the values of sources and/or unreduced mapping functions for every Solr Document to a single value.-The provided reduction functions are detailed in the xref:analytics-reduction-functions.adoc[].--==== Component Ordering--The expression components must be used in the following order to create valid expressions.--. Reduced Mapping Function-.. Constants-.. Reduction Function-... Sources-... Unreduced Mapping Function-.... Sources-.... Unreduced Mapping Function-.. Reduced Mapping Function-. Reduction Function--This ordering is based on the following rules:--* No reduction function can be an argument of another reduction function.-Since all reduction is done together in one step, one reduction function cannot rely on the result of another.-* No fields can be left unreduced, since the analytics component cannot return a list of values for an expression (one for every document).-Every expression must be reduced to a single value.-* Mapping functions are not necessary when creating functions, however as many nested mappings as needed can be used.-* Nested mapping functions must be the same type, so either both must be unreduced or both must be reduced.-A reduced mapping function cannot take an unreduced mapping function as a parameter and vice versa.--==== Example Construction--With the above definitions and ordering, an example expression can be broken up into its components:--[source,bash]-div(sum(a,fill_missing(b,0)),add(10.5,count(mult(a,c)))))--As a whole, this is a reduced mapping function.-The `div` function is a reduced mapping function since it is a xref:analytics-mapping-functions.adoc#division[provided mapping function] and has reduced arguments.--If we break down the expression further:--* `sum(a,fill_missing(b,0))`: Reduction Function +-`sum` is a xref:analytics-reduction-functions.adoc#sum[provided reduction function].-** `a`: Field-** `fill_missing(b,0)`: Unreduced Mapping Function +-`fill_missing` is an unreduced mapping function since it is a xref:analytics-mapping-functions.adoc#fill-missing[provided mapping function] and has a field argument.-*** `b`: Field-*** `0`: Constant--* `add(10.5,count(mult(a,c)))`: Reduced Mapping Function +-`add` is a reduced mapping function since it is a xref:analytics-mapping-functions.adoc#addition[provided mapping function] and has a reduction function argument.-** `10.5`: Constant-** `count(mult(a,c))`: Reduction Function +-`count` is a xref:analytics-reduction-functions.adoc#count[provided reduction function].-*** `mult(a,c)`: Unreduced Mapping Function +-`mult` is an unreduced mapping function since it is a xref:analytics-mapping-functions.adoc#multiplication[provided mapping function] and has two field arguments.-**** `a`: Field-**** `c`: Field--=== Expression Cardinality (Multi-Valued and Single-Valued)--The root of all multi-valued expressions are multi-valued fields.-Single-valued expressions can be started with constants or single-valued fields.-All single-valued expressions can be treated as multi-valued expressions that contain one value.--Single-valued expressions and multi-valued expressions can be used together in many mapping functions, as well as multi-valued expressions being used alone, and many single-valued expressions being used together.-For example:--`add(<single-valued double>, <single-valued double>, ...)`::-Returns a single-valued double expression where the value of the values of each expression are added.--`add(<single-valued double>, <multi-valued double>)`::-Returns a multi-valued double expression where each value of the second expression is added to the single value of the first expression.--`add(<multi-valued double>, <single-valued double>)`::-Acts the same as the above function.--`add(<multi-valued double>)`::-Returns a single-valued double expression which is the sum of the multiple values of the parameter expression.--=== Types and Implicit Casting--The new analytics component currently supports the types listed in the below table.-These types have one-way implicit casting enabled for the following relationships:--[cols="20s,80",options="header"]-|===-| Type | Implicitly Casts To-| Boolean | String-| Date | Long, String-| Integer | Long, Float, Double, String-| Long | Double, String-| Float | Double, String-| Double | String-| String | _none_-|===--An implicit cast means that if a function requires a certain type of value as a parameter, arguments will be automatically converted to that type if it is possible.--For example, `concat()` only accepts string parameters and since all types can be implicitly cast to strings, any type is accepted as an argument.--This also goes for dynamically typed functions.-`fill_missing()` requires two arguments of the same type.-However, two types that implicitly cast to the same type can also be used.--For example, `fill_missing(<long>,<float>)` will be cast to `fill_missing(<double>,<double>)` since long cannot be cast to float and float cannot be cast to long implicitly.--There is an ordering to implicit casts, where the more specialized type is ordered ahead of the more general type.-Therefore even though both long and float can be implicitly cast to double and string, they will be cast to double.-This is because double is a more specialized type than string, which every type can be cast to.--The ordering is the same as their order in the above table.--Cardinality can also be implicitly cast.-Single-valued expressions can always be implicitly cast to multi-valued expressions, since all single-valued expressions are multi-valued expressions with one value.--Implicit casting will only occur when an expression will not "compile" without it.-If an expression follows all typing rules initially, no implicit casting will occur.-Certain functions such as `string()`, `date()`, `round()`, `floor()`, and `ceil()` act as explicit casts, declaring the type that is desired.-However `round()`, `floor()` and `cell()` can return either int or long, depending on the argument type.--== Variable Functions--Variable functions are a way to shorten your expressions and make writing analytics queries easier.-They are essentially lambda functions defined in a request.--[source,json]-.Example Basic Function------{- "functions" : {- "sale()" : "mult(price,quantity)"- },- "expressions" : {- "max_sale" : "max(sale())",- "med_sale" : "median(sale())"- }-}-------In the above request, instead of writing `mult(price,quantity)` twice, a function `sale()` was defined to abstract this idea.-Then that function was used in the multiple expressions.--Suppose that we want to look at the sales of specific categories:--[source,json]------{- "functions" : {- "clothing_sale()" : "filter(mult(price,quantity),equal(category,'Clothing'))",- "kitchen_sale()" : "filter(mult(price,quantity),equal(category,\"Kitchen\"))"- },- "expressions" : {- "max_clothing_sale" : "max(clothing_sale())"- , "med_clothing_sale" : "median(clothing_sale())"- , "max_kitchen_sale" : "max(kitchen_sale())"- , "med_kitchen_sale" : "median(kitchen_sale())"- }-}-------=== Arguments--Instead of making a function for each category, it would be much easier to use `category` as an input to the `sale()` function.-An example of this functionality is shown below:--[source,json]-.Example Function with Arguments------{- "functions" : {- "sale(cat)" : "filter(mult(price,quantity),equal(category,cat))"- },- "expressions" : {- "max_clothing_sale" : "max(sale(\"Clothing\"))"- , "med_clothing_sale" : "median(sale('Clothing'))"- , "max_kitchen_sale" : "max(sale(\"Kitchen\"))"- , "med_kitchen_sale" : "median(sale('Kitchen'))"- }-}-------Variable Functions can take any number of arguments and use them in the function expression as if they were a field or constant.--=== Variable Length Arguments--There are analytics functions that take a variable amount of parameters.-Therefore there are use cases where variable functions would need to take a variable amount of parameters.--For example, maybe there are multiple, yet undetermined, number of components to the price of a product.-Functions can take a variable length of parameters if the last parameter is followed by `..`--[source,json]-.Example Function with a Variable Length Argument------{- "functions" : {- "sale(cat, costs..)" : "filter(mult(add(costs),quantity),equal(category,cat))"- },- "expressions" : {- "max_clothing_sale" : "max(sale('Clothing', material, tariff, tax))"- , "med_clothing_sale" : "median(sale('Clothing', material, tariff, tax))"- , "max_kitchen_sale" : "max(sale('Kitchen', material, construction))"- , "med_kitchen_sale" : "median(sale('Kitchen', material, construction))"- }-}-------In the above example a variable length argument is used to encapsulate all of the costs to use for a product.-There is no definite number of arguments requested for the variable length parameter, therefore the clothing expressions can use 3 and the kitchen expressions can use 2.-When the `sale()` function is called, `costs` is expanded to the arguments given.--Therefore in the above request, inside of the `sale` function:--* `add(costs)`--is expanded to both of the following:--* `add(material, tariff, tax)`-* `add(material, construction)`--=== For-Each Functions--[CAUTION]-.Advanced Functionality-====-The following function details are for advanced requests.-====--Although the above functionality allows for an undefined number of arguments to be passed to a function, it does not allow for interacting with those arguments.--Many times we might want to wrap each argument in additional functions.-For example maybe we want to be able to look at multiple categories at the same time.-So we want to see if `category EQUALS x *OR* category EQUALS y` and so on.--In order to do this we need to use for-each lambda functions, which transform each value of the variable length parameter.-The for-each is started with the `:` character after the variable length parameter.--[source,json]-.Example Function with a For-Each------{- "functions" : {- "sale(cats..)" : "filter(mult(price,quantity),or(cats:equal(category,_)))"- },- "expressions" : {- "max_sale_1" : "max(sale('Clothing', 'Kitchen'))"- , "med_sale_1" : "median(sale('Clothing', 'Kitchen'))"- , "max_sale_2" : "max(sale('Electronics', 'Entertainment', 'Travel'))"- , "med_sale_2" : "median(sale('Electronics', 'Entertainment', 'Travel'))"- }-}-------In this example, `cats:` is the syntax that starts a for-each lambda function over every parameter `cats`, and the `\_` character is used to refer to the value of `cats` in each iteration in the for-each.-When `sale("Clothing", "Kitchen")` is called, the lambda function `equal(category,_)` is applied to both Clothing and Kitchen inside of the `or()` function.--Using all of these rules, the expression:--[source,text]-`sale("Clothing","Kitchen")`--is expanded to:--[source,text]-`filter(mult(price,quantity),or(equal(category,"Kitchen"),equal(category,"Clothing")))`--by the expression parser.--== Groupings And Facets--Facets, much like in other parts of Solr, allow analytics results to be broken up and grouped by attributes of the data that the expressions are being calculated over.--The currently available facets for use in the analytics component are Value Facets, Pivot Facets, Range Facets and Query Facets.-Each facet is required to have a unique name within the grouping it is defined in, and no facet can be defined outside of a grouping.--Groupings allow users to calculate the same grouping of expressions over a set of facets.-Groupings must have both `expressions` and `facets` given.--[source,json]-.Example Base Facet Request------{- "functions" : {- "sale()" : "mult(price,quantity)"- },- "groupings" : {- "sales_numbers" : {- "expressions" : {- "max_sale" : "max(sale())",- "med_sale" : "median(sale())"- },- "facets" : {- "<name>" : "< facet request >"- }- }- }-}-------[source,json]-.Example Base Facet Response------{- "analytics_response" : {- "groupings" : {- "sales_numbers" : {- "<name>" : "< facet response >"- }- }- }-}-------=== Facet Sorting--Some Analytics facets allow for complex sorting of their results.-The two current sortable facets are <<value-facets, Analytic Value Facets>> and <<analytic-pivot-facets, Analytic Pivot Facets>>.--==== Parameters--`criteria`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The list of criteria to sort the facet by.-+-It takes the following parameters:--`type`:::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The type of sort.-There are two possible values:-* `expression`: Sort by the value of an expression defined in the same grouping.-* `facetvalue`: Sort by the string-representation of the facet value.--`Direction`:::-+-[%autowidth,frame=none]-|===-|Optional |Default: `ascending`-|===-+-The direction to sort.-The options are `ascending` or `descending`.--`expression`:::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-When `type` is `expression`, the name of an expression defined in the same grouping.--`limit`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `-1`-|===-+-Limit the number of returned facet values to the top _N_.-The default means there is no limit.--`offset`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `0`-|===-+-When a limit is set, skip the top _N_ facet values.--[source,json]-.Example Sort Request------{- "criteria" : [- {- "type" : "expression",- "expression" : "max_sale",- "direction" : "ascending"- },- {- "type" : "facetvalue",- "direction" : "descending"- }- ],- "limit" : 10,- "offset" : 5-}-------=== Value Facets--Value facets are used to group documents by the value of a mapping expression applied to each document.-Mapping expressions are expressions that do not include a reduction function.--For more information, refer to the <<expression-components, Expressions section>>.-For example:--* `mult(quantity, sum(price, tax))`: breakup documents by the revenue generated.-* `fillmissing(state, "N/A")`: breakup documents by state, where N/A is used when the document doesn't contain a state.--Value facets can be sorted.--==== Parameters--`expression`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The expression to choose a facet bucket for each document.--`sort`::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-A <<Facet Sorting,sort>> for the results of the pivot.--[source,json]-.Example Value Facet Request------{- "type" : "value",- "expression" : "fillmissing(category,'No Category')",- "sort" : {}-}-------[source,json]-.Example Value Facet Response------[- { "..." : "..." },- {- "value" : "Electronics",- "results" : {- "max_sale" : 103.75,- "med_sale" : 15.5- }- },- {- "value" : "Kitchen",- "results" : {- "max_sale" : 88.25,- "med_sale" : 11.37- }- },- { "..." : "..." }-]-------[NOTE]-This is a replacement for field facets that existed in the original Analytics Component.-Field facet functionality is maintained in value facets by using the name of a field as the expression.--=== Analytic Pivot Facets--Pivot Facets are used to group documents by the value of multiple mapping expressions applied to each document.--Pivot Facets work much like layers of <<Value Facets>>.-A list of pivots is required, and the order of the list directly impacts the results returned.-The first pivot given will be treated like a normal value facet.-The second pivot given will be treated like one value facet for each value of the first pivot.-Each of these second-level value facets will be limited to the documents in their first-level facet bucket.-This continues for however many pivots are provided.--Sorting is enabled on a per-pivot basis.-This means that if your top pivot has a sort with `limit:1`, then only that first value of the facet will be drilled down into.-Sorting in each pivot is independent of the other pivots.--==== Parameters--`pivots`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The list of pivots to calculate a drill-down facet for.-The list is ordered by top-most to bottom-most level.--`name`:::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The name of the pivot.--`expression`:::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The expression to choose a facet bucket for each document.--`sort`:::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-A <<Facet Sorting,sort>> for the results of the pivot.--[source,json]-.Example Pivot Facet Request------{- "type" : "pivot",- "pivots" : [- {- "name" : "country",- "expression" : "country",- "sort" : {}- },- {- "name" : "state",- "expression" : "fillmissing(state, fillmissing(providence, territory))"- },- {- "name" : "city",- "expression" : "fillmissing(city, 'N/A')",- "sort" : {}- }- ]-}--------[source,json]-.Example Pivot Facet Response------[- { "..." : "..." },- {- "pivot" : "Country",- "value" : "USA",- "results" : {- "max_sale" : 103.75,- "med_sale" : 15.5- },- "children" : [- { "..." : "..." },- {- "pivot" : "State",- "value" : "Texas",- "results" : {- "max_sale" : 99.2,- "med_sale" : 20.35- },- "children" : [- { "..." : "..." },- {- "pivot" : "City",- "value" : "Austin",- "results" : {- "max_sale" : 94.34,- "med_sale" : 17.60- }- },- { "..." : "..." }- ]- },- { "..." : "..." }- ]- },- { "..." : "..." }-]-------=== Analytics Range Facets--Range Facets are used to group documents by the value of a field into a given set of ranges.-The inputs for analytics range facets are identical to those used for Solr range facets.-Refer to the section xref:faceting.adoc#range-faceting[Range Faceting] for more information regarding use.--==== Parameters--`field`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-Field to be faceted over.--`start`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The bottom end of the range.--`end`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The top end of the range.--`gap`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-A list of range gaps to generate facet buckets.-If the buckets do not add up to fit the `start` to `end` range, then the last `gap` value will repeated as many times as needed to fill any unused range.--`hardend`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `false`-|===-+-Whether to cutoff the last facet bucket range at the `end` value if it spills over.--`include`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `lower`-|===-+-The boundaries to include in the facet buckets.-* `lower` - All gap-based ranges include their lower bound.-* `upper` - All gap-based ranges include their upper bound.-* `edge` - The first and last gap ranges include their edge bounds (lower for the first one, upper for the last one), even if the corresponding upper/lower option is not specified.-* `outer` - The `before` and `after` ranges will be inclusive of their bounds, even if the first or last ranges already include those boundaries.-* `all` - Includes all options: `lower`, `upper`, `edge`, and `outer`.--`others`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `none`-|===-+-Additional ranges to include in the facet.-* `before` - All records with field values lower then lower bound of the first range.-* `after` - All records with field values greater then the upper bound of the last range.-* `between` - All records with field values between the lower bound of the first range and the upper bound of the last range.-* `none` - Include facet buckets for none of the above.-* `all` - Include facet buckets for `before`, `after` and `between`.--[source,json]-.Example Range Facet Request------{- "type" : "range",- "field" : "price",- "start" : "0",- "end" : "100",- "gap" : [- "5",- "10",- "10",- "25"- ],- "hardend" : true,- "include" : [- "lower",- "upper"- ],- "others" : [- "after",- "between"- ]-}-------[source,json]-.Example Range Facet Response------[- {- "value" : "[0 TO 5]",- "results" : {- "max_sale" : 4.75,- "med_sale" : 3.45- }- },- {- "value" : "[5 TO 15]",- "results" : {- "max_sale" : 13.25,- "med_sale" : 10.20- }- },- {- "value" : "[15 TO 25]",- "results" : {- "max_sale" : 22.75,- "med_sale" : 18.50- }- },- {- "value" : "[25 TO 50]",- "results" : {- "max_sale" : 47.55,- "med_sale" : 30.33- }- },- {- "value" : "[50 TO 75]",- "results" : {- "max_sale" : 70.25,- "med_sale" : 64.54- }- },- { "..." : "..." }-]-------=== Query Facets--Query facets are used to group documents by given set of queries.--==== Parameters--`queries`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-The list of queries to facet by.--[source,json]-.Example Query Facet Request------{- "type" : "query",- "queries" : {- "high_quantity" : "quantity:[ 5 TO 14 ] AND price:[ 100 TO * ]",- "low_quantity" : "quantity:[ 1 TO 4 ] AND price:[ 100 TO * ]"- }-}-------[source,json]-.Example Query Facet Response------[- {- "value" : "high_quantity",- "results" : {- "max_sale" : 4.75,- "med_sale" : 3.45- }- },- {- "value" : "low_quantity",- "results" : {- "max_sale" : 13.25,- "med_sale" : 10.20- }- }-]-----diff --git a/solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adoc b/solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adocindex ddf10abd47e..594e4683535 100644--- a/solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adoc+++ b/solr/solr-ref-guide/modules/query-guide/pages/common-query-parameters.adoc@@ -320,7 +320,7 @@ This value is only checked at the time of:As this check is periodically performed, the actual time for which a request can be processed before it is aborted would be marginally greater than or equal to the value of `timeAllowed`.If the request consumes more time in other stages, custom components, etc., this parameter is not expected to abort the request.-Regular search, JSON Facet and the Analytics component abandon requests in accordance with this parameter.+Regular search and the JSON Facet component abandon requests in accordance with this parameter.== segmentTerminateEarly Parameterdiff --git a/solr/solr-ref-guide/modules/query-guide/querying-nav.adoc b/solr/solr-ref-guide/modules/query-guide/querying-nav.adocindex d64e6be6c6b..aa3f0fbade7 100644--- a/solr/solr-ref-guide/modules/query-guide/querying-nav.adoc+++ b/solr/solr-ref-guide/modules/query-guide/querying-nav.adoc@@ -48,10 +48,6 @@** xref:query-re-ranking.adoc[]** xref:learning-to-rank.adoc[]** xref:tagger-handler.adoc[]-** xref:analytics.adoc[]-*** xref:analytics-expression-sources.adoc[]-*** xref:analytics-mapping-functions.adoc[]-*** xref:analytics-reduction-functions.adoc[]** xref:terms-component.adoc[]** xref:term-vector-component.adoc[]** xref:stats-component.adoc[]diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adocindex 9cad5587baf..9b3b8d84df4 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc@@ -34,3 +34,4 @@ Starting in 10, the Maven POM for SolrJ does not refer to SolrJ modules like ZooThe `jaegertracer-configurator` module, which was deprecated in 9.2, is removed. Users should migrate to the `opentelemetry` module.+The `analytics` module, which was deprecated in 9.2, is removed.diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-7.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-7.adocindex cd76c37bfb9..b1f726a9288 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-7.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-7.adoc@@ -61,7 +61,7 @@ At its core, Solr autoscaling provides users with a rule syntax to define prefer=== Other Features & Enhancements-* The xref:query-guide:analytics.adoc[] has been refactored.+* The analytics query guide has been refactored.* There were several other new features released in earlier 6.x releases, which you may have missed:** xref:query-guide:learning-to-rank.adoc[]diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adocindex ac21c45698c..db6367bbc33 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc@@ -113,7 +113,7 @@ the `solrj-streaming` artifacts under the `org.apache.solr` groupId.=== Deprecations* Loading solr.xml from Zookeeper is deprecated. See xref:configuration-guide:configuring-solr-xml.adoc[Configuring solr.xml].-* The xref:query-guide:analytics.adoc[Analytics Component] has been deprecated. Consider using xref:query-guide:json-facet-api.adoc[JSON Facet API] as a substitute. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.+* The Analytics Component has been deprecated. Consider using xref:query-guide:json-facet-api.adoc[JSON Facet API] as a substitute. Please notify the project if there's functionality you need that isn't currently covered by JSON facets.* The `jaegertracer-configurator` module is deprecated for removal in Solr 10. Users should start migrating to the new `opentelemetry` module.== Solr 9.1.1diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.javaindex d9566648bf8..596dc130497 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java@@ -83,9 +83,6 @@ public class SolrTestCase extends LuceneTestCase {@ClassRulepublic static TestRule solrClassRules =RuleChain.outerRule(new SystemPropertiesRestoreRule())- .around(- new VerifyTestClassNamingConvention(- "org.apache.solr.analytics", NAMING_CONVENTION_TEST_SUFFIX)).around(new VerifyTestClassNamingConvention("org.apache.solr.ltr", NAMING_CONVENTION_TEST_PREFIX))