InternalChangeQuery: Add a noFields builder method
Allows to build a query that does not request any stored fields, without the caller explicitly having to call setRequestedFields with an empty set. Change-Id: I1d2be6e9c3947ef79901bd269f33475677863482
This commit is contained in:
		| @@ -15,7 +15,6 @@ | ||||
| package com.google.gerrit.server; | ||||
|  | ||||
| import com.google.common.base.Optional; | ||||
| import com.google.common.collect.ImmutableSet; | ||||
| import com.google.common.primitives.Ints; | ||||
| import com.google.gerrit.reviewdb.client.Change; | ||||
| import com.google.gerrit.server.change.ChangeTriplet; | ||||
| @@ -55,8 +54,7 @@ public class ChangeFinder { | ||||
|       throws OrmException { | ||||
|     // Use the index to search for changes, but don't return any stored fields, | ||||
|     // to force rereading in case the index is stale. | ||||
|     InternalChangeQuery query = queryProvider.get() | ||||
|         .setRequestedFields(ImmutableSet.<String> of()); | ||||
|     InternalChangeQuery query = queryProvider.get().noFields(); | ||||
|  | ||||
|     // Try legacy id | ||||
|     if (!id.isEmpty() && id.charAt(0) != '0') { | ||||
| @@ -96,8 +94,7 @@ public class ChangeFinder { | ||||
|       throws OrmException { | ||||
|     // Use the index to search for changes, but don't return any stored fields, | ||||
|     // to force rereading in case the index is stale. | ||||
|     InternalChangeQuery query = queryProvider.get() | ||||
|         .setRequestedFields(ImmutableSet.<String> of()); | ||||
|     InternalChangeQuery query = queryProvider.get().noFields(); | ||||
|     return asChangeControls(query.byLegacyChangeId(id), user); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import static com.google.gerrit.server.query.change.ChangeStatusPredicate.open; | ||||
|  | ||||
| import com.google.common.annotations.VisibleForTesting; | ||||
| import com.google.common.base.Strings; | ||||
| import com.google.common.collect.ImmutableSet; | ||||
| import com.google.common.collect.Sets; | ||||
| import com.google.gerrit.common.Nullable; | ||||
| import com.google.gerrit.reviewdb.client.Branch; | ||||
| @@ -110,6 +111,11 @@ public class InternalChangeQuery { | ||||
|     return this; | ||||
|   } | ||||
|  | ||||
|   public InternalChangeQuery noFields() { | ||||
|     qp.setRequestedFields(ImmutableSet.<String> of()); | ||||
|     return this; | ||||
|   } | ||||
|  | ||||
|   public List<ChangeData> byKey(Change.Key key) throws OrmException { | ||||
|     return byKeyPrefix(key.get()); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse