@Override
 public Bits getDocsWithField(FieldInfo field) throws IOException {
   if (field.getDocValuesType() == DocValuesType.SORTED_SET) {
     return DocValues.docsWithValue(getSortedSet(field), maxDoc);
   } else {
     return new Bits.MatchAllBits(maxDoc);
   }
 }
    @Override
    public MultiGeoPointValues getGeoPointValues() {
      final RandomAccessOrds ords = ordinals.ordinals();
      final SortedDocValues singleOrds = DocValues.unwrapSingleton(ords);
      if (singleOrds != null) {
        final GeoPoint point = new GeoPoint();
        final GeoPointValues values =
            new GeoPointValues() {
              @Override
              public GeoPoint get(int docID) {
                final int ord = singleOrds.getOrd(docID);
                if (ord >= 0) {
                  return point.reset(lat.get(ord), lon.get(ord));
                }
                return point.reset(Double.NaN, Double.NaN);
              }
            };
        return FieldData.singleton(values, DocValues.docsWithValue(singleOrds, maxDoc));
      } else {
        final GeoPoint point = new GeoPoint();
        return new MultiGeoPointValues() {

          @Override
          public GeoPoint valueAt(int index) {
            final long ord = ords.ordAt(index);
            if (ord >= 0) {
              return point.reset(lat.get(ord), lon.get(ord));
            }
            return point.reset(Double.NaN, Double.NaN);
          }

          @Override
          public void setDocument(int docId) {
            ords.setDocument(docId);
          }

          @Override
          public int count() {
            return ords.cardinality();
          }
        };
      }
    }
  private static SortedNumericDocValues withOrdinals(
      Ordinals ordinals, final LongValues values, int maxDoc) {
    final RandomAccessOrds ords = ordinals.ordinals();
    final SortedDocValues singleOrds = DocValues.unwrapSingleton(ords);
    if (singleOrds != null) {
      final NumericDocValues singleValues =
          new NumericDocValues() {
            @Override
            public long get(int docID) {
              final int ord = singleOrds.getOrd(docID);
              if (ord >= 0) {
                return values.get(singleOrds.getOrd(docID));
              } else {
                return 0;
              }
            }
          };
      return DocValues.singleton(singleValues, DocValues.docsWithValue(ords, maxDoc));
    } else {
      return new SortedNumericDocValues() {
        @Override
        public long valueAt(int index) {
          return values.get(ords.ordAt(index));
        }

        @Override
        public void setDocument(int doc) {
          ords.setDocument(doc);
        }

        @Override
        public int count() {
          return ords.cardinality();
        }
      };
    }
  }