org.infinispan.query.impl.LazyIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-embedded-query
Show all versions of infinispan-embedded-query
Infinispan Embedded Query All-in-One module
The newest version!
package org.infinispan.query.impl;
import java.io.IOException;
import org.hibernate.search.query.engine.spi.DocumentExtractor;
import org.hibernate.search.query.engine.spi.EntityInfo;
import org.infinispan.commons.CacheException;
import net.jcip.annotations.NotThreadSafe;
/**
* Implementation for {@link org.infinispan.query.ResultIterator}. This loads the results only when required
* and hence differs from {@link EagerIterator} which is the other implementation of ResultIterator.
*
* @author Navin Surtani
* @author Marko Luksa
* @author Ales Justin
*/
@NotThreadSafe
public class LazyIterator extends AbstractIterator {
private final DocumentExtractor extractor;
public LazyIterator(DocumentExtractor extractor, QueryResultLoader resultLoader, int fetchSize) {
super(resultLoader, extractor.getFirstIndex(), extractor.getMaxIndex(), fetchSize);
this.extractor = extractor;
}
@Override
public void close() {
extractor.close();
}
@Override
protected EntityInfo loadEntityInfo(int index) {
try {
return extractor.extract(index);
} catch (IOException e) {
throw new CacheException("Cannot load result at index " + index, e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy