For IntelliJ IDEA,
Android Studio or Eclipse



@Override public FacetResult getTopChildren(int topN, String dim, String... path) throws IOException { Facets facets = dimToFacets.get(dim); if (facets == null) { if (defaultFacets == null) { throw new IllegalArgumentException("invalid dim \"" + dim + "\""); } facets = defaultFacets; } return facets.getTopChildren(topN, dim, path); }
@Override public List<FacetResult> getAllDims(int topN) throws IOException { List<FacetResult> results = new ArrayList<FacetResult>(); // First add the specific dim's facets: for(Map.Entry<String,Facets> ent : dimToFacets.entrySet()) { results.add(ent.getValue().getTopChildren(topN, ent.getKey())); } if (defaultFacets != null) { // Then add all default facets as long as we didn't // already add that dim: for(FacetResult result : defaultFacets.getAllDims(topN)) { if (dimToFacets.containsKey(result.dim) == false) { results.add(result); } } } return results; } }
/** * Returns the matching source facets for a given query */ private List<CodeFacetSource> getSourceFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetSource> codeFacetSource = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.SOURCE); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.SOURCE); if (result != null) { int stepThrough = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount; for (int i = 0; i < stepThrough; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetSource.add(new CodeFacetSource(lv.label, lv.value.intValue())); } } } } catch (Exception ignore) {} return codeFacetSource; }
/** * Returns the matching revision facets for a given query */ private List<CodeFacetDeleted> getDeletedFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetDeleted> deletedFacets = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DELETED); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.DELETED); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { deletedFacets.add(new CodeFacetDeleted(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return deletedFacets; }
/** * Returns the matching owner facets for a given query */ private List<CodeFacetOwner> getOwnerFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetOwner> codeFacetRepo = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.CODEOWNER); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.CODEOWNER); if (result != null) { int stepThrough = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount; for (int i = 0; i < stepThrough; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetRepo.add(new CodeFacetOwner(lv.label, lv.value.intValue())); } } } } catch (Exception ignore) {} return codeFacetRepo; }
FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.CODEOWNER);
/** * Returns the matching language facets for a given query */ private List<CodeFacetLanguage> getLanguageFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetLanguage> codeFacetLanguages = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.LANGUAGENAME); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.LANGUAGENAME); if (result != null) { int stepThru = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetLanguages.add(new CodeFacetLanguage(lv.label, lv.value.intValue())); } } } } catch (Exception ignore) {} return codeFacetLanguages; }
/** * Returns the matching yearmonthday facets for a given query */ private List<CodeFacetYearMonthDay> getYearMonthDayFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetYearMonthDay> codeFacetYearMonthDay = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEARMONTHDAY); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.DATEYEARMONTHDAY); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetYearMonthDay.add(new CodeFacetYearMonthDay(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return codeFacetYearMonthDay; }
/** * Returns the matching repository facets for a given query */ private List<CodeFacetRepo> getRepoFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetRepo> codeFacetRepo = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.REPONAME); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.REPONAME); if (result != null) { int stepThru = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetRepo.add(new CodeFacetRepo(lv.label, lv.value.intValue())); } } } } catch (Exception ignore) {} return codeFacetRepo; }
/** * Returns the matching yearmonth facets for a given query */ private List<CodeFacetYear> getYearFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetYear> codeFacetYear = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEAR); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.DATEYEAR); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetYear.add(new CodeFacetYear(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return codeFacetYear; }
/** * Returns the matching repository facets for a given query */ private List<CodeFacetRepo> getRepoFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetRepo> codeFacetRepo = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.REPONAME); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.REPONAME); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetRepo.add(new CodeFacetRepo(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return codeFacetRepo; }
/** * Returns the matching yearmonth facets for a given query */ private List<CodeFacetYearMonth> getYearMonthFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetYearMonth> codeFacetYearMonth = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEARMONTH); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.DATEYEARMONTH); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetYearMonth.add(new CodeFacetYearMonth(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return codeFacetYearMonth; }
/** * Returns the matching language facets for a given query */ private List<CodeFacetLanguage> getLanguageFacetResults(IndexSearcher searcher, IndexReader reader, Query query) { List<CodeFacetLanguage> codeFacetLanguages = new ArrayList<>(); try { SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.LANGUAGENAME); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, query, 10, fc); Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(200, Values.LANGUAGENAME); if (result != null) { int stepThru = result.childCount > 200 ? 200 : result.childCount; for (int i = 0; i < stepThru; i++) { LabelAndValue lv = result.labelValues[i]; if (lv != null && lv.value != null) { codeFacetLanguages.add(new CodeFacetLanguage(lv.label, lv.value.intValue())); } } } } catch(IOException ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } catch(Exception ex) { LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage()); } return codeFacetLanguages; }
@Override public FacetResult getTopChildren(int topN, String dim, String... path) throws IOException { Facets facets = dimToFacets.get(dim); if (facets == null) { if (defaultFacets == null) { throw new IllegalArgumentException("invalid dim \"" + dim + "\""); } facets = defaultFacets; } return facets.getTopChildren(topN, dim, path); }
@Override public List<FacetResult> getAllDims(int topN) throws IOException { List<FacetResult> results = new ArrayList<FacetResult>(); // First add the specific dim's facets: for(Map.Entry<String,Facets> ent : dimToFacets.entrySet()) { results.add(ent.getValue().getTopChildren(topN, ent.getKey())); } if (defaultFacets != null) { // Then add all default facets as long as we didn't // already add that dim: for(FacetResult result : defaultFacets.getAllDims(topN)) { if (dimToFacets.containsKey(result.dim) == false) { results.add(result); } } } return results; } }