use of org.mycore.oai.pmh.Header in project mycore by MyCoRe-Org.
the class MCROAISolrSearcher method toHeader.
Header toHeader(SolrDocument doc, Collection<MCROAISetResolver<String, SolrDocument>> setResolver) {
Date modified = (Date) doc.getFieldValue(getModifiedField());
String docId = doc.getFieldValue("id").toString();
Header header = new Header(getObjectManager().getOAIId(docId), modified.toInstant());
setResolver.parallelStream().map(r -> r.getSets(docId)).flatMap(Collection::stream).sorted(this::compare).sequential().forEachOrdered(header.getSetList()::add);
return header;
}
use of org.mycore.oai.pmh.Header in project mycore by MyCoRe-Org.
the class MCROAISearchManager method getRecordListParallel.
private OAIDataList<Record> getRecordListParallel(MCROAISearcher searcher, MCROAIResult result) {
List<Header> headerList = result.list();
int listSize = headerList.size();
Record[] records = new Record[listSize];
@SuppressWarnings("rawtypes") CompletableFuture[] futures = new CompletableFuture[listSize];
MetadataFormat metadataFormat = searcher.getMetadataFormat();
MCRSession mcrSession = MCRSessionMgr.getCurrentSession();
for (int i = 0; i < listSize; i++) {
Header header = headerList.get(i);
int resultIndex = i;
MCRTransactionableRunnable r = new MCRTransactionableRunnable(() -> records[resultIndex] = this.objManager.getRecord(header, metadataFormat), mcrSession);
CompletableFuture<Void> future = CompletableFuture.runAsync(r, executorService);
futures[i] = future;
}
CompletableFuture.allOf(futures).join();
OAIDataList<Record> recordList = new OAIDataList<>();
recordList.addAll(Arrays.asList(records));
return recordList;
}
Aggregations