本文整理汇总了Java中org.apache.solr.common.util.NamedList.size方法的典型用法代码示例。如果您正苦于以下问题:Java NamedList.size方法的具体用法?Java NamedList.size怎么用?Java NamedList.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.NamedList
的用法示例。
在下文中一共展示了NamedList.size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMultiMap
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/** Create a Map<String,String[]> from a NamedList */
public static Map<String,String[]> toMultiMap(NamedList params) {
HashMap<String,String[]> map = new HashMap<>();
for (int i=0; i<params.size(); i++) {
String name = params.getName(i);
Object val = params.getVal(i);
if (val instanceof String[]) {
MultiMapSolrParams.addParam(name, (String[]) val, map);
} else if (val instanceof List) {
List l = (List) val;
String[] s = new String[l.size()];
for (int j = 0; j < l.size(); j++) {
s[j] = l.get(j) == null ? null : String.valueOf(l.get(j));
}
MultiMapSolrParams.addParam(name, s, map);
} else {
MultiMapSolrParams.addParam(name, val.toString(), map);
}
}
return map;
}
示例2: toMultiMap
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
static Map<String, String[]> toMultiMap(ModifiableSolrParams solrQueryParameter) {
NamedList<Object> namedList = solrQueryParameter.toNamedList();
//disabled for MCR-953 and https://issues.apache.org/jira/browse/SOLR-7508
//Map<String, String[]> parameters = ModifiableSolrParams.toMultiMap(namedList);
HashMap<String, String[]> parameters = new HashMap<>();
for (int i = 0; i < namedList.size(); i++) {
String name = namedList.getName(i);
Object val = namedList.getVal(i);
if (val instanceof String[]) {
MultiMapSolrParams.addParam(name, (String[]) val, parameters);
} else {
MultiMapSolrParams.addParam(name, val.toString(), parameters);
}
}
//end of fix
return parameters;
}
示例3: iterateOverSpellcheckerSuggestionsForAllIncorrectWords
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Contains logic for iterating over spellchecker's suggestions. If any of input parameters is null, just exits. This method
* iterates over suggestions for ALL incorrectly spelled words. It will not sub-iterate over suggestions of each incorrect
* word, that is the logic which SpellcheckerSuggestionProcessor should take care off.
*
* @param suggestions list of all suggestions, can be extracted with method .extractSpellcheckerSuggestions().
* @param processor instance of processor which will handle all suggestions for word
*/
@SuppressWarnings("unchecked")
public static void iterateOverSpellcheckerSuggestionsForAllIncorrectWords(NamedList suggestions, SpellcheckerSuggestionProcessor processor) {
if (suggestions == null || processor == null) {
return;
}
for (int i = 0; i < suggestions.size(); i++) {
// find first acceptable suggestion
if (suggestions.getVal(i) instanceof SimpleOrderedMap) {
processor.process((SimpleOrderedMap) suggestions.getVal(i), suggestions.getName(i));
}
}
processor.afterProcessingFinished();
}
示例4: Tag
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
Tag(NamedList<Object> res){
for( int i=0; i<res.size(); i++ ) {
String n = res.getName( i );
switch (n) {
case "startOffset":
_start = (Integer)res.getVal(i);
break;
case "endOffset":
_end = (Integer)res.getVal(i);
break;
case "ids":
_ids = (List<Object>)res.getVal(i);
break;
default:
break;
}
}
}
示例5: pingSolr
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
protected void pingSolr()
{
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/admin/cores");
params.set("action", "STATUS");
QueryResponse response = basicQuery(params);
if(response != null && response.getStatus() == 0)
{
NamedList<Object> results = response.getResponse();
@SuppressWarnings("unchecked")
NamedList<Object> report = (NamedList<Object>)results.get("status");
Iterator<Map.Entry<String, Object>> coreIterator = report.iterator();
List<String> cores = new ArrayList<String>(report.size());
while(coreIterator.hasNext())
{
Map.Entry<String, Object> core = coreIterator.next();
cores.add(core.getKey());
}
registerCores(cores);
setSolrActive(true);
}
else
{
setSolrActive(false);
}
}
示例6: toMap
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/** Create a Map<String,String> from a NamedList given no keys are repeated */
public static Map<String,String> toMap(NamedList params) {
HashMap<String,String> map = new HashMap<>();
for (int i=0; i<params.size(); i++) {
map.put(params.getName(i), params.getVal(i).toString());
}
return map;
}
示例7: checkCustomSpellcheckingSuggestionPossible
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private boolean checkCustomSpellcheckingSuggestionPossible(ResponseBuilder rb, NamedList suggestions,
int spellcheckCount, long originalQueryHits) {
if (suggestions == null || suggestions.size() == 0) {
// if there are no spellchecking suggestions, we can't create spellchecking suggestions
return false;
}
if (originalQueryHits > getMaxOriginalResults()) {
return false;
}
return true;
}
示例8: checkSpellcheckedQueryNeeded
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private boolean checkSpellcheckedQueryNeeded(SolrQueryResponse rsp, NamedList suggestions, long originalQueryHits) {
if (suggestions == null || suggestions.size() == 0) {
// if there are no spellchecking suggestions, we can't run the spellchecked query
return false;
}
if (originalQueryHits > maxOriginalResultsToReturnResults) {
// if there are enough results already, no need to run the spellchecked query
return false;
}
return true;
}
示例9: iterateOverSpellcheckerSuggestionsForWord
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Contains logic for iterating over spellchecker's suggestions. If any of input parameters is null, just exits. This method
* iterates over suggestions for one incorrect word (for which parameter <code>suggestions</code> should contain spellchecker's suggestions).
*
*
* @param suggestions list of suggestions for some word, so word parameter isn't needed
* @param processor instance of processor which will handle all suggestions for word
*/
@SuppressWarnings("unchecked")
public static void iterateOverSpellcheckerSuggestionsForWord(NamedList suggestions, SpellcheckerSuggestionProcessor processor) {
int i = 4;
// double topFreq = 0;
if (suggestions.getVal(4) instanceof List) {
// support for new version of Solr (valid after 2009-09-09 in version 1.4)
List<SimpleOrderedMap> l = (List<SimpleOrderedMap>) suggestions.getVal(4);
i = 0;
while (true) {
if (l.size() <= i) {
break;
}
processor.process(l.get(i), (String) l.get(i).get("word"));
i++;
}
}
else {
// old way, before 2009-09-09
while (true) {
if (suggestions.size() <= i) {
break;
}
processor.process((NamedList) (suggestions).getVal(i), suggestions.getName(i));
i++;
}
}
processor.afterProcessingFinished();
}
示例10: updateExternalRepresentation
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public void updateExternalRepresentation(NamedList<Object> nl) {
for (int i = 0; i < nl.size(); i++) {
String rawName = nl.getName(i);
String externalName = readableToExternal(rawName);
nl.setName(i, externalName);
Object val = nl.getVal(i);
Object updatedVal;
if (!(val instanceof Number) && (updatedVal = updateValueExternalRepresentation(val)) != null) {
nl.setVal(i, updatedVal);
}
}
}
示例11: finalize
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public NamedList<Object> finalize(NamedList<Object> ret) {
ret = super.finalize(ret);
for (int i = 0; i < ret.size(); i++) {
NamedList<Object> termEntry = (NamedList<Object>)ret.getVal(i);
int docsIdx = termEntry.size() - 1;
Deque<Entry<String, SolrDocument>> docDeque = (Deque<Entry<String, SolrDocument>>)termEntry.getVal(docsIdx);
NamedList<SolrDocument> docsExternal = new NamedList(docDeque.toArray(new Entry[docDeque.size()]));
termEntry.setVal(docsIdx, docsExternal);
}
return ret;
}
示例12: QuerySegmenterConfig
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public QuerySegmenterConfig(NamedList args) {
segmenter = new QuerySegmenterDefaultImpl();
NamedList segments = (NamedList) args.get(INIT_ATTR_SEGMENTS);
for (int i = 0; i < segments.size(); i++) {
String name = segments.getName(i);
NamedList values = (NamedList) segments.getVal(i);
initSegmentType(name, values);
}
}
示例13: buildEntryValue
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
private NamedList<Object> buildEntryValue(MultiPartString term, long count, Term t, List<Entry<LeafReader, Bits>> leaves) throws IOException {
NamedList<Object> entry = new NamedList<>();
// document count for this term
entry.add(KEY_COUNT, count);
NamedList<Object> self = new NamedList<>();
entry.add(KEY_SELF, self);
self.add(KEY_COUNT, 0L);
overwriteInNamedList(self, KEY_FILING, term.getFiling());
if(term.getPrefix() != null) {
overwriteInNamedList(self, KEY_PREFIX, term.getPrefix());
}
NamedList<Object> refs = new NamedList<>();
Set<BytesRef> trackDuplicates = new HashSet<>();
for (Entry<LeafReader, Bits> e : leaves) {
PostingsEnum postings = e.getKey().postings(t, PostingsEnum.PAYLOADS);
if (postings == null) {
continue;
}
Bits liveDocs = e.getValue();
while (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
if (liveDocs != null && !liveDocs.get(postings.docID())) {
continue;
}
trackDuplicates.clear();
for (int j = 0; j < postings.freq(); j++) {
postings.nextPosition();
BytesRef payload = postings.getPayload();
if (!trackDuplicates.add(payload)) {
continue;
}
if (payload != null) {
String payloadStr = payload.utf8ToString();
int pos = payloadStr.indexOf(JsonReferencePayloadTokenizer.PAYLOAD_ATTR_SEPARATOR);
if (pos != -1) {
String referenceType = payloadStr.substring(0, pos);
String target = payloadStr.substring(pos + 1);
MultiPartString multiPartString = MultiPartString.parseFilingAndPrefix(target);
String displayName = multiPartString.getDisplay();
NamedList<Object> displayNameStructs = getOrCreateNamedListValue(refs, referenceType);
NamedList<Object> nameStruct = getOrCreateNamedListValue(displayNameStructs, displayName);
incrementLongInNamedList(nameStruct, KEY_COUNT);
overwriteInNamedList(nameStruct, KEY_FILING, multiPartString.getFiling());
if (multiPartString.getPrefix() != null) {
overwriteInNamedList(nameStruct, KEY_PREFIX, multiPartString.getPrefix());
}
}
} else {
// no payload means term is for self, so increment count
incrementLongInNamedList(self, KEY_COUNT);
}
// Couldn't get this to work: postings.attributes() doesn't return anything: why?
/*
ReferenceAttribute refAtt = postings.attributes().getAttribute(ReferenceAttribute.class);
if(refAtt != null) {
System.out.println("found refAttr, " + refAtt.getReferenceType() + "," + refAtt.getTarget());
}
*/
}
}
}
if(refs.size() > 0) {
entry.add(KEY_REFS, refs);
}
return entry;
}