You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Pulkit Singhal <pu...@gmail.com> on 2010/09/18 01:33:58 UTC

How to close the wrapped directory implementation

With RAMDirectory we have the option of providing another Directory
implementation such as FSDirectory that can be wrapped and loaded into
memory:

Directory directory = new RAMDirectory(FSDirectory.open(new
File(fileDirectoryName)));

But after building the index, if I close the IndexWriter then the data
is still available for searches in the directory bean but nothing ever
gets written to the disk!

Is this a bug? Is there a workaround?

Or is this by design? Is the RAMDirectory constructor only meant to
read in data from the passed in argument? Or is it supposed to keep it
around and update it when closing?

Please write back, Thanks!
- Pulkit

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: How to close the wrapped directory implementation

Posted by Sanne Grinovero <sa...@gmail.com>.
2010/9/18 Pulkit Singhal <pu...@gmail.com>:
> With RAMDirectory we have the option of providing another Directory
> implementation such as FSDirectory that can be wrapped and loaded into
> memory:
>
> Directory directory = new RAMDirectory(FSDirectory.open(new
> File(fileDirectoryName)));
>
> But after building the index, if I close the IndexWriter then the data
> is still available for searches in the directory bean but nothing ever
> gets written to the disk!
>
> Is this a bug? Is there a workaround?
>
> Or is this by design? Is the RAMDirectory constructor only meant to
> read in data from the passed in argument? Or is it supposed to keep it
> around and update it when closing?
>
> Please write back, Thanks!
> - Pulkit

hi Pulkit, no that's not a bug, as the javadoc explains it's going to
copy the given Directory in the RAMDirectory but they are independent.
You could use Directory.copy(source, dest, boolean) to copy it from
ram to the source Directory when you're done with the changes, but I'd
recommend to use the FSDirectory directly if you need persistence.

Regards,
Sanne

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org