Beispiel #1
0
    public BaseArrayProvider(
        DimensionSelector dimSelector, TopNQuery query, Capabilities capabilities) {
      this.dimSelector = dimSelector;
      this.query = query;
      this.capabilities = capabilities;

      previousStop = null;
      ignoreAfterThreshold = false;
      ignoreFirstN = 0;
      keepOnlyN = dimSelector.getValueCardinality();
    }
    public BaseArrayProvider(
        DimensionSelector dimSelector, TopNQuery query, Capabilities capabilities) {
      this.dimSelector = dimSelector;
      this.query = query;
      this.capabilities = capabilities;

      previousStop = null;
      ignoreAfterThreshold = false;
      ignoreFirstN = 0;
      keepOnlyN = dimSelector.getValueCardinality();

      if (keepOnlyN < 0) {
        throw new UnsupportedOperationException("Cannot operate on a dimension with no dictionary");
      }
    }
  @Override
  public DimensionSelector decorate(final DimensionSelector selector) {
    if (selector == null) {
      return selector;
    }

    int count = 0;
    final Map<Integer, Integer> forwardMapping = new HashMap<>();

    for (int i = 0; i < selector.getValueCardinality(); i++) {
      if (compiledRegex.matcher(Strings.nullToEmpty(selector.lookupName(i))).matches()) {
        forwardMapping.put(i, count++);
      }
    }

    final int[] reverseMapping = new int[forwardMapping.size()];
    for (Map.Entry<Integer, Integer> e : forwardMapping.entrySet()) {
      reverseMapping[e.getValue().intValue()] = e.getKey().intValue();
    }
    return BaseFilteredDimensionSpec.decorate(selector, forwardMapping, reverseMapping);
  }