mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
Move getNextBatch into IResultIterator
This commit is contained in:
parent
1d6a26bf1d
commit
0a4d81eb85
@ -23,12 +23,15 @@ package ca.uhn.fhir.jpa.dao;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface IResultIterator extends Iterator<ResourcePersistentId>, Closeable {
|
||||
|
||||
int getSkippedCount();
|
||||
|
||||
int getNonSkippedCount();
|
||||
int getNonSkippedCount();
|
||||
|
||||
Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize);
|
||||
|
||||
}
|
||||
|
@ -1306,12 +1306,22 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
return myNonSkipCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize) {
|
||||
Collection<ResourcePersistentId> batch = new ArrayList<>();
|
||||
while (this.hasNext() && batch.size() < theBatchSize) {
|
||||
batch.add(this.next());
|
||||
}
|
||||
return batch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (myResultsIterator != null) {
|
||||
myResultsIterator.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class CountQueryIterator implements Iterator<Long> {
|
||||
|
@ -84,7 +84,7 @@ public class EmpiBatchSvcImpl implements IEmpiBatchSvc {
|
||||
try (IResultIterator query = theSearchBuilder.createQuery(theSpMap, searchRuntimeDetails, null, RequestPartitionId.defaultPartition())) {
|
||||
Collection<ResourcePersistentId> pidBatch;
|
||||
do {
|
||||
pidBatch = getPidBatch(query);
|
||||
pidBatch = query.getNextResultBatch(BUFFER_SIZE);
|
||||
total += loadPidsAndSubmitToEmpiChannel(theSearchBuilder, pidBatch);
|
||||
} while (query.hasNext());
|
||||
} catch (IOException theE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user