LCOV - code coverage report
Current view: top level - index - IndexDefinition.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 12 12 100.0 %
Date: 2022-11-19 15:00:39 Functions: 7 7 100.0 %

          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.index;
      16             : 
      17             : import com.google.common.collect.ImmutableSortedMap;
      18             : import com.google.gerrit.common.Nullable;
      19             : 
      20             : /**
      21             :  * Definition of an index over a Gerrit data type.
      22             :  *
      23             :  * <p>An <em>index</em> includes a set of schema definitions along with the specific implementations
      24             :  * used to query the secondary index implementation in a running server. If you are just interested
      25             :  * in the static definition of one or more schemas, see the implementations of {@link
      26             :  * SchemaDefinitions}.
      27             :  */
      28             : public abstract class IndexDefinition<K, V, I extends Index<K, V>> {
      29             :   public interface IndexFactory<K, V, I extends Index<K, V>> {
      30             :     I create(Schema<V> schema);
      31             :   }
      32             : 
      33             :   private final SchemaDefinitions<V> schemaDefs;
      34             :   private final IndexCollection<K, V, I> indexCollection;
      35             :   private final IndexFactory<K, V, I> indexFactory;
      36             :   private final SiteIndexer<K, V, I> siteIndexer;
      37             : 
      38             :   protected IndexDefinition(
      39             :       SchemaDefinitions<V> schemaDefs,
      40             :       IndexCollection<K, V, I> indexCollection,
      41             :       IndexFactory<K, V, I> indexFactory,
      42         151 :       @Nullable SiteIndexer<K, V, I> siteIndexer) {
      43         151 :     this.schemaDefs = schemaDefs;
      44         151 :     this.indexCollection = indexCollection;
      45         151 :     this.indexFactory = indexFactory;
      46         151 :     this.siteIndexer = siteIndexer;
      47         151 :   }
      48             : 
      49             :   public final String getName() {
      50         151 :     return schemaDefs.getName();
      51             :   }
      52             : 
      53             :   public final ImmutableSortedMap<Integer, Schema<V>> getSchemas() {
      54         146 :     return schemaDefs.getSchemas();
      55             :   }
      56             : 
      57             :   public final Schema<V> getLatest() {
      58          31 :     return schemaDefs.getLatest();
      59             :   }
      60             : 
      61             :   public final IndexCollection<K, V, I> getIndexCollection() {
      62         151 :     return indexCollection;
      63             :   }
      64             : 
      65             :   public final IndexFactory<K, V, I> getIndexFactory() {
      66         151 :     return indexFactory;
      67             :   }
      68             : 
      69             :   @Nullable
      70             :   public final SiteIndexer<K, V, I> getSiteIndexer() {
      71         138 :     return siteIndexer;
      72             :   }
      73             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750