NissimShiman commented on code in PR #5878:
URL: https://github.com/apache/nifi/pull/5878#discussion_r901833913
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SampleRecord.java:
##########
@@ -332,6 +383,86 @@ public WriteResult finish() throws IOException {
}
}
+ static class RangeSamplingStrategy implements SamplingStrategy {
+
+ final RecordSetWriter writer;
+ final String rangeExpression;
+ int currentCount = 1;
+ final List<Range<Integer>> ranges = new ArrayList<>();
+
+ RangeSamplingStrategy(final RecordSetWriter writer, final String
rangeExpression) {
+ this.writer = writer;
+ this.rangeExpression = rangeExpression;
+ }
+
+ @Override
+ public void init() throws IOException {
+ currentCount = 1;
+ ranges.clear();
+ writer.beginRecordSet();
+ Matcher validateRangeExpression =
RANGE_PATTERN.matcher(rangeExpression);
+ if (!validateRangeExpression.matches()) {
+ throw new IOException(rangeExpression + " is not a valid range
expression");
+ }
+ Integer startRange, endRange;
+ if (StringUtils.isEmpty(rangeExpression)) {
+ startRange = 0;
+ endRange = Integer.MAX_VALUE;
+ ranges.add(Range.between(startRange, endRange));
Review Comment:
If range is purposefully set to blank then including everything. (i.e.
defaulting to letting everything through as opposed to nothing through). Makes
sense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]