List of usage examples for org.apache.lucene.util.mutable MutableValueBool MutableValueBool
MutableValueBool
From source file:org.apache.solr.schema.BoolField.java
License:Apache License
@Override public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException { final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(readerContext.reader(), field); // figure out what ord maps to true int nord = sindex.getValueCount(); BytesRef br = new BytesRef(); // if no values in the segment, default trueOrd to something other then -1 (missing) int tord = -2; for (int i = 0; i < nord; i++) { sindex.lookupOrd(i, br);//from w w w.ja v a 2 s . com if (br.length == 1 && br.bytes[br.offset] == 'T') { tord = i; break; } } final int trueOrd = tord; return new BoolDocValues(this) { @Override public boolean boolVal(int doc) { return sindex.getOrd(doc) == trueOrd; } @Override public boolean exists(int doc) { return sindex.getOrd(doc) != -1; } @Override public ValueFiller getValueFiller() { return new ValueFiller() { private final MutableValueBool mval = new MutableValueBool(); @Override public MutableValue getValue() { return mval; } @Override public void fillValue(int doc) { int ord = sindex.getOrd(doc); mval.value = (ord == trueOrd); mval.exists = (ord != -1); } }; } }; }