Skip to content

Commit

Permalink
Improve reporting for VcfToLuceneIndexer
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 7, 2024
1 parent 6f9c818 commit 9e37cbf
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public Object onTraversalSuccess() {

if (indexStatsPath != null) {
try (ICSVWriter csvWriter = CsvUtils.getTsvWriter(indexStatsPath.toPath())) {
csvWriter.writeNext(new String[]{"Key", "Type", "ContainedMultiValuedRow", "MinVal", "MaxVal", "DistinctValues"});
csvWriter.writeNext(new String[]{"Key", "Type", "TotalIndexed", "ContainedMultiValuedRow", "MinVal", "MaxVal", "DistinctValues"});

for (String key : stats.collectorMap.keySet()) {
IndexStats.Collector c = stats.collectorMap.get(key);
Expand Down Expand Up @@ -462,6 +462,7 @@ public void inspectValue(String key, Object val) {

public abstract static class Collector {
protected boolean containedMultiValue = false;
protected long totalIndexed = 0L;

public void inspect(Object val) {
if (val == null || "".equals(val) || VCFConstants.EMPTY_INFO_FIELD.equals(val)) {
Expand Down Expand Up @@ -502,6 +503,7 @@ protected void inspectValue(Object val) {
}
}

totalIndexed++;
if (minVal == null || d < minVal) {
minVal = d;
}
Expand All @@ -513,7 +515,7 @@ protected void inspectValue(Object val) {

@Override
public String[] getCsvRow(String key) {
return new String[]{key, "Numeric", String.valueOf(containedMultiValue), minVal == null ? "" : String.valueOf(minVal), maxVal == null ? "" : String.valueOf(maxVal), ""};
return new String[]{key, "Numeric", String.valueOf(totalIndexed), String.valueOf(containedMultiValue), minVal == null ? "" : String.valueOf(minVal), maxVal == null ? "" : String.valueOf(maxVal), ""};
}
}

Expand All @@ -526,12 +528,13 @@ protected void inspectValue(Object val) {
return;
}

totalIndexed++;
values.add(String.valueOf(val));
}

@Override
public String[] getCsvRow(String key) {
return new String[]{key, "String", String.valueOf(containedMultiValue), "", "", values.size() > MAX_VALUES_TO_PRINT ? "Too many: " + values.size() : StringUtils.join(values, ", ")};
return new String[]{key, "String", String.valueOf(totalIndexed), String.valueOf(containedMultiValue), "", "", values.size() > MAX_VALUES_TO_PRINT ? "Too many: " + values.size() : StringUtils.join(values, ", ")};
}
}
}
Expand Down

0 comments on commit 9e37cbf

Please sign in to comment.