Extract interfaces for Index and IndexCollection
Add another type argument for the key type, e.g. Change.Id. Keep subinterfaces ChangeIndex and ChangeIndexCollection to avoid having to pass around lots of type arguments; Schema<ChangeData> was bad enough, adding one more would be tortuous. Change-Id: Id54b985692ca41ffcaabe9793d8b9035cb1d4e82
This commit is contained in:
@@ -45,6 +45,7 @@ import com.google.gerrit.server.index.FieldDef;
|
|||||||
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
||||||
import com.google.gerrit.server.index.FieldType;
|
import com.google.gerrit.server.index.FieldType;
|
||||||
import com.google.gerrit.server.index.IndexExecutor;
|
import com.google.gerrit.server.index.IndexExecutor;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.index.Schema.Values;
|
import com.google.gerrit.server.index.Schema.Values;
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
@@ -57,7 +58,6 @@ import com.google.gerrit.server.query.Predicate;
|
|||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
import com.google.gwtorm.protobuf.ProtobufCodec;
|
import com.google.gwtorm.protobuf.ProtobufCodec;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ package com.google.gerrit.lucene;
|
|||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
import com.google.gerrit.server.index.IndexModule;
|
import com.google.gerrit.server.index.IndexModule;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.ChangeSchemas;
|
import com.google.gerrit.server.index.change.ChangeSchemas;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -88,11 +88,11 @@ public class LuceneIndexModule extends LifecycleModule {
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
static class SingleVersionListener implements LifecycleListener {
|
static class SingleVersionListener implements LifecycleListener {
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final LuceneChangeIndex index;
|
private final LuceneChangeIndex index;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SingleVersionListener(IndexCollection indexes,
|
SingleVersionListener(ChangeIndexCollection indexes,
|
||||||
LuceneChangeIndex index) {
|
LuceneChangeIndex index) {
|
||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import com.google.common.primitives.Ints;
|
|||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.ChangeSchemas;
|
import com.google.gerrit.server.index.change.ChangeSchemas;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -92,7 +92,7 @@ public class LuceneVersionManager implements LifecycleListener {
|
|||||||
|
|
||||||
private final SitePaths sitePaths;
|
private final SitePaths sitePaths;
|
||||||
private final LuceneChangeIndex.Factory indexFactory;
|
private final LuceneChangeIndex.Factory indexFactory;
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final OnlineReindexer.Factory reindexerFactory;
|
private final OnlineReindexer.Factory reindexerFactory;
|
||||||
private final boolean onlineUpgrade;
|
private final boolean onlineUpgrade;
|
||||||
private OnlineReindexer reindexer;
|
private OnlineReindexer reindexer;
|
||||||
@@ -102,7 +102,7 @@ public class LuceneVersionManager implements LifecycleListener {
|
|||||||
@GerritServerConfig Config cfg,
|
@GerritServerConfig Config cfg,
|
||||||
SitePaths sitePaths,
|
SitePaths sitePaths,
|
||||||
LuceneChangeIndex.Factory indexFactory,
|
LuceneChangeIndex.Factory indexFactory,
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
OnlineReindexer.Factory reindexerFactory) {
|
OnlineReindexer.Factory reindexerFactory) {
|
||||||
this.sitePaths = sitePaths;
|
this.sitePaths = sitePaths;
|
||||||
this.indexFactory = indexFactory;
|
this.indexFactory = indexFactory;
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ package com.google.gerrit.lucene;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
import com.google.gerrit.server.index.Index;
|
||||||
import com.google.gerrit.server.index.SiteIndexer;
|
import com.google.gerrit.server.index.SiteIndexer;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -39,7 +40,7 @@ public class OnlineReindexer {
|
|||||||
OnlineReindexer create(int version);
|
OnlineReindexer create(int version);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final SiteIndexer batchIndexer;
|
private final SiteIndexer batchIndexer;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
private final int version;
|
private final int version;
|
||||||
@@ -48,7 +49,7 @@ public class OnlineReindexer {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OnlineReindexer(
|
OnlineReindexer(
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
SiteIndexer batchIndexer,
|
SiteIndexer batchIndexer,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
@Assisted int version) {
|
@Assisted int version) {
|
||||||
@@ -84,7 +85,7 @@ public class OnlineReindexer {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int version(ChangeIndex i) {
|
private static int version(Index<?, ?> i) {
|
||||||
return i.getSchema().getVersion();
|
return i.getSchema().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.git.ScanningChangeCacheImpl;
|
import com.google.gerrit.server.git.ScanningChangeCacheImpl;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexModule;
|
import com.google.gerrit.server.index.IndexModule;
|
||||||
import com.google.gerrit.server.index.IndexModule.IndexType;
|
import com.google.gerrit.server.index.IndexModule.IndexType;
|
||||||
import com.google.gerrit.server.index.SiteIndexer;
|
import com.google.gerrit.server.index.SiteIndexer;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.ChangeSchemas;
|
import com.google.gerrit.server.index.change.ChangeSchemas;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
@@ -100,7 +100,8 @@ public class Reindex extends SiteProgram {
|
|||||||
projectCache = sysInjector.getInstance(ProjectCache.class);
|
projectCache = sysInjector.getInstance(ProjectCache.class);
|
||||||
repoManager = sysInjector.getInstance(GitRepositoryManager.class);
|
repoManager = sysInjector.getInstance(GitRepositoryManager.class);
|
||||||
|
|
||||||
index = sysInjector.getInstance(IndexCollection.class).getSearchIndex();
|
index = sysInjector.getInstance(ChangeIndexCollection.class)
|
||||||
|
.getSearchIndex();
|
||||||
int result = 0;
|
int result = 0;
|
||||||
try {
|
try {
|
||||||
index.markReady(false);
|
index.markReady(false);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index;
|
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.gerrit.server.index.change.DummyChangeIndex;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
@@ -24,6 +23,6 @@ public class DummyIndexModule extends AbstractModule {
|
|||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new IndexModule(1));
|
install(new IndexModule(1));
|
||||||
bind(IndexConfig.class).toInstance(IndexConfig.createDefault());
|
bind(IndexConfig.class).toInstance(IndexConfig.createDefault());
|
||||||
bind(ChangeIndex.class).toInstance(new DummyChangeIndex());
|
bind(Index.class).toInstance(new DummyChangeIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// Copyright (C) 2013 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.index;
|
||||||
|
|
||||||
|
import com.google.gerrit.server.query.DataSource;
|
||||||
|
import com.google.gerrit.server.query.Predicate;
|
||||||
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secondary index implementation for arbitrary documents.
|
||||||
|
* <p>
|
||||||
|
* Documents are inserted into the index and are queried by converting special
|
||||||
|
* {@link com.google.gerrit.server.query.Predicate} instances into index-aware
|
||||||
|
* predicates that use the index search results as a source.
|
||||||
|
* <p>
|
||||||
|
* Implementations must be thread-safe and should batch inserts/updates where
|
||||||
|
* appropriate.
|
||||||
|
*/
|
||||||
|
public interface Index<K, V> {
|
||||||
|
/** @return the schema version used by this index. */
|
||||||
|
Schema<V> getSchema();
|
||||||
|
|
||||||
|
/** Close this index. */
|
||||||
|
void close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a document in the index.
|
||||||
|
* <p>
|
||||||
|
* Semantically equivalent to deleting the document and reinserting it with
|
||||||
|
* new field values. A document that does not already exist is created. Results
|
||||||
|
* may not be immediately visible to searchers, but should be visible within a
|
||||||
|
* reasonable amount of time.
|
||||||
|
*
|
||||||
|
* @param obj document object
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
void replace(V obj) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a document from the index by key.
|
||||||
|
*
|
||||||
|
* @param key document key
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
void delete(K key) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all documents from the index.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
void deleteAll() throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given operator predicate into a source searching the index and
|
||||||
|
* returning only the documents matching that predicate.
|
||||||
|
* <p>
|
||||||
|
* This method may be called multiple times for variations on the same
|
||||||
|
* predicate or multiple predicate subtrees in the course of processing a
|
||||||
|
* single query, so it should not have any side effects (e.g. starting a
|
||||||
|
* search in the background).
|
||||||
|
*
|
||||||
|
* @param p the predicate to match. Must be a tree containing only AND, OR,
|
||||||
|
* or NOT predicates as internal nodes, and {@link IndexPredicate}s as
|
||||||
|
* leaves.
|
||||||
|
* @param opts query options not implied by the predicate, such as start and
|
||||||
|
* limit.
|
||||||
|
* @return a source of documents matching the predicate, returned in a
|
||||||
|
* defined order depending on the type of documents.
|
||||||
|
*
|
||||||
|
* @throws QueryParseException if the predicate could not be converted to an
|
||||||
|
* indexed data source.
|
||||||
|
*/
|
||||||
|
DataSource<V> getSource(Predicate<V> p, QueryOptions opts)
|
||||||
|
throws QueryParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark whether this index is up-to-date and ready to serve reads.
|
||||||
|
*
|
||||||
|
* @param ready whether the index is ready
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
void markReady(boolean ready) throws IOException;
|
||||||
|
}
|
||||||
@@ -17,9 +17,7 @@ package com.google.gerrit.server.index;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -27,10 +25,10 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
/** Dynamic pointers to the index versions used for searching and writing. */
|
/** Dynamic pointers to the index versions used for searching and writing. */
|
||||||
@Singleton
|
public abstract class IndexCollection<K, V, I extends Index<K, V>>
|
||||||
public class IndexCollection implements LifecycleListener {
|
implements LifecycleListener {
|
||||||
private final CopyOnWriteArrayList<ChangeIndex> writeIndexes;
|
private final CopyOnWriteArrayList<I> writeIndexes;
|
||||||
private final AtomicReference<ChangeIndex> searchIndex;
|
private final AtomicReference<I> searchIndex;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -40,22 +38,22 @@ public class IndexCollection implements LifecycleListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return the current search index version. */
|
/** @return the current search index version. */
|
||||||
public ChangeIndex getSearchIndex() {
|
public I getSearchIndex() {
|
||||||
return searchIndex.get();
|
return searchIndex.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchIndex(ChangeIndex index) {
|
public void setSearchIndex(I index) {
|
||||||
ChangeIndex old = searchIndex.getAndSet(index);
|
I old = searchIndex.getAndSet(index);
|
||||||
if (old != null && old != index && !writeIndexes.contains(old)) {
|
if (old != null && old != index && !writeIndexes.contains(old)) {
|
||||||
old.close();
|
old.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ChangeIndex> getWriteIndexes() {
|
public Collection<I> getWriteIndexes() {
|
||||||
return Collections.unmodifiableCollection(writeIndexes);
|
return Collections.unmodifiableCollection(writeIndexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ChangeIndex addWriteIndex(ChangeIndex index) {
|
public synchronized I addWriteIndex(I index) {
|
||||||
int version = index.getSchema().getVersion();
|
int version = index.getSchema().getVersion();
|
||||||
for (int i = 0; i < writeIndexes.size(); i++) {
|
for (int i = 0; i < writeIndexes.size(); i++) {
|
||||||
if (writeIndexes.get(i).getSchema().getVersion() == version) {
|
if (writeIndexes.get(i).getSchema().getVersion() == version) {
|
||||||
@@ -83,8 +81,8 @@ public class IndexCollection implements LifecycleListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeIndex getWriteIndex(int version) {
|
public I getWriteIndex(int version) {
|
||||||
for (ChangeIndex i : writeIndexes) {
|
for (I i : writeIndexes) {
|
||||||
if (i.getSchema().getVersion() == version) {
|
if (i.getSchema().getVersion() == version) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -98,11 +96,11 @@ public class IndexCollection implements LifecycleListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
ChangeIndex read = searchIndex.get();
|
I read = searchIndex.get();
|
||||||
if (read != null) {
|
if (read != null) {
|
||||||
read.close();
|
read.close();
|
||||||
}
|
}
|
||||||
for (ChangeIndex write : writeIndexes) {
|
for (I write : writeIndexes) {
|
||||||
if (write != read) {
|
if (write != read) {
|
||||||
write.close();
|
write.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.index;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ import org.eclipse.jgit.lib.Config;
|
|||||||
* Implementation-specific configuration for secondary indexes.
|
* Implementation-specific configuration for secondary indexes.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains configuration that is tied to a specific index implementation but is
|
* Contains configuration that is tied to a specific index implementation but is
|
||||||
* otherwise global, i.e. not tied to a specific {@link ChangeIndex} and schema
|
* otherwise global, i.e. not tied to a specific {@link Index} and schema
|
||||||
* version.
|
* version.
|
||||||
*/
|
*/
|
||||||
@AutoValue
|
@AutoValue
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.common.util.concurrent.MoreExecutors;
|
|||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.git.WorkQueue;
|
import com.google.gerrit.server.git.WorkQueue;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndexer;
|
import com.google.gerrit.server.index.change.ChangeIndexer;
|
||||||
import com.google.gerrit.server.index.change.IndexRewriter;
|
import com.google.gerrit.server.index.change.IndexRewriter;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
@@ -69,8 +70,7 @@ public class IndexModule extends LifecycleModule {
|
|||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(IndexRewriter.class);
|
bind(IndexRewriter.class);
|
||||||
bind(IndexCollection.class);
|
listener().to(ChangeIndexCollection.class);
|
||||||
listener().to(IndexCollection.class);
|
|
||||||
factory(ChangeIndexer.Factory.class);
|
factory(ChangeIndexer.Factory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class IndexModule extends LifecycleModule {
|
|||||||
ChangeIndexer getChangeIndexer(
|
ChangeIndexer getChangeIndexer(
|
||||||
@IndexExecutor(INTERACTIVE) ListeningExecutorService executor,
|
@IndexExecutor(INTERACTIVE) ListeningExecutorService executor,
|
||||||
ChangeIndexer.Factory factory,
|
ChangeIndexer.Factory factory,
|
||||||
IndexCollection indexes) {
|
ChangeIndexCollection indexes) {
|
||||||
// Bind default indexer to interactive executor; callers who need a
|
// Bind default indexer to interactive executor; callers who need a
|
||||||
// different executor can use the factory directly.
|
// different executor can use the factory directly.
|
||||||
return factory.create(executor, indexes);
|
return factory.create(executor, indexes);
|
||||||
|
|||||||
@@ -12,17 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.gerrit.server.index.change.ChangeField.CHANGE;
|
|
||||||
import static com.google.gerrit.server.index.change.ChangeField.PROJECT;
|
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
@@ -31,23 +27,10 @@ public abstract class QueryOptions {
|
|||||||
Set<String> fields) {
|
Set<String> fields) {
|
||||||
checkArgument(start >= 0, "start must be nonnegative: %s", start);
|
checkArgument(start >= 0, "start must be nonnegative: %s", start);
|
||||||
checkArgument(limit > 0, "limit must be positive: %s", limit);
|
checkArgument(limit > 0, "limit must be positive: %s", limit);
|
||||||
|
|
||||||
// Always include project since it is needed to load the change from notedb.
|
|
||||||
if (!fields.contains(CHANGE.getName())
|
|
||||||
&& !fields.contains(PROJECT.getName())) {
|
|
||||||
fields = new HashSet<>(fields);
|
|
||||||
fields.add(PROJECT.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AutoValue_QueryOptions(config, start, limit,
|
return new AutoValue_QueryOptions(config, start, limit,
|
||||||
ImmutableSet.copyOf(fields));
|
ImmutableSet.copyOf(fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QueryOptions oneResult() {
|
|
||||||
return create(IndexConfig.createDefault(), 0, 1,
|
|
||||||
ImmutableSet.<String> of());
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract IndexConfig config();
|
public abstract IndexConfig config();
|
||||||
public abstract int start();
|
public abstract int start();
|
||||||
public abstract int limit();
|
public abstract int limit();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2013 The Android Open Source Project
|
// Copyright (C) 2016 The Android Open Source Project
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@@ -15,91 +15,8 @@
|
|||||||
package com.google.gerrit.server.index.change;
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.Index;
|
||||||
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;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
public interface ChangeIndex extends Index<Change.Id, ChangeData> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Secondary index implementation for change documents.
|
|
||||||
* <p>
|
|
||||||
* {@link ChangeData} objects are inserted into the index and are queried by
|
|
||||||
* converting special {@link com.google.gerrit.server.query.Predicate} instances
|
|
||||||
* into index-aware predicates that use the index search results as a source.
|
|
||||||
* <p>
|
|
||||||
* Implementations must be thread-safe and should batch inserts/updates where
|
|
||||||
* appropriate.
|
|
||||||
*/
|
|
||||||
public interface ChangeIndex {
|
|
||||||
/** @return the schema version used by this index. */
|
|
||||||
Schema<ChangeData> getSchema();
|
|
||||||
|
|
||||||
/** Close this index. */
|
|
||||||
void close();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a change document in the index.
|
|
||||||
* <p>
|
|
||||||
* Semantically equivalent to deleting the document and reinserting it with
|
|
||||||
* new field values. A document that does not already exist is created. Results
|
|
||||||
* may not be immediately visible to searchers, but should be visible within a
|
|
||||||
* reasonable amount of time.
|
|
||||||
*
|
|
||||||
* @param cd change document
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
void replace(ChangeData cd) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a change document from the index by id.
|
|
||||||
*
|
|
||||||
* @param id change id
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
void delete(Change.Id id) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all change documents from the index.
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
void deleteAll() throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given operator predicate into a source searching the index and
|
|
||||||
* returning only the documents matching that predicate.
|
|
||||||
* <p>
|
|
||||||
* This method may be called multiple times for variations on the same
|
|
||||||
* predicate or multiple predicate subtrees in the course of processing a
|
|
||||||
* single query, so it should not have any side effects (e.g. starting a
|
|
||||||
* search in the background).
|
|
||||||
*
|
|
||||||
* @param p the predicate to match. Must be a tree containing only AND, OR,
|
|
||||||
* or NOT predicates as internal nodes, and {@link IndexPredicate}s as
|
|
||||||
* leaves.
|
|
||||||
* @param opts query options not implied by the predicate, such as start and
|
|
||||||
* limit.
|
|
||||||
* @return a source of documents matching the predicate. Documents must be
|
|
||||||
* returned in descending updated timestamp order.
|
|
||||||
*
|
|
||||||
* @throws QueryParseException if the predicate could not be converted to an
|
|
||||||
* indexed data source.
|
|
||||||
*/
|
|
||||||
ChangeDataSource getSource(Predicate<ChangeData> p, QueryOptions opts)
|
|
||||||
throws QueryParseException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark whether this index is up-to-date and ready to serve reads.
|
|
||||||
*
|
|
||||||
* @param ready whether the index is ready
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
void markReady(boolean ready) throws IOException;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2016 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.index.IndexCollection;
|
||||||
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class ChangeIndexCollection extends
|
||||||
|
IndexCollection<Change.Id, ChangeData, ChangeIndex> {
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.extensions.events.ChangeIndexedListener;
|
import com.google.gerrit.server.extensions.events.ChangeIndexedListener;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
import com.google.gerrit.server.index.Index;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.util.RequestContext;
|
import com.google.gerrit.server.util.RequestContext;
|
||||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||||
@@ -64,7 +64,7 @@ public class ChangeIndexer {
|
|||||||
public interface Factory {
|
public interface Factory {
|
||||||
ChangeIndexer create(ListeningExecutorService executor, ChangeIndex index);
|
ChangeIndexer create(ListeningExecutorService executor, ChangeIndex index);
|
||||||
ChangeIndexer create(ListeningExecutorService executor,
|
ChangeIndexer create(ListeningExecutorService executor,
|
||||||
IndexCollection indexes);
|
ChangeIndexCollection indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckedFuture<?, IOException> allAsList(
|
public static CheckedFuture<?, IOException> allAsList(
|
||||||
@@ -91,7 +91,7 @@ public class ChangeIndexer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final ChangeIndex index;
|
private final ChangeIndex index;
|
||||||
private final SchemaFactory<ReviewDb> schemaFactory;
|
private final SchemaFactory<ReviewDb> schemaFactory;
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
@@ -121,7 +121,7 @@ public class ChangeIndexer {
|
|||||||
ThreadLocalRequestContext context,
|
ThreadLocalRequestContext context,
|
||||||
DynamicSet<ChangeIndexedListener> indexedListener,
|
DynamicSet<ChangeIndexedListener> indexedListener,
|
||||||
@Assisted ListeningExecutorService executor,
|
@Assisted ListeningExecutorService executor,
|
||||||
@Assisted IndexCollection indexes) {
|
@Assisted ChangeIndexCollection indexes) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.schemaFactory = schemaFactory;
|
this.schemaFactory = schemaFactory;
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
@@ -165,7 +165,7 @@ public class ChangeIndexer {
|
|||||||
* @param cd change to index.
|
* @param cd change to index.
|
||||||
*/
|
*/
|
||||||
public void index(ChangeData cd) throws IOException {
|
public void index(ChangeData cd) throws IOException {
|
||||||
for (ChangeIndex i : getWriteIndexes()) {
|
for (Index<?, ChangeData> i : getWriteIndexes()) {
|
||||||
i.replace(cd);
|
i.replace(cd);
|
||||||
}
|
}
|
||||||
fireChangeIndexedEvent(cd);
|
fireChangeIndexedEvent(cd);
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
package com.google.gerrit.server.index.change;
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
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.IndexConfig;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.query.AndPredicate;
|
import com.google.gerrit.server.query.AndPredicate;
|
||||||
import com.google.gerrit.server.query.NotPredicate;
|
import com.google.gerrit.server.query.NotPredicate;
|
||||||
import com.google.gerrit.server.query.OrPredicate;
|
import com.google.gerrit.server.query.OrPredicate;
|
||||||
@@ -31,7 +31,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
|||||||
import com.google.gerrit.server.query.change.ChangeStatusPredicate;
|
import com.google.gerrit.server.query.change.ChangeStatusPredicate;
|
||||||
import com.google.gerrit.server.query.change.LimitPredicate;
|
import com.google.gerrit.server.query.change.LimitPredicate;
|
||||||
import com.google.gerrit.server.query.change.OrSource;
|
import com.google.gerrit.server.query.change.OrSource;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@@ -121,11 +120,11 @@ public class IndexRewriter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final IndexConfig config;
|
private final IndexConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
IndexRewriter(IndexCollection indexes,
|
IndexRewriter(ChangeIndexCollection indexes,
|
||||||
IndexConfig config) {
|
IndexConfig config) {
|
||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -208,7 +207,8 @@ public class IndexRewriter {
|
|||||||
return partitionChildren(in, newChildren, isIndexed, index, opts);
|
return partitionChildren(in, newChildren, isIndexed, index, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIndexPredicate(Predicate<ChangeData> in, ChangeIndex index) {
|
private boolean isIndexPredicate(Predicate<ChangeData> in,
|
||||||
|
ChangeIndex index) {
|
||||||
if (!(in instanceof IndexPredicate)) {
|
if (!(in instanceof IndexPredicate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,25 +14,33 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.change;
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.index.change.ChangeField.CHANGE;
|
||||||
|
import static com.google.gerrit.server.index.change.ChangeField.PROJECT;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
|
import com.google.gerrit.server.query.DataSource;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||||
import com.google.gerrit.server.query.change.Paginated;
|
import com.google.gerrit.server.query.change.Paginated;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper combining an {@link IndexPredicate} together with a
|
* Wrapper combining an {@link IndexPredicate} together with a
|
||||||
@@ -44,6 +52,22 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class IndexedChangeQuery extends Predicate<ChangeData>
|
public class IndexedChangeQuery extends Predicate<ChangeData>
|
||||||
implements ChangeDataSource, Paginated {
|
implements ChangeDataSource, Paginated {
|
||||||
|
public static QueryOptions oneResult() {
|
||||||
|
return createOptions(IndexConfig.createDefault(), 0, 1,
|
||||||
|
ImmutableSet.<String> of());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueryOptions createOptions(IndexConfig config, int start,
|
||||||
|
int limit, Set<String> fields) {
|
||||||
|
// Always include project since it is needed to load the change from notedb.
|
||||||
|
if (!fields.contains(CHANGE.getName())
|
||||||
|
&& !fields.contains(PROJECT.getName())) {
|
||||||
|
fields = new HashSet<>(fields);
|
||||||
|
fields.add(PROJECT.getName());
|
||||||
|
}
|
||||||
|
return QueryOptions.create(config, start, limit, fields);
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static QueryOptions convertOptions(QueryOptions opts) {
|
static QueryOptions convertOptions(QueryOptions opts) {
|
||||||
// Increase the limit rather than skipping, since we don't know how many
|
// Increase the limit rather than skipping, since we don't know how many
|
||||||
@@ -51,14 +75,14 @@ public class IndexedChangeQuery extends Predicate<ChangeData>
|
|||||||
int backendLimit = opts.config().maxLimit();
|
int backendLimit = opts.config().maxLimit();
|
||||||
int limit = Ints.saturatedCast((long) opts.limit() + opts.start());
|
int limit = Ints.saturatedCast((long) opts.limit() + opts.start());
|
||||||
limit = Math.min(limit, backendLimit);
|
limit = Math.min(limit, backendLimit);
|
||||||
return QueryOptions.create(opts.config(), 0, limit, opts.fields());
|
return IndexedChangeQuery.createOptions(opts.config(), 0, limit, opts.fields());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ChangeIndex index;
|
private final ChangeIndex index;
|
||||||
|
|
||||||
private QueryOptions opts;
|
private QueryOptions opts;
|
||||||
private Predicate<ChangeData> pred;
|
private Predicate<ChangeData> pred;
|
||||||
private ChangeDataSource source;
|
private DataSource<ChangeData> source;
|
||||||
|
|
||||||
public IndexedChangeQuery(ChangeIndex index, Predicate<ChangeData> pred,
|
public IndexedChangeQuery(ChangeIndex index, Predicate<ChangeData> pred,
|
||||||
QueryOptions opts) throws QueryParseException {
|
QueryOptions opts) throws QueryParseException {
|
||||||
@@ -103,7 +127,7 @@ public class IndexedChangeQuery extends Predicate<ChangeData>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<ChangeData> read() throws OrmException {
|
public ResultSet<ChangeData> read() throws OrmException {
|
||||||
final ChangeDataSource currSource = source;
|
final DataSource<ChangeData> currSource = source;
|
||||||
final ResultSet<ChangeData> rs = currSource.read();
|
final ResultSet<ChangeData> rs = currSource.read();
|
||||||
|
|
||||||
return new ResultSet<ChangeData>() {
|
return new ResultSet<ChangeData>() {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.git.QueueProvider.QueueType;
|
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.index.IndexExecutor;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
@@ -52,7 +51,7 @@ public class ReindexAfterUpdate implements GitReferenceUpdatedListener {
|
|||||||
private final OneOffRequestContext requestContext;
|
private final OneOffRequestContext requestContext;
|
||||||
private final Provider<InternalChangeQuery> queryProvider;
|
private final Provider<InternalChangeQuery> queryProvider;
|
||||||
private final ChangeIndexer.Factory indexerFactory;
|
private final ChangeIndexer.Factory indexerFactory;
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final ChangeNotes.Factory notesFactory;
|
private final ChangeNotes.Factory notesFactory;
|
||||||
private final ListeningExecutorService executor;
|
private final ListeningExecutorService executor;
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ public class ReindexAfterUpdate implements GitReferenceUpdatedListener {
|
|||||||
OneOffRequestContext requestContext,
|
OneOffRequestContext requestContext,
|
||||||
Provider<InternalChangeQuery> queryProvider,
|
Provider<InternalChangeQuery> queryProvider,
|
||||||
ChangeIndexer.Factory indexerFactory,
|
ChangeIndexer.Factory indexerFactory,
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
@IndexExecutor(QueueType.BATCH) ListeningExecutorService executor) {
|
@IndexExecutor(QueueType.BATCH) ListeningExecutorService executor) {
|
||||||
this.requestContext = requestContext;
|
this.requestContext = requestContext;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||||
|
import com.google.gerrit.server.query.DataSource;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
@@ -315,7 +316,7 @@ public class ChangeData {
|
|||||||
private final NotesMigration notesMigration;
|
private final NotesMigration notesMigration;
|
||||||
private final MergeabilityCache mergeabilityCache;
|
private final MergeabilityCache mergeabilityCache;
|
||||||
private final Change.Id legacyId;
|
private final Change.Id legacyId;
|
||||||
private ChangeDataSource returnedBySource;
|
private DataSource<ChangeData> returnedBySource;
|
||||||
private Project.NameKey project;
|
private Project.NameKey project;
|
||||||
private Change change;
|
private Change change;
|
||||||
private ChangeNotes notes;
|
private ChangeNotes notes;
|
||||||
@@ -528,11 +529,11 @@ public class ChangeData {
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFromSource(ChangeDataSource s) {
|
public boolean isFromSource(DataSource<ChangeData> s) {
|
||||||
return s == returnedBySource;
|
return s == returnedBySource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cacheFromSource(ChangeDataSource s) {
|
public void cacheFromSource(DataSource<ChangeData> s) {
|
||||||
returnedBySource = s;
|
returnedBySource = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
|||||||
import com.google.gerrit.server.git.strategy.SubmitDryRun;
|
import com.google.gerrit.server.git.strategy.SubmitDryRun;
|
||||||
import com.google.gerrit.server.group.ListMembers;
|
import com.google.gerrit.server.group.ListMembers;
|
||||||
import com.google.gerrit.server.index.FieldDef;
|
import com.google.gerrit.server.index.FieldDef;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.IndexRewriter;
|
import com.google.gerrit.server.index.change.IndexRewriter;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.patch.PatchListCache;
|
import com.google.gerrit.server.patch.PatchListCache;
|
||||||
@@ -205,7 +205,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
Provider<ListChildProjects> listChildProjects,
|
Provider<ListChildProjects> listChildProjects,
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
SubmitDryRun submitDryRun,
|
SubmitDryRun submitDryRun,
|
||||||
ConflictsCache conflictsCache,
|
ConflictsCache conflictsCache,
|
||||||
TrackingFooters trackingFooters,
|
TrackingFooters trackingFooters,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.query.change;
|
|||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.IndexedChangeQuery;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -35,7 +36,7 @@ class CommentPredicate extends IndexPredicate<ChangeData> {
|
|||||||
Predicate<ChangeData> p = Predicate.and(
|
Predicate<ChangeData> p = Predicate.and(
|
||||||
new LegacyChangeIdPredicate(object.getId()), this);
|
new LegacyChangeIdPredicate(object.getId()), this);
|
||||||
for (ChangeData cData
|
for (ChangeData cData
|
||||||
: index.getSource(p, QueryOptions.oneResult()).read()) {
|
: index.getSource(p, IndexedChangeQuery.oneResult()).read()) {
|
||||||
if (cData.getId().equals(object.getId())) {
|
if (cData.getId().equals(object.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Iterables;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.IndexedChangeQuery;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -45,7 +46,7 @@ class FuzzyTopicPredicate extends IndexPredicate<ChangeData> {
|
|||||||
try {
|
try {
|
||||||
Predicate<ChangeData> thisId = new LegacyChangeIdPredicate(cd.getId());
|
Predicate<ChangeData> thisId = new LegacyChangeIdPredicate(cd.getId());
|
||||||
Iterable<ChangeData> results =
|
Iterable<ChangeData> results =
|
||||||
index.getSource(and(thisId, this), QueryOptions.oneResult()).read();
|
index.getSource(and(thisId, this), IndexedChangeQuery.oneResult()).read();
|
||||||
return !Iterables.isEmpty(results);
|
return !Iterables.isEmpty(results);
|
||||||
} catch (QueryParseException e) {
|
} catch (QueryParseException e) {
|
||||||
throw new OrmException(e);
|
throw new OrmException(e);
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
@@ -85,14 +85,14 @@ public class InternalChangeQuery {
|
|||||||
|
|
||||||
private final IndexConfig indexConfig;
|
private final IndexConfig indexConfig;
|
||||||
private final QueryProcessor qp;
|
private final QueryProcessor qp;
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final ChangeNotes.Factory notesFactory;
|
private final ChangeNotes.Factory notesFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
InternalChangeQuery(IndexConfig indexConfig,
|
InternalChangeQuery(IndexConfig indexConfig,
|
||||||
QueryProcessor queryProcessor,
|
QueryProcessor queryProcessor,
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
ChangeNotes.Factory notesFactory) {
|
ChangeNotes.Factory notesFactory) {
|
||||||
this.indexConfig = indexConfig;
|
this.indexConfig = indexConfig;
|
||||||
@@ -305,7 +305,8 @@ public class InternalChangeQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Schema<ChangeData> schema(@Nullable IndexCollection indexes) {
|
private static Schema<ChangeData> schema(
|
||||||
|
@Nullable ChangeIndexCollection indexes) {
|
||||||
ChangeIndex index = indexes != null ? indexes.getSearchIndex() : null;
|
ChangeIndex index = indexes != null ? indexes.getSearchIndex() : null;
|
||||||
return index != null ? index.getSchema() : null;
|
return index != null ? index.getSchema() : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.query.change;
|
|||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.IndexedChangeQuery;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -39,7 +40,7 @@ class MessagePredicate extends IndexPredicate<ChangeData> {
|
|||||||
Predicate<ChangeData> p = Predicate.and(
|
Predicate<ChangeData> p = Predicate.and(
|
||||||
new LegacyChangeIdPredicate(object.getId()), this);
|
new LegacyChangeIdPredicate(object.getId()), this);
|
||||||
for (ChangeData cData
|
for (ChangeData cData
|
||||||
: index.getSource(p, QueryOptions.oneResult()).read()) {
|
: index.getSource(p, IndexedChangeQuery.oneResult()).read()) {
|
||||||
if (cData.getId().equals(object.getId())) {
|
if (cData.getId().equals(object.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ import com.google.gerrit.metrics.MetricMaker;
|
|||||||
import com.google.gerrit.metrics.Timer0;
|
import com.google.gerrit.metrics.Timer0;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndex;
|
import com.google.gerrit.server.index.change.ChangeIndex;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.index.change.IndexRewriter;
|
import com.google.gerrit.server.index.change.IndexRewriter;
|
||||||
|
import com.google.gerrit.server.index.change.IndexedChangeQuery;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
@@ -50,7 +52,7 @@ public class QueryProcessor {
|
|||||||
private final Provider<CurrentUser> userProvider;
|
private final Provider<CurrentUser> userProvider;
|
||||||
private final ChangeControl.GenericFactory changeControlFactory;
|
private final ChangeControl.GenericFactory changeControlFactory;
|
||||||
private final ChangeNotes.Factory notesFactory;
|
private final ChangeNotes.Factory notesFactory;
|
||||||
private final IndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
private final IndexRewriter rewriter;
|
private final IndexRewriter rewriter;
|
||||||
private final IndexConfig indexConfig;
|
private final IndexConfig indexConfig;
|
||||||
private final Metrics metrics;
|
private final Metrics metrics;
|
||||||
@@ -65,7 +67,7 @@ public class QueryProcessor {
|
|||||||
Provider<CurrentUser> userProvider,
|
Provider<CurrentUser> userProvider,
|
||||||
ChangeControl.GenericFactory changeControlFactory,
|
ChangeControl.GenericFactory changeControlFactory,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
IndexCollection indexes,
|
ChangeIndexCollection indexes,
|
||||||
IndexRewriter rewriter,
|
IndexRewriter rewriter,
|
||||||
IndexConfig indexConfig,
|
IndexConfig indexConfig,
|
||||||
Metrics metrics) {
|
Metrics metrics) {
|
||||||
@@ -168,7 +170,7 @@ public class QueryProcessor {
|
|||||||
"Cannot go beyond page " + indexConfig.maxPages() + "of results");
|
"Cannot go beyond page " + indexConfig.maxPages() + "of results");
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryOptions opts = QueryOptions.create(
|
QueryOptions opts = IndexedChangeQuery.createOptions(
|
||||||
indexConfig, start, limit + 1, getRequestedFields());
|
indexConfig, start, limit + 1, getRequestedFields());
|
||||||
Predicate<ChangeData> s = rewriter.rewrite(q, opts);
|
Predicate<ChangeData> s = rewriter.rewrite(q, opts);
|
||||||
if (!(s instanceof ChangeDataSource)) {
|
if (!(s instanceof ChangeDataSource)) {
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ package com.google.gerrit.server.index.change;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.index.FieldDef;
|
import com.google.gerrit.server.index.FieldDef;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.index.Schema;
|
import com.google.gerrit.server.index.Schema;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.change;
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.query.OperatorPredicate;
|
import com.google.gerrit.server.query.OperatorPredicate;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
@@ -25,7 +24,7 @@ import org.junit.Ignore;
|
|||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public class FakeQueryBuilder extends ChangeQueryBuilder {
|
public class FakeQueryBuilder extends ChangeQueryBuilder {
|
||||||
FakeQueryBuilder(IndexCollection indexes) {
|
FakeQueryBuilder(ChangeIndexCollection indexes) {
|
||||||
super(
|
super(
|
||||||
new FakeQueryBuilder.Definition<>(
|
new FakeQueryBuilder.Definition<>(
|
||||||
FakeQueryBuilder.class),
|
FakeQueryBuilder.class),
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.IndexConfig;
|
import com.google.gerrit.server.index.IndexConfig;
|
||||||
|
import com.google.gerrit.server.index.QueryOptions;
|
||||||
import com.google.gerrit.server.query.AndPredicate;
|
import com.google.gerrit.server.query.AndPredicate;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
@@ -36,7 +36,6 @@ import com.google.gerrit.server.query.change.AndSource;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||||
import com.google.gerrit.server.query.change.OrSource;
|
import com.google.gerrit.server.query.change.OrSource;
|
||||||
import com.google.gerrit.server.query.change.QueryOptions;
|
|
||||||
import com.google.gerrit.testutil.GerritBaseTests;
|
import com.google.gerrit.testutil.GerritBaseTests;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -50,14 +49,14 @@ public class IndexRewriterTest extends GerritBaseTests {
|
|||||||
private static final IndexConfig CONFIG = IndexConfig.createDefault();
|
private static final IndexConfig CONFIG = IndexConfig.createDefault();
|
||||||
|
|
||||||
private FakeChangeIndex index;
|
private FakeChangeIndex index;
|
||||||
private IndexCollection indexes;
|
private ChangeIndexCollection indexes;
|
||||||
private ChangeQueryBuilder queryBuilder;
|
private ChangeQueryBuilder queryBuilder;
|
||||||
private IndexRewriter rewrite;
|
private IndexRewriter rewrite;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
index = new FakeChangeIndex(FakeChangeIndex.V2);
|
index = new FakeChangeIndex(FakeChangeIndex.V2);
|
||||||
indexes = new IndexCollection();
|
indexes = new ChangeIndexCollection();
|
||||||
indexes.setSearchIndex(index);
|
indexes.setSearchIndex(index);
|
||||||
queryBuilder = new FakeQueryBuilder(indexes);
|
queryBuilder = new FakeQueryBuilder(indexes);
|
||||||
rewrite = new IndexRewriter(indexes,
|
rewrite = new IndexRewriter(indexes,
|
||||||
@@ -288,7 +287,7 @@ public class IndexRewriterTest extends GerritBaseTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static QueryOptions options(int start, int limit) {
|
private static QueryOptions options(int start, int limit) {
|
||||||
return QueryOptions.create(CONFIG, start, limit,
|
return IndexedChangeQuery.createOptions(CONFIG, start, limit,
|
||||||
ImmutableSet.<String> of());
|
ImmutableSet.<String> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ import com.google.gerrit.server.change.ChangeTriplet;
|
|||||||
import com.google.gerrit.server.change.PatchSetInserter;
|
import com.google.gerrit.server.change.PatchSetInserter;
|
||||||
import com.google.gerrit.server.git.BatchUpdate;
|
import com.google.gerrit.server.git.BatchUpdate;
|
||||||
import com.google.gerrit.server.git.validators.CommitValidators;
|
import com.google.gerrit.server.git.validators.CommitValidators;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.project.ProjectControl;
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gerrit.server.project.RefControl;
|
import com.google.gerrit.server.project.RefControl;
|
||||||
@@ -114,7 +114,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Inject protected ChangeQueryBuilder queryBuilder;
|
@Inject protected ChangeQueryBuilder queryBuilder;
|
||||||
@Inject protected GerritApi gApi;
|
@Inject protected GerritApi gApi;
|
||||||
@Inject protected IdentifiedUser.GenericFactory userFactory;
|
@Inject protected IdentifiedUser.GenericFactory userFactory;
|
||||||
@Inject protected IndexCollection indexes;
|
@Inject protected ChangeIndexCollection indexes;
|
||||||
@Inject protected InMemoryDatabase schemaFactory;
|
@Inject protected InMemoryDatabase schemaFactory;
|
||||||
@Inject protected InMemoryRepositoryManager repoManager;
|
@Inject protected InMemoryRepositoryManager repoManager;
|
||||||
@Inject protected InternalChangeQuery internalChangeQuery;
|
@Inject protected InternalChangeQuery internalChangeQuery;
|
||||||
|
|||||||
Reference in New Issue
Block a user