Example usage for org.apache.solr.client.solrj.io Tuple get

List of usage examples for org.apache.solr.client.solrj.io Tuple get

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.io Tuple get.

Prototype

public Object get(Object key) 

Source Link

Usage

From source file:org.apache.drill.exec.store.solr.SolrRecordReader.java

License:Apache License

private int processSolrStream(SolrStream solrStream) {
    int recordCounter = 0;
    try {//from   w  w  w . j  a  v a2  s .  c  o m
        solrStream.open();
        Tuple solrDocument = null;

        while (true) {
            solrDocument = solrStream.read();
            if (solrDocument.EOF) {
                break;
            }
            for (String columns : vectors.keySet()) {
                ValueVector vv = vectors.get(columns);
                Object fieldValue = solrDocument.get(columns);
                processRecord(vv, fieldValue, recordCounter);
            }

            recordCounter++;
        }
    } catch (Exception e) {
        SolrRecordReader.logger.info("Error occured while fetching results from solr server " + e.getMessage());
        solrStreamReadFinished = true;

        return 0;
    } finally {
        try {
            solrStream.close();
            solrStream = null;
        } catch (IOException e) {
            solrStreamReadFinished = true;
            SolrRecordReader.logger
                    .debug("Error occured while fetching results from solr server " + e.getMessage());
        }
    }

    return recordCounter;
}

From source file:org.deeplearning4j.nn.dataimport.solr.client.solrj.io.stream.TupleStreamDataSetIterator.java

License:Apache License

private static double getValue(Tuple tuple, String key, String idKey) {
    final Double value = tuple.getDouble(key);
    if (value == null) {
        // log potentially useful debugging info here ...
        if (idKey == null) {
            log.info("tuple[{}]={}", key, value);
        } else {/*w  w  w .jav  a2 s .  co m*/
            log.info("tuple[{}]={} tuple[{}]={}", key, value, idKey, tuple.get(idKey));
        }
        // ... before proceeding to hit the NullPointerException below
    }
    return value.doubleValue();
}