Skip to content

Commit

Permalink
Fixed #127 Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
baubakg committed Jun 19, 2024
1 parent 55b6459 commit 0e383fb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,24 @@ LogData<GenericEntry> l_myGroupedData = logData.groupBy(Arrays.asList("Definitio

In this case we get :

Definition 4 | Frequence
------------ | ------------
AA | 2
AAA | 1
| Definition 4 | Frequence |
| ------------ |-----------|
| AA | 2 |
| AAA | 1 |

### Comparing Log Data
As of version 1.11.0 we have introduced the possibility to compare two LogData objects. This is a light compare that checks that for a given key, if it is absent, added or changes in frequency. The method `compare` returns a `LogDataComparison` object that contains the results of the comparison. A comparison can be of three types:
* Added : The entry has been added
* Removed : The entry has been removed
* Changed : The entry has changed in frequency

Apart from this we return the :
* delta : The difference in frequency
* deltaRatio : The difference in frequency as a ratio

These values are negative if the values have decreased.

```java

## Assertions and LogDataAssertions
As of version 1.0.5 we have introduced the notion of assertions. Assertions can either take a LogData object or a set of files as input.
Expand All @@ -277,9 +291,10 @@ We now have the possibility to export the log data results into a CSV file. The
## Release Notes

### 1.11.0 (next version)
- (new feature) [#127](https://github.com/adobe/log-parser/issues/127) You can now compare two LogData Objects. This is a light compare that checks that for a given key, if it is absent, added or changes in frequency.
- (new feature) [#117](https://github.com/adobe/log-parser/issues/117) You can now include the file name in the result of the analysis.
- (new feature) [#123](https://github.com/adobe/log-parser/issues/123) We now log the total number and size of the parsed files.
- [#110](https://github.com/adobe/log-parser/issues/110) Moved to Java 11
- [#117](https://github.com/adobe/log-parser/issues/117) You can now include the file name in the result of the analysis.
- [#123](https://github.com/adobe/log-parser/issues/123) We now log the total number and size of the parsed files.
- [#112](https://github.com/adobe/log-parser/issues/112) Updating License Headers
- [#119](https://github.com/adobe/log-parser/issues/119) Cleanup of deprecated methods, and the consequences thereof.

Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,25 @@ public File exportLogDataToCSV(Set<String> in_headerSet, String in_csvFileName)
return new File(in_csvFileName);
}

/**
* This method compares two LogData objects and returns the differences. The difference is map of
* LogDataComparisons. The values of the delta and the deltaRatio are negative if the frequency is decreasing or has
* been removed.
*
* @param in_logData A LogData
* @return A Map of LogDataComparisons containing the differences
*/
public Map<String, LogDataComparison> compare(LogData<T> in_logData) {
Map<String, LogDataComparison> lr_diff = new HashMap<>();


for (String lt_key : this.getEntries().keySet()) {
if (!in_logData.getEntries().containsKey(lt_key)) {
lr_diff.put(lt_key,new LogDataComparison(this.get(lt_key), LogDataComparison.ChangeType.REMOVED,
this.get(lt_key).getFrequence(),0));
} else if (in_logData.get(lt_key).getFrequence() != this.get(lt_key).getFrequence()) {
lr_diff.put(lt_key, new LogDataComparison(this.get(lt_key), LogDataComparison.ChangeType.REMOVED,
this.get(lt_key).getFrequence(), 0));
} else if (in_logData.get(lt_key).getFrequence() != this.get(lt_key).getFrequence()) {

lr_diff.put(lt_key, new LogDataComparison(in_logData.get(lt_key), LogDataComparison.ChangeType.MODIFIED,
this.get(lt_key).getFrequence(),in_logData.get(lt_key).getFrequence()));
this.get(lt_key).getFrequence(), in_logData.get(lt_key).getFrequence()));
}
}

Expand Down

0 comments on commit 0e383fb

Please sign in to comment.