use of org.apache.lucene.util.mutable.MutableValueBool in project lucene-solr by apache.
the class BoolDocValues method getValueFiller.
@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) throws IOException {
mval.value = boolVal(doc);
mval.exists = exists(doc);
}
};
}
use of org.apache.lucene.util.mutable.MutableValueBool in project lucene-solr by apache.
the class BoolFieldSource method getValues.
@Override
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
final SortedDocValues sindex = DocValues.getSorted(readerContext.reader(), field);
// figure out what ord maps to true
int nord = sindex.getValueCount();
// if no values in the segment, default trueOrd to something other then -1 (missing)
int tord = -2;
for (int i = 0; i < nord; i++) {
final BytesRef br = sindex.lookupOrd(i);
if (br.length == 1 && br.bytes[br.offset] == 'T') {
tord = i;
break;
}
}
final int trueOrd = tord;
return new BoolDocValues(this) {
private int getOrdForDoc(int doc) throws IOException {
if (doc > sindex.docID()) {
sindex.advance(doc);
}
if (doc == sindex.docID()) {
return sindex.ordValue();
} else {
return -1;
}
}
@Override
public boolean boolVal(int doc) throws IOException {
return getOrdForDoc(doc) == trueOrd;
}
@Override
public boolean exists(int doc) throws IOException {
return getOrdForDoc(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) throws IOException {
int ord = getOrdForDoc(doc);
mval.value = (ord == trueOrd);
mval.exists = (ord != -1);
}
};
}
};
}
Aggregations