Search in sources :

Example 6 with HdfsDirectory

use of org.apache.solr.store.hdfs.HdfsDirectory in project carbondata by apache.

the class LuceneCoarseGrainDataMap method init.

/**
 * It is called to load the data map to memory or to initialize it.
 */
@Override
public void init(DataMapModel dataMapModel) throws MemoryException, IOException {
    // get this path from file path
    Path indexPath = FileFactory.getPath(dataMapModel.getFilePath());
    LOGGER.info("Lucene index read path " + indexPath.toString());
    // get file system , use hdfs file system , realized in solr project
    FileSystem fs = FileFactory.getFileSystem(indexPath);
    // check this path valid
    if (!fs.exists(indexPath)) {
        String errorMessage = String.format("index directory %s not exists.", indexPath);
        LOGGER.error(errorMessage);
        throw new IOException(errorMessage);
    }
    if (!fs.isDirectory(indexPath)) {
        String errorMessage = String.format("error index path %s, must be directory", indexPath);
        LOGGER.error(errorMessage);
        throw new IOException(errorMessage);
    }
    // open this index path , use HDFS default configuration
    Directory indexDir = new HdfsDirectory(indexPath, FileFactory.getConfiguration());
    IndexReader indexReader = DirectoryReader.open(indexDir);
    if (indexReader == null) {
        throw new RuntimeException("failed to create index reader object");
    }
    // create a index searcher object
    indexSearcher = new IndexSearcher(indexReader);
}
Also used : Path(org.apache.hadoop.fs.Path) IndexSearcher(org.apache.lucene.search.IndexSearcher) FileSystem(org.apache.hadoop.fs.FileSystem) IndexReader(org.apache.lucene.index.IndexReader) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) IOException(java.io.IOException) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) Directory(org.apache.lucene.store.Directory)

Example 7 with HdfsDirectory

use of org.apache.solr.store.hdfs.HdfsDirectory in project carbondata by apache.

the class LuceneDataMapWriter method onBlockStart.

/**
 * Start of new block notification.
 */
public void onBlockStart(String blockId) throws IOException {
    // save this block id for lucene index , used in onPageAdd function
    this.blockId = blockId;
    // get index path, put index data into segment's path
    String strIndexPath = getIndexPath();
    Path indexPath = FileFactory.getPath(strIndexPath);
    FileSystem fs = FileFactory.getFileSystem(indexPath);
    // if index path not exists, create it
    if (fs.exists(indexPath)) {
        fs.mkdirs(indexPath);
    }
    if (null == analyzer) {
        analyzer = new StandardAnalyzer();
    }
    // create a index writer
    Directory indexDir = new HdfsDirectory(indexPath, FileFactory.getConfiguration());
    indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(analyzer));
}
Also used : Path(org.apache.hadoop.fs.Path) CarbonTablePath(org.apache.carbondata.core.util.path.CarbonTablePath) IndexWriter(org.apache.lucene.index.IndexWriter) FileSystem(org.apache.hadoop.fs.FileSystem) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) RAMDirectory(org.apache.lucene.store.RAMDirectory) Directory(org.apache.lucene.store.Directory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 8 with HdfsDirectory

use of org.apache.solr.store.hdfs.HdfsDirectory in project carbondata by apache.

the class LuceneFineGrainDataMap method init.

/**
 * It is called to load the data map to memory or to initialize it.
 */
public void init(DataMapModel dataMapModel) throws MemoryException, IOException {
    // get this path from file path
    Path indexPath = FileFactory.getPath(dataMapModel.getFilePath());
    LOGGER.info("Lucene index read path " + indexPath.toString());
    // get file system , use hdfs file system , realized in solr project
    FileSystem fs = FileFactory.getFileSystem(indexPath);
    // check this path valid
    if (!fs.exists(indexPath)) {
        String errorMessage = String.format("index directory %s not exists.", indexPath);
        LOGGER.error(errorMessage);
        throw new IOException(errorMessage);
    }
    if (!fs.isDirectory(indexPath)) {
        String errorMessage = String.format("error index path %s, must be directory", indexPath);
        LOGGER.error(errorMessage);
        throw new IOException(errorMessage);
    }
    // open this index path , use HDFS default configuration
    Directory indexDir = new HdfsDirectory(indexPath, FileFactory.getConfiguration());
    IndexReader indexReader = DirectoryReader.open(indexDir);
    if (indexReader == null) {
        throw new RuntimeException("failed to create index reader object");
    }
    // create a index searcher object
    indexSearcher = new IndexSearcher(indexReader);
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) IndexReader(org.apache.lucene.index.IndexReader) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) IOException(java.io.IOException) HdfsDirectory(org.apache.solr.store.hdfs.HdfsDirectory) Directory(org.apache.lucene.store.Directory)

Aggregations

HdfsDirectory (org.apache.solr.store.hdfs.HdfsDirectory)8 Path (org.apache.hadoop.fs.Path)6 Directory (org.apache.lucene.store.Directory)6 IOException (java.io.IOException)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Configuration (org.apache.hadoop.conf.Configuration)2 IndexReader (org.apache.lucene.index.IndexReader)2 NRTCachingDirectory (org.apache.lucene.store.NRTCachingDirectory)2 BlockDirectory (org.apache.solr.store.blockcache.BlockDirectory)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)1 FileContext (org.apache.hadoop.fs.FileContext)1 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)1 CheckIndex (org.apache.lucene.index.CheckIndex)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 FSDirectory (org.apache.lucene.store.FSDirectory)1 RAMDirectory (org.apache.lucene.store.RAMDirectory)1