GitHub PullRequestReviewCommentEvent at 2014-04-14 09:57:41
Repository: crate
Actor: dobe
Payload: {"comment":{"url":"https://api.github.com/repos/crate/crate/pulls/comments/11577296","id":11577296,"diff_hunk":"@@ -49,39 +52,44 @@\n     private final CollectInputSymbolVisitor<Input<?>> inputSymbolVisitor;\n     private final static Iterable<UnassignedShard> NO_SHARDS = FluentIterable.from(ImmutableList.<UnassignedShard>of());\n \n+    private final ClusterService clusterService;\n+\n     @Inject\n     @SuppressWarnings(\"unchecked\")\n-    public UnassignedShardsCollectService(Functions functions) {\n+    public UnassignedShardsCollectService(Functions functions, ClusterService clusterService) {\n         this.inputSymbolVisitor = new CollectInputSymbolVisitor<Input<?>>(\n             functions,\n             (DocLevelReferenceResolver)new UnassignedShardsReferenceResolver()\n         );\n+        this.clusterService = clusterService;\n     }\n \n-    private Iterable<UnassignedShard> createIterator(Map<String, Set<Integer>> tablesAndShards) {\n-        if (tablesAndShards == null) {\n+    private Iterable<UnassignedShard> createIterator() {\n+        List<ShardRouting> allShards = clusterService.state().routingTable().allShards();\n+        if (allShards == null || allShards.size() == 0) {\n             return NO_SHARDS;\n         }\n-        return FluentIterable.from(tablesAndShards.entrySet())\n-            .transformAndConcat(new Function<Map.Entry<String, Set<Integer>>, Iterable<UnassignedShard>>() {\n-                @Nullable\n-                @Override\n-                public Iterable<UnassignedShard> apply(@Nullable Map.Entry<String, Set<Integer>> input) {\n-                    assert input != null;\n-                    boolean isBlobIndex = BlobIndices.isBlobIndex(input.getKey());\n-                    final String tableName = isBlobIndex ? BlobIndices.stripPrefix.apply(input.getKey()) : input.getKey();\n-                    final String schemaName = isBlobIndex ? BlobSchemaInfo.NAME : DocSchemaInfo.NAME;\n-                    return FluentIterable.from(input.getValue())\n-                            .transform(new Function<Integer, UnassignedShard>() {\n-                                @Nullable\n-                                @Override\n-                                public UnassignedShard apply(@Nullable Integer input) {\n-                                    assert input != null;\n-                                    return new UnassignedShard(schemaName, tableName, input);\n-                                }\n-                            });\n+\n+        return FluentIterable.from(allShards).transform(new Function<ShardRouting, UnassignedShard>() {\n+            @Nullable\n+            @Override\n+            public UnassignedShard apply(@Nullable ShardRouting input) {\n+                assert input != null;\n+                String index = input.index();\n+                boolean isBlobIndex = BlobIndices.isBlobIndex(index);\n+                final String tableName = isBlobIndex ? BlobIndices.stripPrefix.apply(index) : index;\n+                final String schemaName = isBlobIndex ? BlobSchemaInfo.NAME : DocSchemaInfo.NAME;\n+                if (input.unassigned()) {\n+                    return new UnassignedShard(schemaName, tableName, input.id());\n                 }\n-            });\n+                return null;\n+            }\n+        }).filter(new Predicate<UnassignedShard>() {\n+            @Override","path":"sql/src/main/java/io/crate/operation/collect/UnassignedShardsCollectService.java","position":76,"original_position":76,"commit_id":"68d75490fe279c3c04d400ab7833ece9d8fe94d2","original_commit_id":"68d75490fe279c3c04d400ab7833ece9d8fe94d2","user":{"login":"dobe","id":48020,"avatar_url":"https://avatars.githubusercontent.com/u/48020?","gravatar_id":"8c4c0f6e2a311eb34d48174df24ec6f2","url":"https://api.github.com/users/dobe","html_url":"https://github.com/dobe","followers_url":"https://api.github.com/users/dobe/followers","following_url":"https://api.github.com/users/dobe/following{/other_user}","gists_url":"https://api.github.com/users/dobe/gists{/gist_id}","starred_url":"https://api.github.com/users/dobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobe/subscriptions","organizations_url":"https://api.github.com/users/dobe/orgs","repos_url":"https://api.github.com/users/dobe/repos","events_url":"https://api.github.com/users/dobe/events{/privacy}","received_events_url":"https://api.github.com/users/dobe/received_events","type":"User","site_admin":false},"body":"there is a static notNull predicate in guava","created_at":"2014-04-14T09:57:41Z","updated_at":"2014-04-14T09:57:41Z","html_url":"https://github.com/crate/crate/pull/687#discussion_r11577296","pull_request_url":"https://api.github.com/repos/crate/crate/pulls/687","_links":{"self":{"href":"https://api.github.com/repos/crate/crate/pulls/comments/11577296"},"html":{"href":"https://github.com/crate/crate/pull/687#discussion_r11577296"},"pull_request":{"href":"https://api.github.com/repos/crate/crate/pulls/687"}}}}