Search in sources :

Example 86 with LinkedHashMap

use of java.util.LinkedHashMap in project bazel by bazelbuild.

the class TargetPatternPhaseFunction method compute.

@Override
public TargetPatternPhaseValue compute(SkyKey key, Environment env) throws InterruptedException {
    TargetPatternList options = (TargetPatternList) key.argument();
    PackageValue packageValue = null;
    boolean workspaceError = false;
    try {
        packageValue = (PackageValue) env.getValueOrThrow(PackageValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER), NoSuchPackageException.class);
    } catch (NoSuchPackageException e) {
        env.getListener().handle(Event.error(e.getMessage()));
        workspaceError = true;
    }
    if (env.valuesMissing()) {
        return null;
    }
    String workspaceName = "";
    if (!workspaceError) {
        workspaceName = packageValue.getPackage().getWorkspaceName();
    }
    // Determine targets to build:
    ResolvedTargets<Target> targets = getTargetsToBuild(env, options);
    // If the --build_tests_only option was specified or we want to run tests, we need to determine
    // the list of targets to test. For that, we remove manual tests and apply the command-line
    // filters. Also, if --build_tests_only is specified, then the list of filtered targets will be
    // set as build list as well.
    ResolvedTargets<Target> testTargets = null;
    if (options.getDetermineTests() || options.getBuildTestsOnly()) {
        testTargets = determineTests(env, options.getTargetPatterns(), options.getOffset(), options.getTestFilter());
        Preconditions.checkState(env.valuesMissing() || (testTargets != null));
    }
    Map<Label, SkyKey> testExpansionKeys = new LinkedHashMap<>();
    if (targets != null) {
        for (Target target : targets.getTargets()) {
            if (TargetUtils.isTestSuiteRule(target)) {
                Label label = target.getLabel();
                SkyKey testExpansionKey = TestSuiteExpansionValue.key(ImmutableSet.of(label));
                testExpansionKeys.put(label, testExpansionKey);
            }
        }
    }
    Map<SkyKey, SkyValue> expandedTests = env.getValues(testExpansionKeys.values());
    if (env.valuesMissing()) {
        return null;
    }
    ImmutableSet<Target> filteredTargets = targets.getFilteredTargets();
    ImmutableSet<Target> testsToRun = null;
    ImmutableSet<Target> testFilteredTargets = ImmutableSet.of();
    if (testTargets != null) {
        // Parse the targets to get the tests.
        if (testTargets.getTargets().isEmpty() && !testTargets.getFilteredTargets().isEmpty()) {
            env.getListener().handle(Event.warn("All specified test targets were excluded by filters"));
        }
        if (options.getBuildTestsOnly()) {
            // Replace original targets to build with test targets, so that only targets that are
            // actually going to be built are loaded in the loading phase. Note that this has a side
            // effect that any test_suite target requested to be built is replaced by the set of *_test
            // targets it represents; for example, this affects the status and the summary reports.
            Set<Target> allFilteredTargets = new HashSet<>();
            allFilteredTargets.addAll(targets.getTargets());
            allFilteredTargets.addAll(targets.getFilteredTargets());
            allFilteredTargets.removeAll(testTargets.getTargets());
            allFilteredTargets.addAll(testTargets.getFilteredTargets());
            testFilteredTargets = ImmutableSet.copyOf(allFilteredTargets);
            filteredTargets = ImmutableSet.of();
            targets = ResolvedTargets.<Target>builder().merge(testTargets).mergeError(targets.hasError()).build();
            if (options.getDetermineTests()) {
                testsToRun = testTargets.getTargets();
            }
        } else /*if (determineTests)*/
        {
            testsToRun = testTargets.getTargets();
            targets = ResolvedTargets.<Target>builder().merge(targets).addAll(testsToRun).mergeError(testTargets.hasError()).build();
        // filteredTargets is correct in this case - it cannot contain tests that got back in
        // through test_suite expansion, because the test determination would also filter those out.
        // However, that's not obvious, and it might be better to explicitly recompute it.
        }
        if (testsToRun != null) {
            // Note that testsToRun can still be null here, if buildTestsOnly && !shouldRunTests.
            if (!targets.getTargets().containsAll(testsToRun)) {
                throw new IllegalStateException(String.format("Internal consistency check failed; some targets are scheduled for test execution " + "but not for building (%s)", Sets.difference(testsToRun, targets.getTargets())));
            }
        }
    }
    if (targets.hasError()) {
        env.getListener().handle(Event.warn("Target pattern parsing failed."));
    }
    LoadingPhaseRunner.maybeReportDeprecation(env.getListener(), targets.getTargets());
    boolean preExpansionError = targets.hasError();
    ResolvedTargets.Builder<Target> expandedTargetsBuilder = ResolvedTargets.builder();
    for (Target target : targets.getTargets()) {
        if (TargetUtils.isTestSuiteRule(target)) {
            SkyKey expansionKey = Preconditions.checkNotNull(testExpansionKeys.get(target.getLabel()));
            TestSuiteExpansionValue testExpansion = (TestSuiteExpansionValue) expandedTests.get(expansionKey);
            expandedTargetsBuilder.merge(testExpansion.getTargets());
        } else {
            expandedTargetsBuilder.add(target);
        }
    }
    ResolvedTargets<Target> expandedTargets = expandedTargetsBuilder.build();
    Set<Target> testSuiteTargets = Sets.difference(targets.getTargets(), expandedTargets.getTargets());
    return new TargetPatternPhaseValue(expandedTargets.getTargets(), testsToRun, preExpansionError, expandedTargets.hasError() || workspaceError, filteredTargets, testFilteredTargets, targets.getTargets(), ImmutableSet.copyOf(testSuiteTargets), workspaceName);
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) Label(com.google.devtools.build.lib.cmdline.Label) LinkedHashMap(java.util.LinkedHashMap) SkyValue(com.google.devtools.build.skyframe.SkyValue) Target(com.google.devtools.build.lib.packages.Target) NoSuchPackageException(com.google.devtools.build.lib.packages.NoSuchPackageException) ResolvedTargets(com.google.devtools.build.lib.cmdline.ResolvedTargets) TargetPatternList(com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue.TargetPatternList) HashSet(java.util.HashSet)

Example 87 with LinkedHashMap

use of java.util.LinkedHashMap in project bigbluebutton by bigbluebutton.

the class SearchController method onSubmit.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax
	 * .servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
	 * java.lang.Object, org.springframework.validation.BindException)
	 */
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
    SearchCriteriaCommand srchCriteriaCommand = (SearchCriteriaCommand) command;
    int startFrom = (new Integer(srchCriteriaCommand.getStartFrom())).intValue();
    int endIndex = 0;
    String queryStr = srchCriteriaCommand.getKeyWords();
    String sortBy = srchCriteriaCommand.getSort();
    String operator = srchCriteriaCommand.getOperator();
    String relRange = srchCriteriaCommand.getRangeValue();
    boolean bSmart = (relRange != null) && (!relRange.isEmpty());
    boolean bSortByScore = sortBy.equalsIgnoreCase("byScore");
    if (logger.isInfoEnabled()) {
        logger.info("---search offset=" + startFrom + " sortBy=" + sortBy + "qryString=" + queryStr + "operator=" + operator);
    }
    Map<String, Object> model = new HashMap<String, Object>();
    LinkedHashMap<String, MatchVO> sortedMap = new LinkedHashMap<String, MatchVO>();
    Map<String, SessionHitsOrganizer> hitsOrganizerMap = new HashMap<String, SessionHitsOrganizer>();
    Map<String, String> resultMap = new HashMap<String, String>();
    synchronized (Index.getInstance()) {
        Search search = Search.getInstance();
        search.startSearch();
        TopDocs tps = null;
        Searcher searcher = null;
        ScoreDoc[] hits = null;
        if (bSortByScore) {
            Search.TopDocCollectorSearchResult result = search.searchByScore(queryStr, startFrom, operator);
            TopDocCollector collector = result.getCollector();
            if (collector != null) {
                tps = collector.topDocs();
            }
            hits = tps.scoreDocs;
            searcher = result.getSearcher();
        } else {
            Search.TopFieldDocsSearchResult result = search.searchBySession(queryStr, startFrom, operator);
            TopFieldDocs tfd = result.getTopFieldDocs();
            if (tfd != null) {
                hits = tfd.scoreDocs;
            }
            searcher = result.getSearcher();
        }
        if (hits == null) {
            if (logger.isInfoEnabled()) {
                logger.info("---No hit");
            }
        } else {
            int start = startFrom;
            int end = hits.length;
            endIndex = end;
            if (logger.isInfoEnabled()) {
                logger.info("total match number=" + endIndex);
            }
            String currentSession = "0";
            String lastSession = "0";
            SessionHitsOrganizer hitsOrganizer = null;
            for (int i = start; i < end; i++) {
                float score = hits[i].score;
                Document doc = searcher.doc(hits[i].doc);
                String path = doc.get("path");
                if (path != null) {
                    MatchVO matchVO = new MatchVO();
                    matchVO.setFilePath(path);
                    String fullContent = doc.get("title");
                    String summary = getKeywordContext(queryStr, fullContent);
                    matchVO.setContentSummary(summary);
                    String fileName = doc.get("fileName");
                    matchVO.setFileName(fileName);
                    String indexSummary = doc.get("summary");
                    matchVO.setIndexingSummary(indexSummary);
                    matchVO.setScore(score);
                    String title = indexSummary + ": " + fileName + " (Match Score = " + score + ")";
                    //String content = doc.get("contents");								
                    String allData = title + "%" + summary;
                    if (doc.get("slideTime") != null) {
                        allData += "%" + doc.get("slideTime");
                        matchVO.setSlidePlayTime(doc.get("slideTime"));
                    }
                    //sortedMap.put(path, allData);
                    sortedMap.put(path, matchVO);
                    //model.put(path, newTitle+"%"+doc.get("summary")+"%"+doc.get("slideTime"));
                    if (logger.isInfoEnabled()) {
                        logger.info("----" + allData);
                        logger.info((i + 1) + ". " + path);
                    }
                    if (title != null) {
                        if (logger.isInfoEnabled()) {
                            logger.info("   Title: " + doc.get("title"));
                        }
                    }
                    if (bSmart) {
                        //Prepare for the grouping results						
                        currentSession = getSessionNumberFromFileURL(path);
                        //get existing current session organizer
                        hitsOrganizer = hitsOrganizerMap.get(currentSession);
                        if (hitsOrganizer == null) {
                            //create a new session organizer object
                            hitsOrganizer = new SessionHitsOrganizer();
                            hitsOrganizer.setSessionNum(currentSession);
                            hitsOrganizerMap.put(currentSession, hitsOrganizer);
                        }
                        hitsOrganizer.setReleventRange((new Float(relRange)).floatValue());
                        hitsOrganizer.addExactHits(path, score);
                        matchVO.setSessionHitOrganier(hitsOrganizer);
                    }
                } else {
                    System.out.println((i + 1) + ". " + "No path for this document");
                }
            }
        }
        search.finishSearch();
        //post processing for result grouping...			
        Iterator hitsOrganizerIt = hitsOrganizerMap.keySet().iterator();
        while (hitsOrganizerIt.hasNext()) {
            String key = (String) hitsOrganizerIt.next();
            SessionHitsOrganizer organizer = hitsOrganizerMap.get(key);
            organizer.generateResultGroup();
        }
        model.put("result", sortedMap);
        if (bSmart) {
            model.put("hitsOrganizer", hitsOrganizerMap);
        }
        model.put("searchKeyword", queryStr);
        model.put("startFrom", (new Integer(startFrom)).toString());
        model.put("endAt", (new Integer(endIndex)).toString());
        model.put("sortBy", sortBy);
        model.put("operator", operator);
        model.put("rangeValue", relRange);
    }
    ModelAndView mav = new ModelAndView(this.getSuccessView(), model);
    return mav;
}
Also used : SearchCriteriaCommand(org.bigbluebutton.webminer.web.model.SearchCriteriaCommand) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) MatchVO(org.bigbluebutton.webminer.web.model.MatchVO) TopFieldDocs(org.apache.lucene.search.TopFieldDocs) Document(org.apache.lucene.document.Document) LinkedHashMap(java.util.LinkedHashMap) ScoreDoc(org.apache.lucene.search.ScoreDoc) TopDocs(org.apache.lucene.search.TopDocs) SessionHitsOrganizer(org.bigbluebutton.webminer.web.model.SessionHitsOrganizer) Search(org.bigbluebutton.webminer.search.Search) Iterator(java.util.Iterator) Searcher(org.apache.lucene.search.Searcher) TopDocCollector(org.apache.lucene.search.TopDocCollector)

Example 88 with LinkedHashMap

use of java.util.LinkedHashMap in project bigbluebutton by bigbluebutton.

the class SearchController method groupResultBySession.

private LinkedHashMap groupResultBySession(LinkedHashMap singleHitMap, int extdRange) {
    LinkedHashMap extdResultMap = new LinkedHashMap<String, Object>();
    int lastSessionNum = 0;
    int currentSessionNum = 0;
    return extdResultMap;
}
Also used : LinkedHashMap(java.util.LinkedHashMap)

Example 89 with LinkedHashMap

use of java.util.LinkedHashMap in project gradle by gradle.

the class IdeaModelBuilder method build.

private DefaultIdeaProject build(Project project, DefaultGradleProject rootGradleProject) {
    IdeaModel ideaModel = ideaPluginFor(project).getModel();
    IdeaProject projectModel = ideaModel.getProject();
    JavaVersion projectSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(projectModel.getLanguageLevel());
    JavaVersion projectTargetBytecodeLevel = projectModel.getTargetBytecodeVersion();
    DefaultIdeaProject out = new DefaultIdeaProject().setName(projectModel.getName()).setJdkName(projectModel.getJdkName()).setLanguageLevel(new DefaultIdeaLanguageLevel(projectModel.getLanguageLevel().getLevel())).setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(projectSourceLanguageLevel).setTargetBytecodeVersion(projectTargetBytecodeLevel).setJdk(DefaultInstalledJdk.current()));
    Map<String, DefaultIdeaModule> modules = new LinkedHashMap<String, DefaultIdeaModule>();
    for (IdeaModule module : projectModel.getModules()) {
        appendModule(modules, module, out, rootGradleProject);
    }
    for (IdeaModule module : projectModel.getModules()) {
        buildDependencies(modules, module);
    }
    final Collection<DefaultIdeaModule> ideaModules = modules.values();
    out.setChildren(new LinkedList<DefaultIdeaModule>(ideaModules));
    return out;
}
Also used : DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) JavaVersion(org.gradle.api.JavaVersion) LinkedHashMap(java.util.LinkedHashMap) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel)

Example 90 with LinkedHashMap

use of java.util.LinkedHashMap in project gradle by gradle.

the class GradleBuildBuilder method convert.

private DefaultGradleBuild convert(Gradle gradle) {
    DefaultGradleBuild model = new DefaultGradleBuild();
    Map<Project, BasicGradleProject> convertedProjects = new LinkedHashMap<Project, BasicGradleProject>();
    Project rootProject = gradle.getRootProject();
    BasicGradleProject convertedRootProject = convert(rootProject, convertedProjects);
    model.setRootProject(convertedRootProject);
    for (Project project : rootProject.getAllprojects()) {
        model.addProject(convertedProjects.get(project));
    }
    for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
        Gradle includedGradle = ((IncludedBuildInternal) includedBuild).getConfiguredBuild();
        DefaultGradleBuild convertedIncludedBuild = convert(includedGradle);
        model.addIncludedBuild(convertedIncludedBuild);
    }
    return model;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) IncludedBuildInternal(org.gradle.composite.internal.IncludedBuildInternal) DefaultGradleBuild(org.gradle.tooling.internal.gradle.DefaultGradleBuild) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) Gradle(org.gradle.api.invocation.Gradle) LinkedHashMap(java.util.LinkedHashMap) IncludedBuild(org.gradle.api.initialization.IncludedBuild)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2398 Map (java.util.Map)691 ArrayList (java.util.ArrayList)675 HashMap (java.util.HashMap)439 Test (org.junit.Test)317 List (java.util.List)298 IOException (java.io.IOException)152 HashSet (java.util.HashSet)128 Set (java.util.Set)110 LinkedHashSet (java.util.LinkedHashSet)100 File (java.io.File)93 LinkedList (java.util.LinkedList)75 TreeMap (java.util.TreeMap)72 Node (org.apache.hadoop.hive.ql.lib.Node)70 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)68 Rule (org.apache.hadoop.hive.ql.lib.Rule)68 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)66 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)65 Iterator (java.util.Iterator)64 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)64