{"action":"created","comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/63058422","id":63058422,"diff_hunk":"@@ -117,54 +120,54 @@ protected FileInStream(URIStatus status, InStreamOptions options) {\n     mFileLength = status.getLength();\n     mContext = FileSystemContext.INSTANCE;\n     mAlluxioStorageType = options.getAlluxioStorageType();\n-    mShouldCacheCurrentBlock = mAlluxioStorageType.isStore();\n+    mShouldCache = mAlluxioStorageType.isStore();\n     mShouldCachePartiallyReadBlock = options.isCachePartiallyReadBlock();\n     mClosed = false;\n     mLocationPolicy = options.getLocationPolicy();\n-    if (mShouldCacheCurrentBlock) {\n+    if (mShouldCache) {\n       Preconditions.checkNotNull(options.getLocationPolicy(),\n           PreconditionMessage.FILE_WRITE_LOCATION_POLICY_UNSPECIFIED);\n     }\n-    mSingleByte = new byte[1];\n   }\n \n   @Override\n   public void close() throws IOException {\n     if (mClosed) {\n       return;\n     }\n-    if (mShouldCacheCurrentBlock && mShouldCachePartiallyReadBlock) {\n-      readCurrentBlockToPos(mFileLength);\n+    updateStreams();\n+    if (mCurrentCacheStream != null && mShouldCachePartiallyReadBlock) {\n+      readCurrentBlockToPos(Long.MAX_VALUE);\n     }\n     if (mCurrentBlockInStream != null) {\n       mCurrentBlockInStream.close();\n     }\n-    closeCacheStream();\n+    closeOrCancelCacheStream();\n     mClosed = true;\n   }\n \n   @Override\n   public int read() throws IOException {\n-    if (!validPosition(mPos)) {\n+    if (remaining() <= 0) {\n       return -1;\n     }\n+    updateStreams();\n+    Preconditions.checkState(mCurrentBlockInStream != null, \"Reached EOF unexpectedly.\");\n \n-    checkAndAdvanceBlockInStream();\n     int data = mCurrentBlockInStream.read();\n+\n+    // This should not happen?","path":"core/client/src/main/java/alluxio/client/file/FileInStream.java","position":107,"original_position":107,"commit_id":"10e1c4fce67eba698d82b87071167653cd8c0777","original_commit_id":"773ca7361887db411f79363136340e689c6c7039","user":{"login":"peisun1115","id":18294241,"avatar_url":"https://avatars.githubusercontent.com/u/18294241?v=3","gravatar_id":"","url":"https://api.github.com/users/peisun1115","html_url":"https://github.com/peisun1115","followers_url":"https://api.github.com/users/peisun1115/followers","following_url":"https://api.github.com/users/peisun1115/following{/other_user}","gists_url":"https://api.github.com/users/peisun1115/gists{/gist_id}","starred_url":"https://api.github.com/users/peisun1115/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peisun1115/subscriptions","organizations_url":"https://api.github.com/users/peisun1115/orgs","repos_url":"https://api.github.com/users/peisun1115/repos","events_url":"https://api.github.com/users/peisun1115/events{/privacy}","received_events_url":"https://api.github.com/users/peisun1115/received_events","type":"User","site_admin":false},"body":"That was more of a question. I don't know how this can happen when remaining() > 0 (or in the old version when mPos < mFileLength). I have removed it","created_at":"2016-05-12T17:07:18Z","updated_at":"2016-05-12T17:07:18Z","html_url":"https://github.com/Alluxio/alluxio/pull/3208#discussion_r63058422","pull_request_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208","_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/63058422"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/3208#discussion_r63058422"},"pull_request":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208"}}},"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208","id":69456834,"html_url":"https://github.com/Alluxio/alluxio/pull/3208","diff_url":"https://github.com/Alluxio/alluxio/pull/3208.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/3208.patch","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3208","number":3208,"state":"open","locked":false,"title":"[ALLUXIO-1942] Refactor FileInStream","user":{"login":"peisun1115","id":18294241,"avatar_url":"https://avatars.githubusercontent.com/u/18294241?v=3","gravatar_id":"","url":"https://api.github.com/users/peisun1115","html_url":"https://github.com/peisun1115","followers_url":"https://api.github.com/users/peisun1115/followers","following_url":"https://api.github.com/users/peisun1115/following{/other_user}","gists_url":"https://api.github.com/users/peisun1115/gists{/gist_id}","starred_url":"https://api.github.com/users/peisun1115/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peisun1115/subscriptions","organizations_url":"https://api.github.com/users/peisun1115/orgs","repos_url":"https://api.github.com/users/peisun1115/repos","events_url":"https://api.github.com/users/peisun1115/events{/privacy}","received_events_url":"https://api.github.com/users/peisun1115/received_events","type":"User","site_admin":false},"body":"Preparation PR to fix Parquet related bugs.\r\n\r\nThis PR also fixes some small bugs and simplifies logics in FileInStream and UnknownLengthFileInStream","created_at":"2016-05-10T06:54:27Z","updated_at":"2016-05-12T17:07:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc00a8d0b05a5ece1c1affacd374a1d03791412d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208/commits","review_comments_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208/comments","review_comment_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3208/comments","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/10e1c4fce67eba698d82b87071167653cd8c0777","head":{"label":"peisun1115:ParquetFix","ref":"ParquetFix","sha":"10e1c4fce67eba698d82b87071167653cd8c0777","user":{"login":"peisun1115","id":18294241,"avatar_url":"https://avatars.githubusercontent.com/u/18294241?v=3","gravatar_id":"","url":"https://api.github.com/users/peisun1115","html_url":"https://github.com/peisun1115","followers_url":"https://api.github.com/users/peisun1115/followers","following_url":"https://api.github.com/users/peisun1115/following{/other_user}","gists_url":"https://api.github.com/users/peisun1115/gists{/gist_id}","starred_url":"https://api.github.com/users/peisun1115/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peisun1115/subscriptions","organizations_url":"https://api.github.com/users/peisun1115/orgs","repos_url":"https://api.github.com/users/peisun1115/repos","events_url":"https://api.github.com/users/peisun1115/events{/privacy}","received_events_url":"https://api.github.com/users/peisun1115/received_events","type":"User","site_admin":false},"repo":{"id":55541423,"name":"alluxio","full_name":"peisun1115/alluxio","owner":{"login":"peisun1115","id":18294241,"avatar_url":"https://avatars.githubusercontent.com/u/18294241?v=3","gravatar_id":"","url":"https://api.github.com/users/peisun1115","html_url":"https://github.com/peisun1115","followers_url":"https://api.github.com/users/peisun1115/followers","following_url":"https://api.github.com/users/peisun1115/following{/other_user}","gists_url":"https://api.github.com/users/peisun1115/gists{/gist_id}","starred_url":"https://api.github.com/users/peisun1115/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peisun1115/subscriptions","organizations_url":"https://api.github.com/users/peisun1115/orgs","repos_url":"https://api.github.com/users/peisun1115/repos","events_url":"https://api.github.com/users/peisun1115/events{/privacy}","received_events_url":"https://api.github.com/users/peisun1115/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peisun1115/alluxio","description":"Memory-Speed Virtual Distributed Storage System","fork":true,"url":"https://api.github.com/repos/peisun1115/alluxio","forks_url":"https://api.github.com/repos/peisun1115/alluxio/forks","keys_url":"https://api.github.com/repos/peisun1115/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peisun1115/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peisun1115/alluxio/teams","hooks_url":"https://api.github.com/repos/peisun1115/alluxio/hooks","issue_events_url":"https://api.github.com/repos/peisun1115/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/peisun1115/alluxio/events","assignees_url":"https://api.github.com/repos/peisun1115/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/peisun1115/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/peisun1115/alluxio/tags","blobs_url":"https://api.github.com/repos/peisun1115/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peisun1115/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peisun1115/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/peisun1115/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peisun1115/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/peisun1115/alluxio/languages","stargazers_url":"https://api.github.com/repos/peisun1115/alluxio/stargazers","contributors_url":"https://api.github.com/repos/peisun1115/alluxio/contributors","subscribers_url":"https://api.github.com/repos/peisun1115/alluxio/subscribers","subscription_url":"https://api.github.com/repos/peisun1115/alluxio/subscription","commits_url":"https://api.github.com/repos/peisun1115/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/peisun1115/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/peisun1115/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/peisun1115/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/peisun1115/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/peisun1115/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peisun1115/alluxio/merges","archive_url":"https://api.github.com/repos/peisun1115/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peisun1115/alluxio/downloads","issues_url":"https://api.github.com/repos/peisun1115/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/peisun1115/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/peisun1115/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/peisun1115/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peisun1115/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/peisun1115/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/peisun1115/alluxio/deployments","created_at":"2016-04-05T20:01:18Z","updated_at":"2016-04-05T20:01:22Z","pushed_at":"2016-05-12T16:59:45Z","git_url":"git://github.com/peisun1115/alluxio.git","ssh_url":"git@github.com:peisun1115/alluxio.git","clone_url":"https://github.com/peisun1115/alluxio.git","svn_url":"https://github.com/peisun1115/alluxio","homepage":"http://www.alluxio.org/","size":49480,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Alluxio:master","ref":"master","sha":"769a82f30c36c1248f515fe57a211c65fe29d700","user":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"alluxio","full_name":"Alluxio/alluxio","owner":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Alluxio/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":false,"url":"https://api.github.com/repos/Alluxio/alluxio","forks_url":"https://api.github.com/repos/Alluxio/alluxio/forks","keys_url":"https://api.github.com/repos/Alluxio/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alluxio/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alluxio/alluxio/teams","hooks_url":"https://api.github.com/repos/Alluxio/alluxio/hooks","issue_events_url":"https://api.github.com/repos/Alluxio/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/Alluxio/alluxio/events","assignees_url":"https://api.github.com/repos/Alluxio/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/Alluxio/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/Alluxio/alluxio/tags","blobs_url":"https://api.github.com/repos/Alluxio/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alluxio/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alluxio/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alluxio/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/Alluxio/alluxio/languages","stargazers_url":"https://api.github.com/repos/Alluxio/alluxio/stargazers","contributors_url":"https://api.github.com/repos/Alluxio/alluxio/contributors","subscribers_url":"https://api.github.com/repos/Alluxio/alluxio/subscribers","subscription_url":"https://api.github.com/repos/Alluxio/alluxio/subscription","commits_url":"https://api.github.com/repos/Alluxio/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alluxio/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alluxio/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Alluxio/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/Alluxio/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alluxio/alluxio/merges","archive_url":"https://api.github.com/repos/Alluxio/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alluxio/alluxio/downloads","issues_url":"https://api.github.com/repos/Alluxio/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/Alluxio/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/Alluxio/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/Alluxio/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alluxio/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/Alluxio/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/Alluxio/alluxio/deployments","created_at":"2012-12-21T17:43:46Z","updated_at":"2016-05-11T14:10:44Z","pushed_at":"2016-05-12T16:40:23Z","git_url":"git://github.com/Alluxio/alluxio.git","ssh_url":"git@github.com:Alluxio/alluxio.git","clone_url":"https://github.com/Alluxio/alluxio.git","svn_url":"https://github.com/Alluxio/alluxio","homepage":"http://www.alluxio.org/","size":80761,"stargazers_count":2332,"watchers_count":2332,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":918,"mirror_url":null,"open_issues_count":30,"forks":918,"open_issues":30,"watchers":2332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/3208"},"issue":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/3208"},"comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/3208/comments"},"review_comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208/comments"},"review_comment":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3208/commits"},"statuses":{"href":"https://api.github.com/repos/Alluxio/alluxio/statuses/10e1c4fce67eba698d82b87071167653cd8c0777"}}}}