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


Java ContentStream.getStream方法代码示例

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


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

示例1: write

import org.apache.solr.common.util.ContentStream; //导入方法依赖的package包/类
@Override
public void write(OutputStream out, SolrQueryRequest request,
    SolrQueryResponse response) throws IOException {
    Object obj = response.getValues().get( CONTENT );
    if( obj != null && (obj instanceof ContentStream ) ) {
      // copy the contents to the writer...
      ContentStream content = (ContentStream)obj;
      java.io.InputStream in = content.getStream();
      try {
        IOUtils.copy( in, out );
      } finally {
        in.close();
      }
    }
    else {
      //getBaseWriter( request ).write( writer, request, response );
      throw new IOException("did not find a CONTENT object");
    }

  }
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:RawResponseWriter.java

示例2: load

import org.apache.solr.common.util.ContentStream; //导入方法依赖的package包/类
@Override
public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception {
  InputStream is = null;
  try {
    is = stream.getStream();
    parseAndLoadDocs(req, rsp, is, processor);
  } finally {
    if(is != null) {
      is.close();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:JavabinLoader.java

示例3: resolveAnalysisRequest

import org.apache.solr.common.util.ContentStream; //导入方法依赖的package包/类
/**
 * Resolves the {@link DocumentAnalysisRequest} from the given solr request.
 *
 * @param req The solr request.
 *
 * @return The resolved document analysis request.
 *
 * @throws IOException        Thrown when reading/parsing the content stream of the request fails.
 * @throws XMLStreamException Thrown when reading/parsing the content stream of the request fails.
 */
DocumentAnalysisRequest resolveAnalysisRequest(SolrQueryRequest req) throws IOException, XMLStreamException {

  DocumentAnalysisRequest request = new DocumentAnalysisRequest();

  SolrParams params = req.getParams();

  String query = params.get(AnalysisParams.QUERY, params.get(CommonParams.Q, null));
  request.setQuery(query);

  boolean showMatch = params.getBool(AnalysisParams.SHOW_MATCH, false);
  request.setShowMatch(showMatch);

  ContentStream stream = extractSingleContentStream(req);
  InputStream is = null;
  XMLStreamReader parser = null;
  
  try {
    is = stream.getStream();
    final String charset = ContentStreamBase.getCharsetFromContentType(stream.getContentType());
    parser = (charset == null) ?
      inputFactory.createXMLStreamReader(is) : inputFactory.createXMLStreamReader(is, charset);

    while (true) {
      int event = parser.next();
      switch (event) {
        case XMLStreamConstants.END_DOCUMENT: {
          parser.close();
          return request;
        }
        case XMLStreamConstants.START_ELEMENT: {
          String currTag = parser.getLocalName();
          if ("doc".equals(currTag)) {
            log.trace("Reading doc...");
            SolrInputDocument document = readDocument(parser, req.getSchema());
            request.addDocument(document);
          }
          break;
        }
      }
    }

  } finally {
    if (parser != null) parser.close();
    IOUtils.closeQuietly(is);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:57,代码来源:DocumentAnalysisRequestHandler.java


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