当前位置: 首页>>代码示例>>Java>>正文


Java MMapDirectory.open方法代码示例

本文整理汇总了Java中org.apache.lucene.store.MMapDirectory.open方法的典型用法代码示例。如果您正苦于以下问题:Java MMapDirectory.open方法的具体用法?Java MMapDirectory.open怎么用?Java MMapDirectory.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.store.MMapDirectory的用法示例。


在下文中一共展示了MMapDirectory.open方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		if (args.length != 2) {
			System.err
					.println("Incorrect number of arguments; expected <index_dir> <query_number>");
		}
		String indexDir = args[0];
		int i = Integer.parseInt(args[1]);
		Queries queries = new Queries();
		Directory directory = MMapDirectory.open(new File(indexDir));
		DirectoryReader reader = DirectoryReader.open(directory);
		TermFreqAnalyzer termFreqAnalyzer = new TermFreqAnalyzer(reader,
				queries.getQuery(i));
		termFreqAnalyzer.printAvgTf();
		termFreqAnalyzer.printAvgTfInDocsWithAllTerms();
		reader.close();
//		directory.close();
	}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:22,代码来源:TermFreqAnalyzer.java

示例2: advancedTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
@Test
public void advancedTest() throws IOException {
	File indexFile = new File("data", "test3");
	FSDirectory directory = MMapDirectory.open(indexFile.toPath());

	LuceneObjectKVS<Integer, Sample> kvs = new LuceneObjectKVS<>(directory, indexFile, true);

	Sample sample = new Sample();
	sample.name = "hoge";
	sample.age = 10;

	kvs.put(1, sample);
	kvs.put(2, sample);

	// get object
	Sample actual = kvs.get(1);
	assertEquals(sample.name, actual.name);

	// iterator
	Iterator<Entry<Integer, Sample>> ite = kvs.iterator();
	while(ite.hasNext()) {
		ite.next();
	}

	kvs.close();
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:27,代码来源:LuceneObjectKVSTest.java

示例3: getTaxoWriter

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public DirectoryTaxonomyWriter getTaxoWriter(int segmentNumber) throws IOException {

		Directory d;

		if (indexConfig.getIndexSettings().getStoreIndexOnDisk()) {
			d = MMapDirectory.open(getPathForFacetsIndex(segmentNumber));
		}
		else {
			String indexSegmentDbName = getIndexSegmentDbName(segmentNumber);
			String indexSegmentCollectionName = getIndexSegmentCollectionName(segmentNumber) + "_facets";
			MongoDirectory mongoDirectory = new MongoDirectory(mongo, indexSegmentDbName, indexSegmentCollectionName, clusterConfig.isSharded(),
					clusterConfig.getIndexBlockSize());
			d = new DistributedDirectory(mongoDirectory);
		}

		NRTCachingDirectory nrtCachingDirectory = new NRTCachingDirectory(d, 2, 10);

		return new DirectoryTaxonomyWriter(nrtCachingDirectory);
	}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:20,代码来源:LumongoIndex.java

示例4: SpokendocBaseline

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
/**
 *  
 * @param propatiesPath 設定ファイル.propertiesのパス
 * @throws IOException
 */
public SpokendocBaseline(String propatiesPath) throws IOException {
	Properties conf = new Properties();
	FileInputStream fis = new FileInputStream(new File(propatiesPath));
	conf.load(fis);
	this.analyzer = new WhitespaceAnalyzer(Version.LUCENE_46);
	this.task = conf.getProperty("task");
	this.freqfilePath = conf.getProperty("freqfile");
	this.tokenizerPath = conf.getProperty("tokenizer");
	this.resultPath = conf.getProperty("result");
	this.normalization = new Boolean(conf.getProperty("normalization"));
	//メモリにインデックス保存する。テスト用
	//this.directory = new RAMDirectory();
	//MMapDirectory: 読み込みはメモリ、書き出しはファイルシステムらしい
	String indexPath = conf.getProperty("index");
	this.indexDirectory = MMapDirectory.open(new File(indexPath));

	String selectedSimilarity = conf.getProperty("similarity");
	if (selectedSimilarity.equals("LMDirichlet")) {
		float mu = Float.valueOf(conf.getProperty("mu"));
	    this.similarity = new LMDirichletSimilarity(mu);
	}
	else if (selectedSimilarity.equals("BM25")) {
		float k1 = Float.valueOf(conf.getProperty("k1"));
		float b = Float.valueOf(conf.getProperty("b"));
	    this.similarity = new BM25Similarity(k1, b);
	}
	else {
	    this.similarity = new DefaultSimilarity();	
	}
	fis.close();
}
 
开发者ID:Kesin11,项目名称:Spokendoc-Baseline,代码行数:37,代码来源:SpokendocBaseline.java

示例5: convert

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
/**
 * Transform the index at source to the destination, adjusting DocValues for the given adjustFields underway.
 * @param source       the location of an existing index.
 * @param destination  where the adjusted index should be stored.
 * @param dvConfigs the fields to adjust. Use {@link #getDVConfigs(java.io.File)} to obtain the
 *                         original setup.
 */
public static void convert(
        File source, File destination, Collection<DVConfig> dvConfigs) throws IOException {
    log.info("Converting index at " + source + " to " + destination + " with " + dvConfigs.size()
             + " DocValues adjustment fields");
    final long startTime = System.nanoTime();

    DirectoryReader inner = DirectoryReader.open(MMapDirectory.open(source));
    final long afterInner = System.nanoTime();
    log.info("Opened standard reader(" + source + ") in " + (afterInner-startTime)/M + "ms");

    IndexReader dvReader = new DVDirectoryReader(inner, new HashSet<>(dvConfigs));
    final long afterWrapper = System.nanoTime();
    log.info("Opened DVWrapper(" + source + ") in " + (afterWrapper-afterInner)/M + "ms");

    Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
    IndexWriter writer = new IndexWriter(
            MMapDirectory.open(destination), new IndexWriterConfig(LUCENE_VERSION, analyzer));
    final long afterWriterCreation = System.nanoTime();
    log.info("Created writer(" + destination + ") in " + (afterWriterCreation-afterWrapper)/M + "ms");

    writer.addIndexes(dvReader);
    final long afterConversion = System.nanoTime();
    log.info("Converted index(" + destination + ") in " + (afterConversion-afterWriterCreation)/M + "ms");

    writer.commit();
    final long afterCommit = System.nanoTime();
    log.info("Finished commit(" + destination + ") in " + (afterCommit - afterCommit) / M + "ms");

    // No need for optimize as the addIndexes + commit ensures transformation
    writer.close();
    dvReader.close();
    log.info("All done. Total time " + (System.nanoTime() - startTime) / M + "ms");
}
 
开发者ID:netarchivesuite,项目名称:dvenabler,代码行数:41,代码来源:IndexUtils.java

示例6: testCreateAndReadWrappedIndex

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public void testCreateAndReadWrappedIndex() throws IOException, ParseException {
    log.info("testCreateAndReadPlainIndex started");
    final File INDEX = generateIndex();

    try {
        Directory directory = MMapDirectory.open(INDEX);
        IndexReader reader = new DVDirectoryReader(
                DirectoryReader.open(directory), createDVFieldDescriptions(INDEX));
        IndexSearcher searcher = new IndexSearcher(reader);

        assertIndexValues(reader, searcher, true);
    } finally {
        delete(INDEX);
    }
}
 
开发者ID:netarchivesuite,项目名称:dvenabler,代码行数:16,代码来源:DVReaderTest.java

示例7: CorrectnessTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public CorrectnessTest() throws IOException {
	Directory directory = MMapDirectory.open(new File(INDEX_DIR));
	reader = DirectoryReader.open(directory);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:5,代码来源:CorrectnessTest.java

示例8: DocIterPerformanceTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public DocIterPerformanceTest(String indexDir) throws IOException {
	Directory directory = MMapDirectory.open(new File(indexDir));
	reader = DirectoryReader.open(directory);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:5,代码来源:DocIterPerformanceTest.java

示例9: DocPosIterPerformanceTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public DocPosIterPerformanceTest(String indexDir, LRDP lrdp)
		throws IOException {
	this.lrdp = lrdp;
	Directory directory = MMapDirectory.open(new File(indexDir));
	reader = DirectoryReader.open(directory);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:7,代码来源:DocPosIterPerformanceTest.java

示例10: NumComparisonsTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public NumComparisonsTest(String indexDir) throws IOException {
	Directory directory = MMapDirectory.open(new File(indexDir));
	reader = DirectoryReader.open(directory);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:5,代码来源:NumComparisonsTest.java

示例11: CacheEffectTest

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
public CacheEffectTest(String indexDir, PhysicalPayloadFormat ppf) throws IOException {
	lrdp = new LRDP(ppf);
	Directory directory = MMapDirectory.open(new File(indexDir));
	reader = DirectoryReader.open(directory);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:6,代码来源:CacheEffectTest.java

示例12: generateIndex

import org.apache.lucene.store.MMapDirectory; //导入方法依赖的package包/类
private static File generateIndex(int documents) throws IOException {
    final File INDEX = new File("target/testindex.deletefreely." + documents);
    final long seed = new Random().nextLong();
    Random random = new Random(seed);
    log.info("Testing with random seed" + seed);
    Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);

    final FieldType SINGLE_F = new FieldType();
    SINGLE_F.setIndexed(true);
    SINGLE_F.setStored(true);

    final FieldType MULTI_F = new FieldType();
    MULTI_F.setIndexed(true);
    MULTI_F.setStored(true);

    final FieldType SEARCH_F = new FieldType();
    SEARCH_F.setIndexed(true);

    final FieldType LONG_F = new FieldType();
    LONG_F.setIndexed(true);
    LONG_F.setStored(true);
    LONG_F.setNumericType(FieldType.NumericType.LONG);

    final FieldType DOUBLE_F = new FieldType();
    DOUBLE_F.setIndexed(true);
    DOUBLE_F.setStored(true);
    DOUBLE_F.setNumericType(FieldType.NumericType.DOUBLE);

    IndexWriter indexWriter = new IndexWriter(
            MMapDirectory.open(INDEX), new IndexWriterConfig(LUCENE_VERSION, analyzer));
    for (int docID = 0 ; docID < documents ; docID++) {
        Document document = new Document();
        document.add(new Field(ID, Integer.toString(docID), SINGLE_F));
        document.add(new Field(SEARCH, SEARCH_CONTENT + "_" + docID, SEARCH_F));
        if (random.nextInt(5) > 0) {
            document.add(new Field(SINGLE, SINGLE_CONTENT + "_r" + random.nextInt(), SINGLE_F));
        }
        if (random.nextInt(5) > 0) {
            document.add(new Field(MULTI, MULTI_CONTENT_1 + "_" + docID, MULTI_F));
            if (random.nextInt(3) > 0) {
                document.add(new Field(MULTI, MULTI_CONTENT_2 + "_random" + random.nextInt(5), MULTI_F));
            }
        }
        if (random.nextInt(5) > 0) {
            document.add(new LongField(LONG, random.nextLong(), LONG_F));
        }
        if (random.nextInt(5) > 0) {
            document.add(new DoubleField(DOUBLE, random.nextDouble(), DOUBLE_F));
        }
        indexWriter.addDocument(document);
        if (docID == documents / 3) {
            indexWriter.commit(); // Ensure multi-segment
        }
    }
    indexWriter.commit();
    indexWriter.close();
    return INDEX;
}
 
开发者ID:netarchivesuite,项目名称:dvenabler,代码行数:59,代码来源:DVReaderTest.java


注:本文中的org.apache.lucene.store.MMapDirectory.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。