use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class NumLinesLOCAccessor method processFileCounts.
private boolean processFileCounts(NumLinesLOCAggregator countsAggregator, IndexSearcher searcher, TopDocs hits) throws IOException {
boolean hasDefinedNumLines = false;
for (ScoreDoc sd : hits.scoreDocs) {
Document d = searcher.doc(sd.doc);
NullableNumLinesLOC counts = NumLinesLOCUtil.read(d);
if (counts.getNumLines() != null && counts.getLOC() != null) {
NumLinesLOC defCounts = new NumLinesLOC(counts.getPath(), counts.getNumLines(), counts.getLOC());
countsAggregator.register(defCounts);
hasDefinedNumLines = true;
}
}
return hasDefinedNumLines;
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class DirectoryExtraReader method processHits.
private List<NullableNumLinesLOC> processHits(IndexSearcher searcher, TopDocs hits) throws IOException {
List<NullableNumLinesLOC> results = new ArrayList<>();
for (ScoreDoc sd : hits.scoreDocs) {
Document d = searcher.doc(sd.doc);
NullableNumLinesLOC extra = NumLinesLOCUtil.read(d);
results.add(extra);
}
return results;
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class DirectoryExtraReader method search.
/**
* Search for supplemental file information in the specified {@code path}.
* @param searcher a defined instance
* @param path a defined path to qualify the search
* @return a list of results, limited to 2000 values
* @throws IOException if an error occurs searching the index
*/
public List<NullableNumLinesLOC> search(IndexSearcher searcher, String path) throws IOException {
if (searcher == null) {
throw new IllegalArgumentException("`searcher' is null");
}
if (path == null) {
throw new IllegalArgumentException("`path' is null");
}
QueryBuilder qbuild = new QueryBuilder();
qbuild.setDirPath(path);
Query query;
try {
query = qbuild.build();
} catch (ParseException e) {
final String PARSE_ERROR = "An error occurred while parsing dirpath query";
LOGGER.log(Level.WARNING, PARSE_ERROR, e);
throw new IOException(PARSE_ERROR);
}
Statistics stat = new Statistics();
TopDocs hits = searcher.search(query, DIR_LIMIT_NUM);
stat.report(LOGGER, Level.FINEST, "search via DirectoryExtraReader done", "search.latency", new String[] { "category", "extra", "outcome", hits.scoreDocs.length > 0 ? "success" : "empty" });
List<NullableNumLinesLOC> results = processHits(searcher, hits);
return results;
}
Aggregations