Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/135#discussion_r50328396
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitText.java
 ---
    @@ -198,23 +208,53 @@ private long countBytesToSplitPoint(final InputStream 
in, final OutputStream out
                     return includeLineDelimiter ? bytesRead : bytesRead - 1;
                 }
     
    -            // keep track of what the last byte was that we read so that 
we can detect \r followed by some other
    +            // keep track of what the last byte was that we read so that 
we can
    +            // detect \r followed by some other
                 // character.
                 lastByte = nextByte;
             }
         }
     
    -    private SplitInfo countBytesToSplitPoint(final InputStream in, final 
int numLines, final boolean keepAllNewLines) throws IOException {
    +    private SplitInfo readHeader(final int numHeaderLines,
    +                                 final String headerMarker, final 
InputStream in,
    +                                 final OutputStream out, final boolean 
keepAllNewLines)
    +                                throws IOException {
             SplitInfo info = new SplitInfo();
    -
    -        while (info.lengthLines < numLines) {
    -            final long bytesTillNext = countBytesToSplitPoint(in, null, 
keepAllNewLines || (info.lengthLines != numLines - 1));
    -            if (bytesTillNext <= 0L) {
    -                break;
    +        boolean isHeaderLine = true;
    +
    +        // Read numHeaderLines from file, if specificed; a non-zero value 
takes precedence
    +        // over headerMarker character string
    +        if (numHeaderLines > 0) {
    +            for (int i = 0; i < numHeaderLines; i++) {
    +                int bytesRead = readLine(in, out, keepAllNewLines);
    +                if (bytesRead == 0) {
    +                    break;
    +                }
    +                info.lengthBytes += bytesRead;
    +                info.lengthLines++;
    +            }
    +        // Else, keep reading all lines that begin with headerMarker 
character string
    +        } else if (headerMarker != null) {
    +            while (true) {
    +                in.mark(0);
    --- End diff --
    
    This call to in.mark(0) means that when in.reset() is called, we will reset 
back 0 bytes, essentially making the mark/reset do nothing. Not sure that I am 
following the logic here with how the mark/reset are being used.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to