Serve label predicate from Lucene index

To build the Lucene query we need to know the maximum range a label can
have. Since the label ranges can be defined per project the maximum
range for a label is hard to compute. For this we would need to scan
over all projects and parse the project.config files. Instead of doing
this we hard code for now a maximum query range from -4 to +4. This
range should be wide enough to support most labels.

The query behaviour for searching labels with value 0 has changed. We
now return all changes that have no voting on that label from any
reviewer (this includes changes without any reviewer). Earlier we
returned changes that had a reviewer for which an explicit 0 value was
stored. This old behaviour was unexpected by most users.

Change-Id: Ic0e5ae86933d605e67c9da8ef289a0b099d82cbf
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-06-25 23:58:36 +02:00
parent 889126bc46
commit 451cda472b
3 changed files with 262 additions and 162 deletions

View File

@@ -45,7 +45,7 @@ import java.util.Set;
*/
public class ChangeField {
/** Increment whenever making schema changes. */
public static final int SCHEMA_VERSION = 9;
public static final int SCHEMA_VERSION = 10;
/** Legacy change ID. */
public static final FieldDef<ChangeData, Integer> LEGACY_ID =
@@ -203,6 +203,27 @@ public class ChangeField {
}
};
/** List of labels on the current patch set. */
public static final FieldDef<ChangeData, Iterable<String>> LABEL =
new FieldDef.Repeatable<ChangeData, String>(
ChangeQueryBuilder.FIELD_LABEL, FieldType.EXACT, false) {
@Override
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> distinctApprovals = Sets.newHashSet();
for (PatchSetApproval a : input.currentApprovals(args.db)) {
if (a.getValue() != 0) {
distinctApprovals.add(formatLabel(a.getLabel(), a.getValue()));
}
}
return distinctApprovals;
}
};
public static String formatLabel(String label, int value) {
return label.toLowerCase() + (value >= 0 ? "+" : "") + value;
}
public static final ImmutableMap<String, FieldDef<ChangeData, ?>> ALL;
static {