kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/proto/graph.proto (about)

     1  /*
     2   * Copyright 2016 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  import "kythe/proto/common.proto";
    22  
    23  option go_package = "kythe.io/kythe/proto/graph_go_proto";
    24  option java_package = "com.google.devtools.kythe.proto";
    25  
    26  // This file defines a graph service interface, based on Kythe data.
    27  //
    28  // Tickets are Kythe URIs (http://www.kythe.io/docs/kythe-uri-spec.html).
    29  
    30  // GraphService provides fast single-step node and edge lookups in a Kythe
    31  // graph. The difference between this and a GraphStore is that queries for
    32  // reverse relationships are also expected to be fast.
    33  //
    34  // There is no distinction between "node not found" and "no facts/edges for
    35  // node".  A node is extensionally defined by its facts and edges, so a node
    36  // without any facts or edges is not considered to exist.
    37  service GraphService {
    38    // Nodes returns a subset of the facts for each of the requested nodes.
    39    rpc Nodes(NodesRequest) returns (NodesReply) {}
    40  
    41    // Edges returns a subset of the outbound edges for each of a set of
    42    // requested nodes.
    43    rpc Edges(EdgesRequest) returns (EdgesReply) {}
    44  }
    45  
    46  message NodesRequest {
    47    // The tickets of the nodes to be looked up.
    48    repeated string ticket = 1;
    49  
    50    // A collection of filter globs that specify which facts (by name) should be
    51    // returned for each node.  If filter is empty or unset, all available facts
    52    // are returned for each matching node.  The filter applies to ALL requested
    53    // nodes.  For different filters per node, the client must issue separate
    54    // requests.  See EdgesRequest for the format of the filter globs.
    55    repeated string filter = 2;
    56  }
    57  
    58  message NodesReply {
    59    // One NodeInfo, keyed by its ticket, is returned for each requested node
    60    // that had a non-zero number of matching facts.  Each NodeInfo will not have
    61    // its ticket set since it would just be a copy of the map keys.
    62    map<string, common.NodeInfo> nodes = 1;
    63  }
    64  
    65  message EdgesRequest {
    66    // The tickets of the source nodes for which edges are requested.
    67    // The service will return an error if no tickets are specified.
    68    repeated string ticket = 1;
    69  
    70    // The kinds of outbound edges that should be returned for each matching
    71    // source node.  If empty, all available edge kinds are returned.
    72    repeated string kind = 2;
    73  
    74    // A collection of filter globs that specify which facts (by name) should be
    75    // returned for the target node of each matching edge.  If filter is empty,
    76    // no facts are returned.
    77    //
    78    // The supported glob operators are:
    79    //   *   zero or more non-slash characters ([^/]*)
    80    //   ?   any single non-slash character ([^/])
    81    //   **  zero or more of any character (.*)
    82    //
    83    // All other characters match literally, and the glob must consume the entire
    84    // name in order to match.  The facts returned are the union of those matched
    85    // by all the globs provided.
    86    repeated string filter = 3;
    87  
    88    // The edges matching a request are organized into logical pages.  The size
    89    // of each page is a number of distinct edges.  Notionally: All the matching
    90    // edges are ordered lexicographically by (start_ticket, kind, end_ticket);
    91    // the page_token determines where in the ordering to start, and page_size
    92    // determines how many edges should be returned.
    93    //
    94    // If page_token is empty, edges will be returned starting at the beginning
    95    // of the sequence; otherwise the starting point named by the page_token will
    96    // be used.  Legal values of page_token are returned by the server in the
    97    // next_page_token field of the EdgesReply.  A page token should be treated
    98    // as an opaque value by the client, and is valid only relative to a
    99    // particular set of tickets and kinds.  If an invalid page token is
   100    // requested, the server will return an error.
   101    //
   102    // If page_size > 0, at most that number of edges will be returned by the
   103    // service for this request (see EdgeSet and EdgesReply below).
   104    // If page_size = 0, the default, the server will assume a reasonable default
   105    // page size.  The server will return an error if page_size < 0.
   106    //
   107    // The server is allowed to return fewer edges than the requested page_size,
   108    // even if more are available, save that it must return at least 1 edge if
   109    // any are available at all.
   110    int32 page_size = 8;
   111    string page_token = 9;
   112  
   113    // TODO(fromberger): Should this interface support automatic indirection
   114    // through "name" nodes?
   115    // For now, I'm assuming name-indirecting lookup will be a separate
   116    // API, and that the initial clients will just make two (batching)
   117    // calls if they need to.
   118  }
   119  
   120  // An EdgeSet represents a collection of edges outbound from a single node.  The
   121  // edges are organized into groups, each sharing a common edge kind.
   122  //
   123  // The number of edges represented by an EdgeSet es, denoted len(es), is the sum
   124  // of the lengths of the repeated edge fields for all the groups in the EdgeSet.
   125  // This count is used to determine page size in a request.
   126  message EdgeSet {
   127    message Group {
   128      message Edge {
   129        string target_ticket = 1;
   130  
   131        // An optional integer to give an ordering between multiple edges of same
   132        // source and kind to one or more targets.  See https://kythe.io/schema
   133        // for when ordinals are used for a given edge kind.
   134        int32 ordinal = 2;
   135      }
   136  
   137      repeated Edge edge = 2;
   138  
   139      reserved 1;
   140      reserved "kind";
   141    }
   142  
   143    // Each group is a collection of outbound edges from source node sharing a
   144    // given kind, the map's keys.  In a given EdgeSet, the server will not send
   145    // more than one group with the same kind label.
   146    map<string, Group> groups = 2;
   147  
   148    reserved 1;
   149    reserved "source_ticket";
   150  }
   151  
   152  message EdgesReply {
   153    // This field will contain one EdgeSet for each source node with one or more
   154    // matching outbound edges, keyed by the source node's ticket.  The number of
   155    // edges represented by an EdgesReply er, denoted len(er), is the sum of
   156    // len(es) for each es in edge_sets.  This count is used to determine the page
   157    // size.
   158    map<string, EdgeSet> edge_sets = 1;
   159  
   160    // This field will contain one entry, keyed by ticket, for each distinct node
   161    // referenced by some edge in edgesets, for which there is one or more
   162    // matching facts.
   163    //
   164    // Rationale: This prevents us from having to copy the data to all the end
   165    // nodes, but allows the client to have that information without making
   166    // additional requests.
   167    map<string, common.NodeInfo> nodes = 2;
   168  
   169    // Total number of edges on all pages matching requested kinds, by kind.
   170    map<string, int64> total_edges_by_kind = 5;
   171  
   172    // If there are additional pages of edges after the ones returned in this
   173    // reply, next_page_token is the page token that may be passed to fetch the
   174    // next page in sequence after this one.  If there are no additional edges,
   175    // this field will be empty.
   176    string next_page_token = 9;
   177  }