avoid cloning

This commit is contained in:
Michael Peter Christen 2013-11-03 18:31:50 +01:00
parent cc39667399
commit 5a02d650ee
6 changed files with 8 additions and 10 deletions

View File

@ -21,7 +21,6 @@
package net.yacy.cora.federate.solr.connector;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -235,7 +234,7 @@ public abstract class AbstractSolrConnector implements SolrConnector {
* @return a collection of a subset of the ids which exist in the index
* @throws IOException
*/
public Set<String> existsByIds(Collection<String> ids) throws IOException {
public Set<String> existsByIds(Set<String> ids) throws IOException {
if (ids == null || ids.size() == 0) return new HashSet<String>();
// construct raw query
final SolrQuery params = new SolrQuery();

View File

@ -326,10 +326,10 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
}
@Override
public Set<String> existsByIds(Collection<String> ids) throws IOException {
public Set<String> existsByIds(Set<String> ids) throws IOException {
HashSet<String> e = new HashSet<String>();
if (ids == null || ids.size() == 0) return e;
Collection<String> idsC = new HashSet<String>();
Set<String> idsC = new HashSet<String>();
for (String id: ids) {
if (this.idCache.has(ASCII.getBytes(id))) {cacheSuccessSign(); e.add(id); continue;}
if (existIdFromDeleteQueue(id)) {cacheSuccessSign(); continue;}

View File

@ -22,7 +22,6 @@
package net.yacy.cora.federate.solr.connector;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
@ -224,9 +223,9 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
}
@Override
public Set<String> existsByIds(Collection<String> ids) {
public Set<String> existsByIds(Set<String> ids) {
if (ids == null || ids.size() == 0) return new HashSet<String>();
if (ids.size() == 1 && ids instanceof Set) return existsById(ids.iterator().next()) ? (Set<String>) ids : 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 ");

View File

@ -347,7 +347,7 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
}
@Override
public Set<String> existsByIds(Collection<String> ids) throws IOException {
public Set<String> existsByIds(Set<String> ids) throws IOException {
if (this.solr0 != null && this.solr1 == null) return this.solr0.existsByIds(ids);
if (this.solr0 == null && this.solr1 != null) return this.solr1.existsByIds(ids);
Set<String> s = new HashSet<String>();

View File

@ -106,7 +106,7 @@ public interface SolrConnector extends Iterable<String> /* Iterable of document
* @return a collection of a subset of the ids which exist in the index
* @throws IOException
*/
public Set<String> existsByIds(Collection<String> ids) throws IOException;
public Set<String> existsByIds(Set<String> ids) throws IOException;
/**
* check if a given document exists in solr

View File

@ -620,7 +620,7 @@ public final class Fulltext {
public Set<String> exists(Collection<String> ids) {
HashSet<String> e = new HashSet<String>();
if (ids == null || ids.size() == 0) return e;
Collection<String> idsC = new HashSet<String>();
Set<String> idsC = new HashSet<String>();
idsC.addAll(ids);
if (this.urlIndexFile != null) {
Iterator<String> idsi = idsC.iterator();