Revision 57157
Added by Enrico Ottonello over 4 years ago
IndexFeedActorImpl.java | ||
---|---|---|
4 | 4 |
import java.util.concurrent.ExecutorService; |
5 | 5 |
import java.util.concurrent.Executors; |
6 | 6 |
import java.util.function.Function; |
7 |
import java.util.stream.Stream; |
|
8 |
import java.util.stream.StreamSupport; |
|
7 | 9 |
|
8 | 10 |
import com.google.common.collect.Maps; |
11 |
|
|
12 |
import eu.dnetlib.clients.index.model.Any.ValueType; |
|
9 | 13 |
import eu.dnetlib.clients.index.model.document.IndexDocument; |
10 | 14 |
import eu.dnetlib.clients.index.utils.IndexFieldUtility; |
11 | 15 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
... | ... | |
78 | 82 |
final String backendId, final boolean emptyResult) { |
79 | 83 |
IndexCollection indexCollection = null; |
80 | 84 |
try { |
81 |
startCallback.unschedule(); |
|
82 | 85 |
final MetadataReference mdref = serviceTools.getMetadataRef(dsId); |
83 | 86 |
|
84 | 87 |
final IndexServerDAO serverDAO = indexServerDAOMap.getIndexServerDAO(backendId); |
85 | 88 |
final DocumentMapperFactory docMapperFactory = serverDAO.getDocumentMapperFactory(); |
86 | 89 |
final String version = IndexDateUtility.getParsedDateField(DateUtils.now_ISO8601()); |
87 |
final Function<String, IndexDocument> docMapper = docMapperFactory.getRecordMapper(serverDAO.getSchema(mdref), mdref, dsId, version, emptyResult); |
|
88 |
|
|
89 |
Iterable<IndexDocument> result = DnetStreamSupport.generateStreamFromIterator(docIterator.iterator()).map(docMapper)::iterator; |
|
90 |
|
|
90 |
Map<String, ValueType> fields = serverDAO.getSchema(mdref); |
|
91 |
final Function<String, IndexDocument> docMapper = docMapperFactory.getRecordMapper(fields, mdref, dsId, version, emptyResult); |
|
92 |
|
|
93 |
Stream<IndexDocument> docStream = DnetStreamSupport.generateStreamFromIterator(docIterator.iterator()).map(docMapper); |
|
94 |
|
|
91 | 95 |
indexCollection = serverDAO.getIndexCollection(mdref); |
92 |
final FeedResult res = threadPool.submit(new DocumentFeeder(indexCollection, result)).get();
|
|
93 |
|
|
96 |
final FeedResult res = threadPool.submit(new DocumentFeeder(indexCollection, docStream)).get();
|
|
97 |
|
|
94 | 98 |
cleanMarkedDocuments(indexCollection, dsId); |
95 | 99 |
if (feedMode.equals(FeedMode.REFRESH)) { |
96 | 100 |
deleteByVersion(indexCollection, dsId, version); |
Also available in: Unified diff
solr 772 integration