Skip to content

Commit

Permalink
Working on fixing indexing problems
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Jan 16, 2025
1 parent 84549a3 commit 1ac5675
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ protected <T extends XmlFieldInstance> Object measureWithGenerics(String content
}

public MetricCollector measureWithoutFormat(String content) {
return measureWithoutFormat(content, null);
}

public MetricCollector measureWithoutFormat(String content, String recordId) {
if (schema == null)
throw new IllegalStateException("schema is missing");

Expand All @@ -191,6 +195,8 @@ public MetricCollector measureWithoutFormat(String content) {
conditionalConfiguration();

cache = SelectorFactory.getInstance(schema.getFormat(), content, schema.getNamespaces());
if (recordId != null)
cache.setRecordId(recordId);
if (schema.getFormat().equals(Format.CSV))
initializeCsvCache(content);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public List<MetricResult> measure(Selector cache)
return List.of(new FieldCounterBasedResult<>(getCalculatorName(), resultMap).withNoCompression());
}

private void extractSingleField(Selector cache, FieldCounter<String> resultMap, String path, String fieldName) {
private void extractSingleField(Selector cache,
FieldCounter<String> resultMap,
String path,
String fieldName) {
extractSingleField(cache, resultMap, path, fieldName,null);
}

Expand Down Expand Up @@ -110,8 +113,10 @@ private void extractSingleField(Selector cache,
}
value = StringUtils.join(values, " --- ");
}
if (fieldName.equals(FIELD_NAME) && StringUtils.isBlank(value))
value = IdentifierGenerator.generate();
if (fieldName.equals(FIELD_NAME) && StringUtils.isBlank(value)) {
value = cache.getRecordId() != null ?
IdentifierGenerator.PREFIX + cache.getRecordId() : IdentifierGenerator.generate();
}

// LOGGER.info(String.format("fieldName: %s, value: %s", fieldName, value));
resultMap.put(fieldName, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class IdentifierGenerator {
private static final Logger LOGGER = Logger.getLogger(IdentifierGenerator.class.getCanonicalName());

private static int identifier = 0;
private static String PREFIX = "UNKNOWN-ID-";
public static String PREFIX = "UNKNOWN-ID-";

public static String generate() {
String id = PREFIX + String.valueOf(++identifier);
Expand Down

0 comments on commit 1ac5675

Please sign in to comment.