Delete SQL index support

Require the secondary index to be enabled in Gerrit 2.9.  Unless
configured differently, Lucene is used for the secondary index.

Change-Id: I3d2d804170835d69ffbfef586ddc3873ea3cd1c8
This commit is contained in:
Shawn Pearce
2013-11-24 17:00:31 -08:00
parent 639f2a3081
commit d4ae3a16d5
34 changed files with 238 additions and 1217 deletions

View File

@@ -28,12 +28,12 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.query.AndPredicate;
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gerrit.server.query.RewritePredicate;
import com.google.gerrit.server.query.change.AndSource;
import com.google.gerrit.server.query.change.BasicChangeRewrites;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
import com.google.gerrit.server.query.change.OrSource;
import com.google.gerrit.server.query.change.SqlRewriterImpl;
import org.junit.Before;
import org.junit.Test;
@@ -56,8 +56,7 @@ public class IndexRewriteTest {
rewrite = new IndexRewriteImpl(
indexes,
null,
new IndexRewriteImpl.BasicRewritesImpl(null, indexes),
new SqlRewriterImpl(null));
new BasicChangeRewrites(null, indexes));
}
@Test
@@ -202,19 +201,6 @@ public class IndexRewriteTest {
out.getChildren());
}
@Test
public void testNoChangeIndexUsesSqlRewrites() throws Exception {
Predicate<ChangeData> in = parse("status:open project:p ref:b");
Predicate<ChangeData> out;
out = rewrite(in);
assertTrue(out instanceof AndPredicate || out instanceof IndexedChangeQuery);
indexes.setSearchIndex(null);
out = rewrite(in);
assertTrue(out instanceof RewritePredicate);
}
private Predicate<ChangeData> parse(String query) throws QueryParseException {
return queryBuilder.parse(query);
}

View File

@@ -1,29 +0,0 @@
// 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.query.change;
import com.google.gerrit.testutil.InMemoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.eclipse.jgit.lib.Config;
public class SqlQueryChangesTest extends AbstractQueryChangesTest {
protected Injector createInjector() {
Config cfg = InMemoryModule.newDefaultConfig();
cfg.setString("index", null, "type", "sql");
return Guice.createInjector(new InMemoryModule(cfg));
}
}

View File

@@ -43,7 +43,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.PerThreadRequestScope;
import com.google.gerrit.server.index.ChangeSchemas;
import com.google.gerrit.server.index.IndexModule.IndexType;
import com.google.gerrit.server.index.NoIndexModule;
import com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier;
import com.google.gerrit.server.mail.SmtpEmailSender;
import com.google.gerrit.server.schema.Current;
@@ -83,6 +82,9 @@ public class InMemoryModule extends FactoryModule {
cfg.setString("user", null, "email", "gerrit@localhost");
cfg.setBoolean("sendemail", null, "enable", false);
cfg.setString("cache", null, "directory", null);
cfg.setString("index", null, "type", "lucene");
cfg.setBoolean("index", "lucene", "testInmemory", true);
cfg.setInt("index", "lucene", "testVersion", 4);
return cfg;
}
@@ -155,7 +157,7 @@ public class InMemoryModule extends FactoryModule {
IndexType indexType = null;
try {
indexType = cfg.getEnum("index", null, "type", IndexType.SQL);
indexType = cfg.getEnum("index", null, "type", IndexType.LUCENE);
} catch (IllegalArgumentException e) {
// Custom index type, caller must provide their own module.
}
@@ -164,9 +166,6 @@ public class InMemoryModule extends FactoryModule {
case LUCENE:
install(luceneIndexModule());
break;
case SQL:
install(new NoIndexModule());
break;
default:
throw new ProvisionException(
"index type unsupported in tests: " + indexType);