Example usage for org.apache.lucene.util.fst BytesRefFSTEnum BytesRefFSTEnum

List of usage examples for org.apache.lucene.util.fst BytesRefFSTEnum BytesRefFSTEnum

Introduction

In this page you can find the example usage for org.apache.lucene.util.fst BytesRefFSTEnum BytesRefFSTEnum.

Prototype

public BytesRefFSTEnum(FST<T> fst) 

Source Link

Document

doFloor controls the behavior of advance: if it's true doFloor is true, advance positions to the biggest term before target.

Usage

From source file:org.elasticsearch.index.fielddata.plain.FSTBytesAtomicFieldData.java

License:Apache License

@Override
public BytesValues.WithOrdinals getBytesValues(boolean needsHashes) {
    assert fst != null;
    if (needsHashes) {
        if (hashes == null) {
            BytesRefFSTEnum<Long> fstEnum = new BytesRefFSTEnum<Long>(fst);
            IntArray hashes = BigArrays.newIntArray(ordinals.getMaxOrd());
            // we don't store an ord 0 in the FST since we could have an empty string in there and FST don't support
            // empty strings twice. ie. them merge fails for long output.
            hashes.set(0, new BytesRef().hashCode());
            try {
                for (long i = 1, maxOrd = ordinals.getMaxOrd(); i < maxOrd; ++i) {
                    hashes.set(i, fstEnum.next().input.hashCode());
                }// ww w. j av  a  2 s .co  m
                assert fstEnum.next() == null;
            } catch (IOException e) {
                // Don't use new "AssertionError("Cannot happen", e)" directly as this is a Java 1.7-only API
                final AssertionError error = new AssertionError("Cannot happen");
                error.initCause(e);
                throw error;
            }
            this.hashes = hashes;
        }
        return new HashedBytesValues(fst, ordinals.ordinals(), hashes);
    } else {
        return new BytesValues(fst, ordinals.ordinals());
    }
}

From source file:org.meresco.lucene.numerate.FSTdict.java

License:Open Source License

public long get(String uri) throws IOException {
    if (this.fstbuilder.getTermCount() > 0L) {
        FST<Long> fst = this.fstbuilder.finish();
        if (fst != null)
            this.brfstenum = new BytesRefFSTEnum<Long>(fst);
    }/*from   w  ww. j a v a  2  s .co m*/
    InputOutput<Long> seekExact = this.brfstenum.seekExact(new BytesRef(uri));
    if (seekExact != null)
        return seekExact.output;
    return -1;
}