});
return filterToFbs.get(filter, new Callable<Value>() {
@Override
public Value call() throws Exception {
DocIdSet docIdSet = filter.getDocIdSet(context, null);
final BitDocIdSet bitSet;
if (docIdSet instanceof BitDocIdSet) {
bitSet = (BitDocIdSet) docIdSet;
} else {
BitDocIdSet.Builder builder = new BitDocIdSet.Builder(context.reader().maxDoc());
if (docIdSet != null && docIdSet != DocIdSet.EMPTY) {
builder.or(docIdSet.iterator());
}
BitDocIdSet bits = builder.build();
// code expects this to be non-null
if (bits == null) {
bits = new BitDocIdSet(new SparseFixedBitSet(context.reader().maxDoc()), 0);
}
bitSet = bits;
}
Value value = new Value(bitSet, shardId);