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

com.browseengine.bobo.facets.range.ValueConverterBitSetBuilder Maven / Gradle / Ivy

Go to download

Bobo is a Faceted Search implementation written purely in Java, an extension of Apache Lucene

The newest version!
package com.browseengine.bobo.facets.range;

import org.apache.lucene.util.OpenBitSet;

import com.browseengine.bobo.facets.data.FacetDataCache;
import com.browseengine.bobo.facets.filter.FacetValueConverter;

public class ValueConverterBitSetBuilder implements BitSetBuilder {
  private final FacetValueConverter facetValueConverter;
  private final String[] vals;
  private final boolean takeCompliment;

  public ValueConverterBitSetBuilder(FacetValueConverter facetValueConverter, String[] vals,
      boolean takeCompliment) {
    this.facetValueConverter = facetValueConverter;
    this.vals = vals;
    this.takeCompliment = takeCompliment;
  }

  @Override
  public OpenBitSet bitSet(FacetDataCache dataCache) {
    @SuppressWarnings("unchecked")
    int[] index = facetValueConverter.convert((FacetDataCache) dataCache, vals);

    OpenBitSet bitset = new OpenBitSet(dataCache.valArray.size());
    for (int i : index) {
      bitset.fastSet(i);
    }
    if (takeCompliment) {
      // flip the bits
      for (int i = 0; i < index.length; ++i) {
        bitset.fastFlip(i);
      }
    }
    return bitset;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy