protected MappedFieldNameFilterConverter buildFieldNameConverter(String geoFileName, int maxDoc)
      throws IOException {
    GeoSegmentReader<CartesianGeoRecord> segmentReader =
        new GeoSegmentReader<CartesianGeoRecord>(
            directory, geoFileName, maxDoc, 1024, geoRecordSerializer, geoComparator);

    DataInput input = directory.openInput(geoFileName);
    input.readVInt(); // throw out version
    input.readInt(); // throw out tree position
    input.readVInt(); // throw out the data size
    input.readVInt(); // throw out tree name

    MappedFieldNameFilterConverter fieldNameConverter = new MappedFieldNameFilterConverter();
    fieldNameConverter.loadFromInput(input);

    return fieldNameConverter;
  }
  protected void verifyFilter(String geoFileName, int maxDocs) throws IOException {
    MappedFieldNameFilterConverter fieldNameConverter =
        buildFieldNameConverter(geoFileName, maxDocs);

    // Verify mapping is correct
    List<String> filterFields = fieldNameConverter.getFields(LOCATION_BIT_MASK);
    assertEquals("Expected a single field that maps to the bit mask", 1, filterFields.size());
    assertEquals(LOCATION_FIELD, filterFields.get(0));

    filterFields = fieldNameConverter.getFields(IMAGE_LOCATION_BIT_MASK);
    assertEquals("Expected a single field that maps to the bit mask", 1, filterFields.size());
    assertEquals(IMAGE_LOCATION_FIELD, filterFields.get(0));

    // verify that half the documents have one filter and the other half have the other
    int countImageLocationFiltered = 0;
    int countLocationFiltered = 0;

    GeoSegmentReader<CartesianGeoRecord> reader =
        new GeoSegmentReader<CartesianGeoRecord>(
            directory, geoFileName, maxDocs, 1024, geoRecordSerializer, geoComparator);
    Iterator<CartesianGeoRecord> geoIter =
        reader.getIterator(
            CartesianGeoRecord.MIN_VALID_GEORECORD, CartesianGeoRecord.MAX_VALID_GEORECORD);
    while (geoIter.hasNext()) {
      CartesianGeoRecord geoRecord = geoIter.next();
      if (fieldNameConverter.fieldIsInFilter(LOCATION_FIELD, geoRecord.filterByte)) {
        countLocationFiltered++;
      }

      if (fieldNameConverter.fieldIsInFilter(IMAGE_LOCATION_FIELD, geoRecord.filterByte)) {
        countImageLocationFiltered++;
      }
    }

    assertEquals(
        "Expected one point per doc to be filtered by default location",
        maxDocs,
        countLocationFiltered);
    assertEquals(
        "Expected one point per doc to be filtered by image location",
        maxDocs,
        countImageLocationFiltered);
  }