Add search fields for # of changed lines.
Based off https://gerrit-review.googlesource.com/#/c/52190, but implementing the final suggestion of indexing raw delta counts and allowing arbitrary range queries off of those. Also upgrade Lucene to 4.8.1 as this was released since the last schema change (which was on 4.7.0). Change-Id: Ia8a677e71e133f68eced4c5394df1d23efe7f12a
This commit is contained in:
@@ -29,6 +29,7 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||
import com.google.gerrit.server.query.change.ChangeStatusPredicate;
|
||||
import com.google.gerrit.server.query.change.ChangeData.ChangedLines;
|
||||
import com.google.gwtorm.protobuf.CodecFactory;
|
||||
import com.google.gwtorm.protobuf.ProtobufCodec;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -428,6 +429,40 @@ public class ChangeField {
|
||||
}
|
||||
};
|
||||
|
||||
/** The number of inserted lines in this change. */
|
||||
public static final FieldDef<ChangeData, Integer> ADDED =
|
||||
new FieldDef.Single<ChangeData, Integer>(
|
||||
ChangeQueryBuilder.FIELD_ADDED, FieldType.INTEGER_RANGE, true) {
|
||||
@Override
|
||||
public Integer get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
return input.changedLines().insertions;
|
||||
}
|
||||
};
|
||||
|
||||
/** The number of deleted lines in this change. */
|
||||
public static final FieldDef<ChangeData, Integer> DELETED =
|
||||
new FieldDef.Single<ChangeData, Integer>(
|
||||
ChangeQueryBuilder.FIELD_DELETED, FieldType.INTEGER_RANGE, true) {
|
||||
@Override
|
||||
public Integer get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
return input.changedLines().deletions;
|
||||
}
|
||||
};
|
||||
|
||||
/** The total number of modified lines in this change. */
|
||||
public static final FieldDef<ChangeData, Integer> DELTA =
|
||||
new FieldDef.Single<ChangeData, Integer>(
|
||||
ChangeQueryBuilder.FIELD_DELTA, FieldType.INTEGER_RANGE, false) {
|
||||
@Override
|
||||
public Integer get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
ChangedLines changedLines = input.changedLines();
|
||||
return changedLines.insertions + changedLines.deletions;
|
||||
}
|
||||
};
|
||||
|
||||
private static <T> List<byte[]> toProtos(ProtobufCodec<T> codec, Collection<T> objs)
|
||||
throws OrmException {
|
||||
List<byte[]> result = Lists.newArrayListWithCapacity(objs.size());
|
||||
|
||||
Reference in New Issue
Block a user