You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Bojan Vukojevic <em...@gmail.com> on 2010/10/22 20:56:34 UTC

Re: SolrJ addField with Reader

Is there an example of how to use ContentStreamBase.FileStream from SolrJ
during indexing to reduce memory footprint? Using "addField" is requiring a
string. The only example I could find in JUnits is below and does not show
indexing...

thx!

*public* *void* testFileStream() *throws* IOException {
46:                *File*
<http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/io-nio/java/io/File.java.htm>
file = *new* *File*
<http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/io-nio/java/io/File.java.htm>("README");
47:                assertTrue(file.exists()); // "make sure you are
running from: solr\src\test\test-files"
48:
49:                *ContentStreamBase*
<http://www.java2s.com/Open-Source/Java-Document/Search-Engine/apache-solr-1.2.0/org/apache/solr/util/ContentStreamBase.java.htm>
stream = *new* *ContentStreamBase.FileStream*
<http://www.java2s.com/Open-Source/Java-Document/Search-Engine/apache-solr-1.2.0/org/apache/solr/util/ContentStreamBase.java.htm>(
50:                        file);
51:                assertEquals(file.length(), stream.getSize().intValue());
52:                assertTrue(IOUtils.contentEquals(*new*
*FileInputStream*
<http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/io-nio/java/io/FileInputStream.java.htm>(file),
53:                        stream.getStream()));
54:                assertTrue(IOUtils.contentEquals(*new* *FileReader*
<http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/io-nio/java/io/FileReader.java.htm>(file),
stream
55:                        .getReader()));
56:            }