All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.search.store.impl.NotShardedStrategy Maven / Gradle / Ivy

There is a newer version: 5.11.12.Final
Show newest version
/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.search.store.impl;

import java.util.Properties;
import java.io.Serializable;

import org.apache.lucene.document.Document;
import org.hibernate.search.exception.AssertionFailure;
import org.hibernate.search.filter.FullTextFilterImplementor;
import org.hibernate.search.indexes.spi.IndexManager;
import org.hibernate.search.store.IndexShardingStrategy;

/**
 * @author Emmanuel Bernard
 */
public class NotShardedStrategy implements IndexShardingStrategy {

	private IndexManager[] directoryProvider;

	@Override
	public void initialize(Properties properties, IndexManager[] indexManagers) {
		this.directoryProvider = indexManagers;
		if ( directoryProvider.length > 1 ) {
			throw new AssertionFailure("Using SingleDirectoryProviderSelectionStrategy with multiple DirectoryProviders");
		}
	}

	@Override
	public IndexManager[] getIndexManagersForAllShards() {
		return directoryProvider;
	}

	@Override
	public IndexManager getIndexManagerForAddition(Class entity, Serializable id, String idInString, Document document) {
		return directoryProvider[0];
	}

	@Override
	public IndexManager[] getIndexManagersForDeletion(Class entity, Serializable id, String idInString) {
		return directoryProvider;
	}

	@Override
	public IndexManager[] getIndexManagersForQuery(FullTextFilterImplementor[] fullTextFilters) {
		return directoryProvider;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy