{"action":"created","comment":{"url":"https://api.github.com/repos/apache/nifi/pulls/comments/87826799","pull_request_review_id":8422195,"id":87826799,"diff_hunk":"@@ -0,0 +1,281 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.nifi.provenance.serialization;\n+\n+import java.io.DataInputStream;\n+import java.io.EOFException;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.nio.charset.StandardCharsets;\n+import java.util.zip.GZIPInputStream;\n+\n+import org.apache.nifi.provenance.ProvenanceEventRecord;\n+import org.apache.nifi.provenance.StandardProvenanceEventRecord;\n+import org.apache.nifi.provenance.StandardRecordReader;\n+import org.apache.nifi.provenance.toc.TocReader;\n+import org.apache.nifi.stream.io.BufferedInputStream;\n+import org.apache.nifi.stream.io.ByteCountingInputStream;\n+import org.apache.nifi.stream.io.LimitingInputStream;\n+import org.apache.nifi.stream.io.StreamUtils;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+public abstract class CompressableRecordReader implements RecordReader {\n+    private static final Logger logger = LoggerFactory.getLogger(StandardRecordReader.class);\n+\n+    private final ByteCountingInputStream rawInputStream;\n+    private final String filename;\n+    private final int serializationVersion;\n+    private final boolean compressed;\n+    private final TocReader tocReader;\n+    private final int headerLength;\n+    private final int maxAttributeChars;\n+\n+    private DataInputStream dis;\n+    private ByteCountingInputStream byteCountingIn;\n+\n+    public CompressableRecordReader(final InputStream in, final String filename, final int maxAttributeChars) throws IOException {\n+        this(in, filename, null, maxAttributeChars);\n+    }\n+\n+    public CompressableRecordReader(final InputStream in, final String filename, final TocReader tocReader, final int maxAttributeChars) throws IOException {\n+        logger.trace(\"Creating RecordReader for {}\", filename);\n+\n+        rawInputStream = new ByteCountingInputStream(in);\n+        this.maxAttributeChars = maxAttributeChars;\n+\n+        final InputStream limitedStream;\n+        if (tocReader == null) {\n+            limitedStream = rawInputStream;\n+        } else {\n+            final long offset1 = tocReader.getBlockOffset(1);\n+            if (offset1 < 0) {\n+                limitedStream = rawInputStream;\n+            } else {\n+                limitedStream = new LimitingInputStream(rawInputStream, offset1 - rawInputStream.getBytesConsumed());\n+            }\n+        }\n+\n+        final InputStream readableStream;\n+        if (filename.endsWith(\".gz\")) {\n+            readableStream = new BufferedInputStream(new GZIPInputStream(limitedStream));\n+            compressed = true;\n+        } else {\n+            readableStream = new BufferedInputStream(limitedStream);\n+            compressed = false;\n+        }\n+\n+        byteCountingIn = new ByteCountingInputStream(readableStream);\n+        dis = new DataInputStream(byteCountingIn);\n+\n+        final String repoClassName = dis.readUTF();\n+        final int serializationVersion = dis.readInt();\n+        headerLength = repoClassName.getBytes(StandardCharsets.UTF_8).length + 2 + 4; // 2 bytes for string length, 4 for integer.\n+\n+        if (serializationVersion < 1 || serializationVersion > 9) {\n+            throw new IllegalArgumentException(\"Unable to deserialize record because the version is \" + serializationVersion + \" and supported versions are 1-9\");","path":"nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/CompressableRecordReader.java","position":91,"original_position":91,"commit_id":"153c1e8734371758f990a76284f0bcf113a403cc","original_commit_id":"153c1e8734371758f990a76284f0bcf113a403cc","user":{"login":"markap14","id":184268,"avatar_url":"https://avatars.githubusercontent.com/u/184268?v=3","gravatar_id":"","url":"https://api.github.com/users/markap14","html_url":"https://github.com/markap14","followers_url":"https://api.github.com/users/markap14/followers","following_url":"https://api.github.com/users/markap14/following{/other_user}","gists_url":"https://api.github.com/users/markap14/gists{/gist_id}","starred_url":"https://api.github.com/users/markap14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markap14/subscriptions","organizations_url":"https://api.github.com/users/markap14/orgs","repos_url":"https://api.github.com/users/markap14/repos","events_url":"https://api.github.com/users/markap14/events{/privacy}","received_events_url":"https://api.github.com/users/markap14/received_events","type":"User","site_admin":false},"body":"Really, this logic shouldn't exist at all. The version is really local to the specific reader/writer being used. Will move it there.","created_at":"2016-11-14T15:47:08Z","updated_at":"2016-11-14T15:47:08Z","html_url":"https://github.com/apache/nifi/pull/1202#discussion_r87826799","pull_request_url":"https://api.github.com/repos/apache/nifi/pulls/1202","_links":{"self":{"href":"https://api.github.com/repos/apache/nifi/pulls/comments/87826799"},"html":{"href":"https://github.com/apache/nifi/pull/1202#discussion_r87826799"},"pull_request":{"href":"https://api.github.com/repos/apache/nifi/pulls/1202"}}},"pull_request":{"url":"https://api.github.com/repos/apache/nifi/pulls/1202","id":93207422,"html_url":"https://github.com/apache/nifi/pull/1202","diff_url":"https://github.com/apache/nifi/pull/1202.diff","patch_url":"https://github.com/apache/nifi/pull/1202.patch","issue_url":"https://api.github.com/repos/apache/nifi/issues/1202","number":1202,"state":"open","locked":false,"title":"NIFI-2854: Refactor repositories and swap files to use schema-based s…","user":{"login":"markap14","id":184268,"avatar_url":"https://avatars.githubusercontent.com/u/184268?v=3","gravatar_id":"","url":"https://api.github.com/users/markap14","html_url":"https://github.com/markap14","followers_url":"https://api.github.com/users/markap14/followers","following_url":"https://api.github.com/users/markap14/following{/other_user}","gists_url":"https://api.github.com/users/markap14/gists{/gist_id}","starred_url":"https://api.github.com/users/markap14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markap14/subscriptions","organizations_url":"https://api.github.com/users/markap14/orgs","repos_url":"https://api.github.com/users/markap14/repos","events_url":"https://api.github.com/users/markap14/events{/privacy}","received_events_url":"https://api.github.com/users/markap14/received_events","type":"User","site_admin":false},"body":"Thank you for submitting a contribution to Apache NiFi.\r\n\r\nIn order to streamline the review of the contribution we ask you\r\nto ensure the following steps have been taken:\r\n\r\n### For all changes:\r\n- [ ] Is there a JIRA ticket associated with this PR? Is it referenced \r\n     in the commit message?\r\n\r\n- [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen \"-\" character.\r\n\r\n- [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?\r\n\r\n- [ ] Is your initial contribution a single, squashed commit?\r\n\r\n### For code changes:\r\n- [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?\r\n- [ ] Have you written or updated unit tests to verify your changes?\r\n- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? \r\n- [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?\r\n- [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?\r\n- [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?\r\n\r\n### For documentation related changes:\r\n- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?\r\n\r\n### Note:\r\nPlease ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.\r\n\r\n…erialization so that nifi can be rolled back to a previous version after an upgrade.","created_at":"2016-11-10T18:45:00Z","updated_at":"2016-11-14T15:47:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f32f3ea9722e8aecd2573e6ad034a90cb6d0fdb4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/nifi/pulls/1202/commits","review_comments_url":"https://api.github.com/repos/apache/nifi/pulls/1202/comments","review_comment_url":"https://api.github.com/repos/apache/nifi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/nifi/issues/1202/comments","statuses_url":"https://api.github.com/repos/apache/nifi/statuses/153c1e8734371758f990a76284f0bcf113a403cc","head":{"label":"markap14:NIFI-2854","ref":"NIFI-2854","sha":"153c1e8734371758f990a76284f0bcf113a403cc","user":{"login":"markap14","id":184268,"avatar_url":"https://avatars.githubusercontent.com/u/184268?v=3","gravatar_id":"","url":"https://api.github.com/users/markap14","html_url":"https://github.com/markap14","followers_url":"https://api.github.com/users/markap14/followers","following_url":"https://api.github.com/users/markap14/following{/other_user}","gists_url":"https://api.github.com/users/markap14/gists{/gist_id}","starred_url":"https://api.github.com/users/markap14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markap14/subscriptions","organizations_url":"https://api.github.com/users/markap14/orgs","repos_url":"https://api.github.com/users/markap14/repos","events_url":"https://api.github.com/users/markap14/events{/privacy}","received_events_url":"https://api.github.com/users/markap14/received_events","type":"User","site_admin":false},"repo":{"id":52380182,"name":"nifi","full_name":"markap14/nifi","owner":{"login":"markap14","id":184268,"avatar_url":"https://avatars.githubusercontent.com/u/184268?v=3","gravatar_id":"","url":"https://api.github.com/users/markap14","html_url":"https://github.com/markap14","followers_url":"https://api.github.com/users/markap14/followers","following_url":"https://api.github.com/users/markap14/following{/other_user}","gists_url":"https://api.github.com/users/markap14/gists{/gist_id}","starred_url":"https://api.github.com/users/markap14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markap14/subscriptions","organizations_url":"https://api.github.com/users/markap14/orgs","repos_url":"https://api.github.com/users/markap14/repos","events_url":"https://api.github.com/users/markap14/events{/privacy}","received_events_url":"https://api.github.com/users/markap14/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markap14/nifi","description":"Mirror of Apache NiFi","fork":true,"url":"https://api.github.com/repos/markap14/nifi","forks_url":"https://api.github.com/repos/markap14/nifi/forks","keys_url":"https://api.github.com/repos/markap14/nifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markap14/nifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markap14/nifi/teams","hooks_url":"https://api.github.com/repos/markap14/nifi/hooks","issue_events_url":"https://api.github.com/repos/markap14/nifi/issues/events{/number}","events_url":"https://api.github.com/repos/markap14/nifi/events","assignees_url":"https://api.github.com/repos/markap14/nifi/assignees{/user}","branches_url":"https://api.github.com/repos/markap14/nifi/branches{/branch}","tags_url":"https://api.github.com/repos/markap14/nifi/tags","blobs_url":"https://api.github.com/repos/markap14/nifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markap14/nifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markap14/nifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/markap14/nifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markap14/nifi/statuses/{sha}","languages_url":"https://api.github.com/repos/markap14/nifi/languages","stargazers_url":"https://api.github.com/repos/markap14/nifi/stargazers","contributors_url":"https://api.github.com/repos/markap14/nifi/contributors","subscribers_url":"https://api.github.com/repos/markap14/nifi/subscribers","subscription_url":"https://api.github.com/repos/markap14/nifi/subscription","commits_url":"https://api.github.com/repos/markap14/nifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/markap14/nifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/markap14/nifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/markap14/nifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/markap14/nifi/contents/{+path}","compare_url":"https://api.github.com/repos/markap14/nifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markap14/nifi/merges","archive_url":"https://api.github.com/repos/markap14/nifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markap14/nifi/downloads","issues_url":"https://api.github.com/repos/markap14/nifi/issues{/number}","pulls_url":"https://api.github.com/repos/markap14/nifi/pulls{/number}","milestones_url":"https://api.github.com/repos/markap14/nifi/milestones{/number}","notifications_url":"https://api.github.com/repos/markap14/nifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markap14/nifi/labels{/name}","releases_url":"https://api.github.com/repos/markap14/nifi/releases{/id}","deployments_url":"https://api.github.com/repos/markap14/nifi/deployments","created_at":"2016-02-23T18:02:12Z","updated_at":"2016-02-23T18:02:23Z","pushed_at":"2016-11-11T16:19:57Z","git_url":"git://github.com/markap14/nifi.git","ssh_url":"git@github.com:markap14/nifi.git","clone_url":"https://github.com/markap14/nifi.git","svn_url":"https://github.com/markap14/nifi","homepage":"","size":67828,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"f83863ebae700ade07aa8b93ac1e2d82a6cf053c","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":27911088,"name":"nifi","full_name":"apache/nifi","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/nifi","description":"Mirror of Apache NiFi","fork":false,"url":"https://api.github.com/repos/apache/nifi","forks_url":"https://api.github.com/repos/apache/nifi/forks","keys_url":"https://api.github.com/repos/apache/nifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/nifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/nifi/teams","hooks_url":"https://api.github.com/repos/apache/nifi/hooks","issue_events_url":"https://api.github.com/repos/apache/nifi/issues/events{/number}","events_url":"https://api.github.com/repos/apache/nifi/events","assignees_url":"https://api.github.com/repos/apache/nifi/assignees{/user}","branches_url":"https://api.github.com/repos/apache/nifi/branches{/branch}","tags_url":"https://api.github.com/repos/apache/nifi/tags","blobs_url":"https://api.github.com/repos/apache/nifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/nifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/nifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/nifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/nifi/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/nifi/languages","stargazers_url":"https://api.github.com/repos/apache/nifi/stargazers","contributors_url":"https://api.github.com/repos/apache/nifi/contributors","subscribers_url":"https://api.github.com/repos/apache/nifi/subscribers","subscription_url":"https://api.github.com/repos/apache/nifi/subscription","commits_url":"https://api.github.com/repos/apache/nifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/nifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/nifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/nifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/nifi/contents/{+path}","compare_url":"https://api.github.com/repos/apache/nifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/nifi/merges","archive_url":"https://api.github.com/repos/apache/nifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/nifi/downloads","issues_url":"https://api.github.com/repos/apache/nifi/issues{/number}","pulls_url":"https://api.github.com/repos/apache/nifi/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/nifi/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/nifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/nifi/labels{/name}","releases_url":"https://api.github.com/repos/apache/nifi/releases{/id}","deployments_url":"https://api.github.com/repos/apache/nifi/deployments","created_at":"2014-12-12T08:00:05Z","updated_at":"2016-11-13T22:06:12Z","pushed_at":"2016-11-14T15:34:13Z","git_url":"git://github.com/apache/nifi.git","ssh_url":"git@github.com:apache/nifi.git","clone_url":"https://github.com/apache/nifi.git","svn_url":"https://github.com/apache/nifi","homepage":"","size":95475,"stargazers_count":397,"watchers_count":397,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":356,"mirror_url":"git://git.apache.org/nifi.git","open_issues_count":63,"forks":356,"open_issues":63,"watchers":397,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/nifi/pulls/1202"},"html":{"href":"https://github.com/apache/nifi/pull/1202"},"issue":{"href":"https://api.github.com/repos/apache/nifi/issues/1202"},"comments":{"href":"https://api.github.com/repos/apache/nifi/issues/1202/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/nifi/pulls/1202/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/nifi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/nifi/pulls/1202/commits"},"statuses":{"href":"https://api.github.com/repos/apache/nifi/statuses/153c1e8734371758f990a76284f0bcf113a403cc"}}}}
{"actor":{"display_login":"markap14"}}