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


Java ParallelIndexer.run方法代码示例

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


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

示例1: testSearchSpeed

import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入方法依赖的package包/类
private void testSearchSpeed(ArrayList<String> images, final Class featureClass) throws IOException {
    parallelIndexer = new ParallelIndexer(8, indexPath, testExtensive, true) {
        @Override
        public void addBuilders(ChainedDocumentBuilder builder) {
            builder.addBuilder(new GenericDocumentBuilder(featureClass, "feature"));
        }
    };
    parallelIndexer.run();
    IndexReader reader = DirectoryReader.open(new RAMDirectory(FSDirectory.open(new File(indexPath)), IOContext.READONCE));
    Bits liveDocs = MultiFields.getLiveDocs(reader);
    double queryCount = 0d;
    ImageSearcher searcher = new GenericFastImageSearcher(100, featureClass, "feature");
    long ms = System.currentTimeMillis();
    for (int i = 0; i < reader.maxDoc(); i++) {
        if (reader.hasDeletions() && !liveDocs.get(i)) continue; // if it is deleted, just ignore it.
        String fileName = getIDfromFileName(reader.document(i).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0]);
        if (queries.keySet().contains(fileName)) {
            queryCount += 1d;
            // ok, we've got a query here for a document ...
            Document queryDoc = reader.document(i);
            ImageSearchHits hits = searcher.search(queryDoc, reader);
        }
    }
    ms = System.currentTimeMillis() - ms;
    System.out.printf("%s \t %3.1f \n", featureClass.getName().substring(featureClass.getName().lastIndexOf('.')+1), (double) ms / queryCount);
}
 
开发者ID:fish2000,项目名称:lire,代码行数:27,代码来源:TestUCID.java

示例2: main

import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    // Checking if arg[0] is there and if it is a directory.
    boolean passed = false;
    if (args.length > 0) {
        File f = new File(args[0]);
        System.out.println("Indexing images in " + args[0]);
        if (f.exists() && f.isDirectory()) passed = true;
    }
    if (!passed) {
        System.out.println("No directory given as first argument.");
        System.out.println("Run \"ParallelIndexing <directory>\" to index files of a directory.");
        System.exit(1);
    }

    // use ParallelIndexer to index all photos from args[0] into "index" ... use 6 threads (actually 7 with the I/O thread).
    ParallelIndexer indexer = new ParallelIndexer(6, "index", args[0]) {
        // use this to add you preferred builders. For now we go for CEDD, FCTH and AutoColorCorrelogram
        public void addBuilders(ChainedDocumentBuilder builder) {
            builder.addBuilder(DocumentBuilderFactory.getCEDDDocumentBuilder());
            builder.addBuilder(DocumentBuilderFactory.getFCTHDocumentBuilder());
            builder.addBuilder(DocumentBuilderFactory.getAutoColorCorrelogramDocumentBuilder());
        }
    };
    indexer.run();
    System.out.println("Finished indexing.");
}
 
开发者ID:fish2000,项目名称:lire,代码行数:27,代码来源:ParallelIndexing.java

示例3: testIndexingAndSearchSurf

import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入方法依赖的package包/类
public void testIndexingAndSearchSurf() throws IOException {
    ParallelIndexer pin = new ParallelIndexer(8, pathName, "wang-1000") {
        @Override
        public void addBuilders(ChainedDocumentBuilder builder) {
            builder.addBuilder(new SurfDocumentBuilder());
        }
    };
    pin.run();
    IndexReader ir = DirectoryReader.open(FSDirectory.open(indexPath));
    SurfFeatureHistogramBuilder sfh = new SurfFeatureHistogramBuilder(ir, 1000, 50);
    sfh.index();
}
 
开发者ID:fish2000,项目名称:lire,代码行数:13,代码来源:VisualWordsTest.java

示例4: testParallelIndexMSER

import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入方法依赖的package包/类
public void testParallelIndexMSER() throws IOException {
    ParallelIndexer pin = new ParallelIndexer(1, "mser-idx", "D:\\DataSets\\WIPO\\CA\\sample") {
        @Override
        public void addBuilders(ChainedDocumentBuilder builder) {
            builder.addBuilder(new MSERDocumentBuilder());
        }
    };
    pin.run();
}
 
开发者ID:fish2000,项目名称:lire,代码行数:10,代码来源:MserTest.java

示例5: testFastSearch

import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入方法依赖的package包/类
public void testFastSearch() throws IOException {
        Codec.forName("LireCustomCodec");
//        ParallelIndexer pin = new ParallelIndexer(7, "./index-fast-3", "testdata/wang-1000") {
        ParallelIndexer pin = new ParallelIndexer(7, "./index-fast-3", "D:\\DataSets\\Flickrphotos\\01", true) {
            @Override
            public void addBuilders(ChainedDocumentBuilder builder) {
                builder.addBuilder(DocumentBuilderFactory.getOpponentHistogramDocumentBuilder());
            }
        };
        pin.run();
        IndexReader ir = DirectoryReader.open(MMapDirectory.open(new File("./index-fast-3")));
        System.out.println("ir.maxDoc() = " + ir.maxDoc());

        long ms = System.currentTimeMillis();
        ImageSearcher is = new FastOpponentImageSearcher(50);
        ms = System.currentTimeMillis() - ms;
        System.out.println("init ms = " + ms);

        ms = System.currentTimeMillis();
        for (int i = 0; i < 100; i++) is.search(ir.document(i), ir);
        ms = System.currentTimeMillis() - ms;
        System.out.println("cached ms = " + ms);

        is = ImageSearcherFactory.createOpponentHistogramSearcher(50);
        ms = System.currentTimeMillis();
        for (int i = 0; i < 100; i++) is.search(ir.document(i), ir);
        ms = System.currentTimeMillis() - ms;
        System.out.println("read from Lucene ms = " + ms);
    }
 
开发者ID:fish2000,项目名称:lire,代码行数:30,代码来源:OpponentHistogramTest.java


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