use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class DirectoryListing method printNumlines.
private void printNumlines(Writer out, DirectoryEntry entry, boolean isDir) throws IOException {
Long numlines = null;
String readableNumlines = "";
NullableNumLinesLOC extra = entry.getExtra();
if (extra != null) {
numlines = extra.getNumLines();
}
if (numlines != null) {
readableNumlines = Util.readableCount(numlines, isDir);
}
out.write("<td class=\"numlines\">");
out.write(readableNumlines);
out.write("</td>");
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class FileExtraZipper method indexExtraByName.
private Map<String, NullableNumLinesLOC> indexExtraByName(List<NullableNumLinesLOC> extras) {
Map<String, NullableNumLinesLOC> byPath = new HashMap<>();
for (NullableNumLinesLOC extra : extras) {
if (extra.getPath() != null) {
File f = new File(extra.getPath());
String filename = f.getName();
byPath.put(filename, extra);
}
}
return byPath;
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class FileExtraZipper method zip.
/**
* Merge the specified lists by looking up a possible entry in
* {@code extras} for every element in {@code files}.
* @param dir the files' directory
* @param files the file names
* @param extras some OpenGrok-analyzed extra metadata
* @return a list of the same size as {@code files}
*/
public List<DirectoryEntry> zip(File dir, List<String> files, List<NullableNumLinesLOC> extras) {
if (extras == null) {
return files.stream().map(f -> new DirectoryEntry(new File(dir, f))).collect(Collectors.toList());
}
Map<String, NullableNumLinesLOC> byName = indexExtraByName(extras);
List<DirectoryEntry> result = new ArrayList<>(files.size());
for (String file : files) {
File fileobj = new File(dir, file);
NullableNumLinesLOC extra = findExtra(byName, fileobj);
DirectoryEntry entry = new DirectoryEntry(fileobj, extra);
result.add(entry);
}
return result;
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class IndexDatabase method removeFile.
/**
* Remove a stale file (uidIter.term().text()) from the index database and
* history cache, and queue the removal of xref.
*
* @param removeHistory if false, do not remove history cache for this file
* @throws java.io.IOException if an error occurs
*/
private void removeFile(boolean removeHistory) throws IOException {
String path = Util.uid2url(uidIter.term().utf8ToString());
for (IndexChangedListener listener : listeners) {
listener.fileRemove(path);
}
// Determine if a reversal of counts is necessary, and execute if so.
if (isCountingDeltas) {
postsIter = uidIter.postings(postsIter);
while (postsIter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
// Read a limited-fields version of the document.
Document doc = reader.document(postsIter.docID(), REVERT_COUNTS_FIELDS);
if (doc != null) {
NullableNumLinesLOC nullableCounts = NumLinesLOCUtil.read(doc);
if (nullableCounts.getNumLines() != null && nullableCounts.getLOC() != null) {
NumLinesLOC counts = new NumLinesLOC(path, -nullableCounts.getNumLines(), -nullableCounts.getLOC());
countsAggregator.register(counts);
}
break;
}
}
}
writer.deleteDocuments(new Term(QueryBuilder.U, uidIter.term()));
removeXrefFile(path);
if (removeHistory) {
removeHistoryFile(path);
}
setDirty();
for (IndexChangedListener listener : listeners) {
listener.fileRemoved(path);
}
}
use of org.opengrok.indexer.analysis.NullableNumLinesLOC in project OpenGrok by OpenGrok.
the class DirectoryListing method printLoc.
private void printLoc(Writer out, DirectoryEntry entry, boolean isDir) throws IOException {
Long loc = null;
String readableLoc = "";
NullableNumLinesLOC extra = entry.getExtra();
if (extra != null) {
loc = extra.getLOC();
}
if (loc != null) {
readableLoc = Util.readableCount(loc, isDir);
}
out.write("<td class=\"loc\">");
out.write(readableLoc);
out.write("</td>");
}
Aggregations