Chromium Code Reviews (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out

Unified Diff: appengine/monorail/proto/

Issue 1868553004: Open Source Monorail (Closed) Base URL:
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/proto/ ('k') | appengine/monorail/proto/ » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/proto/
diff --git a/appengine/monorail/proto/ b/appengine/monorail/proto/
new file mode 100644
index 0000000000000000000000000000000000000000..db911270118c85eca4b011cdb155ac7ac3913c5a
--- /dev/null
+++ b/appengine/monorail/proto/
@@ -0,0 +1,87 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+"""Protocol buffers for user queries parsed into abstract syntax trees.
+A user issue query can look like [Type=Defect owner:jrobbins "memory leak"].
+In that simple form, all the individual search conditions are simply ANDed
+together. In the code, a list of conditions to be ANDed is called a
+Monorail also supports a quick-or feature: [Type=Defect,Enhancement]. That
+will match any issue that has labels Type-Defect or Type-Enhancement, or both.
+TODO(jrobbins): Monorail should also support a top-level "OR" keyword that can
+be used to logically OR a series of conjunctions. For example:
+[Type=Defect stars>10 OR Type=Enhancement stars>50]. Right now, these queries
+are parsed and represented in the AST, but not fully processed.
+There are no parenthesis and no "AND" keyword. So, the AST is always exactly
+two levels: the overall tree consistes of a list of conjunctions, and each
+conjunction consists of a list of conditions.
+A condition can look like [stars>10] or [summary:memory] or
+[Type=Defect,Enhancement]. Each condition has a single comparison operator.
+Most conditions refer to a single field definition, but in the case of
+cross-project search a single condition can have a list of field definitions
+from the different projects being searched. Each condition can have a list
+of constant values to compare against. The values may be all strings or all
+Some conditions are procesed by the SQL database and others by the GAE
+search API. All conditions are passed to each module and it is up to
+the module to decide which conditions to handle and which to ignore.
+from protorpc import messages
+from proto import tracker_pb2
+# This is a special field_name for a FieldDef that means to do a fulltext
+# search for words that occur in any part of the issue.
+ANY_FIELD = 'any_field'
+class QueryOp(messages.Enum):
+ """Enumeration of possible query condition operators."""
+ EQ = 1
+ NE = 2
+ LT = 3
+ GT = 4
+ LE = 5
+ GE = 6
+ TEXT_HAS = 7
+ KEY_HAS = 13
+class Condition(messages.Message):
+ """Representation of one query condition. E.g., [Type=Defect,Task]."""
+ op = messages.EnumField(QueryOp, 1, required=True)
+ field_defs = messages.MessageField(tracker_pb2.FieldDef, 2, repeated=True)
+ str_values = messages.StringField(3, repeated=True)
+ int_values = messages.IntegerField(4, repeated=True)
+class Conjunction(messages.Message):
+ """A list of conditions that are implicitly ANDed together."""
+ conds = messages.MessageField(Condition, 1, repeated=True)
+class QueryAST(messages.Message):
+ """Abstract syntax tree for the user's query."""
+ conjunctions = messages.MessageField(Conjunction, 1, repeated=True)
+def MakeCond(op, field_defs, str_values, int_values):
+ """Shorthand function to construct a Condition PB."""
+ return Condition(
+ op=op, field_defs=field_defs, str_values=str_values,
+ int_values=int_values)
« no previous file with comments | « appengine/monorail/proto/ ('k') | appengine/monorail/proto/ » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698