use of org.opengrok.suggest.Suggester in project OpenGrok by OpenGrok.
the class SuggesterControllerProjectsDisabledTest method getSuggesterProjectDataSize.
private static int getSuggesterProjectDataSize() throws Exception {
Field f = SuggesterServiceImpl.class.getDeclaredField("suggester");
f.setAccessible(true);
Suggester suggester = (Suggester) f.get(SuggesterServiceImpl.getInstance());
Field f2 = Suggester.class.getDeclaredField("projectData");
f2.setAccessible(true);
return ((Map) f2.get(suggester)).size();
}
use of org.opengrok.suggest.Suggester in project OpenGrok by OpenGrok.
the class SuggesterServiceImpl method initSuggester.
private void initSuggester() {
SuggesterConfig suggesterConfig = env.getSuggesterConfig();
if (!suggesterConfig.isEnabled()) {
logger.log(Level.INFO, "Suggester disabled");
return;
}
File suggesterDir = new File(env.getDataRootPath(), IndexDatabase.SUGGESTER_DIR);
int rebuildParalleismLevel = (int) (((float) suggesterConfig.getRebuildThreadPoolSizeInNcpuPercent() / 100) * Runtime.getRuntime().availableProcessors());
if (rebuildParalleismLevel == 0) {
rebuildParalleismLevel = 1;
}
logger.log(Level.FINER, "Suggester rebuild parallelism level: " + rebuildParalleismLevel);
suggester = new Suggester(suggesterDir, suggesterConfig.getMaxResults(), Duration.ofSeconds(suggesterConfig.getBuildTerminationTime()), suggesterConfig.isAllowMostPopular(), env.isProjectsEnabled(), suggesterConfig.getAllowedFields(), suggesterConfig.getTimeThreshold(), rebuildParalleismLevel, Metrics.getRegistry());
new Thread(() -> {
suggester.init(getAllProjectIndexDirs());
scheduleRebuild();
}).start();
}
Aggregations