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

org.hibernate.search.query.fieldcache.impl.FloatFieldLoadingStrategy 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.query.fieldcache.impl;

import java.io.IOException;

import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.Floats;

/**
 * We need a collection of similar implementations, one per each FieldCache.DEFAULT.accessmethod
 * to be able to deal with arrays of primitive values without autoboxing all of them.
 *
 * @author Sanne Grinovero  (C) 2011 Red Hat Inc.
 * @see FieldLoadingStrategy
 */
public final class FloatFieldLoadingStrategy implements FieldLoadingStrategy {
	private final String fieldName;
	private Floats currentCache;

	public FloatFieldLoadingStrategy(String fieldName) {
		this.fieldName = fieldName;
	}

	@Override
	public void loadNewCacheValues(AtomicReaderContext context) throws IOException {
		final AtomicReader reader = context.reader();
		currentCache = FieldCache.DEFAULT.getFloats( reader, fieldName, false );
	}

	@Override
	public Float collect(int relativeDocId) {
		return currentCache.get( relativeDocId );
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy