Example usage for org.apache.solr.common.util ContentStream getSourceInfo

List of usage examples for org.apache.solr.common.util ContentStream getSourceInfo

Introduction

In this page you can find the example usage for org.apache.solr.common.util ContentStream getSourceInfo.

Prototype

String getSourceInfo();

Source Link

Usage

From source file:org.vootoo.client.netty.util.ProtobufUtil.java

License:Apache License

public static List<SolrProtocol.ContentStream> toProtobufContentStreams(
        Collection<ContentStream> contentStreams) {
    return Lists.transform(Lists.newArrayList(contentStreams),
            new Function<ContentStream, SolrProtocol.ContentStream>() {
                @Override/*w  w  w. jav a 2  s  . c om*/
                public SolrProtocol.ContentStream apply(ContentStream input) {
                    SolrProtocol.ContentStream.Builder stream = SolrProtocol.ContentStream.newBuilder();

                    if (input.getName() != null) {
                        stream.setName(input.getName());
                    }
                    String contentType = input.getContentType();
                    if (contentType == null) {
                        // default javabin
                        contentType = BinaryResponseParser.BINARY_CONTENT_TYPE;
                    }
                    stream.setContentType(contentType);
                    stream.setSourceInfo(input.getSourceInfo());
                    stream.setSize(input.getSize());
                    try {
                        //TODO zero copy byte
                        stream.setStream(ByteString.readFrom(input.getStream()));
                    } catch (IOException e) {
                        //TODO dealing input.getStream() exception
                        throw new RuntimeException("ContentStream.getStream() exception", e);
                    }

                    return stream.build();
                }
            });
}