{"action":"created","comment":{"url":"https://api.github.com/repos/osmlab/atlas/pulls/comments/222815274","pull_request_review_id":161788602,"id":222815274,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjgxNTI3NA==","diff_hunk":"@@ -0,0 +1,114 @@\n+package org.openstreetmap.atlas.geography.atlas.sqlite;\n+\n+import java.io.IOException;\n+import java.nio.file.Path;\n+import java.sql.Connection;\n+import java.sql.DriverManager;\n+import java.sql.SQLException;\n+import java.sql.Statement;\n+\n+import org.openstreetmap.atlas.streaming.resource.File;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+/**\n+ * SQLiteMerger takes a path to an output database file that it will create. It then can attach\n+ * Atlas SQLite shard databases and merge those into this output database.\n+ *\n+ * @author hallahan\n+ */\n+public class SQLiteMerger\n+{\n+\n+    private static final Logger logger = LoggerFactory.getLogger(SQLiteMerger.class);\n+\n+    private static final String CONNECTION_URL_TEMPLATE = \"jdbc:sqlite:%s\";\n+\n+    private static final String ATTACH_SQL = \"ATTACH DATABASE'%s' as merge\";\n+    private static final String DETACH_SQL = \"DETACH DATABASE merge\";\n+    private static final String MERGE_EDGES_SQL = \"INSERT OR IGNORE INTO edge SELECT * FROM merge.edge\";\n+    private static final String MERGE_EDGES_TAGS_SQL = \"INSERT OR IGNORE INTO edge_tags SELECT * FROM merge.edge_tags\";\n+\n+    private final Connection connection;\n+    private final SQLiteSchema schema;\n+\n+    /**\n+     * This class lets you specify a path to where you'd like an output database with your merged\n+     * data. Then, you call the #merge method to attach and merge in a shard database.\n+     *\n+     * @param output\n+     *            The path to the merge database.\n+     * @throws SQLException\n+     *             If an attach, merge, or detach statement fails.\n+     * @throws IOException\n+     *             If connecting to a database fails.\n+     */\n+    public SQLiteMerger(final Path output) throws SQLException, IOException\n+    {\n+        final String url = String.format(CONNECTION_URL_TEMPLATE, output);\n+\n+        try\n+        {\n+            this.connection = DriverManager.getConnection(url);\n+        }\n+        catch (final SQLException sqlException)\n+        {\n+            logger.error(\"Unable to connect to merge output SQLite database.\", sqlException);\n+            throw sqlException;\n+        }\n+\n+        try\n+        {\n+            this.schema = new SQLiteSchema();\n+            this.schema.buildTables(this.connection);\n+        }\n+        catch (final IOException ioException)\n+        {\n+            logger.error(\"Unable to build Atlas SQLite table schema in merge output database.\",\n+                    ioException);\n+            throw ioException;\n+        }\n+\n+    }\n+\n+    public void buildIndices() throws SQLException\n+    {\n+        try\n+        {\n+            this.schema.buildIndices(this.connection);\n+        }\n+        catch (final SQLException sqlException)\n+        {\n+            logger.error(\"Unable to build indices on merge database.\");","path":"src/main/java/org/openstreetmap/atlas/geography/atlas/sqlite/SQLiteMerger.java","position":82,"original_position":82,"commit_id":"52fb867c2f61f2f2091950da9cb45841d56af1ce","original_commit_id":"52fb867c2f61f2f2091950da9cb45841d56af1ce","user":{"login":"MikeGost","id":18317260,"node_id":"MDQ6VXNlcjE4MzE3MjYw","avatar_url":"https://avatars3.githubusercontent.com/u/18317260?v=4","gravatar_id":"","url":"https://api.github.com/users/MikeGost","html_url":"https://github.com/MikeGost","followers_url":"https://api.github.com/users/MikeGost/followers","following_url":"https://api.github.com/users/MikeGost/following{/other_user}","gists_url":"https://api.github.com/users/MikeGost/gists{/gist_id}","starred_url":"https://api.github.com/users/MikeGost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikeGost/subscriptions","organizations_url":"https://api.github.com/users/MikeGost/orgs","repos_url":"https://api.github.com/users/MikeGost/repos","events_url":"https://api.github.com/users/MikeGost/events{/privacy}","received_events_url":"https://api.github.com/users/MikeGost/received_events","type":"User","site_admin":false},"body":"Consider logging the error, might help in debugging","created_at":"2018-10-04T20:25:57Z","updated_at":"2018-10-04T20:32:40Z","html_url":"https://github.com/osmlab/atlas/pull/232#discussion_r222815274","pull_request_url":"https://api.github.com/repos/osmlab/atlas/pulls/232","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/comments/222815274"},"html":{"href":"https://github.com/osmlab/atlas/pull/232#discussion_r222815274"},"pull_request":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/232"}}},"pull_request":{"url":"https://api.github.com/repos/osmlab/atlas/pulls/232","id":220192701,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwMTkyNzAx","html_url":"https://github.com/osmlab/atlas/pull/232","diff_url":"https://github.com/osmlab/atlas/pull/232.diff","patch_url":"https://github.com/osmlab/atlas/pull/232.patch","issue_url":"https://api.github.com/repos/osmlab/atlas/issues/232","number":232,"state":"open","locked":false,"title":"Initial SQLite Atlas file format","user":{"login":"lucaspcram","id":8269882,"node_id":"MDQ6VXNlcjgyNjk4ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/8269882?v=4","gravatar_id":"","url":"https://api.github.com/users/lucaspcram","html_url":"https://github.com/lucaspcram","followers_url":"https://api.github.com/users/lucaspcram/followers","following_url":"https://api.github.com/users/lucaspcram/following{/other_user}","gists_url":"https://api.github.com/users/lucaspcram/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaspcram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaspcram/subscriptions","organizations_url":"https://api.github.com/users/lucaspcram/orgs","repos_url":"https://api.github.com/users/lucaspcram/repos","events_url":"https://api.github.com/users/lucaspcram/events{/privacy}","received_events_url":"https://api.github.com/users/lucaspcram/received_events","type":"User","site_admin":false},"body":"### Description:\r\n\r\nThese are the beginnings of a SQLite atlas file format. Things are still very much WIP, but I would like to get them merged in to encourage collaboration.\r\n\r\n### Potential Impact:\r\n\r\nNo downstream impact.\r\n\r\n### Unit Test Approach:\r\n\r\nThis is an area we still need to flesh out. Testing has been ad-hoc, using the various creation commands found in the PR.\r\n\r\n### Test Results:\r\n\r\nResults look good so far, but we initially have only implemented the basics.\r\n\r\n------\r\n\r\nIn doubt: [Contributing Guidelines](CONTRIBUTING.md)","created_at":"2018-10-03T21:57:21Z","updated_at":"2018-10-04T20:32:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5ad6dc5b5bfa2ab826e294f70cdcc42c8dc8f294","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":664543820,"node_id":"MDU6TGFiZWw2NjQ1NDM4MjA=","url":"https://api.github.com/repos/osmlab/atlas/labels/New%20Feature","name":"New Feature","color":"128A0C","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/osmlab/atlas/pulls/232/commits","review_comments_url":"https://api.github.com/repos/osmlab/atlas/pulls/232/comments","review_comment_url":"https://api.github.com/repos/osmlab/atlas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/osmlab/atlas/issues/232/comments","statuses_url":"https://api.github.com/repos/osmlab/atlas/statuses/52fb867c2f61f2f2091950da9cb45841d56af1ce","head":{"label":"lucaspcram:sqlatlas","ref":"sqlatlas","sha":"52fb867c2f61f2f2091950da9cb45841d56af1ce","user":{"login":"lucaspcram","id":8269882,"node_id":"MDQ6VXNlcjgyNjk4ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/8269882?v=4","gravatar_id":"","url":"https://api.github.com/users/lucaspcram","html_url":"https://github.com/lucaspcram","followers_url":"https://api.github.com/users/lucaspcram/followers","following_url":"https://api.github.com/users/lucaspcram/following{/other_user}","gists_url":"https://api.github.com/users/lucaspcram/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaspcram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaspcram/subscriptions","organizations_url":"https://api.github.com/users/lucaspcram/orgs","repos_url":"https://api.github.com/users/lucaspcram/repos","events_url":"https://api.github.com/users/lucaspcram/events{/privacy}","received_events_url":"https://api.github.com/users/lucaspcram/received_events","type":"User","site_admin":false},"repo":{"id":127447366,"node_id":"MDEwOlJlcG9zaXRvcnkxMjc0NDczNjY=","name":"atlas","full_name":"lucaspcram/atlas","private":false,"owner":{"login":"lucaspcram","id":8269882,"node_id":"MDQ6VXNlcjgyNjk4ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/8269882?v=4","gravatar_id":"","url":"https://api.github.com/users/lucaspcram","html_url":"https://github.com/lucaspcram","followers_url":"https://api.github.com/users/lucaspcram/followers","following_url":"https://api.github.com/users/lucaspcram/following{/other_user}","gists_url":"https://api.github.com/users/lucaspcram/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaspcram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaspcram/subscriptions","organizations_url":"https://api.github.com/users/lucaspcram/orgs","repos_url":"https://api.github.com/users/lucaspcram/repos","events_url":"https://api.github.com/users/lucaspcram/events{/privacy}","received_events_url":"https://api.github.com/users/lucaspcram/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lucaspcram/atlas","description":"OSM in memory","fork":true,"url":"https://api.github.com/repos/lucaspcram/atlas","forks_url":"https://api.github.com/repos/lucaspcram/atlas/forks","keys_url":"https://api.github.com/repos/lucaspcram/atlas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucaspcram/atlas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucaspcram/atlas/teams","hooks_url":"https://api.github.com/repos/lucaspcram/atlas/hooks","issue_events_url":"https://api.github.com/repos/lucaspcram/atlas/issues/events{/number}","events_url":"https://api.github.com/repos/lucaspcram/atlas/events","assignees_url":"https://api.github.com/repos/lucaspcram/atlas/assignees{/user}","branches_url":"https://api.github.com/repos/lucaspcram/atlas/branches{/branch}","tags_url":"https://api.github.com/repos/lucaspcram/atlas/tags","blobs_url":"https://api.github.com/repos/lucaspcram/atlas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucaspcram/atlas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucaspcram/atlas/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucaspcram/atlas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucaspcram/atlas/statuses/{sha}","languages_url":"https://api.github.com/repos/lucaspcram/atlas/languages","stargazers_url":"https://api.github.com/repos/lucaspcram/atlas/stargazers","contributors_url":"https://api.github.com/repos/lucaspcram/atlas/contributors","subscribers_url":"https://api.github.com/repos/lucaspcram/atlas/subscribers","subscription_url":"https://api.github.com/repos/lucaspcram/atlas/subscription","commits_url":"https://api.github.com/repos/lucaspcram/atlas/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucaspcram/atlas/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucaspcram/atlas/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucaspcram/atlas/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucaspcram/atlas/contents/{+path}","compare_url":"https://api.github.com/repos/lucaspcram/atlas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucaspcram/atlas/merges","archive_url":"https://api.github.com/repos/lucaspcram/atlas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucaspcram/atlas/downloads","issues_url":"https://api.github.com/repos/lucaspcram/atlas/issues{/number}","pulls_url":"https://api.github.com/repos/lucaspcram/atlas/pulls{/number}","milestones_url":"https://api.github.com/repos/lucaspcram/atlas/milestones{/number}","notifications_url":"https://api.github.com/repos/lucaspcram/atlas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucaspcram/atlas/labels{/name}","releases_url":"https://api.github.com/repos/lucaspcram/atlas/releases{/id}","deployments_url":"https://api.github.com/repos/lucaspcram/atlas/deployments","created_at":"2018-03-30T16:07:04Z","updated_at":"2018-10-03T21:51:36Z","pushed_at":"2018-10-03T22:17:07Z","git_url":"git://github.com/lucaspcram/atlas.git","ssh_url":"git@github.com:lucaspcram/atlas.git","clone_url":"https://github.com/lucaspcram/atlas.git","svn_url":"https://github.com/lucaspcram/atlas","homepage":null,"size":53692,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"osmlab:dev","ref":"dev","sha":"3a678e60d2b25d4763a37e08894192b2e25141bf","user":{"login":"osmlab","id":3856374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NTYzNzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3856374?v=4","gravatar_id":"","url":"https://api.github.com/users/osmlab","html_url":"https://github.com/osmlab","followers_url":"https://api.github.com/users/osmlab/followers","following_url":"https://api.github.com/users/osmlab/following{/other_user}","gists_url":"https://api.github.com/users/osmlab/gists{/gist_id}","starred_url":"https://api.github.com/users/osmlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osmlab/subscriptions","organizations_url":"https://api.github.com/users/osmlab/orgs","repos_url":"https://api.github.com/users/osmlab/repos","events_url":"https://api.github.com/users/osmlab/events{/privacy}","received_events_url":"https://api.github.com/users/osmlab/received_events","type":"Organization","site_admin":false},"repo":{"id":99717758,"node_id":"MDEwOlJlcG9zaXRvcnk5OTcxNzc1OA==","name":"atlas","full_name":"osmlab/atlas","private":false,"owner":{"login":"osmlab","id":3856374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NTYzNzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3856374?v=4","gravatar_id":"","url":"https://api.github.com/users/osmlab","html_url":"https://github.com/osmlab","followers_url":"https://api.github.com/users/osmlab/followers","following_url":"https://api.github.com/users/osmlab/following{/other_user}","gists_url":"https://api.github.com/users/osmlab/gists{/gist_id}","starred_url":"https://api.github.com/users/osmlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osmlab/subscriptions","organizations_url":"https://api.github.com/users/osmlab/orgs","repos_url":"https://api.github.com/users/osmlab/repos","events_url":"https://api.github.com/users/osmlab/events{/privacy}","received_events_url":"https://api.github.com/users/osmlab/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/osmlab/atlas","description":"OSM in memory","fork":false,"url":"https://api.github.com/repos/osmlab/atlas","forks_url":"https://api.github.com/repos/osmlab/atlas/forks","keys_url":"https://api.github.com/repos/osmlab/atlas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/osmlab/atlas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/osmlab/atlas/teams","hooks_url":"https://api.github.com/repos/osmlab/atlas/hooks","issue_events_url":"https://api.github.com/repos/osmlab/atlas/issues/events{/number}","events_url":"https://api.github.com/repos/osmlab/atlas/events","assignees_url":"https://api.github.com/repos/osmlab/atlas/assignees{/user}","branches_url":"https://api.github.com/repos/osmlab/atlas/branches{/branch}","tags_url":"https://api.github.com/repos/osmlab/atlas/tags","blobs_url":"https://api.github.com/repos/osmlab/atlas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/osmlab/atlas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/osmlab/atlas/git/refs{/sha}","trees_url":"https://api.github.com/repos/osmlab/atlas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/osmlab/atlas/statuses/{sha}","languages_url":"https://api.github.com/repos/osmlab/atlas/languages","stargazers_url":"https://api.github.com/repos/osmlab/atlas/stargazers","contributors_url":"https://api.github.com/repos/osmlab/atlas/contributors","subscribers_url":"https://api.github.com/repos/osmlab/atlas/subscribers","subscription_url":"https://api.github.com/repos/osmlab/atlas/subscription","commits_url":"https://api.github.com/repos/osmlab/atlas/commits{/sha}","git_commits_url":"https://api.github.com/repos/osmlab/atlas/git/commits{/sha}","comments_url":"https://api.github.com/repos/osmlab/atlas/comments{/number}","issue_comment_url":"https://api.github.com/repos/osmlab/atlas/issues/comments{/number}","contents_url":"https://api.github.com/repos/osmlab/atlas/contents/{+path}","compare_url":"https://api.github.com/repos/osmlab/atlas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/osmlab/atlas/merges","archive_url":"https://api.github.com/repos/osmlab/atlas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/osmlab/atlas/downloads","issues_url":"https://api.github.com/repos/osmlab/atlas/issues{/number}","pulls_url":"https://api.github.com/repos/osmlab/atlas/pulls{/number}","milestones_url":"https://api.github.com/repos/osmlab/atlas/milestones{/number}","notifications_url":"https://api.github.com/repos/osmlab/atlas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/osmlab/atlas/labels{/name}","releases_url":"https://api.github.com/repos/osmlab/atlas/releases{/id}","deployments_url":"https://api.github.com/repos/osmlab/atlas/deployments","created_at":"2017-08-08T17:14:27Z","updated_at":"2018-10-02T22:19:40Z","pushed_at":"2018-10-03T22:17:08Z","git_url":"git://github.com/osmlab/atlas.git","ssh_url":"git@github.com:osmlab/atlas.git","clone_url":"https://github.com/osmlab/atlas.git","svn_url":"https://github.com/osmlab/atlas","homepage":null,"size":53671,"stargazers_count":87,"watchers_count":87,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":33,"open_issues":15,"watchers":87,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/232"},"html":{"href":"https://github.com/osmlab/atlas/pull/232"},"issue":{"href":"https://api.github.com/repos/osmlab/atlas/issues/232"},"comments":{"href":"https://api.github.com/repos/osmlab/atlas/issues/232/comments"},"review_comments":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/232/comments"},"review_comment":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/osmlab/atlas/pulls/232/commits"},"statuses":{"href":"https://api.github.com/repos/osmlab/atlas/statuses/52fb867c2f61f2f2091950da9cb45841d56af1ce"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MikeGost"}}