/** * Converts a time series of type <T> to SolInputDocument * * @param ts - the time series * @return a filled SolrInputDocument */ private static <T> SolrInputDocument convert(T ts, TimeSeriesConverter<T> converter) { BinaryTimeSeries series = converter.to(ts); SolrInputDocument solrDocument = new SolrInputDocument(); series.getFields().entrySet().forEach(entry -> solrDocument.addField(entry.getKey(), entry.getValue())); return solrDocument; } }
/** * Converts a time series of type <T> to SolInputDocument * * @param ts - the time series * @return a filled SolrInputDocument */ private static <T> SolrInputDocument convert(T ts, TimeSeriesConverter<T> converter) { BinaryTimeSeries series = converter.to(ts); SolrInputDocument solrDocument = new SolrInputDocument(); series.getFields().entrySet().forEach(entry -> solrDocument.addField(entry.getKey(), entry.getValue())); return solrDocument; } }
/** * Converts a time series of type <T> to lucene document. * Handles the default java object types (e.g. double, int, array, collections, ...) * and wraps them into the matching lucene fields (int -> IntField). * * @param ts the time series of type <T> * @return a filled lucene document */ private static <T> Document convert(T ts, TimeSeriesConverter<T> converter) { BinaryTimeSeries series = converter.to(ts); Document document = new Document(); series.getFields().entrySet().forEach(entry -> { if (entry.getValue() instanceof Number) { handleNumbers(document, entry.getKey(), entry.getValue()); } else if (entry.getValue() instanceof String || entry.getValue() instanceof byte[]) { handleStringsAndBytes(document, entry.getKey(), entry.getValue()); } else if (entry.getValue() instanceof Collection || entry.getValue() instanceof Object[]) { handleArraysAndIterable(document, entry.getKey(), entry.getValue()); } else { LOGGER.debug("Field {} could not be handled. Type is not supported", entry); } }); return document; }