add index.provider.lucene.fsType for test
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/52087a0b Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/52087a0b Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/52087a0b Branch: refs/heads/master Commit: 52087a0bf8ba316b55c662f8c865140f0605abe1 Parents: d7a630d Author: daewon <[email protected]> Authored: Mon Apr 23 12:08:56 2018 +0900 Committer: daewon <[email protected]> Committed: Mon Apr 23 12:08:56 2018 +0900 ---------------------------------------------------------------------- .../apache/s2graph/core/index/LuceneIndexProvider.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/52087a0b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala index 16c094a..1b9d087 100644 --- a/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala +++ b/s2core/src/main/scala/org/apache/s2graph/core/index/LuceneIndexProvider.scala @@ -56,8 +56,16 @@ class LuceneIndexProvider(config: Config) extends IndexProvider { val MAX_RESULTS = 100000 private def getOrElseDirectory(indexName: String): BaseDirectory = { - val pathname = s"${baseDirectory}/${indexName}" - val dir = directories.getOrElseUpdate(indexName, new SimpleFSDirectory(new File(pathname).toPath)) + val fsType = scala.util.Try(config.getString("index.provider.lucene.fsType")).getOrElse("memory") + + val fsDir = if (fsType == "memory") { + new RAMDirectory() + } else { + val pathname = s"${baseDirectory}/${indexName}" + new SimpleFSDirectory(new File(pathname).toPath) + } + + val dir = directories.getOrElseUpdate(indexName, fsDir) dir }
