Ejemplo n.º 1
0
 public DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, String field)
     throws IOException {
   try {
     termsIndex = FieldCache.DEFAULT.getTermsIndex(context.reader(), field);
   } catch (RuntimeException e) {
     throw new DocTermsIndexException(field, e);
   }
   this.vs = vs;
 }
 @Override
 public void setNextReader(IndexReader reader, int docBase) throws IOException {
   termsIndex = FieldCache.DEFAULT.getTermsIndex(reader, field);
   currentReaderGen++;
   assert termsIndex.numOrd() > 0;
   if (bottomSlot != -1) {
     convert(bottomSlot);
     bottomOrd = ords[bottomSlot];
   }
 }
Ejemplo n.º 3
0
  @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);
      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);
          }
        };
      }
    };
  }