forked from senseidb/zoie
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default is RAMDirectory. We also have DefaultRAMDiskIndexFactory so t…
…hat ram index can be hosted on a ram disk or /tmp in nix systems
- Loading branch information
1 parent
758aa28
commit 231fb90
Showing
4 changed files
with
112 additions
and
75 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
java/proj/zoie/impl/indexing/internal/DefaultRAMDiskIndexFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package proj.zoie.impl.indexing.internal; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.SimpleFSDirectory; | ||
|
||
import proj.zoie.api.indexing.IndexReaderDecorator; | ||
|
||
/** | ||
* @author "Xiaoyang Gu<xgu@linkedin.com>" | ||
* | ||
* @param <R> | ||
*/ | ||
public class DefaultRAMDiskIndexFactory<R extends IndexReader> extends RAMIndexFactory<R> | ||
{ | ||
private static final Logger log = Logger.getLogger(DefaultRAMIndexFactory.class); | ||
private static int fold = 10000; | ||
|
||
@Override | ||
public synchronized RAMSearchIndex<R> newInstance(long version, IndexReaderDecorator<R> decorator, SearchIndexManager<R> idxMgr) | ||
{ | ||
Directory ramIdxDir; | ||
try | ||
{ | ||
File backingdir = new File("/tmp/ram" + fold);// /Volumes/ramdisk/ | ||
ramIdxDir = new SimpleFSDirectory(backingdir); | ||
fold++; | ||
return new RAMSearchIndex<R>(version, decorator, idxMgr, ramIdxDir, backingdir); | ||
} catch (IOException e) | ||
{ | ||
// TODO Auto-generated catch block | ||
log.error(e); | ||
e.printStackTrace(); | ||
}// new RAMDirectory(); | ||
return null; | ||
} | ||
|
||
} |
26 changes: 3 additions & 23 deletions
26
java/proj/zoie/impl/indexing/internal/DefaultRAMIndexFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,22 @@ | ||
package proj.zoie.impl.indexing.internal; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.RAMDirectory; | ||
import org.apache.lucene.store.SimpleFSDirectory; | ||
|
||
import proj.zoie.api.indexing.IndexReaderDecorator; | ||
|
||
/** | ||
* @author "Xiaoyang Gu<xgu@linkedin.com>" | ||
* | ||
* | ||
* @param <R> | ||
*/ | ||
public class DefaultRAMIndexFactory<R extends IndexReader> extends RAMIndexFactory<R> | ||
{ | ||
private static final Logger log = Logger.getLogger(DefaultRAMIndexFactory.class); | ||
private static int fold =10000; | ||
|
||
@Override | ||
public synchronized RAMSearchIndex<R> newInstance(long version, IndexReaderDecorator<R> decorator, SearchIndexManager<R> idxMgr) | ||
{ | ||
Directory ramIdxDir; | ||
try | ||
{ | ||
File backingdir = new File("/tmp/ram"+fold);///Volumes/ramdisk/ | ||
ramIdxDir = new SimpleFSDirectory(backingdir ); | ||
fold++; | ||
return new RAMSearchIndex<R>(version, decorator, idxMgr, ramIdxDir, backingdir); | ||
} catch (IOException e) | ||
{ | ||
// TODO Auto-generated catch block | ||
log.error(e); | ||
e.printStackTrace(); | ||
}//new RAMDirectory(); | ||
return null; | ||
return new RAMSearchIndex<R>(version, decorator, idxMgr, new RAMDirectory(), null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters