本文整理汇总了Java中org.apache.solr.common.util.NamedList.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java NamedList.iterator方法的具体用法?Java NamedList.iterator怎么用?Java NamedList.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.NamedList
的用法示例。
在下文中一共展示了NamedList.iterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: mergePayload
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public NamedList<Object> mergePayload(NamedList<Object> preExisting, NamedList<Object> add, long preExistingCount, long addCount) {
if (addCount != ((Number)add.get(KEY_COUNT)).longValue()) {
throw new IllegalStateException("fieldType-internal and -external counts do not match");
}
int countIndex = preExisting.indexOf(KEY_COUNT, 0);
long preCount = ((Number)preExisting.getVal(countIndex)).longValue();
preExisting.setVal(countIndex, preCount + addCount);
if(add.get(KEY_SELF) != null) {
NamedList<Object> addSelf = (NamedList<Object>) add.get(KEY_SELF);
NamedList<Object> preExistingSelf = getOrCreateNamedListValue(preExisting, KEY_SELF);
mergeCount(addSelf, preExistingSelf, KEY_COUNT);
copyFieldInNamedList(addSelf, preExistingSelf, KEY_FILING);
copyFieldInNamedList(addSelf, preExistingSelf, KEY_PREFIX);
}
if(add.get(KEY_REFS) != null) {
NamedList<Object> addRefs = (NamedList<Object>) add.get(KEY_REFS);
Iterator<Map.Entry<String, Object>> refTypesIter = addRefs.iterator();
while (refTypesIter.hasNext()) {
Map.Entry<String, Object> entry = refTypesIter.next();
String addReferenceType = entry.getKey();
NamedList<Object> addNameStructs = (NamedList<Object>) entry.getValue();
// if "refs" doesn't exist in preExisting yet, create it
NamedList<Object> preExistingRefs = getOrCreateNamedListValue(preExisting, KEY_REFS);
// if referenceType doesn't exist in preExisting yet, create it
NamedList<Object> preExistingNameStructs = getOrCreateNamedListValue(preExistingRefs, addReferenceType);
// loop through names and merge them into preExisting
Iterator<Map.Entry<String, Object>> addNameStructsIter = addNameStructs.iterator();
while (addNameStructsIter.hasNext()) {
Map.Entry<String, Object> nameStructEntry = addNameStructsIter.next();
String name = nameStructEntry.getKey();
NamedList<Object> addNameStruct = (NamedList<Object>) nameStructEntry.getValue();
// if name doesn't exist in preExisting yet, create it
NamedList<Object> preExistingNameStruct = getOrCreateNamedListValue(preExistingNameStructs, name);
mergeCount(addNameStruct, preExistingNameStruct, KEY_COUNT);
copyFieldInNamedList(addNameStruct, preExistingNameStruct, KEY_FILING);
copyFieldInNamedList(addNameStruct, preExistingNameStruct, KEY_PREFIX);
}
}
}
return preExisting;
}