当前位置: 首页>>代码示例>>Java>>正文


Java NamedList.indexOf方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:13,代码来源:JsonReferencePayloadHandler.java

示例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);
    }
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:16,代码来源:JsonReferencePayloadHandler.java

示例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);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:14,代码来源:JsonReferencePayloadHandler.java

示例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);
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:15,代码来源:JsonReferencePayloadHandler.java

示例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;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:12,代码来源:ProofOfConceptPayloadHandler.java

示例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;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:55,代码来源:JsonReferencePayloadHandler.java


注:本文中的org.apache.solr.common.util.NamedList.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。