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


Java AddUpdateCommand.getPrintableId方法代码示例

本文整理汇总了Java中org.apache.solr.update.AddUpdateCommand.getPrintableId方法的典型用法代码示例。如果您正苦于以下问题:Java AddUpdateCommand.getPrintableId方法的具体用法?Java AddUpdateCommand.getPrintableId怎么用?Java AddUpdateCommand.getPrintableId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.update.AddUpdateCommand的用法示例。


在下文中一共展示了AddUpdateCommand.getPrintableId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }

  // call delegate first so we can log things like the version that get set later
  if (next != null) next.processAdd(cmd);

  // Add a list of added id's to the response
  if (adds == null) {
    adds = new ArrayList<>();
    toLog.add("add",adds);
  }

  if (adds.size() < maxNumToLog) {
    long version = cmd.getVersion();
    String msg = cmd.getPrintableId();
    if (version != 0) msg = msg + " (" + version + ')';
    adds.add(msg);
  }

  numAdds++;
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:LogUpdateProcessorFactory.java

示例2: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }

  // call delegate first so we can log things like the version that get set later
  if (next != null) next.processAdd(cmd);

  // Add a list of added id's to the response
  if (adds == null) {
    adds = new ArrayList<String>();
    toLog.add("add",adds);
  }

  if (adds.size() < maxNumToLog) {
    long version = cmd.getVersion();
    String msg = cmd.getPrintableId();
    if (version != 0) msg = msg + " (" + version + ')';
    adds.add(msg);
  }

  numAdds++;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:23,代码来源:LogUpdateProcessorFactory.java

示例3: getUpdatedDocument

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
boolean getUpdatedDocument(AddUpdateCommand cmd, long versionOnUpdate) throws IOException {
  if (!isAtomicUpdate(cmd)) return false;

  SolrInputDocument sdoc = cmd.getSolrInputDocument();
  BytesRef id = cmd.getIndexedId();
  SolrInputDocument oldDoc = RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id);

  if (oldDoc == null) {
    // create a new doc by default if an old one wasn't found
    if (versionOnUpdate <= 0) {
      oldDoc = new SolrInputDocument();
    } else {
      // could just let the optimistic locking throw the error
      throw new SolrException(ErrorCode.CONFLICT, "Document not found for update.  id=" + cmd.getPrintableId());
    }
  } else {
    oldDoc.remove(VERSION_FIELD);
  }

  IndexSchema schema = cmd.getReq().getSchema();
  for (SolrInputField sif : sdoc.values()) {
   Object val = sif.getValue();
    if (val instanceof Map) {
      for (Entry<String,Object> entry : ((Map<String,Object>) val).entrySet()) {
        String key = entry.getKey();
        Object fieldVal = entry.getValue();
        boolean updateField = false;
        switch (key) {
          case "add":
            updateField = true;
            oldDoc.addField(sif.getName(), fieldVal, sif.getBoost());
            break;
          case "set":
            updateField = true;
            oldDoc.setField(sif.getName(), fieldVal, sif.getBoost());
            break;
          case "remove":
            updateField = true;
            doRemove(oldDoc, sif, fieldVal);
            break;
          case "inc":
            updateField = true;
            doInc(oldDoc, schema, sif, fieldVal);
            break;
          default:
            //Perhaps throw an error here instead?
            log.warn("Unknown operation for the an atomic update, operation ignored: " + key);
            break;
        }
        // validate that the field being modified is not the id field.
        if (updateField && idField.getName().equals(sif.getName())) {
          throw new SolrException(ErrorCode.BAD_REQUEST, "Invalid update of id field: " + sif);
        }

      }
    } else {
      // normal fields are treated as a "set"
      oldDoc.put(sif.getName(), sif);
    }

  }

  cmd.solrDoc = oldDoc;
  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:66,代码来源:DistributedUpdateProcessor.java

示例4: getUpdatedDocument

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
boolean getUpdatedDocument(AddUpdateCommand cmd, long versionOnUpdate) throws IOException {
  if (!isAtomicUpdate(cmd)) return false;

  SolrInputDocument sdoc = cmd.getSolrInputDocument();
  BytesRef id = cmd.getIndexedId();
  SolrInputDocument oldDoc = RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id);

  if (oldDoc == null) {
    // create a new doc by default if an old one wasn't found
    if (versionOnUpdate <= 0) {
      oldDoc = new SolrInputDocument();
    } else {
      // could just let the optimistic locking throw the error
      throw new SolrException(ErrorCode.CONFLICT, "Document not found for update.  id=" + cmd.getPrintableId());
    }
  } else {
    oldDoc.remove(VERSION_FIELD);
  }

  for (SolrInputField sif : sdoc.values()) {
    Object val = sif.getValue();
    if (val instanceof Map) {
      for (Entry<String,Object> entry : ((Map<String,Object>) val).entrySet()) {
        String key = entry.getKey();
        Object fieldVal = entry.getValue();
        boolean updateField = false;
        if ("add".equals(key)) {
          updateField = true;
          oldDoc.addField( sif.getName(), fieldVal, sif.getBoost());
        } else if ("set".equals(key)) {
          updateField = true;
          oldDoc.setField(sif.getName(),  fieldVal, sif.getBoost());
        } else if ("inc".equals(key)) {
          updateField = true;
          SolrInputField numericField = oldDoc.get(sif.getName());
          if (numericField == null) {
            oldDoc.setField(sif.getName(),  fieldVal, sif.getBoost());
          } else {
            // TODO: fieldtype needs externalToObject?
            String oldValS = numericField.getFirstValue().toString();
            SchemaField sf = cmd.getReq().getSchema().getField(sif.getName());
            BytesRef term = new BytesRef();
            sf.getType().readableToIndexed(oldValS, term);
            Object oldVal = sf.getType().toObject(sf, term);

            String fieldValS = fieldVal.toString();
            Number result;
            if (oldVal instanceof Long) {
              result = ((Long) oldVal).longValue() + Long.parseLong(fieldValS);
            } else if (oldVal instanceof Float) {
              result = ((Float) oldVal).floatValue() + Float.parseFloat(fieldValS);
            } else if (oldVal instanceof Double) {
              result = ((Double) oldVal).doubleValue() + Double.parseDouble(fieldValS);
            } else {
              // int, short, byte
              result = ((Integer) oldVal).intValue() + Integer.parseInt(fieldValS);
            }

            oldDoc.setField(sif.getName(),  result, sif.getBoost());
          }

        }

        // validate that the field being modified is not the id field.
        if (updateField && idField.getName().equals(sif.getName())) {
          throw new SolrException(ErrorCode.BAD_REQUEST, "Invalid update of id field: " + sif);
        }

      }
    } else {
      // normal fields are treated as a "set"
      oldDoc.put(sif.getName(), sif);
    }

  }

  cmd.solrDoc = oldDoc;
  return true;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:80,代码来源:DistributedUpdateProcessor.java

示例5: getUpdatedDocument

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
boolean getUpdatedDocument(AddUpdateCommand cmd, long versionOnUpdate) throws IOException {
  if (!isAtomicUpdate(cmd)) return false;

  SolrInputDocument sdoc = cmd.getSolrInputDocument();
  BytesRef id = cmd.getIndexedId();
  SolrInputDocument oldDoc = RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id);

  if (oldDoc == null) {
    // create a new doc by default if an old one wasn't found
    if (versionOnUpdate <= 0) {
      oldDoc = new SolrInputDocument();
    } else {
      // could just let the optimistic locking throw the error
      throw new SolrException(ErrorCode.CONFLICT, "Document not found for update.  id=" + cmd.getPrintableId());
    }
  } else {
    oldDoc.remove(VERSION_FIELD);
  }

  IndexSchema schema = cmd.getReq().getSchema();
  for (SolrInputField sif : sdoc.values()) {
    Object val = sif.getValue();
    if (val instanceof Map) {
      for (Entry<String,Object> entry : ((Map<String,Object>) val).entrySet()) {
        String key = entry.getKey();
        Object fieldVal = entry.getValue();
        boolean updateField = false;
        if ("add".equals(key)) {
          updateField = true;
          oldDoc.addField( sif.getName(), fieldVal, sif.getBoost());
        } else if ("set".equals(key)) {
          updateField = true;
          oldDoc.setField(sif.getName(),  fieldVal, sif.getBoost());
        } else if ("inc".equals(key)) {
          updateField = true;
          SolrInputField numericField = oldDoc.get(sif.getName());
          if (numericField == null) {
            oldDoc.setField(sif.getName(),  fieldVal, sif.getBoost());
          } else {
            // TODO: fieldtype needs externalToObject?
            String oldValS = numericField.getFirstValue().toString();
            SchemaField sf = schema.getField(sif.getName());
            BytesRef term = new BytesRef();
            sf.getType().readableToIndexed(oldValS, term);
            Object oldVal = sf.getType().toObject(sf, term);

            String fieldValS = fieldVal.toString();
            Number result;
            if (oldVal instanceof Long) {
              result = ((Long) oldVal).longValue() + Long.parseLong(fieldValS);
            } else if (oldVal instanceof Float) {
              result = ((Float) oldVal).floatValue() + Float.parseFloat(fieldValS);
            } else if (oldVal instanceof Double) {
              result = ((Double) oldVal).doubleValue() + Double.parseDouble(fieldValS);
            } else {
              // int, short, byte
              result = ((Integer) oldVal).intValue() + Integer.parseInt(fieldValS);
            }

            oldDoc.setField(sif.getName(),  result, sif.getBoost());
          }

        }

        // validate that the field being modified is not the id field.
        if (updateField && idField.getName().equals(sif.getName())) {
          throw new SolrException(ErrorCode.BAD_REQUEST, "Invalid update of id field: " + sif);
        }

      }
    } else {
      // normal fields are treated as a "set"
      oldDoc.put(sif.getName(), sif);
    }

  }

  cmd.solrDoc = oldDoc;
  return true;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:81,代码来源:DistributedUpdateProcessor.java


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