{"action":"created","comment":{"url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments/56088235","id":56088235,"diff_hunk":"@@ -0,0 +1,185 @@\n+/**\n+ *   Copyright 2016, Quickstep Research Group, Computer Sciences Department,\n+ *     University of Wisconsin—Madison.\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+\n+#ifndef QUICKSTEP_CATALOG_INDEX_SCHEME_HPP_\n+#define QUICKSTEP_CATALOG_INDEX_SCHEME_HPP_\n+\n+#include <cstddef>\n+#include <memory>\n+#include <string>\n+#include <unordered_map>\n+#include <vector>\n+\n+#include \"catalog/Catalog.pb.h\"\n+#include \"catalog/CatalogTypedefs.hpp\"\n+#include \"storage/StorageBlockInfo.hpp\"\n+#include \"threading/SpinSharedMutex.hpp\"\n+#include \"types/TypedValue.hpp\"\n+#include \"types/operations/comparisons/Comparison.hpp\"\n+#include \"types/operations/comparisons/LessComparison.hpp\"\n+#include \"utility/Macros.hpp\"\n+\n+#include \"glog/logging.h\"\n+\n+namespace quickstep {\n+\n+/** \\addtogroup Catalog\n+ *  @{\n+ */\n+\n+/**\n+ * @brief The Index Scheme class which stores the information about\n+ *        various indicies defined for a particular relation.\n+ **/\n+class IndexScheme {\n+ public:\n+  /**\n+   * @brief Constructor.\n+   **/\n+  IndexScheme() {\n+  }\n+\n+  /**\n+   * @brief Virtual destructor.\n+   **/\n+  ~IndexScheme() {\n+  }\n+\n+  /**\n+   * @brief Reconstruct an Index Scheme from its serialized\n+   *        Protocol Buffer form.\n+   *\n+   * @param proto The Protocol Buffer serialization of a Index Scheme,\n+   *              previously produced by getProto().\n+   * @return The deserialied index scheme object.\n+   **/\n+  static IndexScheme* ReconstructFromProto(const serialization::IndexScheme &proto);\n+\n+  /**\n+   * @brief Check whether a serialization::IndexScheme is fully-formed and\n+   *        all parts are valid.\n+   *\n+   * @param proto A serialized Protocol Buffer representation of a\n+   *              IndexScheme, originally generated by getProto().\n+   * @return Whether proto is fully-formed and valid.\n+   **/\n+  static bool ProtoIsValid(const serialization::IndexScheme &proto);\n+\n+  /**\n+   * @brief Serialize the Index Scheme as Protocol Buffer.\n+   *\n+   * @return The Protocol Buffer representation of Index Scheme.\n+   **/\n+  serialization::IndexScheme getProto() const;\n+\n+  /**\n+   * @brief Get the number of indices for the relation.\n+   *\n+   * @return The number of indices defined for the relation.\n+   **/\n+  inline const std::size_t getNumIndices() const {\n+    return index_map_.size();\n+  }\n+\n+  /**\n+   * @brief Check whether an index with the given exists or not.\n+   *\n+   * @param index_name Name of the index to be checked.\n+   * @return Whether the index exists or not.\n+   **/\n+  bool hasIndexWithName(const std::string &index_name) const {\n+    return index_map_.find(index_name) != index_map_.end();\n+  }\n+\n+  /**\n+   * @brief Check whether an index with the given description\n+   *        containing the same attribute id and index type\n+   *        exists or not in the index map.\n+   *\n+   * @param index_descripton Index Description to check against.\n+   * @return Whether a similar index description was already defined or not.\n+   **/\n+  bool hasIndexWithDescription(const IndexSubBlockDescription &index_description) const {\n+    // Iterate through every vector of descriptions corresponding to all keys in the index map.\n+    for (auto cit = index_map_.cbegin(); cit != index_map_.cend(); ++cit) {\n+      std::vector<IndexSubBlockDescription> index_descriptions = cit->second;\n+      for (auto index_description_itr = index_descriptions.cbegin();\n+           index_description_itr != index_descriptions.cend();\n+           ++index_description_itr) {\n+        const IndexSubBlockDescription &stored_description = *index_description_itr;\n+        // Check if the stored description matches as the given description.\n+        if (areIndexDescriptionsSimilar(stored_description, index_description)) {","path":"catalog/IndexScheme.hpp","position":125,"original_position":125,"commit_id":"501fe4864f4abf639987b8e6601361731e0782e4","original_commit_id":"501fe4864f4abf639987b8e6601361731e0782e4","user":{"login":"zuyu","id":2245572,"avatar_url":"https://avatars.githubusercontent.com/u/2245572?v=3","gravatar_id":"","url":"https://api.github.com/users/zuyu","html_url":"https://github.com/zuyu","followers_url":"https://api.github.com/users/zuyu/followers","following_url":"https://api.github.com/users/zuyu/following{/other_user}","gists_url":"https://api.github.com/users/zuyu/gists{/gist_id}","starred_url":"https://api.github.com/users/zuyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuyu/subscriptions","organizations_url":"https://api.github.com/users/zuyu/orgs","repos_url":"https://api.github.com/users/zuyu/repos","events_url":"https://api.github.com/users/zuyu/events{/privacy}","received_events_url":"https://api.github.com/users/zuyu/received_events","type":"User","site_admin":false},"body":"Use `*index_description_itr` directly, and remove above definition for `stored_description`.\r\n\r\nRename `index_description_itr` to `description_it`?","created_at":"2016-03-14T22:35:39Z","updated_at":"2016-03-14T22:35:39Z","html_url":"https://github.com/pivotalsoftware/quickstep/pull/69#discussion_r56088235","pull_request_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments/56088235"},"html":{"href":"https://github.com/pivotalsoftware/quickstep/pull/69#discussion_r56088235"},"pull_request":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69","id":61910618,"html_url":"https://github.com/pivotalsoftware/quickstep/pull/69","diff_url":"https://github.com/pivotalsoftware/quickstep/pull/69.diff","patch_url":"https://github.com/pivotalsoftware/quickstep/pull/69.patch","issue_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/69","number":69,"state":"open","locked":false,"title":"CREATE INDEX now saves a new index and its properties in the catalog","user":{"login":"saketj","id":3624476,"avatar_url":"https://avatars.githubusercontent.com/u/3624476?v=3","gravatar_id":"","url":"https://api.github.com/users/saketj","html_url":"https://github.com/saketj","followers_url":"https://api.github.com/users/saketj/followers","following_url":"https://api.github.com/users/saketj/following{/other_user}","gists_url":"https://api.github.com/users/saketj/gists{/gist_id}","starred_url":"https://api.github.com/users/saketj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saketj/subscriptions","organizations_url":"https://api.github.com/users/saketj/orgs","repos_url":"https://api.github.com/users/saketj/repos","events_url":"https://api.github.com/users/saketj/events{/privacy}","received_events_url":"https://api.github.com/users/saketj/received_events","type":"User","site_admin":false},"body":"This is the final PR towards CREATE INDEX implementation in Quickstep that saves newly created indices and their properties in the catalog. \r\nThe CatalogProto has been modified to define a new message type- 'IndexScheme', which contains the set of indices defined on the relation. Within the index scheme, each index is represented as an IndexEntry that contains a string index_name, and an associated protobuf IndexSubBlockDescription. \r\n\r\nAddition of an index creates an IndexEntry in the catalog and also adds a new index sub block to the StorageBlockLayout. Duplicate indices can be checked by going through a map of indices maintained by the catalog. The PR also adds support for flexible parsing and definition of any number of properties on a given index. \r\n\r\nOpen Issues (to be fixed in the next commit to this PR):\r\n- Add more tests for ExecutionGenerator and CreateIndexOperator\r\n- Cleanup and fix IWYU issues\r\n- Complete comments for the cpp files, as well","created_at":"2016-03-07T12:28:16Z","updated_at":"2016-03-14T22:35:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"643ad2e49a8365596a1bb5b75b2eed1097e43dfa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69/commits","review_comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69/comments","review_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/69/comments","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/501fe4864f4abf639987b8e6601361731e0782e4","head":{"label":"pivotalsoftware:index-properties-resolver","ref":"index-properties-resolver","sha":"501fe4864f4abf639987b8e6601361731e0782e4","user":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":45578105,"name":"quickstep","full_name":"pivotalsoftware/quickstep","owner":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pivotalsoftware/quickstep","description":"Quickstep Project","fork":false,"url":"https://api.github.com/repos/pivotalsoftware/quickstep","forks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/forks","keys_url":"https://api.github.com/repos/pivotalsoftware/quickstep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pivotalsoftware/quickstep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pivotalsoftware/quickstep/teams","hooks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/hooks","issue_events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/events{/number}","events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/events","assignees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/assignees{/user}","branches_url":"https://api.github.com/repos/pivotalsoftware/quickstep/branches{/branch}","tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/tags","blobs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/refs{/sha}","trees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/{sha}","languages_url":"https://api.github.com/repos/pivotalsoftware/quickstep/languages","stargazers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/stargazers","contributors_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contributors","subscribers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscribers","subscription_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscription","commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/commits{/sha}","git_commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/commits{/sha}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/comments{/number}","issue_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/comments{/number}","contents_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contents/{+path}","compare_url":"https://api.github.com/repos/pivotalsoftware/quickstep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pivotalsoftware/quickstep/merges","archive_url":"https://api.github.com/repos/pivotalsoftware/quickstep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pivotalsoftware/quickstep/downloads","issues_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues{/number}","pulls_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls{/number}","milestones_url":"https://api.github.com/repos/pivotalsoftware/quickstep/milestones{/number}","notifications_url":"https://api.github.com/repos/pivotalsoftware/quickstep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pivotalsoftware/quickstep/labels{/name}","releases_url":"https://api.github.com/repos/pivotalsoftware/quickstep/releases{/id}","deployments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/deployments","created_at":"2015-11-05T01:06:50Z","updated_at":"2016-03-09T18:55:47Z","pushed_at":"2016-03-14T21:06:17Z","git_url":"git://github.com/pivotalsoftware/quickstep.git","ssh_url":"git@github.com:pivotalsoftware/quickstep.git","clone_url":"https://github.com/pivotalsoftware/quickstep.git","svn_url":"https://github.com/pivotalsoftware/quickstep","homepage":null,"size":6827,"stargazers_count":7,"watchers_count":7,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":16,"forks":7,"open_issues":16,"watchers":7,"default_branch":"master"}},"base":{"label":"pivotalsoftware:master","ref":"master","sha":"c7cfe583ba626947c8489bb9c1b353fe908943a5","user":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":45578105,"name":"quickstep","full_name":"pivotalsoftware/quickstep","owner":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pivotalsoftware/quickstep","description":"Quickstep Project","fork":false,"url":"https://api.github.com/repos/pivotalsoftware/quickstep","forks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/forks","keys_url":"https://api.github.com/repos/pivotalsoftware/quickstep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pivotalsoftware/quickstep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pivotalsoftware/quickstep/teams","hooks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/hooks","issue_events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/events{/number}","events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/events","assignees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/assignees{/user}","branches_url":"https://api.github.com/repos/pivotalsoftware/quickstep/branches{/branch}","tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/tags","blobs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/refs{/sha}","trees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/{sha}","languages_url":"https://api.github.com/repos/pivotalsoftware/quickstep/languages","stargazers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/stargazers","contributors_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contributors","subscribers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscribers","subscription_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscription","commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/commits{/sha}","git_commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/commits{/sha}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/comments{/number}","issue_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/comments{/number}","contents_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contents/{+path}","compare_url":"https://api.github.com/repos/pivotalsoftware/quickstep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pivotalsoftware/quickstep/merges","archive_url":"https://api.github.com/repos/pivotalsoftware/quickstep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pivotalsoftware/quickstep/downloads","issues_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues{/number}","pulls_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls{/number}","milestones_url":"https://api.github.com/repos/pivotalsoftware/quickstep/milestones{/number}","notifications_url":"https://api.github.com/repos/pivotalsoftware/quickstep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pivotalsoftware/quickstep/labels{/name}","releases_url":"https://api.github.com/repos/pivotalsoftware/quickstep/releases{/id}","deployments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/deployments","created_at":"2015-11-05T01:06:50Z","updated_at":"2016-03-09T18:55:47Z","pushed_at":"2016-03-14T21:06:17Z","git_url":"git://github.com/pivotalsoftware/quickstep.git","ssh_url":"git@github.com:pivotalsoftware/quickstep.git","clone_url":"https://github.com/pivotalsoftware/quickstep.git","svn_url":"https://github.com/pivotalsoftware/quickstep","homepage":null,"size":6827,"stargazers_count":7,"watchers_count":7,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":16,"forks":7,"open_issues":16,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69"},"html":{"href":"https://github.com/pivotalsoftware/quickstep/pull/69"},"issue":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/69"},"comments":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/501fe4864f4abf639987b8e6601361731e0782e4"}}}}