Relation#each had previously delegated to Relation#to_a, which sends
N requests to Fedora (plus one to Solr) and loads all the objects into memory
before beginning work.
This introduces an Enumerator based implementation, using #find_each. When
#to_a has already been called, we take advantage of the existing caching;
otherwise we yield items individually.
We also delegate certain other methods to #each instead of #to_a,
extending the same benefits to #collect, and getting massively
better performance from #blank?, #present?, #include? and #any?. There
are probably other optimizations to be explored based on this.
#map is kept as is, since delegating it to #each breaks ordering code. Since
it would be rasonable to assume that #map would have effient access
properties and not cast to an Array, this should be investigated.
Relation#each
had previously delegated toRelation#to_a
, which sends N requests to Fedora (plus one to Solr) and loads all the objects into memory before beginning work.This introduces an
Enumerator
based implementation, using#find_each
. When#to_a
has already been called, we take advantage of the existing caching; otherwise we yield items individually.We also delegate certain other methods to
#each
instead of#to_a
, extending the same benefits to#collect
, and getting massively better performance from#blank?
,#present?
,#include?
and#any?
. There are probably other optimizations to be explored based on this.#map
is kept as is, since delegating it to#each
breaks ordering code. Since it would be rasonable to assume that#map
would have effient access properties and not cast to an Array, this should be investigated.