@Override public void run() { // Retrieve the most recent results and count the total number of matches final AtomicInteger matchingCount = new AtomicInteger(0); final List<ProvenanceEventRecord> matchingRecords = new ArrayList<>(maxRecords); ringBuffer.forEach(new ForEachEvaluator<ProvenanceEventRecord>() { @Override public boolean evaluate(final ProvenanceEventRecord record) { if (filter.select(record)) { if (matchingCount.incrementAndGet() <= maxRecords) { matchingRecords.add(record); } } return true; } }, IterationDirection.BACKWARD); submission.getResult().update(matchingRecords, matchingCount.get()); } }
@Override public void run() { try { final IndexSearch search = new IndexSearch(PersistentProvenanceRepository.this, indexDir, getIndexManager(), maxAttributeChars); final StandardQueryResult queryResult = search.search(query, user, retrievalCount, firstEventTimestamp); submission.getResult().update(queryResult.getMatchingEvents(), queryResult.getTotalHitCount()); } catch (final Throwable t) { logger.error("Failed to query Provenance Repository Index {} due to {}", indexDir, t.toString()); if (logger.isDebugEnabled()) { logger.error("", t); } if (t.getMessage() == null) { submission.getResult().setError(t.toString()); } else { submission.getResult().setError(t.getMessage()); } } } }
if (retrievedCount.get() >= provenanceQuery.getMaxResults()) { final StandardQueryResult sqr = new StandardQueryResult(provenanceQuery, 1); sqr.update(Collections.<ProvenanceEventRecord> emptyList(), 0L); sqr.update(Collections.<ProvenanceEventRecord>emptyList(), 0); return sqr; logger.debug("Reading {} records took {} millis for {}", matchingRecords.size(), TimeUnit.NANOSECONDS.toMillis(readRecordsNanos), this); sqr.update(matchingRecords, topDocs.totalHits); sqr.update(Collections.<ProvenanceEventRecord>emptyList(), 0); return sqr; } finally {
result.getResult().update(Collections.<ProvenanceEventRecord>emptyList(), 0L); maxEventId = 0L; result.getResult().update(trimmed, totalNumDocs); } else { queryExecService.submit(new GetMostRecentRunnable(query, result, user)); result.getResult().update(Collections.<ProvenanceEventRecord>emptyList(), 0L); } else { for (final File indexDir : indexDirectories) {
try { events = eventStore.getEvents(eventIds, authorizer, EventTransformer.EMPTY_TRANSFORMER); submission.getResult().update(events, eventIds.size()); } catch (final Exception e) { submission.getResult().setError("Failed to retrieve Provenance Events from store; see logs for more details"); submission.getResult().update(Collections.emptyList(), 0L); } else { Collections.sort(indexDirectories, DirectoryUtils.NEWEST_INDEX_FIRST);