本文整理汇总了Java中org.apache.solr.common.util.NamedList.setVal方法的典型用法代码示例。如果您正苦于以下问题:Java NamedList.setVal方法的具体用法?Java NamedList.setVal怎么用?Java NamedList.setVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.NamedList
的用法示例。
在下文中一共展示了NamedList.setVal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: overwriteInNamedList
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* overwrite entry in NamedList with new value
* (update existing key, or add the key/value if key doesn't already exist)
*/
private static void overwriteInNamedList(NamedList<Object> namedList, String key, Object value) {
int indexOfKey = namedList.indexOf(key, 0);
if(indexOfKey != -1) {
namedList.setVal(indexOfKey, value);
} else {
namedList.add(key, value);
}
}
示例3: copyFieldInNamedList
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Copies a field value from one NamedList into another
*/
private static void copyFieldInNamedList(NamedList<Object> from, NamedList<Object> to, String key) {
int index = from.indexOf(key, 0);
if(index != -1) {
Object value = from.get(key);
int index2 = to.indexOf(key, 0);
if(index2 != -1) {
to.setVal(index2, value);
} else {
to.add(key, value);
}
}
}
示例4: incrementLongInNamedList
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* increment a Long value in a NamedList stored under "key", creating it with value of 1
* if it doesn't exist.
*/
private static void incrementLongInNamedList(NamedList<Object> namedList, String key) {
int index = namedList.indexOf(key, 0);
if(index != -1) {
long oldCount = ((Number) namedList.getVal(index)).longValue();
namedList.setVal(index, oldCount + 1L);
} else {
namedList.add(key, 1L);
}
}
示例5: 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.remove("count")).longValue()) {
throw new IllegalStateException("fieldType-internal and -external counts do not match");
}
int countIndex = preExisting.indexOf("count", 0);
long preCount = ((Number)preExisting.getVal(countIndex)).longValue();
preExisting.setVal(countIndex, preCount + addCount);
preExisting.addAll(add);
return preExisting;
}
示例6: 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;
}
示例7: 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;
}