Move most Change-related index code to an index subpackage

Change-Id: I8812982c88f8fb0b97b14adacf358153f1db4e9c
This commit is contained in:
Dave Borowitz
2016-03-15 13:53:57 +01:00
parent ec015a446d
commit e023347830
79 changed files with 137 additions and 112 deletions

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.index;
import com.google.gerrit.server.index.change.ChangeIndex;
import com.google.gerrit.server.index.change.DummyChangeIndex;
import com.google.inject.AbstractModule;
public class DummyIndexModule extends AbstractModule {
@@ -22,6 +24,6 @@ public class DummyIndexModule extends AbstractModule {
protected void configure() {
install(new IndexModule(1));
bind(IndexConfig.class).toInstance(IndexConfig.createDefault());
bind(ChangeIndex.class).toInstance(new DummyIndex());
bind(ChangeIndex.class).toInstance(new DummyChangeIndex());
}
}

View File

@@ -36,7 +36,7 @@ import org.eclipse.jgit.lib.Config;
public abstract class FieldDef<I, T> {
/** Definition of a single (non-repeatable) field. */
public abstract static class Single<I, T> extends FieldDef<I, T> {
Single(String name, FieldType<T> type, boolean stored) {
protected Single(String name, FieldType<T> type, boolean stored) {
super(name, type, stored);
}
@@ -49,7 +49,7 @@ public abstract class FieldDef<I, T> {
/** Definition of a repeatable field. */
public abstract static class Repeatable<I, T>
extends FieldDef<I, Iterable<T>> {
Repeatable(String name, FieldType<T> type, boolean stored) {
protected Repeatable(String name, FieldType<T> type, boolean stored) {
super(name, type, stored);
Preconditions.checkArgument(type != FieldType.INTEGER_RANGE,
"Range queries against repeated fields are unsupported");
@@ -63,8 +63,8 @@ public abstract class FieldDef<I, T> {
/** Arguments needed to fill in missing data in the input object. */
public static class FillArgs {
final TrackingFooters trackingFooters;
final boolean allowsDrafts;
public final TrackingFooters trackingFooters;
public final boolean allowsDrafts;
@Inject
FillArgs(TrackingFooters trackingFooters,

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.index;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.server.index.change.ChangeIndex;
import com.google.inject.Inject;
import com.google.inject.Singleton;

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.index;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.auto.value.AutoValue;
import com.google.gerrit.server.index.change.ChangeIndex;
import org.eclipse.jgit.lib.Config;

View File

@@ -22,6 +22,8 @@ import com.google.common.util.concurrent.MoreExecutors;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.git.WorkQueue;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.index.change.IndexRewriter;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Provides;

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.index;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
@@ -65,11 +64,10 @@ public class Schema<T> {
private int version;
protected Schema(Iterable<FieldDef<T, ?>> fields) {
public Schema(Iterable<FieldDef<T, ?>> fields) {
this(0, fields);
}
@VisibleForTesting
public Schema(int version, Iterable<FieldDef<T, ?>> fields) {
this.version = version;
ImmutableMap.Builder<String, FieldDef<T, ?>> b = ImmutableMap.builder();
@@ -190,7 +188,7 @@ public class Schema<T> {
.toString();
}
void setVersion(int version) {
public void setVersion(int version) {
this.version = version;
}
}

View File

@@ -36,6 +36,8 @@ import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MergeUtil;
import com.google.gerrit.server.git.MultiProgressMonitor;
import com.google.gerrit.server.git.MultiProgressMonitor.Task;
import com.google.gerrit.server.index.change.ChangeIndex;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.patch.PatchListLoader;
import com.google.gerrit.server.query.change.ChangeData;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import static com.google.common.base.MoreObjects.firstNonNull;
@@ -30,6 +30,8 @@ import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.client.PatchLineComment;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.server.index.FieldDef;
import com.google.gerrit.server.index.FieldType;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeData.ChangedLines;
import com.google.gerrit.server.query.change.ChangeQueryBuilder;

View File

@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.IndexPredicate;
import com.google.gerrit.server.index.Schema;
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gerrit.server.query.change.ChangeData;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Atomics;
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.extensions.events.ChangeIndexedListener;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.util.RequestContext;
import com.google.gerrit.server.util.ThreadLocalRequestContext;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import static com.google.common.base.Preconditions.checkArgument;
@@ -20,6 +20,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.gerrit.server.index.FieldDef;
import com.google.gerrit.server.index.Schema;
import com.google.gerrit.server.query.change.ChangeData;
import java.lang.reflect.Field;

View File

@@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.index.Schema;
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeDataSource;
@@ -22,7 +23,7 @@ import com.google.gerrit.server.query.change.QueryOptions;
import java.io.IOException;
public class DummyIndex implements ChangeIndex {
public class DummyChangeIndex implements ChangeIndex {
@Override
public Schema<ChangeData> getSchema() {
throw new UnsupportedOperationException();

View File

@@ -12,12 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Change.Status;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.index.IndexConfig;
import com.google.gerrit.server.index.IndexPredicate;
import com.google.gerrit.server.query.AndPredicate;
import com.google.gerrit.server.query.NotPredicate;
import com.google.gerrit.server.query.OrPredicate;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -20,6 +20,7 @@ import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import com.google.gerrit.server.index.IndexPredicate;
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gerrit.server.query.change.ChangeData;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.index;
package com.google.gerrit.server.index.change;
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
@@ -26,6 +26,8 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.git.QueueProvider.QueueType;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.index.IndexExecutor;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.query.change.InternalChangeQuery;