Java Code Examples for org.apache.solr.client.solrj.io.Tuple#EOF

The following examples show how to use org.apache.solr.client.solrj.io.Tuple#EOF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudSolrStream.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected Tuple _read() throws IOException {
  TupleWrapper tw = tuples.pollFirst();
  if(tw != null) {
    Tuple t = tw.getTuple();

    if (trace) {
      t.put("_COLLECTION_", this.collection);
    }

    if(tw.next()) {
      tuples.add(tw);
    }
    return t;
  } else {
    Tuple tuple = Tuple.EOF();
    if(trace) {
      tuple.put("_COLLECTION_", this.collection);
    }
    return tuple;
  }
}
 
Example 2
Source File: ExportWriter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Tuple read() throws IOException {
  if (pos < 0) {
    if (count < totalHits) {
      outDocIndex = exportWriter.fillOutDocs(leaves, sortDoc, queue, docs);
      count += (outDocIndex + 1);
      pos = outDocIndex;
    } else {
      return Tuple.EOF();
    }
  }
  if (pos < 0) {
    return Tuple.EOF();
  }
  Tuple tuple = new Tuple();
  entryWriter.setTuple(tuple);
  SortDoc s = docs[pos];
  exportWriter.writeDoc(s, leaves, entryWriter);
  s.reset();
  pos--;
  return tuple;
}
 
Example 3
Source File: TupStream.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public Tuple read() throws IOException {

    if(unnestedTuples == null) {
      if (finished) {
        return Tuple.EOF();
      } else {
        finished = true;
        if(unnestedTuple != null) {
          return unnestedTuple;
        } else {
          return tup;
        }
      }
    } else {
      if(unnestedTuples.hasNext()) {
        return unnestedTuples.next();
      } else {
        return Tuple.EOF();
      }
    }
  }
 
Example 4
Source File: ListStream.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public Tuple read() throws IOException {
  while(true) {
    if (currentStream == null) {
      if (streamIndex < streams.length) {
        currentStream = streams[streamIndex];
        // Set the stream to null in the array of streams once its been set to the current stream.
        // This will remove the reference to the stream
        // and should allow it to be garbage collected once it's no longer the current stream.
        streams[streamIndex] = null;
        currentStream.open();
      } else {
        return Tuple.EOF();
      }
    }

    Tuple tuple = currentStream.read();
    if (tuple.EOF) {
      currentStream.close();
      currentStream = null;
      ++streamIndex;
    } else {
      return tuple;
    }
  }
}
 
Example 5
Source File: DeepRandomStream.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected Tuple _read() throws IOException {
  if(tuples.size() > 0) {
    TupleWrapper tw = tuples.removeFirst();
    Tuple t = tw.getTuple();

    if (trace) {
      t.put("_COLLECTION_", this.collection);
    }

    if(tw.next()) {
      tuples.addLast(tw);
    }
    return t;
  } else {
    Tuple tuple = Tuple.EOF();
    if(trace) {
      tuple.put("_COLLECTION_", this.collection);
    }
    return tuple;
  }
}
 
Example 6
Source File: StatsStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  if(index == 0) {
    ++index;
    return tuple;
  } else {
    return Tuple.EOF();
  }
}
 
Example 7
Source File: KnnStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  if(documentIterator.hasNext()) {
    Tuple tuple = new Tuple();
    SolrDocument doc = documentIterator.next();
    for(Entry<String, Object> entry : doc.entrySet()) {
      tuple.put(entry.getKey(), entry.getValue());
    }
    return tuple;
  } else {
    return Tuple.EOF();
  }
}
 
Example 8
Source File: LimitStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  ++count;
  if(count > limit) {
    return Tuple.EOF();
  }

  return stream.read();
}
 
Example 9
Source File: GetStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  if (tupleIterator.hasNext()) {
    Tuple t = tupleIterator.next();
    return t.clone();
  } else {
    return Tuple.EOF();
  }
}
 
Example 10
Source File: HelloStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple read() throws IOException {
  if (isSentHelloWorld) {
    return Tuple.EOF();
  } else {
    isSentHelloWorld = true;
    return new Tuple("msg", "Hello World!");
  }
}
 
Example 11
Source File: GatherNodesStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() {
  if(it.hasNext()) {
    return new Tuple("node",it.next());
  } else {
    return Tuple.EOF();
  }
}
 
Example 12
Source File: TimeSeriesStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  if(index < tuples.size()) {
    Tuple tuple = tuples.get(index);
    ++index;
    return tuple;
  } else {
    return Tuple.EOF();
  }
}
 
Example 13
Source File: TextLogitStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple read() throws IOException {
  if (it.hasNext()) {
    Tuple tuple = new Tuple();
    tuple.put("term_s", it.next());
    tuple.put("score_f", 1.0);
    return tuple;
  } else {
    return Tuple.EOF();
  }
}
 
Example 14
Source File: StreamHandler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() {
  if (sendEOF) {
    return Tuple.EOF();
  } else {
    sendEOF = true;
    return new Tuple("DaemonOp", message);
  }
}
 
Example 15
Source File: CalculatorStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {

    if (finished) {
      return Tuple.EOF();
    } else {
      finished = true;
      return new Tuple();
    }
  }
 
Example 16
Source File: ModelStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  Tuple tuple = null;

  if(model != null) {
    tuple = model;
    model = null;
  } else {
    tuple = Tuple.EOF();
  }

  return tuple;
}
 
Example 17
Source File: DrillStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  Tuple tuple = _read();

  if(tuple.EOF) {
    return Tuple.EOF();
  }

  return tuple;
}
 
Example 18
Source File: Facet2DStream.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public Tuple read() throws IOException {
  if (out.hasNext()) {
    return out.next();
  } else {
    Tuple tuple = Tuple.EOF();
    tuple.put("rows", tuples.size());
    return tuple;
  }

}
 
Example 19
Source File: TextLogitStream.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
public Tuple read() throws IOException {
  try {

    if(++iteration > maxIterations) {
      return Tuple.EOF();
    } else {

      if (this.idfs == null) {
        loadTerms();

        if (weights != null && terms.size() + 1 != weights.size()) {
          throw new IOException(String.format(Locale.ROOT,"invalid expression %s - the number of weights must be %d, found %d", terms.size()+1, weights.size()));
        }
      }

      List<List<Double>> allWeights = new ArrayList<>();
      this.evaluation = new ClassificationEvaluation();

      this.error = 0;
      for (Future<Tuple> logitCall : callShards(getShardUrls())) {

        Tuple tuple = logitCall.get();
        List<Double> shardWeights = (List<Double>) tuple.get("weights");
        allWeights.add(shardWeights);
        this.error += tuple.getDouble("error");
        @SuppressWarnings({"rawtypes"})
        Map shardEvaluation = (Map) tuple.get("evaluation");
        this.evaluation.addEvaluation(shardEvaluation);
      }

      this.weights = averageWeights(allWeights);
      @SuppressWarnings({"rawtypes"})
      Map map = new HashMap();
      map.put(ID, name+"_"+iteration);
      map.put("name_s", name);
      map.put("field_s", field);
      map.put("terms_ss", terms);
      map.put("iteration_i", iteration);

      if(weights != null) {
        map.put("weights_ds", weights);
      }

      map.put("error_d", error);
      evaluation.putToMap(map);
      map.put("alpha_d", this.learningRate);
      map.put("idfs_ds", this.idfs);

      if (iteration != 1) {
        if (lastError <= error) {
          this.learningRate *= 0.5;
        } else {
          this.learningRate *= 1.05;
        }
      }

      lastError = error;

      return new Tuple(map);
    }

  } catch(Exception e) {
    throw new IOException(e);
  }
}
 
Example 20
Source File: NoOpStream.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public Tuple read() throws IOException {
  return Tuple.EOF();
}