{"action":"created","comment":{"url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments/228836135","pull_request_review_id":169192426,"id":228836135,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODgzNjEzNQ==","diff_hunk":"@@ -67,13 +71,30 @@\n \n   final private static String THREAD_GROUP_NAME = \"HiveMetaStore Client Group\";\n \n+  @SuppressWarnings(\"UnstableApiUsage\")\n+  private final com.google.common.cache.Cache<\n+      Map.Entry<String, String>, Boolean> nonExistentTables;\n+  @SuppressWarnings(\"UnstableApiUsage\")\n+  private final com.google.common.cache.LoadingCache<\n+      Map.Entry<String, String>, Table> tableCache;\n+\n   private final Future<?> initFuture;\n \n   public static final Object hiveClientSync = new Object();\n \n   private final ExecutorService hmsQueriesExecutorService;\n \n   public SnappyHiveCatalog() {\n+    this.nonExistentTables = CacheBuilder.newBuilder().maximumSize(2000).build();\n+    this.tableCache = CacheBuilder.newBuilder().maximumSize(2000).build(\n+        new CacheLoader<Map.Entry<String, String>, Table>() {\n+          @Override\n+          public Table load(@Nonnull Map.Entry<String, String> table) throws Exception {\n+            Hive client = Hive.get();\n+            return client.getTable(table.getKey(), table.getValue());","path":"core/src/main/java/io/snappydata/impl/SnappyHiveCatalog.java","position":52,"original_position":52,"commit_id":"49d4a45b20cb54e736c2fceb1ed88adcce04ecad","original_commit_id":"49d4a45b20cb54e736c2fceb1ed88adcce04ecad","user":{"login":"sumwale","id":11540628,"node_id":"MDQ6VXNlcjExNTQwNjI4","avatar_url":"https://avatars3.githubusercontent.com/u/11540628?v=4","gravatar_id":"","url":"https://api.github.com/users/sumwale","html_url":"https://github.com/sumwale","followers_url":"https://api.github.com/users/sumwale/followers","following_url":"https://api.github.com/users/sumwale/following{/other_user}","gists_url":"https://api.github.com/users/sumwale/gists{/gist_id}","starred_url":"https://api.github.com/users/sumwale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumwale/subscriptions","organizations_url":"https://api.github.com/users/sumwale/orgs","repos_url":"https://api.github.com/users/sumwale/repos","events_url":"https://api.github.com/users/sumwale/events{/privacy}","received_events_url":"https://api.github.com/users/sumwale/received_events","type":"User","site_admin":false},"body":"I didn't see any significant slowdown even in first explicit call. Likely due to internal calls by stats provider etc.","created_at":"2018-10-29T08:42:38Z","updated_at":"2018-10-29T08:42:38Z","html_url":"https://github.com/SnappyDataInc/snappydata/pull/1190#discussion_r228836135","pull_request_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments/228836135"},"html":{"href":"https://github.com/SnappyDataInc/snappydata/pull/1190#discussion_r228836135"},"pull_request":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190"}},"in_reply_to_id":228826462},"pull_request":{"url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190","id":226400073,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NDAwMDcz","html_url":"https://github.com/SnappyDataInc/snappydata/pull/1190","diff_url":"https://github.com/SnappyDataInc/snappydata/pull/1190.diff","patch_url":"https://github.com/SnappyDataInc/snappydata/pull/1190.patch","issue_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/1190","number":1190,"state":"open","locked":false,"title":"[SNAP-2657] added caching for hive catalog lookups","user":{"login":"sumwale","id":11540628,"node_id":"MDQ6VXNlcjExNTQwNjI4","avatar_url":"https://avatars3.githubusercontent.com/u/11540628?v=4","gravatar_id":"","url":"https://api.github.com/users/sumwale","html_url":"https://github.com/sumwale","followers_url":"https://api.github.com/users/sumwale/followers","following_url":"https://api.github.com/users/sumwale/following{/other_user}","gists_url":"https://api.github.com/users/sumwale/gists{/gist_id}","starred_url":"https://api.github.com/users/sumwale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumwale/subscriptions","organizations_url":"https://api.github.com/users/sumwale/orgs","repos_url":"https://api.github.com/users/sumwale/repos","events_url":"https://api.github.com/users/sumwale/events{/privacy}","received_events_url":"https://api.github.com/users/sumwale/received_events","type":"User","site_admin":false},"body":"Meta-data queries with large number of tables take quite long because of nested loop joins between\r\nSYSTABLES and HIVETABLES for most meta-data queries. Additionally each row in SYSTABLES\r\nlooks up hive-metastore separately to determine if the table is a column table or not. Overall this\r\nresults in close to a million hive-metastore lookups for each meta-data query when there are tables\r\nin the range of hundreds.\r\n\r\nThe changes below add caching for hive meta-store lookups (with invalidation) which improves the\r\nperformance by nearly two orders of magnitude (though the design itself can use some improvement).\r\n\r\n## Changes proposed in this pull request\r\n\r\n- added caching in SnappyHiveCatalog lookups to improve meta-data lookup performance\r\n  for large number of tables\r\n- separate bounded caches for successful and unsucessful lookups; latter are kept separate\r\n  to not push out former if large (unsuccessful lookups are common for internal column store regions)\r\n- added a new RefreshMetadata function for meta-data changes on all executors; this replaces\r\n  most uses of Utils.mapExecutors in the product to avoid dependency on Spark scheduling and also\r\n  because mapExecutors can fail with timeout in case scheduling never gets a core whereas\r\n  GemFire Function execution will keep trying until it goes through if a node is part of the cluster\r\n- added invalidation of the new cache in SnappyHiveCatalog as part of sendRegisterRelationDestroy\r\n  and added appropriate calls to new table/policy creation to invoke it\r\n- also fixed cases where PartitionedRegion.needsBatching may have been cached incorrectly before\r\n  the column store for a region was created\r\n- removed isRowTable/isColumnTable hive operations from SnappyHiveCatalog and instead\r\n  determine directly from HiveTable already looked up (or use GET_TABLE if not)\r\n- cleaned up SNAPPY_URL_PREFIX and JDBC_URL_PREFIX handling removing latter which was\r\n  incorrectly named\r\n- fixed some scalastyle warnings in LeadImpl and few others\r\n\r\n## Patch testing\r\n\r\nprecheckin; manual with large number of tables (700)\r\n\r\n## ReleaseNotes.txt changes\r\n\r\nNA\r\n\r\n## Other PRs \r\n\r\nrelated store PR https://github.com/SnappyDataInc/snappy-store/pull/444","created_at":"2018-10-28T21:50:29Z","updated_at":"2018-10-29T08:42:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b0a2d1a3756ac682ce4ee73411decebce5f8033","assignee":null,"assignees":[],"requested_reviewers":[{"login":"suranjan","id":189977,"node_id":"MDQ6VXNlcjE4OTk3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/189977?v=4","gravatar_id":"","url":"https://api.github.com/users/suranjan","html_url":"https://github.com/suranjan","followers_url":"https://api.github.com/users/suranjan/followers","following_url":"https://api.github.com/users/suranjan/following{/other_user}","gists_url":"https://api.github.com/users/suranjan/gists{/gist_id}","starred_url":"https://api.github.com/users/suranjan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suranjan/subscriptions","organizations_url":"https://api.github.com/users/suranjan/orgs","repos_url":"https://api.github.com/users/suranjan/repos","events_url":"https://api.github.com/users/suranjan/events{/privacy}","received_events_url":"https://api.github.com/users/suranjan/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190/commits","review_comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190/comments","review_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/1190/comments","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/49d4a45b20cb54e736c2fceb1ed88adcce04ecad","head":{"label":"SnappyDataInc:SNAP-2657","ref":"SNAP-2657","sha":"49d4a45b20cb54e736c2fceb1ed88adcce04ecad","user":{"login":"SnappyDataInc","id":11342682,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQyNjgy","avatar_url":"https://avatars2.githubusercontent.com/u/11342682?v=4","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"repo":{"id":42580991,"node_id":"MDEwOlJlcG9zaXRvcnk0MjU4MDk5MQ==","name":"snappydata","full_name":"SnappyDataInc/snappydata","private":false,"owner":{"login":"SnappyDataInc","id":11342682,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQyNjgy","avatar_url":"https://avatars2.githubusercontent.com/u/11342682?v=4","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/SnappyDataInc/snappydata","description":"SnappyData - The Spark Database. Stream, Transact, Analyze, Predict in one cluster ","fork":false,"url":"https://api.github.com/repos/SnappyDataInc/snappydata","forks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/forks","keys_url":"https://api.github.com/repos/SnappyDataInc/snappydata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SnappyDataInc/snappydata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SnappyDataInc/snappydata/teams","hooks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/hooks","issue_events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/events{/number}","events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/events","assignees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/assignees{/user}","branches_url":"https://api.github.com/repos/SnappyDataInc/snappydata/branches{/branch}","tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/tags","blobs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/refs{/sha}","trees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/{sha}","languages_url":"https://api.github.com/repos/SnappyDataInc/snappydata/languages","stargazers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/stargazers","contributors_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contributors","subscribers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscribers","subscription_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscription","commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/commits{/sha}","git_commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/commits{/sha}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/comments{/number}","issue_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/comments{/number}","contents_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contents/{+path}","compare_url":"https://api.github.com/repos/SnappyDataInc/snappydata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SnappyDataInc/snappydata/merges","archive_url":"https://api.github.com/repos/SnappyDataInc/snappydata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SnappyDataInc/snappydata/downloads","issues_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues{/number}","pulls_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls{/number}","milestones_url":"https://api.github.com/repos/SnappyDataInc/snappydata/milestones{/number}","notifications_url":"https://api.github.com/repos/SnappyDataInc/snappydata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SnappyDataInc/snappydata/labels{/name}","releases_url":"https://api.github.com/repos/SnappyDataInc/snappydata/releases{/id}","deployments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/deployments","created_at":"2015-09-16T10:36:36Z","updated_at":"2018-10-29T06:00:49Z","pushed_at":"2018-10-29T06:37:42Z","git_url":"git://github.com/SnappyDataInc/snappydata.git","ssh_url":"git@github.com:SnappyDataInc/snappydata.git","clone_url":"https://github.com/SnappyDataInc/snappydata.git","svn_url":"https://github.com/SnappyDataInc/snappydata","homepage":"http://www.snappydata.io","size":415602,"stargazers_count":794,"watchers_count":794,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":147,"mirror_url":null,"archived":false,"open_issues_count":92,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":147,"open_issues":92,"watchers":794,"default_branch":"master"}},"base":{"label":"SnappyDataInc:SNAP-2656","ref":"SNAP-2656","sha":"405a821a0387a7c1a5bd0fc3a4d29b57fc813a56","user":{"login":"SnappyDataInc","id":11342682,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQyNjgy","avatar_url":"https://avatars2.githubusercontent.com/u/11342682?v=4","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"repo":{"id":42580991,"node_id":"MDEwOlJlcG9zaXRvcnk0MjU4MDk5MQ==","name":"snappydata","full_name":"SnappyDataInc/snappydata","private":false,"owner":{"login":"SnappyDataInc","id":11342682,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzQyNjgy","avatar_url":"https://avatars2.githubusercontent.com/u/11342682?v=4","gravatar_id":"","url":"https://api.github.com/users/SnappyDataInc","html_url":"https://github.com/SnappyDataInc","followers_url":"https://api.github.com/users/SnappyDataInc/followers","following_url":"https://api.github.com/users/SnappyDataInc/following{/other_user}","gists_url":"https://api.github.com/users/SnappyDataInc/gists{/gist_id}","starred_url":"https://api.github.com/users/SnappyDataInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SnappyDataInc/subscriptions","organizations_url":"https://api.github.com/users/SnappyDataInc/orgs","repos_url":"https://api.github.com/users/SnappyDataInc/repos","events_url":"https://api.github.com/users/SnappyDataInc/events{/privacy}","received_events_url":"https://api.github.com/users/SnappyDataInc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/SnappyDataInc/snappydata","description":"SnappyData - The Spark Database. Stream, Transact, Analyze, Predict in one cluster ","fork":false,"url":"https://api.github.com/repos/SnappyDataInc/snappydata","forks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/forks","keys_url":"https://api.github.com/repos/SnappyDataInc/snappydata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SnappyDataInc/snappydata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SnappyDataInc/snappydata/teams","hooks_url":"https://api.github.com/repos/SnappyDataInc/snappydata/hooks","issue_events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/events{/number}","events_url":"https://api.github.com/repos/SnappyDataInc/snappydata/events","assignees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/assignees{/user}","branches_url":"https://api.github.com/repos/SnappyDataInc/snappydata/branches{/branch}","tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/tags","blobs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/refs{/sha}","trees_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/{sha}","languages_url":"https://api.github.com/repos/SnappyDataInc/snappydata/languages","stargazers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/stargazers","contributors_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contributors","subscribers_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscribers","subscription_url":"https://api.github.com/repos/SnappyDataInc/snappydata/subscription","commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/commits{/sha}","git_commits_url":"https://api.github.com/repos/SnappyDataInc/snappydata/git/commits{/sha}","comments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/comments{/number}","issue_comment_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/comments{/number}","contents_url":"https://api.github.com/repos/SnappyDataInc/snappydata/contents/{+path}","compare_url":"https://api.github.com/repos/SnappyDataInc/snappydata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SnappyDataInc/snappydata/merges","archive_url":"https://api.github.com/repos/SnappyDataInc/snappydata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SnappyDataInc/snappydata/downloads","issues_url":"https://api.github.com/repos/SnappyDataInc/snappydata/issues{/number}","pulls_url":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls{/number}","milestones_url":"https://api.github.com/repos/SnappyDataInc/snappydata/milestones{/number}","notifications_url":"https://api.github.com/repos/SnappyDataInc/snappydata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SnappyDataInc/snappydata/labels{/name}","releases_url":"https://api.github.com/repos/SnappyDataInc/snappydata/releases{/id}","deployments_url":"https://api.github.com/repos/SnappyDataInc/snappydata/deployments","created_at":"2015-09-16T10:36:36Z","updated_at":"2018-10-29T06:00:49Z","pushed_at":"2018-10-29T06:37:42Z","git_url":"git://github.com/SnappyDataInc/snappydata.git","ssh_url":"git@github.com:SnappyDataInc/snappydata.git","clone_url":"https://github.com/SnappyDataInc/snappydata.git","svn_url":"https://github.com/SnappyDataInc/snappydata","homepage":"http://www.snappydata.io","size":415602,"stargazers_count":794,"watchers_count":794,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":147,"mirror_url":null,"archived":false,"open_issues_count":92,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":147,"open_issues":92,"watchers":794,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190"},"html":{"href":"https://github.com/SnappyDataInc/snappydata/pull/1190"},"issue":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/1190"},"comments":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/issues/1190/comments"},"review_comments":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190/comments"},"review_comment":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/pulls/1190/commits"},"statuses":{"href":"https://api.github.com/repos/SnappyDataInc/snappydata/statuses/49d4a45b20cb54e736c2fceb1ed88adcce04ecad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sumwale"}}