kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/proto/storage.proto (about) 1 /* 2 * Copyright 2014 The Kythe Authors. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 syntax = "proto3"; 18 19 package kythe.proto; 20 21 option go_package = "kythe.io/kythe/proto/storage_go_proto"; 22 option java_package = "com.google.devtools.kythe.proto"; 23 24 // VName is a proto representation of a vector name. 25 // See also 26 // https://kythe.io/docs/kythe-storage.html#_a_id_termvname_a_vector_name_strong_vname_strong 27 // 28 // Rules: 29 // - All fields must be optional, and must have default values. 30 // - No field may ever be removed. If a field is deprecated, it may be 31 // renamed or marked with a comment, but must not be deleted. 32 // - New fields are always added to the end of the message. 33 // - All fields must be strings, not messages. 34 // 35 // One of the key principles is that we want as few fields as possible in a 36 // vname. We're not trying to exhaust the possible dimensions along which a 37 // name could vary, but to find a minimal basis. Be conservative. 38 message VName { 39 // A language-specific signature assigned by the analyzer. 40 // e.g., "com.google.common.collect.Lists.newLinkedList<#1>()" 41 string signature = 1; 42 43 // The corpus this name belongs to. 44 // e.g., "kythe", "chromium", "github.com/creachadair/imath", "aosp" 45 // The corpus label "kythe" is reserved for internal use. 46 string corpus = 2; 47 48 // A corpus-specific root label, designating a subordinate collection within 49 // the corpus. If a corpus stores files in unrelated directory structures, 50 // for example, the root can be used to distinguish them. Or, if a corpus 51 // incorporates subprojects, the root can be a project ID that it governs. 52 // This may also be used to distinguish virtual subgroups of a corpus such as 53 // generated files. 54 string root = 3; 55 56 // A path-structured label describing the location of this object relative to 57 // the corpus and the root. For code, this will generally be the relative 58 // path to the file containing the code, e.g., "storage/service.go" in kythe. 59 // The individual elements of the path are separated by "/". 60 // The path must not start with "/". 61 // The path must be normalized to a canonical form (with no path 62 // elements "", ".", or ".."). 63 // 64 // However, this need not be a true file path; virtual objects like figments 65 // can assign an ad-hoc abstract ID, or omit it entirely. 66 // 67 // Examples: 68 // "devools/kythe/platform/go/datastore.go" (a file) 69 // "type/cpp/void.cc" (a type figment) 70 string path = 4; 71 72 // The language this name belongs to. 73 // e.g., "c++", "python", "elisp", "haskell", "java" 74 // 75 // The schema will define specific labels for each supported language, so we 76 // don't wind up with a confusion of names like "cxx", "cpp", "C++", etc. 77 // Prototype: Official language name converted to lowercase. If a version 78 // number is necessary, include it, e.g., "python3". 79 string language = 5; 80 81 // Other fields we may need in the future, but do not currently use: 82 // branch -- a branch name within the corpus depot, e.g., "gslb_branch". 83 // client -- a source-control client ID, e.g., "sergey:googlex:8:citc". 84 85 // Note: We have intentionally NOT included a revision or timestamp here. 86 // Time should be recorded as facts belonging to the appropriate Nodes and 87 // Edges. Having records of when something existed may be important, but time 88 // is not a good axis for a name -- a name should say "what" something is, not 89 // "when". So we will store timestamps, revisions, and other markers of this 90 // kind as facts inside the graph. 91 } 92 93 message VNameMask { 94 bool signature = 1; 95 bool corpus = 2; 96 bool root = 3; 97 bool path = 4; 98 bool language = 5; 99 } 100 101 // An Entry associates a fact with a graph object (node or edge). This is the 102 // the primary unit of storage. 103 message Entry { 104 VName source = 1; 105 106 // The following two fields must either be both empty, or both nonempty. 107 string edge_kind = 2; 108 VName target = 3; 109 110 // The grammar for fact_name: 111 // name = "/" | 1*path 112 // path = "/" word 113 // word = 1*{LETTER|DIGIT|PUNCT} 114 // LETTER = [A-Za-z] 115 // DIGIT = [0-9] 116 // PUNCT = [-.@#$%&_+:()] 117 string fact_name = 4; 118 bytes fact_value = 5; 119 } 120 121 // A collection of Entry instances. 122 message Entries { 123 repeated Entry entries = 1; 124 } 125 126 // Request for a stream of Entry objects from a GraphStore. Read operations 127 // should be implemented with time complexity proportional to the size of the 128 // return set. 129 message ReadRequest { 130 // Return entries having this source VName, which may not be empty. 131 VName source = 1; 132 133 // Return entries having this edge kind; if empty, only entries with an empty 134 // edge kind are returned; if "*", entries of any edge kind are returned. 135 string edge_kind = 2; 136 } 137 138 // Request to write Entry objects to a GraphStore 139 message WriteRequest { 140 message Update { 141 string edge_kind = 1; 142 VName target = 2; 143 string fact_name = 3; 144 bytes fact_value = 4; 145 } 146 147 VName source = 1; 148 repeated Update update = 2; 149 } 150 151 // Response to a WriteRequest 152 message WriteReply {} 153 154 // Request for a stream of Entry objects resulting from a full scan of a 155 // GraphStore. 156 message ScanRequest { 157 // Return entries having this target VName; if empty, any target field is 158 // matched, including empty. 159 VName target = 1; 160 161 // Return entries having this kind; if empty, any kind is matched, including 162 // empty. 163 string edge_kind = 2; 164 165 // Return entries having fact labels with this prefix; if empty, any fact 166 // label is matched, 167 string fact_prefix = 3; 168 } 169 170 // Request for the size of the shard at the given index. 171 message CountRequest { 172 int64 index = 1; 173 int64 shards = 2; 174 } 175 176 // Response for a CountRequest 177 message CountReply { 178 // Total number of entries in the specified shard. 179 int64 entries = 1; 180 } 181 182 // Request for a stream of Entry objects in the given shard. 183 message ShardRequest { 184 int64 index = 1; 185 int64 shards = 2; 186 } 187 188 // A VNameRewriteRule associates a regular expression pattern with a VName 189 // template. A rule can be applied to a string to produce a VName. 190 message VNameRewriteRule { 191 // An RE2 pattern to match against an input string. Patterns are implicitly 192 // anchored at both ends. 193 string pattern = 1; 194 195 // A template VName to populate with matches from the input. The template 196 // strings may contain markers of the form @n@, that will be replaced by the 197 // n'th regexp group on a successful input match. 198 VName v_name = 2 [json_name = "vname"]; 199 } 200 201 // VNameRewriteRules is a container for multiple VNameRewriteRules. 202 message VNameRewriteRules { 203 repeated VNameRewriteRule rule = 1; 204 }