當前位置: 首頁>>代碼示例>>Java>>正文


Java NamedList.size方法代碼示例

本文整理匯總了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;
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:22,代碼來源:SolrParams.java

示例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;
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:18,代碼來源:MCRSolrProxyServlet.java

示例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();
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:24,代碼來源:ReSearcherUtils.java

示例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;
        }
    }
}
 
開發者ID:redlink-gmbh,項目名稱:solrj-text-tagger,代碼行數:20,代碼來源:TagResponse.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:29,代碼來源:SOLRAdminClient.java

示例6: toMap

import org.apache.solr.common.util.NamedList; //導入方法依賴的package包/類
/** Create a Map&lt;String,String&gt; 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;
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:9,代碼來源:SolrParams.java

示例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;
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:15,代碼來源:DymReSearcher.java

示例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;
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:14,代碼來源:DymReSearcher.java

示例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();
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:45,代碼來源:ReSearcherUtils.java

示例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);
    }
  }
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:14,代碼來源:CaseInsensitiveSortingTextField.java

示例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;
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:13,代碼來源:BidirectionalFacetResponseBuilder.java

示例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);
  }
}
 
開發者ID:sematext,項目名稱:query-segmenter,代碼行數:12,代碼來源:QuerySegmenterConfig.java

示例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;
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:80,代碼來源:JsonReferencePayloadHandler.java


注:本文中的org.apache.solr.common.util.NamedList.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。