• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BinaryResponseWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.solr.response.BinaryResponseWriter的典型用法代码示例。如果您正苦于以下问题:Java BinaryResponseWriter类的具体用法?Java BinaryResponseWriter怎么用?Java BinaryResponseWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: handleRequestBody

import org.apache.solr.response.BinaryResponseWriter; //导入依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
  NamedList<NamedList<NamedList<Object>>> cats = getMBeanInfo(req);
  if(req.getParams().getBool("diff", false)) {
    ContentStream body = null;
    try {
      body = req.getContentStreams().iterator().next();
    }
    catch(Exception ex) {
      throw new SolrException(ErrorCode.BAD_REQUEST, "missing content-stream for diff");
    }
    String content = IOUtils.toString(body.getReader());
    
    NamedList<NamedList<NamedList<Object>>> ref = fromXML(content);
    
    
    // Normalize the output 
    SolrQueryResponse wrap = new SolrQueryResponse();
    wrap.add("solr-mbeans", cats);
    cats = (NamedList<NamedList<NamedList<Object>>>)
        BinaryResponseWriter.getParsedResponse(req, wrap).get("solr-mbeans");
    
    // Get rid of irrelevant things
    ref = normalize(ref);
    cats = normalize(cats);
    
    // Only the changes
    boolean showAll = req.getParams().getBool("all", false);
    rsp.add("solr-mbeans", getDiff(ref,cats, showAll));
  }
  else {
    rsp.add("solr-mbeans", cats);
  }
  rsp.setHttpCaching(false); // never cache, no matter what init config looks like
}
 
开发者ID:europeana,项目名称:search,代码行数:36,代码来源:SolrInfoMBeanHandler.java


示例2: testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin

import org.apache.solr.response.BinaryResponseWriter; //导入依赖的package包/类
@Test
public void testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin() throws Exception {
  assertU(add(doc("id", "1", "nullfirst", "1")));
  assertU(add(doc("id", "2", "nullfirst", "1")));
  assertU(add(doc("id", "3", "nullfirst", "2")));
  assertU(add(doc("id", "4", "nullfirst", "2")));
  assertU(add(doc("id", "5", "nullfirst", "2")));
  assertU(add(doc("id", "6", "nullfirst", "3")));
  assertU(commit());

  SolrQueryRequest request =
      req("q", "*:*","group", "true", "group.field", "nullfirst", "group.main", "true", "wt", "javabin", "start", "4", "rows", "10");

  SolrQueryResponse response = new SolrQueryResponse();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try {
    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(request, response));
    String handlerName = request.getParams().get(CommonParams.QT);
    h.getCore().execute(h.getCore().getRequestHandler(handlerName), request, response);
    BinaryResponseWriter responseWriter = new BinaryResponseWriter();
    responseWriter.write(out, request, response);
  } finally {
    request.close();
    SolrRequestInfo.clearRequestInfo();
  }

  assertEquals(6, ((ResultContext) response.getValues().get("response")).docs.matches());
  new BinaryResponseParser().processResponse(new ByteArrayInputStream(out.toByteArray()), "");
  out.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestGroupingSearch.java


示例3: getParsedResponse

import org.apache.solr.response.BinaryResponseWriter; //导入依赖的package包/类
/**
 * Parse the solr response to named list (need to create solrj query
 * respond).
 * 
 * @param req
 *            The request.
 * @param rsp
 *            The response.
 * @return The named list.
 */
public NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
	try {
		BinaryResponseWriter writer = new BinaryResponseWriter();
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		writer.write(bos, req, rsp);
		BinaryResponseParser parser = new BinaryResponseParser();
		return parser.processResponse(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:22,代码来源:SolrServletEmulator.java


示例4: processAdd

import org.apache.solr.response.BinaryResponseWriter; //导入依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument updateDoc = cmd.getSolrInputDocument();
    String id = (String) updateDoc.getField(ID_FIELD).getValue();
    String query = "+" + ID_FIELD + ":" + escape(id);
    final SolrIndexSearcher searcher = cmd.getReq().getSearcher();
    LocalSolrQueryRequest newReq = new LocalSolrQueryRequest(cmd.getReq().getCore(), query, "", 0, 1, REQ_ARGS) {
            @Override
            public SolrIndexSearcher getSearcher() { return searcher; }
            @Override
            public void close() { }
        };
    SolrQueryResponse rsp = new SolrQueryResponse();
    cmd.getReq().getCore().execute(cmd.getReq().getCore().getRequestHandler(REQUEST_HANDLER), newReq, rsp);
    QueryResponse qRsp = new QueryResponse();
    qRsp.setResponse(BinaryResponseWriter.getParsedResponse(newReq, rsp));
    if (qRsp.getResults().size() > 0) {
        SolrDocument existingDoc = qRsp.getResults().get(0);
        String existingContent = (String) existingDoc.getFieldValue(CONTENT_FIELD);
        Collection existingArcnames = existingDoc.getFieldValues(ARCNAME_FIELD);

        if (existingArcnames.contains((String)updateDoc.getFieldValue(ARCNAME_FIELD))) {
            /* abort if already indexed */
            return;
        } else {
            List<String> removedFields = new ArrayList<String>();
            /* fields that should be the same */
            for (String fieldName : updateDoc.getFieldNames()) {
                if (!fieldName.equals(DATE_FIELD) &&
                    !fieldName.equals(JOB_FIELD) &&
                    !fieldName.equals(ARCNAME_FIELD) &&
                    !fieldName.equals(ID_FIELD) &&
                    !fieldName.equals(CONTENT_FIELD)) {
                    removedFields.add(fieldName);
                }
            }

            for (String removedField : removedFields) {
                updateDoc.removeField(removedField);
            }

            for (String f : UPDATE_FIELD_ARR) {
                final String val = (String) updateDoc.getFieldValue(f);
                updateDoc.setField(f, new HashMap(){{ put("add", val); }});
            }

            /* in case we had empty content before */
            if (existingContent == null || existingContent == "") {
                final String updateDocContent = (String) updateDoc.getFieldValue(CONTENT_FIELD);
                updateDoc.setField(CONTENT_FIELD, new HashMap(){{ put("set", updateDocContent); }});
            } else {
                /* otherwise just keep the old content */
                updateDoc.removeField(CONTENT_FIELD);
            }
        }
    }
    super.processAdd(cmd);
}
 
开发者ID:cdlib,项目名称:weari,代码行数:59,代码来源:DedupeUpdateProcessor.java


示例5: getParsedResponse

import org.apache.solr.response.BinaryResponseWriter; //导入依赖的package包/类
/**
 * Returns a response object equivalent to what you get from the XML/JSON/javabin parser. Documents
 * become SolrDocuments, DocList becomes SolrDocumentList etc.
 * 
 * @deprecated use {@link BinaryResponseWriter#getParsedResponse(SolrQueryRequest, SolrQueryResponse)}
 */
@Deprecated
public NamedList<Object> getParsedResponse( SolrQueryRequest req, SolrQueryResponse rsp )
{
  return BinaryResponseWriter.getParsedResponse(req, rsp);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:EmbeddedSolrServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IncorrectUpdateSemanticsDataAccessException类代码示例发布时间:2022-05-23
下一篇:
Java CatmullRomSpline类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap