Line data Source code
1 : // Copyright (C) 2016 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.index.account; 16 : 17 : import static com.google.gerrit.index.SchemaUtil.schema; 18 : 19 : import com.google.common.collect.ImmutableList; 20 : import com.google.gerrit.index.IndexedField; 21 : import com.google.gerrit.index.Schema; 22 : import com.google.gerrit.index.SchemaDefinitions; 23 : import com.google.gerrit.server.account.AccountState; 24 : 25 : /** 26 : * Definition of account index versions (schemata). See {@link SchemaDefinitions}. 27 : * 28 : * <p>Upgrades are subject to constraints, see {@code 29 : * com.google.gerrit.index.IndexUpgradeValidator}. 30 : */ 31 : public class AccountSchemaDefinitions extends SchemaDefinitions<AccountState> { 32 : 33 : @Deprecated 34 153 : static final Schema<AccountState> V8 = 35 153 : schema( 36 : /* version= */ 8, 37 153 : ImmutableList.of(), 38 153 : ImmutableList.of( 39 : AccountField.ID_FIELD, 40 : AccountField.ACTIVE_FIELD, 41 : AccountField.EMAIL_FIELD, 42 : AccountField.EXTERNAL_ID_FIELD, 43 : AccountField.EXTERNAL_ID_STATE_FIELD, 44 : AccountField.FULL_NAME_FIELD, 45 : AccountField.NAME_PART_FIELD, 46 : AccountField.NAME_PART_NO_SECONDARY_EMAIL_FIELD, 47 : AccountField.PREFERRED_EMAIL_EXACT_FIELD, 48 : AccountField.PREFERRED_EMAIL_LOWER_CASE_FIELD, 49 : AccountField.REF_STATE_FIELD, 50 : AccountField.REGISTERED_FIELD, 51 : AccountField.USERNAME_FIELD, 52 : AccountField.WATCHED_PROJECT_FIELD), 53 153 : ImmutableList.<IndexedField<AccountState, ?>.SearchSpec>of( 54 : AccountField.ID_FIELD_SPEC, 55 : AccountField.ACTIVE_FIELD_SPEC, 56 : AccountField.EMAIL_SPEC, 57 : AccountField.EXTERNAL_ID_FIELD_SPEC, 58 : AccountField.EXTERNAL_ID_STATE_SPEC, 59 : AccountField.FULL_NAME_SPEC, 60 : AccountField.NAME_PART_NO_SECONDARY_EMAIL_SPEC, 61 : AccountField.NAME_PART_SPEC, 62 : AccountField.PREFERRED_EMAIL_LOWER_CASE_SPEC, 63 : AccountField.PREFERRED_EMAIL_EXACT_SPEC, 64 : AccountField.REF_STATE_SPEC, 65 : AccountField.REGISTERED_SPEC, 66 : AccountField.USERNAME_SPEC, 67 : AccountField.WATCHED_PROJECT_SPEC)); 68 : 69 : // Bump Lucene version requires reindexing 70 153 : @Deprecated static final Schema<AccountState> V9 = schema(V8); 71 : 72 : // Lucene index was changed to add additional fields for sorting. 73 153 : @Deprecated static final Schema<AccountState> V10 = schema(V9); 74 : 75 : // New numeric types: use dimensional points using the k-d tree geo-spatial data structure 76 : // to offer fast single- and multi-dimensional numeric range. As the consequense, integer 77 : // document id type is replaced with string document id type. 78 : @Deprecated 79 153 : static final Schema<AccountState> V11 = 80 : new Schema.Builder<AccountState>() 81 153 : .add(V10) 82 153 : .remove(AccountField.ID_FIELD_SPEC) 83 153 : .remove(AccountField.ID_FIELD) 84 153 : .addIndexedFields(AccountField.ID_STR_FIELD) 85 153 : .addSearchSpecs(AccountField.ID_STR_FIELD_SPEC) 86 153 : .build(); 87 : 88 : // Upgrade Lucene to 7.x requires reindexing. 89 153 : static final Schema<AccountState> V12 = schema(V11); 90 : 91 : /** 92 : * Name of the account index to be used when contacting index backends or loading configurations. 93 : */ 94 : public static final String NAME = "accounts"; 95 : 96 : /** Singleton instance of the schema definitions. This is one per JVM. */ 97 153 : public static final AccountSchemaDefinitions INSTANCE = new AccountSchemaDefinitions(); 98 : 99 : private AccountSchemaDefinitions() { 100 153 : super(NAME, AccountState.class); 101 153 : } 102 : }