Search in sources :

Example 26 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class HyperbolicTangentEvaluatorTest method noValue.

@Test
public void noValue() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("tanh(a)");
    values.clear();
    Object result = evaluator.evaluate(new Tuple(values));
    assertNull(result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 27 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class CubedRootEvaluatorTest method noValue.

@Test
public void noValue() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("cbrt(a)");
    values.clear();
    Object result = evaluator.evaluate(new Tuple(values));
    assertNull(result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 28 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class DivideEvaluatorTest method divTwoFieldsWithValues.

@Test
public void divTwoFieldsWithValues() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
    Object result;
    values.clear();
    values.put("a", 1);
    values.put("b", 2);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Double);
    Assert.assertEquals(1.0 / 2, result);
    values.clear();
    values.put("a", 1.1);
    values.put("b", 2);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Double);
    Assert.assertEquals(1.1 / 2, result);
    values.clear();
    values.put("a", 1.1);
    values.put("b", 2.1);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Double);
    Assert.assertEquals(1.1 / 2.1, result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 29 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class DivideEvaluatorTest method divTwoFieldsWithMissingNumerator.

@Test(expected = IOException.class)
public void divTwoFieldsWithMissingNumerator() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
    values.clear();
    values.put("b", 1);
    evaluator.evaluate(new Tuple(values));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 30 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class DivideEvaluatorTest method divManyFieldsWithSubdivs.

@Test
public void divManyFieldsWithSubdivs() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("div(a,div(b,c))");
    Object result;
    values.clear();
    values.put("a", 1);
    values.put("b", 2);
    values.put("c", 3);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Double);
    Assert.assertEquals((1.0 / (2.0 / 3)), result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Aggregations

StreamEvaluator (org.apache.solr.client.solrj.io.eval.StreamEvaluator)137 Tuple (org.apache.solr.client.solrj.io.Tuple)135 Test (org.junit.Test)119 StreamContext (org.apache.solr.client.solrj.io.stream.StreamContext)6 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 UUID (java.util.UUID)1 StreamOperation (org.apache.solr.client.solrj.io.ops.StreamOperation)1