Skip to content

Commit cd75424

Browse files
authored
Merge pull request #4840 from gchq/gh-4839
#4839 Change record count filter to allow counting of records at a cu…
2 parents b8e4068 + afc31e3 commit cd75424

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ DO NOT ADD CHANGES HERE - ADD THEM USING log_change.sh
1919

2020
* Issue **#4827** : Fix NPE when opening the Nodes screen.
2121

22-
*
23-
2422

2523
## [v7.9-beta.3] - 2025-03-24
2624

stroom-pipeline/src/main/java/stroom/pipeline/filter/RecordCountFilter.java

+22-15
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,21 @@ public class RecordCountFilter extends AbstractXMLFilter {
5252
private static final Logger LOGGER = LoggerFactory.getLogger(RecordCountFilter.class);
5353
private static final int LOG_COUNT = 10000;
5454

55+
/**
56+
* The default depth of records. Set to 2 as we normally count second
57+
* level elements.
58+
*/
59+
private static final int DEFAULT_RECORD_DEPTH = 2;
60+
5561
private final RecordCountService recordCountService;
5662
private final RecordCount recordCount;
5763

64+
/**
65+
* This defines the depth at which to count records. It is zero based (root
66+
* element = 0).
67+
*/
68+
private int recordDepth = DEFAULT_RECORD_DEPTH;
69+
5870
private boolean countRead = true;
5971
private int depth = 0;
6072
private long logCounter = 0;
@@ -77,7 +89,6 @@ public RecordCountFilter(final RecordCountService recordCountService,
7789
public void startProcessing() {
7890
try {
7991
recordCount.setStartMs(System.currentTimeMillis());
80-
// if (recordCount != null && recordCountService != null) {
8192
if (countRead) {
8293
incrementor = () -> {
8394
recordCount.getReadIncrementor().increment();
@@ -89,19 +100,6 @@ public void startProcessing() {
89100
recordCountService.getWriteIncrementor().increment();
90101
};
91102
}
92-
// } else if (recordCount != null) {
93-
// if (countRead) {
94-
// incrementor = recordCount.getReadIncrementor();
95-
// } else {
96-
// incrementor = recordCount.getWriteIncrementor();
97-
// }
98-
// } else if (recordCountService != null) {
99-
// if (countRead) {
100-
// incrementor = recordCountService.getReadIncrementor();
101-
// } else {
102-
// incrementor = recordCountService.getWriteIncrementor();
103-
// }
104-
// }
105103
} finally {
106104
super.startProcessing();
107105
}
@@ -158,7 +156,7 @@ public void startElement(final String uri, final String localName, final String
158156

159157
depth++;
160158

161-
if (depth == 2) {
159+
if (depth == recordDepth) {
162160
// This is a first level element.
163161
incrementor.increment();
164162

@@ -203,4 +201,13 @@ public void endElement(final String uri, final String localName, final String qN
203201
public void setCountRead(final boolean countRead) {
204202
this.countRead = countRead;
205203
}
204+
205+
@PipelineProperty(
206+
description = "The depth of XML elements to count records.",
207+
defaultValue = "1",
208+
displayPriority = 2)
209+
public void setRecordDepth(final int recordDepth) {
210+
// Add a fudge in here to cope with legacy depth being 0 based.
211+
this.recordDepth = recordDepth + 1;
212+
}
206213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#4839** : Change record count filter to allow counting of records at a custom depth to match split filter.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: Split depth during stepping is always `1`
7+
# Issue link: https://github.com/gchq/stroom/issues/2334
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)