use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.
the class EvalStream method open.
public void open() throws IOException {
try {
stream.open();
Tuple tuple = stream.read();
String expr = tuple.getString("expr_s");
if (expr == null) {
throw new IOException("expr_s cannot be empty for the EvalStream");
}
evalStream = streamFactory.constructStream(expr);
evalStream.setStreamContext(streamContext);
evalStream.open();
} finally {
stream.close();
}
}
use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.
the class HashJoinStream method read.
public Tuple read() throws IOException {
findNextWorkingFullTuple: while (null == workingFullTuple) {
Tuple fullTuple = fullStream.read();
// We're at the end of the line
if (fullTuple.EOF) {
return fullTuple;
}
// If fullTuple doesn't have a valid hash or if there is no doc to
// join with then retry loop - keep going until we find one
Integer fullHash = calculateHash(fullTuple, leftHashOn);
if (null == fullHash || !hashedTuples.containsKey(fullHash)) {
continue findNextWorkingFullTuple;
}
workingFullTuple = fullTuple;
workingFullHash = fullHash;
workngHashSetIdx = 0;
}
// At this point we know we have at least one doc to match on
// Due to the check at the end, before returning, we know we have at least one to match with left
List<Tuple> matches = hashedTuples.get(workingFullHash);
Tuple returnTuple = workingFullTuple.clone();
returnTuple.merge(matches.get(workngHashSetIdx));
// Increment this so the next time we hit the next matching tuple
workngHashSetIdx++;
if (workngHashSetIdx >= matches.size()) {
// well, now we've reached all the matches, clear it all out
workingFullTuple = null;
workingFullHash = null;
workngHashSetIdx = 0;
}
return returnTuple;
}
use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.
the class CartesianProductStream method read.
public Tuple read() throws IOException {
if (generatedTuples.isEmpty()) {
Tuple tuple = stream.read();
if (tuple.EOF) {
return tuple;
}
// returns tuples in desired sorted order
generatedTuples = generateTupleList(tuple);
}
return generatedTuples.pop();
}
use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.
the class GreaterThanEqualToEvaluatorTest method gteDifferentTypes1.
@Test(expected = IOException.class)
public void gteDifferentTypes1() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
values.clear();
values.put("a", true);
values.put("b", 1);
evaluator.evaluate(new Tuple(values));
}
use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.
the class GreaterThanEvaluatorTest method gtTwoIntegers.
@Test
public void gtTwoIntegers() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
Object result;
values.clear();
values.put("a", 1);
values.put("b", 1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 1);
values.put("b", 1.0);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 1.0);
values.put("b", 1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 1);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", -1);
values.put("b", -1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 1);
values.put("b", 2.0);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 1.0);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(false, result);
values.clear();
values.put("a", 2);
values.put("b", 1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", 2);
values.put("b", 1.0);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", 2.0);
values.put("b", 1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", 3);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", -1);
values.put("b", -2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", 3);
values.put("b", 2.0);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
values.clear();
values.put("a", 3.0);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Boolean);
Assert.assertEquals(true, result);
}
Aggregations