com.google.gerrit.index.IndexDefinition Maven / Gradle / Ivy
// 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.index;
import com.google.common.collect.ImmutableSortedMap;
import com.google.gerrit.common.Nullable;
/**
 * Definition of an index over a Gerrit data type.
 *
 * An index includes a set of schema definitions along with the specific implementations
 * used to query the secondary index implementation in a running server. If you are just interested
 * in the static definition of one or more schemas, see the implementations of {@link
 * SchemaDefinitions}.
 */
public abstract class IndexDefinition> {
  public interface IndexFactory> {
    I create(Schema schema);
  }
  private final SchemaDefinitions schemaDefs;
  private final IndexCollection indexCollection;
  private final IndexFactory indexFactory;
  private final SiteIndexer siteIndexer;
  protected IndexDefinition(
      SchemaDefinitions schemaDefs,
      IndexCollection indexCollection,
      IndexFactory indexFactory,
      @Nullable SiteIndexer siteIndexer) {
    this.schemaDefs = schemaDefs;
    this.indexCollection = indexCollection;
    this.indexFactory = indexFactory;
    this.siteIndexer = siteIndexer;
  }
  public final String getName() {
    return schemaDefs.getName();
  }
  public final ImmutableSortedMap> getSchemas() {
    return schemaDefs.getSchemas();
  }
  public final Schema getLatest() {
    return schemaDefs.getLatest();
  }
  public final IndexCollection getIndexCollection() {
    return indexCollection;
  }
  public final IndexFactory getIndexFactory() {
    return indexFactory;
  }
  @Nullable
  public SiteIndexer getSiteIndexer() {
    return siteIndexer;
  }
  public SiteIndexer getSiteIndexer(boolean reuseExistingDocuments) {
    return siteIndexer;
  }
}