You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/07/03 11:57:46 UTC
[06/58] [abbrv] lucene-solr:jira/solr-10879: SOLR-10123: Upgraded the
Analytics Component to version 2.0
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java
deleted file mode 100644
index fa29022..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.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.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.request.RangeFacetRequest;
-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.SchemaField;
-import org.apache.solr.schema.TrieDateField;
-import org.apache.solr.schema.TrieField;
-import org.apache.solr.util.DateMathParser;
-
-
-public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
- protected final SchemaField field;
- protected final RangeFacetRequest request;
-
- public RangeEndpointCalculator(final RangeFacetRequest request) {
- this.field = request.getField();
- this.request = request;
- }
-
- /**
- * 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.
- *
- * 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.
- *
- * 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;
-
- 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;
- }
- }
-
- public List<FacetRange> getRanges(){
-
- final T start = getValue(request.getStart());
- T end = getValue(request.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 String[] gaps = request.getGaps();
- String gap = gaps[0];
-
- final EnumSet<FacetRangeInclude> include = request.getInclude();
-
- T low = start;
-
- List<FacetRange> ranges = new ArrayList<>();
-
- int gapCounter = 0;
-
- while (low.compareTo(end) < 0) {
- if (gapCounter<gaps.length) {
- gap = gaps[gapCounter++];
- }
- T high = addGap(low,gap);
- if (end.compareTo(high) < 0) {
- if (request.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 = request.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 RangeEndpointCalculator<? extends Comparable<?>> create(RangeFacetRequest request){
- final SchemaField sf = request.getField();
- final FieldType ft = sf.getType();
- final RangeEndpointCalculator<?> calc;
- if (ft instanceof TrieField) {
- switch (ft.getNumberType()) {
- case FLOAT:
- calc = new FloatRangeEndpointCalculator(request);
- break;
- case DOUBLE:
- calc = new DoubleRangeEndpointCalculator(request);
- break;
- case INTEGER:
- calc = new IntegerRangeEndpointCalculator(request);
- break;
- case LONG:
- calc = new LongRangeEndpointCalculator(request);
- break;
- case DATE:
- calc = new DateRangeEndpointCalculator(request, null);
- break;
- default:
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + sf.getName());
- }
- } else {
- throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
- }
- return calc;
- }
-
- public static class FloatRangeEndpointCalculator extends RangeEndpointCalculator<Float> {
-
- public FloatRangeEndpointCalculator(final RangeFacetRequest request) { super(request); }
-
- @Override
- protected Float parseVal(String rawval) {
- return Float.valueOf(rawval);
- }
-
- @Override
- public Float parseAndAddGap(Float value, String gap) {
- return new Float(value.floatValue() + Float.parseFloat(gap));
- }
-
- }
-
- public static class DoubleRangeEndpointCalculator extends RangeEndpointCalculator<Double> {
-
- public DoubleRangeEndpointCalculator(final RangeFacetRequest request) { super(request); }
-
- @Override
- protected Double parseVal(String rawval) {
- return Double.valueOf(rawval);
- }
-
- @Override
- public Double parseAndAddGap(Double value, String gap) {
- return new Double(value.doubleValue() + Double.parseDouble(gap));
- }
-
- }
-
- public static class IntegerRangeEndpointCalculator extends RangeEndpointCalculator<Integer> {
-
- public IntegerRangeEndpointCalculator(final RangeFacetRequest request) { super(request); }
-
- @Override
- protected Integer parseVal(String rawval) {
- return Integer.valueOf(rawval);
- }
-
- @Override
- public Integer parseAndAddGap(Integer value, String gap) {
- return new Integer(value.intValue() + Integer.parseInt(gap));
- }
-
- }
-
- public static class LongRangeEndpointCalculator extends RangeEndpointCalculator<Long> {
-
- public LongRangeEndpointCalculator(final RangeFacetRequest request) { super(request); }
-
- @Override
- protected Long parseVal(String rawval) {
- return Long.valueOf(rawval);
- }
-
- @Override
- public Long parseAndAddGap(Long value, String gap) {
- return new Long(value.longValue() + Long.parseLong(gap));
- }
-
- }
-
- public static class DateRangeEndpointCalculator extends RangeEndpointCalculator<Date> {
- private final Date now;
- public DateRangeEndpointCalculator(final RangeFacetRequest request, final Date now) {
- super(request);
- this.now = now;
- if (! (field.getType() instanceof TrieDateField) ) {
- throw new IllegalArgumentException("SchemaField must use field type extending TrieDateField");
- }
- }
-
- @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);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java
new file mode 100644
index 0000000..66d7a13
--- /dev/null
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/BooleanConsumer.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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); };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java
new file mode 100644
index 0000000..baa5c12
--- /dev/null
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatConsumer.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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); };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java
new file mode 100644
index 0000000..9801ea7
--- /dev/null
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/FloatSupplier.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java
new file mode 100644
index 0000000..9d07e10
--- /dev/null
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/function/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/package-info.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/package-info.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/package-info.java
index a5676f1..49602c7 100644
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/package-info.java
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/package-info.java
@@ -16,9 +16,8 @@
*/
/**
- * Utilities used by analytics component
+ * Utility classes for the analytics component.
*/
package org.apache.solr.analytics.util;
-
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AbsoluteValueDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AbsoluteValueDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AbsoluteValueDoubleFunction.java
deleted file mode 100644
index f1e996c..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AbsoluteValueDoubleFunction.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.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>AbsoluteValueDoubleFunction</code> takes the absolute value of the double value of the source it contains.
- */
-public class AbsoluteValueDoubleFunction extends SingleDoubleFunction {
- public final static String NAME = AnalyticsParams.ABSOLUTE_VALUE;
-
- public AbsoluteValueDoubleFunction(ValueSource source) {
- super(source);
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- public String description() {
- return name()+"("+source.description()+")";
- }
-
- protected double func(int doc, FunctionValues vals) throws IOException {
- double d = vals.doubleVal(doc);
- if (d<0) {
- return d*-1;
- } else {
- return d;
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- AbsoluteValueDoubleFunction other = (AbsoluteValueDoubleFunction)o;
- return this.source.equals(other.source);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AddDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AddDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AddDoubleFunction.java
deleted file mode 100644
index c47a0a3..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/AddDoubleFunction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>AddDoubleFunction</code> returns the sum of its components.
- */
-public class AddDoubleFunction extends MultiDoubleFunction {
- public final static String NAME = AnalyticsParams.ADD;
-
- public AddDoubleFunction(ValueSource[] sources) {
- super(sources);
- }
-
- @Override
- protected String name() {
- return NAME;
- }
-
- @Override
- protected double func(int doc, FunctionValues[] valsArr) throws IOException {
- double sum = 0d;
- for (FunctionValues val : valsArr) {
- sum += val.doubleVal(doc);
- }
- return sum;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDateSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDateSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDateSource.java
deleted file mode 100644
index 3ce608f..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDateSource.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.docvalues.FloatDocValues;
-import org.apache.lucene.util.mutable.MutableValue;
-import org.apache.lucene.util.mutable.MutableValueDate;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>ConstDateSource</code> returns a constant date for all documents
- */
-public class ConstDateSource extends ConstDoubleSource {
- public final static String NAME = AnalyticsParams.CONSTANT_DATE;
-
- public ConstDateSource(Date constant) {
- super(constant.getTime());
- }
-
- public ConstDateSource(Long constant) {
- super(constant);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public String description() {
- return name()+"(" + Instant.ofEpochMilli(getLong()) + ")";
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- return new FloatDocValues(this) {
- @Override
- public float floatVal(int doc) {
- return getFloat();
- }
- @Override
- public int intVal(int doc) {
- return getInt();
- }
- @Override
- public long longVal(int doc) {
- return getLong();
- }
- @Override
- public double doubleVal(int doc) {
- return getDouble();
- }
- @Override
- public String toString(int doc) {
- return description();
- }
- @Override
- public Object objectVal(int doc) {
- return new Date(longVal(doc));
- }
- @SuppressWarnings("deprecation")
- @Override
- public String strVal(int doc) {
- return Instant.ofEpochMilli(longVal(doc)).toString();
- }
- @Override
- public boolean boolVal(int doc) {
- return getFloat() != 0.0f;
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueDate mval = new MutableValueDate();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) {
- mval.value = longVal(doc);
- mval.exists = true;
- }
- };
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDoubleSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDoubleSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDoubleSource.java
deleted file mode 100644
index e0ebad6..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstDoubleSource.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.util.valuesource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
-import org.apache.lucene.queries.function.valuesource.ConstNumberSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>ConstDoubleSource</code> returns a constant double for all documents
- */
-public class ConstDoubleSource extends ConstNumberSource {
- public final static String NAME = AnalyticsParams.CONSTANT_NUMBER;
- final double constant;
-
- public ConstDoubleSource(double constant) {
- this.constant = constant;
- }
-
- @Override
- public String description() {
- return name()+"(" + getFloat() + ")";
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- return new DoubleDocValues(this) {
- @Override
- public double doubleVal(int doc) {
- return constant;
- }
- @Override
- public boolean exists(int doc) {
- return true;
- }
- };
- }
-
- @Override
- public int hashCode() {
- return (int)Double.doubleToLongBits(constant) * 31;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof ConstDoubleSource)) return false;
- ConstDoubleSource other = (ConstDoubleSource)o;
- return this.constant == other.constant;
- }
-
- @Override
- public int getInt() {
- return (int)constant;
- }
-
- @Override
- public long getLong() {
- return (long)constant;
- }
-
- @Override
- public float getFloat() {
- return (float)constant;
- }
-
- @Override
- public double getDouble() {
- return constant;
- }
-
- @Override
- public Number getNumber() {
- return new Double(constant);
- }
-
- @Override
- public boolean getBool() {
- return constant != 0.0f;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstStringSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstStringSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstStringSource.java
deleted file mode 100644
index 52bdf52..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ConstStringSource.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import org.apache.lucene.queries.function.valuesource.LiteralValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>ConstStringSource</code> returns a constant string for all documents
- */
-public class ConstStringSource extends LiteralValueSource {
- public final static String NAME = AnalyticsParams.CONSTANT_STRING;
-
- public ConstStringSource(String string) {
- super(string);
- }
-
- @Override
- public String description() {
- return name()+"(" + string + ")";
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ConstStringSource)) return false;
- ConstStringSource that = (ConstStringSource) o;
-
- return getValue().equals(that.getValue());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
deleted file mode 100644
index 803d8e0..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.NumericDocValues;
-import org.apache.solr.legacy.LegacyNumericUtils;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.docvalues.LongDocValues;
-import org.apache.lucene.queries.function.valuesource.LongFieldSource;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.mutable.MutableValue;
-import org.apache.lucene.util.mutable.MutableValueDate;
-
-/**
- * Extends {@link LongFieldSource} to have a field source that takes in
- * and returns {@link Date} values while working with long values internally.
- */
-public class DateFieldSource extends LongFieldSource {
-
- public DateFieldSource(String field) {
- super(field);
- }
-
- public long externalToLong(String extVal) {
- return LegacyNumericUtils.prefixCodedToLong(new BytesRef(extVal));
- }
-
- public Object longToObject(long val) {
- return new Date(val);
- }
-
- @SuppressWarnings("deprecation")
- public String longToString(long val) {
- return Instant.ofEpochMilli(val).toString();
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final NumericDocValues arr = DocValues.getNumeric(readerContext.reader(), field);
- return new LongDocValues(this) {
-
- private long getDocValue(int doc) throws IOException {
- int arrDocID = arr.docID();
- if (arrDocID < doc) {
- arrDocID = arr.advance(doc);
- }
- if (arrDocID == doc) {
- return arr.longValue();
- } else {
- return 0;
- }
- }
-
- @Override
- public long longVal(int doc) throws IOException {
- return getDocValue(doc);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- getDocValue(doc);
- return arr.docID() == doc;
- }
-
- @Override
- public Object objectVal(int doc) throws IOException {
- return exists(doc) ? longToObject(getDocValue(doc)) : null;
- }
-
- @Override
- public String strVal(int doc) throws IOException {
- return exists(doc) ? longToString(getDocValue(doc)) : null;
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueDate mval = new MutableValueDate();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- mval.value = getDocValue(doc);
- mval.exists = exists(doc);
- }
- };
- }
-
- };
- }
-
- @Override
- public boolean equals(Object o) {
- if (o.getClass() != this.getClass()) return false;
- DateFieldSource other = (DateFieldSource) o;
- return field.equals(other.field);
- }
-
- @Override
- public int hashCode() {
- int h = this.getClass().hashCode();
- h += super.hashCode();
- return h;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateMathFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateMathFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateMathFunction.java
deleted file mode 100644
index 77b172a..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateMathFunction.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.Date;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.valuesource.BytesRefFieldSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-import org.apache.solr.util.DateMathParser;
-
-/**
- * <code>DateMathFunction</code> returns a start date modified by a list of DateMath operations.
- */
-public class DateMathFunction extends MultiDateFunction {
- public final static String NAME = AnalyticsParams.DATE_MATH;
- final private DateMathParser parser;
-
- /**
- * @param sources A list of ValueSource objects. The first element in the list
- * should be a {@link DateFieldSource} or {@link ConstDateSource} object which
- * represents the starting date. The rest of the field should be {@link BytesRefFieldSource}
- * or {@link ConstStringSource} objects which contain the DateMath operations to perform on
- * the start date.
- */
- public DateMathFunction(ValueSource[] sources) {
- super(sources);
- parser = new DateMathParser();
- }
-
- @Override
- protected String name() {
- return NAME;
- }
-
- @Override
- protected long func(int doc, FunctionValues[] valsArr) throws IOException {
- long time = 0;
- Date date = (Date)valsArr[0].objectVal(doc);
- try {
- parser.setNow(date);
- for (int count = 1; count < valsArr.length; count++) {
- date = parser.parseMath(valsArr[count].strVal(doc));
- parser.setNow(date);
- }
- time = parser.getNow().getTime();
- } catch (ParseException e) {
- e.printStackTrace();
- time = date.getTime();
- }
- return time;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DivDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DivDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DivDoubleFunction.java
deleted file mode 100644
index 25c4c96..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DivDoubleFunction.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.util.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>DivDoubleFunction</code> returns the quotient of 'a' and 'b'.
- */
-public class DivDoubleFunction extends DualDoubleFunction {
- public final static String NAME = AnalyticsParams.DIVIDE;
-
- /**
- * @param a the numerator.
- * @param b the denominator.
- */
- public DivDoubleFunction(ValueSource a, ValueSource b) {
- super(a, b);
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- protected double func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return aVals.doubleVal(doc)/bVals.doubleVal(doc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DualDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DualDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DualDoubleFunction.java
deleted file mode 100644
index 97b8af7..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DualDoubleFunction.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.util.valuesource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
-import org.apache.lucene.search.IndexSearcher;
-
-/**
- * Abstract {@link ValueSource} implementation which wraps two ValueSources
- * and applies an extendible double function to their values.
- **/
-public abstract class DualDoubleFunction extends ValueSource {
- protected final ValueSource a;
- protected final ValueSource b;
-
- public DualDoubleFunction(ValueSource a, ValueSource b) {
- this.a = a;
- this.b = b;
- }
-
- protected abstract String name();
- protected abstract double func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException;
-
- @Override
- public String description() {
- return name() + "(" + a.description() + "," + b.description() + ")";
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues aVals = a.getValues(context, readerContext);
- final FunctionValues bVals = b.getValues(context, readerContext);
- return new DoubleDocValues(this) {
- @Override
- public double doubleVal(int doc) throws IOException {
- return func(doc, aVals, bVals);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- return aVals.exists(doc) & bVals.exists(doc);
- }
-
- @Override
- public String toString(int doc) throws IOException {
- return name() + '(' + aVals.toString(doc) + ',' + bVals.toString(doc) + ')';
- }
- };
- }
-
- @Override
- public void createWeight(Map context, IndexSearcher searcher) throws IOException {
- a.createWeight(context,searcher);
- b.createWeight(context,searcher);
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- DualDoubleFunction other = (DualDoubleFunction)o;
- return this.a.equals(other.a)
- && this.b.equals(other.b);
- }
-
- @Override
- public int hashCode() {
- int h = a.hashCode();
- h ^= (h << 13) | (h >>> 20);
- h += b.hashCode();
- h ^= (h << 23) | (h >>> 10);
- h += name().hashCode();
- return h;
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/FilterFieldSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/FilterFieldSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/FilterFieldSource.java
deleted file mode 100644
index 3f374dc..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/FilterFieldSource.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.util.valuesource;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.util.mutable.MutableValue;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>DefaultIsMissingFieldSource</code> wraps a field source to return missing values
- * if the value is equal to the default value.
- */
-public class FilterFieldSource extends ValueSource {
- public final static String NAME = AnalyticsParams.FILTER;
- public final Object missValue;
- protected final ValueSource source;
-
- public FilterFieldSource(ValueSource source, Object missValue) {
- this.source = source;
- this.missValue = missValue;
- }
-
- protected String name() {
- return NAME;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public String description() {
- if (missValue.getClass().equals(Date.class)) {
- return name()+"("+source.description()+","+ ((Date)missValue).toInstant() +")";
- } else {
- return name()+"("+source.description()+","+missValue.toString()+")";
- }
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues vals = source.getValues(context, readerContext);
- return new FunctionValues() {
-
- @Override
- public byte byteVal(int doc) throws IOException {
- return vals.byteVal(doc);
- }
-
- @Override
- public short shortVal(int doc) throws IOException {
- return vals.shortVal(doc);
- }
-
- @Override
- public float floatVal(int doc) throws IOException {
- return vals.floatVal(doc);
- }
-
- @Override
- public int intVal(int doc) throws IOException {
- return vals.intVal(doc);
- }
-
- @Override
- public long longVal(int doc) throws IOException {
- return vals.longVal(doc);
- }
-
- @Override
- public double doubleVal(int doc) throws IOException {
- return vals.doubleVal(doc);
- }
-
- @Override
- public String strVal(int doc) throws IOException {
- return vals.strVal(doc);
- }
-
- @Override
- public Object objectVal(int doc) throws IOException {
- return exists(doc)? vals.objectVal(doc) : null;
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- Object other = vals.objectVal(doc);
- return other!=null&&!missValue.equals(other);
- }
-
- @Override
- public String toString(int doc) throws IOException {
- return NAME + '(' + vals.toString(doc) + ')';
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final ValueFiller delegateFiller = vals.getValueFiller();
- private final MutableValue mval = delegateFiller.getValue();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- delegateFiller.fillValue(doc);
- mval.exists = exists(doc);
- }
- };
- }
- };
- }
-
- public ValueSource getRootSource() {
- if (source instanceof FilterFieldSource) {
- return ((FilterFieldSource)source).getRootSource();
- } else {
- return source;
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- FilterFieldSource other = (FilterFieldSource)o;
- return this.source.equals(other.source) && this.missValue.equals(other.missValue);
- }
-
- @Override
- public int hashCode() {
- return source.hashCode()+name().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/LogDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/LogDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/LogDoubleFunction.java
deleted file mode 100644
index 41a6b67..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/LogDoubleFunction.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.util.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>LogDoubleFunction</code> returns the log of a double value with a given base.
- */
-public class LogDoubleFunction extends DualDoubleFunction {
- public final static String NAME = AnalyticsParams.LOG;
-
- public LogDoubleFunction(ValueSource a, ValueSource b) {
- super(a,b);
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- protected double func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return Math.log(aVals.doubleVal(doc))/Math.log(bVals.doubleVal(doc));
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDateFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDateFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDateFunction.java
deleted file mode 100644
index beeaaa7..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDateFunction.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.valuesource;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.docvalues.LongDocValues;
-import org.apache.lucene.util.mutable.MutableValue;
-import org.apache.lucene.util.mutable.MutableValueDate;
-
-/**
- * Abstract {@link ValueSource} implementation which wraps multiple ValueSources
- * and applies an extendible date function to their values.
- **/
-public abstract class MultiDateFunction extends ValueSource {
- protected final ValueSource[] sources;
-
- public MultiDateFunction(ValueSource[] sources) {
- this.sources = sources;
- }
-
- abstract protected String name();
- abstract protected long func(int doc, FunctionValues[] valsArr) throws IOException;
-
- @Override
- public String description() {
- StringBuilder sb = new StringBuilder();
- sb.append(name()).append('(');
- boolean firstTime=true;
- for (ValueSource source : sources) {
- if (firstTime) {
- firstTime=false;
- } else {
- sb.append(',');
- }
- sb.append(source);
- }
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues[] valsArr = new FunctionValues[sources.length];
- for (int i=0; i<sources.length; i++) {
- valsArr[i] = sources[i].getValues(context, readerContext);
- }
-
- return new LongDocValues(this) {
- @Override
- public long longVal(int doc) throws IOException {
- return func(doc, valsArr);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- boolean exists = true;
- for (FunctionValues val : valsArr) {
- exists = exists & val.exists(doc);
- }
- return exists;
- }
-
- @Override
- public String toString(int doc) throws IOException {
- StringBuilder sb = new StringBuilder();
- sb.append(name()).append('(');
- boolean firstTime=true;
- for (FunctionValues vals : valsArr) {
- if (firstTime) {
- firstTime=false;
- } else {
- sb.append(',');
- }
- sb.append(vals.toString(doc));
- }
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueDate mval = new MutableValueDate();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- mval.value = longVal(doc);
- mval.exists = exists(doc);
- }
- };
- }
- };
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- MultiDateFunction other = (MultiDateFunction)o;
- return this.name().equals(other.name())
- && Arrays.equals(this.sources, other.sources);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(sources) + name().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDoubleFunction.java
deleted file mode 100644
index 09956f2..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiDoubleFunction.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.util.valuesource;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
-import org.apache.lucene.search.IndexSearcher;
-
-/**
- * Abstract {@link ValueSource} implementation which wraps multiple ValueSources
- * and applies an extendible double function to their values.
- **/
-public abstract class MultiDoubleFunction extends ValueSource {
- protected final ValueSource[] sources;
-
- public MultiDoubleFunction(ValueSource[] sources) {
- this.sources = sources;
- }
-
- abstract protected String name();
- abstract protected double func(int doc, FunctionValues[] valsArr) throws IOException;
-
- @Override
- public String description() {
- StringBuilder sb = new StringBuilder();
- sb.append(name()).append('(');
- boolean firstTime=true;
- for (ValueSource source : sources) {
- if (firstTime) {
- firstTime=false;
- } else {
- sb.append(',');
- }
- sb.append(source);
- }
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues[] valsArr = new FunctionValues[sources.length];
- for (int i=0; i<sources.length; i++) {
- valsArr[i] = sources[i].getValues(context, readerContext);
- }
-
- return new DoubleDocValues(this) {
- @Override
- public double doubleVal(int doc) throws IOException {
- return func(doc, valsArr);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- boolean exists = true;
- for (FunctionValues val : valsArr) {
- exists = exists & val.exists(doc);
- }
- return exists;
- }
-
- @Override
- public String toString(int doc) throws IOException {
- StringBuilder sb = new StringBuilder();
- sb.append(name()).append('(');
- boolean firstTime=true;
- for (FunctionValues vals : valsArr) {
- if (firstTime) {
- firstTime=false;
- } else {
- sb.append(',');
- }
- sb.append(vals.toString(doc));
- }
- sb.append(')');
- return sb.toString();
- }
- };
- }
-
- @Override
- public void createWeight(Map context, IndexSearcher searcher) throws IOException {
- for (ValueSource source : sources)
- source.createWeight(context, searcher);
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- MultiDoubleFunction other = (MultiDoubleFunction)o;
- return this.name().equals(other.name())
- && Arrays.equals(this.sources, other.sources);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(sources) + name().hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiplyDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiplyDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiplyDoubleFunction.java
deleted file mode 100644
index 83f26f0..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/MultiplyDoubleFunction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>MultiplyDoubleFunction</code> returns the product of its components.
- */
-public class MultiplyDoubleFunction extends MultiDoubleFunction {
- public final static String NAME = AnalyticsParams.MULTIPLY;
-
- public MultiplyDoubleFunction(ValueSource[] sources) {
- super(sources);
- }
-
- @Override
- protected String name() {
- return NAME;
- }
-
- @Override
- protected double func(int doc, FunctionValues[] valsArr) throws IOException {
- double product = 1d;
- for (FunctionValues val : valsArr) {
- product *= val.doubleVal(doc);
- }
- return product;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/NegateDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/NegateDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/NegateDoubleFunction.java
deleted file mode 100644
index 9c8445d..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/NegateDoubleFunction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>NegateDoubleFunction</code> negates the double value of the source it contains.
- */
-public class NegateDoubleFunction extends SingleDoubleFunction {
- public final static String NAME = AnalyticsParams.NEGATE;
-
- public NegateDoubleFunction(ValueSource source) {
- super(source);
- }
-
- protected String name() {
- return NAME;
- }
-
- @Override
- public String description() {
- return name()+"("+source.description()+")";
- }
-
- protected double func(int doc, FunctionValues vals) throws IOException {
- return vals.doubleVal(doc)*-1;
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- NegateDoubleFunction other = (NegateDoubleFunction)o;
- return this.source.equals(other.source);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/PowDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/PowDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/PowDoubleFunction.java
deleted file mode 100644
index 043313b..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/PowDoubleFunction.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.util.valuesource;
-
-import java.io.IOException;
-
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>PowDoubleFunction</code> returns 'a' raised to the power of 'b'.
- */
-public class PowDoubleFunction extends DualDoubleFunction {
- public final static String NAME = AnalyticsParams.POWER;
-
- /**
- * @param a the base.
- * @param b the exponent.
- */
- public PowDoubleFunction(ValueSource a, ValueSource b) {
- super(a, b);
- }
-
- @Override
- protected String name() {
- return NAME;
- }
-
- @Override
- protected double func(int doc, FunctionValues aVals, FunctionValues bVals) throws IOException {
- return Math.pow(aVals.doubleVal(doc), bVals.doubleVal(doc));
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ReverseStringFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ReverseStringFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ReverseStringFunction.java
deleted file mode 100644
index 4fa0f99..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/ReverseStringFunction.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.util.valuesource;
-
-import java.io.IOException;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.solr.analytics.util.AnalyticsParams;
-
-/**
- * <code>ReverseStringFunction</code> reverses the string value of the source it contains.
- */
-public class ReverseStringFunction extends SingleStringFunction {
- public final static String NAME = AnalyticsParams.REVERSE;
-
- public ReverseStringFunction(ValueSource source) {
- super(source);
- }
-
- protected String name() {
- return NAME;
- }
-
- protected CharSequence func(int doc, FunctionValues vals) throws IOException {
- String val = vals.strVal(doc);
- return val != null ? StringUtils.reverse(val) : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleDoubleFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleDoubleFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleDoubleFunction.java
deleted file mode 100644
index 04f79ed..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleDoubleFunction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.util.valuesource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
-
-/**
- * Abstract {@link ValueSource} implementation which wraps one ValueSource
- * and applies an extendible double function to its values.
- */
-public abstract class SingleDoubleFunction extends ValueSource {
- protected final ValueSource source;
-
- public SingleDoubleFunction(ValueSource source) {
- this.source = source;
- }
-
- @Override
- public String description() {
- return name()+"("+source.description()+")";
- }
-
- abstract String name();
- abstract double func(int doc, FunctionValues vals) throws IOException;
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues vals = source.getValues(context, readerContext);
- return new DoubleDocValues(this) {
- @Override
- public double doubleVal(int doc) throws IOException {
- return func(doc, vals);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- return vals.exists(doc);
- }
-
- @Override
- public String toString(int doc) throws IOException {
- return name() + '(' + vals.toString(doc) + ')';
- }
- };
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- SingleDoubleFunction other = (SingleDoubleFunction)o;
- return this.source.equals(other.source);
- }
-
- @Override
- public int hashCode() {
- return source.hashCode()+name().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleStringFunction.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleStringFunction.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleStringFunction.java
deleted file mode 100644
index b3357f9..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/SingleStringFunction.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.util.valuesource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.docvalues.StrDocValues;
-import org.apache.lucene.util.BytesRefBuilder;
-import org.apache.lucene.util.mutable.MutableValue;
-import org.apache.lucene.util.mutable.MutableValueStr;
-
-/**
- * Abstract {@link ValueSource} implementation which wraps one ValueSource
- * and applies an extendible string function to its values.
- */
-public abstract class SingleStringFunction extends ValueSource {
- protected final ValueSource source;
-
- public SingleStringFunction(ValueSource source) {
- this.source = source;
- }
-
- @Override
- public String description() {
- return name()+"("+source.description()+")";
- }
-
- abstract String name();
- abstract CharSequence func(int doc, FunctionValues vals) throws IOException;
-
- @Override
- public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
- final FunctionValues vals = source.getValues(context, readerContext);
- return new StrDocValues(this) {
- @Override
- public String strVal(int doc) throws IOException {
- CharSequence cs = func(doc, vals);
- return cs != null ? cs.toString() : null;
- }
-
- @Override
- public boolean bytesVal(int doc, BytesRefBuilder bytes) throws IOException {
- CharSequence cs = func(doc, vals);
- if( cs != null ){
- bytes.copyChars(func(doc,vals));
- return true;
- } else {
- bytes.clear();
- return false;
- }
- }
-
- @Override
- public Object objectVal(int doc) throws IOException {
- return strVal(doc);
- }
-
- @Override
- public boolean exists(int doc) throws IOException {
- return vals.exists(doc);
- }
-
- @Override
- public String toString(int doc) throws IOException {
- return name() + '(' + strVal(doc) + ')';
- }
-
- @Override
- public ValueFiller getValueFiller() {
- return new ValueFiller() {
- private final MutableValueStr mval = new MutableValueStr();
-
- @Override
- public MutableValue getValue() {
- return mval;
- }
-
- @Override
- public void fillValue(int doc) throws IOException {
- mval.exists = bytesVal(doc, mval.value);
- }
- };
- }
- };
- }
-
- @Override
- public boolean equals(Object o) {
- if (getClass() != o.getClass()) return false;
- SingleStringFunction other = (SingleStringFunction)o;
- return this.source.equals(other.source);
- }
-
- @Override
- public int hashCode() {
- return source.hashCode()+name().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5963beb/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/package-info.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/package-info.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/package-info.java
deleted file mode 100644
index 72a23d2..0000000
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * ValueSource function/sources used by analytics component
- */
-package org.apache.solr.analytics.util.valuesource;
-
-
-