lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Winton Davies <wdav...@overture.com>
Subject Re: RAMdirectory from Directory ?
Date Thu, 15 Nov 2001 00:43:20 GMT
Hi again (sorry for the volume of question!)

I implemented this, with one change (the IndexWriter has to have TRUE 
set at the end, as ramdiris a new directory).

It loaded into memory, but then when I tried a search I got this stack trace:

java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at org.apache.lucene.store.RAMInputStream.readInternal(Unknown Source)
         at org.apache.lucene.store.InputStream.readBytes(Unknown Source)
         at org.apache.lucene.index.SegmentReader.norms(Unknown Source)
         at org.apache.lucene.index.SegmentReader.norms(Unknown Source)
         at org.apache.lucene.search.TermQuery.scorer(Unknown Source)
         at org.apache.lucene.search.Query.scorer(Unknown Source)
         at org.apache.lucene.search.IndexSearcher.search(Unknown Source)
         at org.apache.lucene.search.Hits.getMoreDocs(Unknown Source)
         at org.apache.lucene.search.Hits.<init>(Unknown Source)
         at org.apache.lucene.search.Searcher.search(Unknown Source)
         at org.apache.lucene.search.Searcher.search(Unknown Source)
         at 
com.go2.idxsearch.godzilla.MiniSearchListings.processOneQueryStringArr 
ay(MiniSearchListings.java:175)
         at 
com.go2.idxsearch.godzilla.FastGodzilla.callSearchResult(FastGodzilla. 
java:55)
         at 
com.go2.idxsearch.godzilla.FastGodzilla.setSortType(FastGodzilla.java: 
199)

Anyone have any ideas why it could fail ?

  Cheers,
    Winton


>Winton Davies wrote:
>>   I've an index that should fit in RAM -- but I need it stored as a
>> file. Is there anyway to read in the regular directory in the the
>> RAMDirectory and then create an IndexSearcher from this ? It seems
>> that there should be, but I can't find a method to construct a
>> RAMDirectory from a regular Directory ?
>
>Look at IndexWriter.addIndexes( Directory[] dirs )
>
>You can store your RAMDirectory into a new FSDirectory and load a
>FSDircetory into a new RAMDirectory.
>
>Something like:
>
>Directory loadIndex() {
>	Directory fs = FSDirectory.getDirectory( pathToIndex, false );
>	RAMDirectory ramdir = new RAMDircetory();
>	IndexWriter iw = new IndexWriter( ramdir, myAnalyzer, false );
>	iw.addIndexes( new Directory[]{fs} );
>	iw.close();
>	fs.close();
>	return ramdir;
>}
>void storeIndex( Directory ramdir ) {
>	Directory fs = FSDirectory.getDirectory( pathToIndex, true ); // create
>a new Index here
>	IndexWriter iw = new IndexWriter( fs, myAnalyzer, true );
>	iw.addIndexes( new Directory[]{ramdir} );
>	iw.close();
>	fs.close();
>}
>
>
>HTH,
>Gerhard
>
>--
>To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Winton Davies
Lead Engineer, Overture (NSDQ: OVER)
1820 Gateway Drive, Suite 360
San Mateo, CA 94404
work: (650) 403-2259
cell: (650) 867-1598
http://www.overture.com/

--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message