removed debug code for existsByIds

pull/1/head
Michael Peter Christen 11 years ago
parent 087df05e24
commit 24a052ecb9

@ -442,7 +442,6 @@ seedScpPath=
peerCycle=2
# debug flags
debug.search.profiling=false
debug.search.local.dht.off=false
debug.search.local.solr.off=false
debug.search.remote.dht.off=false

@ -247,29 +247,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
@Override
public Set<String> existsByIds(Set<String> ids) {
boolean debug = Switchboard.getSwitchboard().getConfigBool("debug.search.profiling", false);
if (!debug) return existsByIdsNew(ids);
long debugSingleTime = 0; int debugSingleCount = 0;
long start = System.currentTimeMillis();
Set<String> idsrn = existsByIdsNew(ids);
debugSingleTime = System.currentTimeMillis() - start;
debugSingleCount = idsrn.size();
start = System.currentTimeMillis();
Set<String> idsro = existsByIdsOld(ids);
long debugCollectionTime = System.currentTimeMillis() - start;
// check if they are equal
boolean eq = idsrn.size() == idsro.size();
if (eq) {
Iterator<String> n = idsrn.iterator();
Iterator<String> o = idsro.iterator();
while (n.hasNext()) if (!n.next().equals(o.next())) {eq = false; break;}
}
ConcurrentLog.info("EmbeddedSolrConnector",
"Comparisment of existsByIds: input=" + ids.size() + " records, singleTime=" + debugSingleTime + ", collectionTime=" + debugCollectionTime + ", singleCount=" + debugSingleCount + ", collectionCount=" + idsro.size() + ", " + (eq ? "equal" : "not equal") + " result sets");
return idsro;
}
public Set<String> existsByIdsNew(Set<String> ids) {
if (ids == null || ids.size() == 0) return new HashSet<String>();
if (ids.size() == 1) return existsById(ids.iterator().next()) ? ids : new HashSet<String>();
Set<String> idsr = new TreeSet<String>();
@ -286,9 +263,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
for (String id: ids) {
params.setQuery("{!raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id);
SolrQueryResponse rsp = new SolrQueryResponse();
//NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
//responseHeader.add("params", req.getOriginalParams().toNamedList());
//rsp.add("responseHeader", responseHeader);
this.requestHandler.handleRequest(req, rsp);
DocList response = ((ResultContext) rsp.getValues().get("response")).docs;
if (response.matches() > 0) idsr.add(id);
@ -297,31 +271,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
return idsr;
}
public Set<String> existsByIdsOld(Set<String> ids) {
if (ids == null || ids.size() == 0) return new HashSet<String>();
if (ids.size() == 1) return existsById(ids.iterator().next()) ? ids : new HashSet<String>();
StringBuilder sb = new StringBuilder(); // construct something like "({!raw f=id}Ij7B63g-gSHA) OR ({!raw f=id}PBcGI3g-gSHA)"
for (String id: ids) {
sb.append("({!raw f=").append(CollectionSchema.id.getSolrFieldName()).append('}').append(id).append(") OR ");
}
if (sb.length() > 0) sb.setLength(sb.length() - 4); // cut off the last 'or'
DocListSearcher docListSearcher = new DocListSearcher(sb.toString(), 0, ids.size(), CollectionSchema.id.getSolrFieldName());
int responseCount = docListSearcher.response.size();
SolrIndexSearcher searcher = docListSearcher.request.getSearcher();
DocIterator iterator = docListSearcher.response.iterator();
Set<String> idsr = new TreeSet<String>();
try {
for (int i = 0; i < responseCount; i++) {
Document doc = searcher.doc(iterator.nextDoc(), SOLR_ID_FIELDS);
idsr.add(doc.get(CollectionSchema.id.getSolrFieldName()));
}
} catch (IOException e) {
} finally {
docListSearcher.close();
}
return idsr;
}
@Override
public String getFieldById(final String id, final String field) throws IOException {
DocListSearcher docListSearcher = new DocListSearcher("{!raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id, 0, 1, CollectionSchema.id.getSolrFieldName());

Loading…
Cancel
Save