Search in sources :

Example 1 with Suggester

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();
}
Also used : Field(java.lang.reflect.Field) Suggester(org.opengrok.suggest.Suggester) Map(java.util.Map)

Example 2 with Suggester

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();
}
Also used : Suggester(org.opengrok.suggest.Suggester) File(java.io.File) SuggesterConfig(org.opengrok.indexer.configuration.SuggesterConfig)

Aggregations

Suggester (org.opengrok.suggest.Suggester)2 File (java.io.File)1 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 SuggesterConfig (org.opengrok.indexer.configuration.SuggesterConfig)1