org.hibernate.search.query.fieldcache.impl.IntFieldLoadingStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Core of the Object/Lucene mapper, query engine and index management
/*
* 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.Ints;
/**
* 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 IntFieldLoadingStrategy implements FieldLoadingStrategy {
private final String fieldName;
private Ints currentCache;
public IntFieldLoadingStrategy(String fieldName) {
this.fieldName = fieldName;
}
@Override
public void loadNewCacheValues(AtomicReaderContext context) throws IOException {
final AtomicReader reader = context.reader();
currentCache = FieldCache.DEFAULT.getInts( reader, fieldName, false );
}
@Override
public Integer collect(int relativeDocId) {
return currentCache.get( relativeDocId );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy