Skip to content

Commit

Permalink
PR review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gross cogross committed Aug 20, 2024
1 parent 30fc6b1 commit 77ba2d1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.concurrent.atomic.AtomicInteger;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
Expand Down Expand Up @@ -50,19 +51,14 @@ void format(Writer writer) throws IOException {
writer.write(transformToXmlString(ruleConfig));
}

private static void increment() {
index++;
}

private AgeOffRuleLoader.RuleConfig createRuleConfig(AgeOffRuleConfiguration configuration) throws IOException {
AgeOffRuleLoader.RuleConfig ruleConfig = new AgeOffRuleLoader.RuleConfig(this.configuration.getFilterClass().getName(), index);
increment();
private static AgeOffRuleLoader.RuleConfig createRuleConfig(AgeOffRuleConfiguration configuration) throws IOException {
AgeOffRuleLoader.RuleConfig ruleConfig = new AgeOffRuleLoader.RuleConfig(configuration.getFilterClass().getName(), index++);
ruleConfig.label(configuration.getRuleLabel());
ruleConfig.setIsMerge(this.configuration.shouldMerge());
ruleConfig.ttlValue(this.configuration.getTtlDuration());
ruleConfig.ttlUnits(this.configuration.getTtlUnits());
ruleConfig.matchPattern(buildMatchPattern());
ruleConfig.customElements(this.configuration.getCustomElements());
ruleConfig.setIsMerge(configuration.shouldMerge());
ruleConfig.ttlValue(configuration.getTtlDuration());
ruleConfig.ttlUnits(configuration.getTtlUnits());
ruleConfig.matchPattern(buildMatchPattern(configuration, configuration.getIndentation()));
ruleConfig.customElements(configuration.getCustomElements());
return ruleConfig;
}

Expand Down Expand Up @@ -98,7 +94,7 @@ private String calculateIndentAmount() {
return Integer.toString(length);
}

private String buildMatchPattern() throws IOException {
private static String buildMatchPattern(AgeOffRuleConfiguration configuration, String indent) throws IOException {
if (configuration.getPatternConfiguration() == null) {
return "";
}
Expand All @@ -109,14 +105,14 @@ private String buildMatchPattern() throws IOException {
AgeOffCsvToMatchPatternFormatter patternFormatter = new AgeOffCsvToMatchPatternFormatter(configuration.getPatternConfiguration());

// add two indentations: one for items under the rule element and another for items under the matchPattern element
String extraIndentation = this.indent + this.indent;
String extraIndentation = indent + indent;
patternFormatter.write(new IndentingDelegatingWriter(extraIndentation, writer));

String result = writer.toString();

// final indentation to precede the closing of matchPattern
if (result.endsWith("\n")) {
return result + this.indent;
return result + indent;
}
return result;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public abstract class BaseIngestHelper extends AbstractIngestHelper implements C
public static final String FIELD_CONFIG_FILE = ".data.category.field.config.file";

private static final String PROPERTY_MALFORMED = " property malformed: ";
private static final String ADDED_NORMALIZED_FIELD = "added normalized field ";
private static final String TO_VALUES = " to values ";

private static final Logger log = ThreadConfigurableLogger.getLogger(BaseIngestHelper.class);

Expand Down Expand Up @@ -749,9 +747,7 @@ public HashSet<NormalizedContentInterface> normalizeFieldValue(String fieldName,
value.setEventFieldValue(null);
}
values.add(value);
if (log.isDebugEnabled()) {
log.debug(ADDED_NORMALIZED_FIELD + value + " to values set.");
}
logNormalizedField(normalizedContent, values);
}
return values;
}
Expand Down Expand Up @@ -799,9 +795,7 @@ protected Set<NormalizedContentInterface> normalize(NormalizedContentInterface n
} else {
values.add(normalize(normalizedContent, dataType));
}
if (log.isDebugEnabled()) {
log.debug(ADDED_NORMALIZED_FIELD + normalizedContent + TO_VALUES + values);
}
logNormalizedField(normalizedContent, values);
}
return values;
}
Expand All @@ -816,9 +810,7 @@ protected Set<NormalizedContentInterface> normalize(NormalizedContentInterface n
HashSet<NormalizedContentInterface> values = new HashSet<>(dataTypes.size());
for (datawave.data.type.Type<?> dataType : dataTypes) {
values.add(normalizeFieldValue(normalizedContent, dataType));
if (log.isDebugEnabled()) {
log.debug(ADDED_NORMALIZED_FIELD + normalizedContent + TO_VALUES + values);
}
logNormalizedField(normalizedContent, values);
}
return values;
} else {
Expand All @@ -830,14 +822,18 @@ protected Set<NormalizedContentInterface> normalize(NormalizedContentInterface n
HashSet<NormalizedContentInterface> values = new HashSet<>(dataTypes.size());
for (datawave.data.type.Type<?> dataType : dataTypes) {
values.add(normalize(normalizedContent, dataType));
if (log.isDebugEnabled()) {
log.debug(ADDED_NORMALIZED_FIELD + normalizedContent + TO_VALUES + values);
}
logNormalizedField(normalizedContent, values);
}
return values;
}
}

private void logNormalizedField(NormalizedContentInterface normalizedContent, HashSet<NormalizedContentInterface> values) {
if (log.isDebugEnabled()) {
log.debug("added normalized field " + normalizedContent + " to values " + values);
}
}

@Override
public boolean isNormalizedField(String fieldName) {
if (this.normalizedFields.contains(fieldName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,8 @@ public void testCleanUpJobDirectoryMakesDirectory() throws Exception {

try {
Whitebox.invokeMethod(FileSystem.class, "addFileSystemForTesting", BulkIngestMapFileLoaderTest.FILE_SYSTEM_URI, conf, fs);
} catch (IOException ioException) {
Assert.fail(ioException.getMessage());
} catch (Exception e) {
Assert.fail(e.getMessage());
}
Expand Down

0 comments on commit 77ba2d1

Please sign in to comment.