use of org.apache.lucene.store.MMapDirectory in project Krill by KorAP.
the class TestBenchmarkSpans method checkBenchmarkClasses.
@Test
public void checkBenchmarkClasses() throws IOException {
// [orth=Der]{1:[orth=Mann]{2:[orth=und]}}
Properties prop = new Properties();
InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
prop.load(fr);
// Get the real index
KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(prop.getProperty("krill.indexDir"))));
// Create a container for virtual collections:
KrillCollection kc = new KrillCollection(ki);
long t1 = 0, t2 = 0;
// Without classes
String json = getString(getClass().getResource("/queries/benchmark5-ohne.jsonld").getFile());
int rounds = 2000;
Result kr = new Result();
t1 = System.nanoTime();
for (int i = 1; i <= rounds; i++) {
kr = new Krill(json).apply(ki);
}
;
t2 = System.nanoTime();
double seconds = (double) (t2 - t1) / 1000000000.0;
// System.out.println("It took " + seconds + " seconds without classes");
t1 = 0;
t2 = 0;
// With classes
json = getString(getClass().getResource("/queries/benchmark5.jsonld").getFile());
t1 = System.nanoTime();
for (int i = 1; i <= rounds; i++) {
kr = new Krill(json).apply(ki);
}
;
t2 = System.nanoTime();
seconds = (double) (t2 - t1) / 1000000000.0;
// System.out.println("It took " + seconds + " seconds with classes");
t1 = 0;
t2 = 0;
// With submatch
json = getString(getClass().getResource("/queries/benchmark5-submatch.jsonld").getFile());
t1 = System.nanoTime();
for (int i = 1; i <= rounds; i++) {
kr = new Krill(json).apply(ki);
}
;
t2 = System.nanoTime();
seconds = (double) (t2 - t1) / 1000000000.0;
// System.out.println("It took " + seconds + " seconds with submatches");
/**
* HERE IS A BUG!
*/
// System.err.println(kr.toJsonString());
// System.err.println(kr.toJSON());
// System.err.println(kr.getMatch(3).getSnippetBrackets());
// 2000 rounds:
// It took 10.872934435 seconds without classes
// It took 22.581117396 seconds with classes
// It took 10.703933598 seconds without classes
// It took 19.354674517 seconds with classes
// It took 10.939948726 seconds without classes
// It took 16.998470662 seconds with classes
// It took 10.900975837 seconds without classes
// It took 14.902590949 seconds with classes
// It took 10.365989238 seconds without classes
// It took 13.833405885 seconds with classes
// It took 15.368675425 seconds without classes
// It took 18.347603186 seconds with classes
// It took 15.941057294 seconds with submatches
// It took 15.241253549 seconds without classes
// It took 17.30375624 seconds with classes
// It took 15.367171254 seconds with submatches
}
use of org.apache.lucene.store.MMapDirectory in project Krill by KorAP.
the class TestBenchmarkSpans method checkBenchmark3.
@Test
public void checkBenchmark3() throws IOException {
Properties prop = new Properties();
InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
prop.load(fr);
// Get the real index
KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(prop.getProperty("krill.indexDir"))));
// Create a container for virtual collections:
KrillCollection kc = new KrillCollection(ki);
long t1 = 0, t2 = 0;
// / cosmas20.json!!!
String json = getString(getClass().getResource("/queries/benchmark3.jsonld").getFile());
int rounds = 500;
Result kr = new Result();
t1 = System.nanoTime();
for (int i = 1; i <= rounds; i++) {
kr = new Krill(json).apply(ki);
}
;
t2 = System.nanoTime();
assertEquals("TotalResults", kr.getTotalResults(), 70229);
// System.err.println(kr.toJSON());
// long seconds = (long) (t2 - t1 / 1000) % 60 ;
double seconds = (double) (t2 - t1) / 1000000000.0;
System.out.println("It took " + seconds + " seconds");
// 500 times:
// 71.715862716 seconds
}
use of org.apache.lucene.store.MMapDirectory in project Krill by KorAP.
the class Node method getIndex.
/**
* Get the associuated {@link KrillIndex}.
*
* @return The associated {@link KrillIndex}.
*/
public static KrillIndex getIndex() {
// Index already instantiated
if (index != null)
return index;
try {
// Get a temporary index
if (path == null) {
// Temporary index
index = new KrillIndex();
} else // Get a MMap directory index
{
Path file = Paths.get(path);
log.info("Loading index from {}", path);
if (!file.toFile().exists()) {
log.error("Index not found at {}", path);
return null;
}
;
// Set real index
index = new KrillIndex(new MMapDirectory(file));
}
;
return index;
} catch (IOException e) {
log.error("Index not loadable at {}: {}", path, e.getMessage());
}
;
return null;
}
use of org.apache.lucene.store.MMapDirectory in project cxf by apache.
the class TikaLuceneContentExtractorTest method setUp.
@Before
public void setUp() throws Exception {
final Analyzer analyzer = new StandardAnalyzer();
tempDirectory = Files.createTempDirectory("lucene");
directory = new MMapDirectory(tempDirectory);
IndexWriterConfig config = new IndexWriterConfig(analyzer);
writer = new IndexWriter(directory, config);
writer.commit();
parser = new FiqlParser<>(SearchBean.class);
extractor = new TikaLuceneContentExtractor(new PDFParser());
}
use of org.apache.lucene.store.MMapDirectory in project crate by crate.
the class FsDirectoryFactoryTests method testPreload.
@Test
public void testPreload() throws IOException {
doTestPreload();
doTestPreload("nvd", "dvd", "tim");
doTestPreload("*");
Settings build = Settings.builder().put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.HYBRIDFS.name().toLowerCase(Locale.ROOT)).putList(IndexModule.INDEX_STORE_PRE_LOAD_SETTING.getKey(), "dvd", "bar").build();
try (Directory directory = newDirectory(build)) {
assertTrue(FsDirectoryFactory.isHybridFs(directory));
FsDirectoryFactory.HybridDirectory hybridDirectory = (FsDirectoryFactory.HybridDirectory) directory;
assertTrue(hybridDirectory.useDelegate("foo.dvd"));
assertTrue(hybridDirectory.useDelegate("foo.nvd"));
assertTrue(hybridDirectory.useDelegate("foo.tim"));
assertTrue(hybridDirectory.useDelegate("foo.tip"));
assertTrue(hybridDirectory.useDelegate("foo.cfs"));
assertTrue(hybridDirectory.useDelegate("foo.dim"));
assertFalse(hybridDirectory.useDelegate("foo.bar"));
MMapDirectory delegate = hybridDirectory.getDelegate();
assertThat(delegate, Matchers.instanceOf(FsDirectoryFactory.PreLoadMMapDirectory.class));
FsDirectoryFactory.PreLoadMMapDirectory preLoadMMapDirectory = (FsDirectoryFactory.PreLoadMMapDirectory) delegate;
assertTrue(preLoadMMapDirectory.useDelegate("foo.dvd"));
assertTrue(preLoadMMapDirectory.useDelegate("foo.bar"));
}
}
Aggregations