enhanced postprocessing by usage of a field-list generation to prevent

lazy initialization of the documents. This is useful because the
documents must be read completely anyway.
pull/1/head
orbiter 10 years ago
parent dbafd4865e
commit 71758f0d62

@ -461,14 +461,15 @@ public abstract class AbstractSolrConnector implements SolrConnector {
query.clearSorts();
query.setRows(1);
query.setStart(0);
if (fields.length > 0) query.setFields(fields);
if (fields != null && fields.length > 0) query.setFields(fields);
query.setIncludeScore(false);
// query the server
try {
final SolrDocumentList docs = getDocumentListByParams(query);
if (docs == null || docs.isEmpty()) return null;
return docs.get(0);
SolrDocument doc = docs.get(0);
return doc;
} catch (final Throwable e) {
clearCaches(); // we clear the in case that this is caused by OOM
throw new IOException(e.getMessage(), e);

@ -146,6 +146,14 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
}
}
public String[] allFields() {
ArrayList<String> a = new ArrayList<>(this.size());
for (CollectionSchema f: CollectionSchema.values()) {
if (this.contains(f)) a.add(f.getSolrFieldName());
}
return a.toArray(new String[a.size()]);
}
public Ranking getRanking(final int idx) {
return this.rankings.get(idx % this.rankings.size()); // simply prevent out of bound exeption (& callers don't check for null)
@ -1267,6 +1275,9 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
0, 100000000, Long.MAX_VALUE, concurrency + 1, concurrency, true,
byPartialUpdate ?
new String[]{
// the following fields are needed to perform the postprocessing
// and should only be used for partial updates; for full updates use a
// full list of fields to avoid LazyInstantiation which has poor performace
CollectionSchema.id.getSolrFieldName(),
CollectionSchema.sku.getSolrFieldName(),
CollectionSchema.harvestkey_s.getSolrFieldName(),
@ -1285,7 +1296,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
CollectionSchema.httpstatus_i.getSolrFieldName(),
CollectionSchema.inboundlinkscount_i.getSolrFieldName(),
CollectionSchema.robots_i.getSolrFieldName()} :
new String[0]);
this.allFields());
final AtomicInteger proccount = new AtomicInteger();
final AtomicInteger proccount_referencechange = new AtomicInteger();
final AtomicInteger proccount_citationchange = new AtomicInteger();

Loading…
Cancel
Save