Пример #1
0
  public LongFilter convertToLongFilter(DocValueFormat format) {

    if (isPartitionBased()) {
      return new PartitionedLongFilter();
    }

    int numValids = includeValues == null ? 0 : includeValues.size();
    int numInvalids = excludeValues == null ? 0 : excludeValues.size();
    SetBackedLongFilter result = new SetBackedLongFilter(numValids, numInvalids);
    if (includeValues != null) {
      for (BytesRef val : includeValues) {
        result.addAccept(format.parseLong(val.utf8ToString(), false, null));
      }
    }
    if (excludeValues != null) {
      for (BytesRef val : excludeValues) {
        result.addReject(format.parseLong(val.utf8ToString(), false, null));
      }
    }
    return result;
  }
Пример #2
0
  public LongFilter convertToDoubleFilter() {
    if (isPartitionBased()) {
      return new PartitionedLongFilter();
    }

    int numValids = includeValues == null ? 0 : includeValues.size();
    int numInvalids = excludeValues == null ? 0 : excludeValues.size();
    SetBackedLongFilter result = new SetBackedLongFilter(numValids, numInvalids);
    if (includeValues != null) {
      for (BytesRef val : includeValues) {
        double dval = Double.parseDouble(val.utf8ToString());
        result.addAccept(NumericUtils.doubleToSortableLong(dval));
      }
    }
    if (excludeValues != null) {
      for (BytesRef val : excludeValues) {
        double dval = Double.parseDouble(val.utf8ToString());
        result.addReject(NumericUtils.doubleToSortableLong(dval));
      }
    }
    return result;
  }