{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/presto/pulls/comments/33979305","id":33979305,"diff_hunk":"@@ -0,0 +1,211 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * 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+package com.facebook.presto.spi.block;\n+\n+import io.airlift.slice.Slice;\n+\n+public abstract class AbstractArrayElementBlock\n+        implements Block\n+{\n+    protected final int start;\n+\n+    protected AbstractArrayElementBlock(int start)\n+    {\n+        this.start = start;\n+    }\n+\n+    int getStart()\n+    {\n+        return start;\n+    }\n+\n+    protected abstract BlockBuilder getBlock();\n+\n+    private void checkReadablePosition(int position)\n+    {\n+        if (position < 0 || position >= getPositionCount()) {\n+            throw new IllegalArgumentException(\"position is not valid\");\n+        }\n+    }\n+\n+    @Override\n+    public int getLength(int position)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getLength(position + start);\n+    }\n+\n+    @Override\n+    public byte getByte(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getByte(position + start, offset);\n+    }\n+\n+    @Override\n+    public short getShort(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getShort(position + start, offset);\n+    }\n+\n+    @Override\n+    public int getInt(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getInt(position + start, offset);\n+    }\n+\n+    @Override\n+    public long getLong(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getLong(position + start, offset);\n+    }\n+\n+    @Override\n+    public float getFloat(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getFloat(position + start, offset);\n+    }\n+\n+    @Override\n+    public double getDouble(int position, int offset)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getDouble(position + start, offset);\n+    }\n+\n+    @Override\n+    public Slice getSlice(int position, int offset, int length)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getSlice(position + start, offset, length);\n+    }\n+\n+    @Override\n+    public <T> T getObject(int position, Class<T> clazz)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().getObject(position + start, clazz);\n+    }\n+\n+    @Override\n+    public boolean bytesEqual(int position, int offset, Slice otherSlice, int otherOffset, int length)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().bytesEqual(position + start, offset, otherSlice, otherOffset, length);\n+    }\n+\n+    @Override\n+    public int bytesCompare(int position, int offset, int length, Slice otherSlice, int otherOffset, int otherLength)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().bytesCompare(position + start, offset, length, otherSlice, otherOffset, otherLength);\n+    }\n+\n+    @Override\n+    public void writeBytesTo(int position, int offset, int length, BlockBuilder blockBuilder)\n+    {\n+        checkReadablePosition(position);\n+        getBlock().writeBytesTo(position + start, offset, length, blockBuilder);\n+    }\n+\n+    @Override\n+    public void writePositionTo(int position, BlockBuilder blockBuilder)\n+    {\n+        checkReadablePosition(position);\n+        getBlock().writePositionTo(position + start, blockBuilder);\n+    }\n+\n+    @Override\n+    public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().equals(position + start, offset, otherBlock, otherPosition, otherOffset, length);\n+    }\n+\n+    @Override\n+    public int hash(int position, int offset, int length)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().hash(position + start, offset, length);\n+    }\n+\n+    @Override\n+    public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)\n+    {\n+        checkReadablePosition(leftPosition);\n+        return getBlock().compareTo(leftPosition + start, leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);\n+    }\n+\n+    @Override\n+    public Block getSingleValueBlock(int position)\n+    {\n+        return getRegion(position, 1, true);\n+    }\n+\n+    @Override\n+    public boolean isNull(int position)\n+    {\n+        checkReadablePosition(position);\n+        return getBlock().isNull(position + start);\n+    }\n+\n+    @Override\n+    public void assureLoaded()\n+    {\n+    }\n+\n+    @Override\n+    public BlockEncoding getEncoding()\n+    {\n+        // ArrayElementBlock does not exist\n+        throw new UnsupportedOperationException();\n+    }\n+\n+    @Override\n+    public Block getRegion(int position, int length)\n+    {\n+        return getRegion(position, length, false);\n+    }\n+\n+    @Override\n+    public Block copyRegion(int position, int length)\n+    {\n+        return getRegion(position, length, true);\n+    }\n+\n+    private Block getRegion(int position, int length, boolean compact)","path":"presto-spi/src/main/java/com/facebook/presto/spi/block/AbstractArrayElementBlock.java","position":191,"original_position":191,"commit_id":"558bb9cd4f591bbffe3c13fcbb647b37f8ab01a1","original_commit_id":"558bb9cd4f591bbffe3c13fcbb647b37f8ab01a1","user":{"login":"cberner","id":842688,"avatar_url":"https://avatars.githubusercontent.com/u/842688?v=3","gravatar_id":"","url":"https://api.github.com/users/cberner","html_url":"https://github.com/cberner","followers_url":"https://api.github.com/users/cberner/followers","following_url":"https://api.github.com/users/cberner/following{/other_user}","gists_url":"https://api.github.com/users/cberner/gists{/gist_id}","starred_url":"https://api.github.com/users/cberner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cberner/subscriptions","organizations_url":"https://api.github.com/users/cberner/orgs","repos_url":"https://api.github.com/users/cberner/repos","events_url":"https://api.github.com/users/cberner/events{/privacy}","received_events_url":"https://api.github.com/users/cberner/received_events","type":"User","site_admin":false},"body":"inline this method, since it just throws and exception. You can remove the comment too","created_at":"2015-07-06T20:38:00Z","updated_at":"2015-07-06T20:38:00Z","html_url":"https://github.com/facebook/presto/pull/2912#discussion_r33979305","pull_request_url":"https://api.github.com/repos/facebook/presto/pulls/2912","_links":{"self":{"href":"https://api.github.com/repos/facebook/presto/pulls/comments/33979305"},"html":{"href":"https://github.com/facebook/presto/pull/2912#discussion_r33979305"},"pull_request":{"href":"https://api.github.com/repos/facebook/presto/pulls/2912"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/presto/pulls/2912","id":35282517,"html_url":"https://github.com/facebook/presto/pull/2912","diff_url":"https://github.com/facebook/presto/pull/2912.diff","patch_url":"https://github.com/facebook/presto/pull/2912.patch","issue_url":"https://api.github.com/repos/facebook/presto/issues/2912","number":2912,"state":"open","locked":false,"title":"Add new Blocks for structural types","user":{"login":"haozhun","id":2020503,"avatar_url":"https://avatars.githubusercontent.com/u/2020503?v=3","gravatar_id":"","url":"https://api.github.com/users/haozhun","html_url":"https://github.com/haozhun","followers_url":"https://api.github.com/users/haozhun/followers","following_url":"https://api.github.com/users/haozhun/following{/other_user}","gists_url":"https://api.github.com/users/haozhun/gists{/gist_id}","starred_url":"https://api.github.com/users/haozhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haozhun/subscriptions","organizations_url":"https://api.github.com/users/haozhun/orgs","repos_url":"https://api.github.com/users/haozhun/repos","events_url":"https://api.github.com/users/haozhun/events{/privacy}","received_events_url":"https://api.github.com/users/haozhun/received_events","type":"User","site_admin":false},"body":"Depends on ~~#2910~~ ~~#3148~~\r\n\r\nAdd ArrayBlock, InterleavedBlock, ArrayBlockBuilder, InterleavedBlockBuilder, ArrayElementBlockWriter,\r\nLazyArrayBlock","created_at":"2015-05-12T23:50:17Z","updated_at":"2015-07-06T20:38:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c7dccc1080ca965d6a99a60a15623146fcc1c87","assignee":{"login":"cberner","id":842688,"avatar_url":"https://avatars.githubusercontent.com/u/842688?v=3","gravatar_id":"","url":"https://api.github.com/users/cberner","html_url":"https://github.com/cberner","followers_url":"https://api.github.com/users/cberner/followers","following_url":"https://api.github.com/users/cberner/following{/other_user}","gists_url":"https://api.github.com/users/cberner/gists{/gist_id}","starred_url":"https://api.github.com/users/cberner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cberner/subscriptions","organizations_url":"https://api.github.com/users/cberner/orgs","repos_url":"https://api.github.com/users/cberner/repos","events_url":"https://api.github.com/users/cberner/events{/privacy}","received_events_url":"https://api.github.com/users/cberner/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/facebook/presto/pulls/2912/commits","review_comments_url":"https://api.github.com/repos/facebook/presto/pulls/2912/comments","review_comment_url":"https://api.github.com/repos/facebook/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/presto/issues/2912/comments","statuses_url":"https://api.github.com/repos/facebook/presto/statuses/558bb9cd4f591bbffe3c13fcbb647b37f8ab01a1","head":{"label":"haozhun:block","ref":"block","sha":"558bb9cd4f591bbffe3c13fcbb647b37f8ab01a1","user":{"login":"haozhun","id":2020503,"avatar_url":"https://avatars.githubusercontent.com/u/2020503?v=3","gravatar_id":"","url":"https://api.github.com/users/haozhun","html_url":"https://github.com/haozhun","followers_url":"https://api.github.com/users/haozhun/followers","following_url":"https://api.github.com/users/haozhun/following{/other_user}","gists_url":"https://api.github.com/users/haozhun/gists{/gist_id}","starred_url":"https://api.github.com/users/haozhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haozhun/subscriptions","organizations_url":"https://api.github.com/users/haozhun/orgs","repos_url":"https://api.github.com/users/haozhun/repos","events_url":"https://api.github.com/users/haozhun/events{/privacy}","received_events_url":"https://api.github.com/users/haozhun/received_events","type":"User","site_admin":false},"repo":{"id":31032158,"name":"presto","full_name":"haozhun/presto","owner":{"login":"haozhun","id":2020503,"avatar_url":"https://avatars.githubusercontent.com/u/2020503?v=3","gravatar_id":"","url":"https://api.github.com/users/haozhun","html_url":"https://github.com/haozhun","followers_url":"https://api.github.com/users/haozhun/followers","following_url":"https://api.github.com/users/haozhun/following{/other_user}","gists_url":"https://api.github.com/users/haozhun/gists{/gist_id}","starred_url":"https://api.github.com/users/haozhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haozhun/subscriptions","organizations_url":"https://api.github.com/users/haozhun/orgs","repos_url":"https://api.github.com/users/haozhun/repos","events_url":"https://api.github.com/users/haozhun/events{/privacy}","received_events_url":"https://api.github.com/users/haozhun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haozhun/presto","description":"Distributed SQL query engine for running interactive analytic queries against big data sources.","fork":true,"url":"https://api.github.com/repos/haozhun/presto","forks_url":"https://api.github.com/repos/haozhun/presto/forks","keys_url":"https://api.github.com/repos/haozhun/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haozhun/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haozhun/presto/teams","hooks_url":"https://api.github.com/repos/haozhun/presto/hooks","issue_events_url":"https://api.github.com/repos/haozhun/presto/issues/events{/number}","events_url":"https://api.github.com/repos/haozhun/presto/events","assignees_url":"https://api.github.com/repos/haozhun/presto/assignees{/user}","branches_url":"https://api.github.com/repos/haozhun/presto/branches{/branch}","tags_url":"https://api.github.com/repos/haozhun/presto/tags","blobs_url":"https://api.github.com/repos/haozhun/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haozhun/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haozhun/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/haozhun/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haozhun/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/haozhun/presto/languages","stargazers_url":"https://api.github.com/repos/haozhun/presto/stargazers","contributors_url":"https://api.github.com/repos/haozhun/presto/contributors","subscribers_url":"https://api.github.com/repos/haozhun/presto/subscribers","subscription_url":"https://api.github.com/repos/haozhun/presto/subscription","commits_url":"https://api.github.com/repos/haozhun/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/haozhun/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/haozhun/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/haozhun/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/haozhun/presto/contents/{+path}","compare_url":"https://api.github.com/repos/haozhun/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haozhun/presto/merges","archive_url":"https://api.github.com/repos/haozhun/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haozhun/presto/downloads","issues_url":"https://api.github.com/repos/haozhun/presto/issues{/number}","pulls_url":"https://api.github.com/repos/haozhun/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/haozhun/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/haozhun/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haozhun/presto/labels{/name}","releases_url":"https://api.github.com/repos/haozhun/presto/releases{/id}","created_at":"2015-02-19T19:19:31Z","updated_at":"2015-04-04T00:15:06Z","pushed_at":"2015-07-06T20:00:46Z","git_url":"git://github.com/haozhun/presto.git","ssh_url":"git@github.com:haozhun/presto.git","clone_url":"https://github.com/haozhun/presto.git","svn_url":"https://github.com/haozhun/presto","homepage":"https://prestodb.io","size":43669,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"3f5d1a51c264b47a6e9a1520c1861b5e104338f0","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":5349565,"name":"presto","full_name":"facebook/presto","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/presto","description":"Distributed SQL query engine for running interactive analytic queries against big data sources.","fork":false,"url":"https://api.github.com/repos/facebook/presto","forks_url":"https://api.github.com/repos/facebook/presto/forks","keys_url":"https://api.github.com/repos/facebook/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/presto/teams","hooks_url":"https://api.github.com/repos/facebook/presto/hooks","issue_events_url":"https://api.github.com/repos/facebook/presto/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/presto/events","assignees_url":"https://api.github.com/repos/facebook/presto/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/presto/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/presto/tags","blobs_url":"https://api.github.com/repos/facebook/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/presto/languages","stargazers_url":"https://api.github.com/repos/facebook/presto/stargazers","contributors_url":"https://api.github.com/repos/facebook/presto/contributors","subscribers_url":"https://api.github.com/repos/facebook/presto/subscribers","subscription_url":"https://api.github.com/repos/facebook/presto/subscription","commits_url":"https://api.github.com/repos/facebook/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/presto/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/presto/merges","archive_url":"https://api.github.com/repos/facebook/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/presto/downloads","issues_url":"https://api.github.com/repos/facebook/presto/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/presto/labels{/name}","releases_url":"https://api.github.com/repos/facebook/presto/releases{/id}","created_at":"2012-08-09T01:03:37Z","updated_at":"2015-07-06T15:44:03Z","pushed_at":"2015-07-06T20:00:47Z","git_url":"git://github.com/facebook/presto.git","ssh_url":"git@github.com:facebook/presto.git","clone_url":"https://github.com/facebook/presto.git","svn_url":"https://github.com/facebook/presto","homepage":"https://prestodb.io","size":93080,"stargazers_count":3611,"watchers_count":3611,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":893,"mirror_url":null,"open_issues_count":287,"forks":893,"open_issues":287,"watchers":3611,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/presto/pulls/2912"},"html":{"href":"https://github.com/facebook/presto/pull/2912"},"issue":{"href":"https://api.github.com/repos/facebook/presto/issues/2912"},"comments":{"href":"https://api.github.com/repos/facebook/presto/issues/2912/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/presto/pulls/2912/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/presto/pulls/2912/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/presto/statuses/558bb9cd4f591bbffe3c13fcbb647b37f8ab01a1"}}}}