本文整理汇总了Java中org.apache.solr.common.util.NamedList.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java NamedList.indexOf方法的具体用法?Java NamedList.indexOf怎么用?Java NamedList.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.NamedList
的用法示例。
在下文中一共展示了NamedList.indexOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
}
示例3: 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);
}
}
示例4: mergeCount
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Updates the Long value for the specified key in the 'preExisting' NamedList
* by adding the value from the 'add' NamedList.
*/
private static void mergeCount(NamedList<Object> from, NamedList<Object> to, String key) {
// merge count
long existingCount = 0;
int indexOfCount = to.indexOf(key, 0);
if(indexOfCount != -1) {
existingCount = ((Number) to.get(key)).longValue();
}
long newCount = existingCount + ((Number) from.get(key)).longValue();
overwriteInNamedList(to, key, newCount);
}
示例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: 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;
}