SOLR-7622: changed return type from array to Set

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1687307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2015-06-24 15:28:23 +00:00
parent 33a4099b98
commit 6416f8bad3
3 changed files with 14 additions and 10 deletions

View File

@ -63,15 +63,15 @@ public abstract class DocTransformer {
public abstract void transform(SolrDocument doc, int docid) throws IOException;
/**
* When a transformer needs access to fields that are not automaticaly derived from the
* When a transformer needs access to fields that are not automatically derived from the
* input fields names, this option lets us explicitly say the field names that we hope
* will be in the SolrDocument. These fields will be requestd from the
* will be in the SolrDocument. These fields will be requested from the
* {@link SolrIndexSearcher} but may or may not be returned in the final
* {@link QueryResponseWriter}
*
* @return a list of extra lucene fields
* @return a set of extra lucene fields
*/
public String[] getExtraRequestFields() {
public Set<String> getExtraRequestFields() {
return null;
}

View File

@ -265,7 +265,7 @@ public class SolrReturnFields extends ReturnFields {
DocTransformer t = factory.create(disp, augmenterParams, req);
if(t!=null) {
if(!_wantsAllFields) {
String[] extra = t.getExtraRequestFields();
Set<String> extra = t.getExtraRequestFields();
if(extra!=null) {
for(String f : extra) {
fields.add(f); // also request this field from IndexSearcher

View File

@ -18,7 +18,11 @@ package org.apache.solr.response;
*/
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
@ -75,10 +79,10 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
public static class CustomTransformerFactory extends TransformerFactory {
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
String[] extra = null;
Set<String> extra = null;
String ext = params.get("extra");
if(ext!=null) {
extra = Strings.split(ext, ',');
extra = new HashSet<>(Arrays.asList(Strings.split(ext,',')));
}
return new CustomTransformer(field, extra);
}
@ -86,10 +90,10 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
public static class CustomTransformer extends DocTransformer {
final String name;
final String[] extra;
final Set<String> extra;
final StringBuilder str = new StringBuilder();
public CustomTransformer(String name, String[] extra) {
public CustomTransformer(String name, Set<String> extra) {
this.name = name;
this.extra = extra;
}
@ -100,7 +104,7 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
}
@Override
public String[] getExtraRequestFields() {
public Set<String> getExtraRequestFields() {
return extra;
}