Пример #1
0
  /**
   * Fills all keys contained in the receiver into the specified list. Fills the list, starting at
   * index 0. After this call returns the specified list has a new size that equals
   * <tt>this.size()</tt>. Iteration order is guaranteed to be <i>identical</i> to the order used by
   * method {@link #forEachKey(LongProcedure)}.
   *
   * <p>This method can be used to iterate over the keys of the receiver.
   *
   * @param list the list to be filled, can have any size.
   */
  @Override
  public void keys(LongArrayList list) {
    list.setSize(distinct);
    long[] elements = list.elements();

    int j = 0;
    for (int i = table.length; i-- > 0; ) {
      if (state[i] == FULL) {
        elements[j++] = table[i];
      }
    }
  }
  /**
   * Fills all pairs satisfying a given condition into the specified lists. Fills into the lists,
   * starting at index 0. After this call returns the specified lists both have a new size, the
   * number of pairs satisfying the condition. Iteration order is guaranteed to be <i>identical</i>
   * to the order used by method {@link #forEachKey(LongProcedure)}.
   *
   * <p><b>Example:</b> <br>
   *
   * <pre>
   * LongFloatProcedure condition = new LongFloatProcedure() { // match even values only
   * public boolean apply(long key, float value) { return value%2==0; }
   * }
   * keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
   * </pre>
   *
   * @param condition the condition to be matched. Takes the current key as first and the current
   *     value as second argument.
   * @param keyList the list to be filled with keys, can have any size.
   * @param valueList the list to be filled with values, can have any size.
   */
  @Override
  public void pairsMatching(
      LongFloatProcedure condition, LongArrayList keyList, FloatArrayList valueList) {
    keyList.clear();
    valueList.clear();

    for (int i = table.length; i-- > 0; ) {
      if (state[i] == FULL && condition.apply(table[i], values[i])) {
        keyList.add(table[i]);
        valueList.add(values[i]);
      }
    }
  }
  @Override
  protected void setup(Context context) throws IOException, InterruptedException {

    super.setup(context);
    Parameters params =
        new Parameters(context.getConfiguration().get(PFPGrowth.PFP_PARAMETERS, ""));

    for (Pair<String, Long> e : PFPGrowth.readFList(context.getConfiguration())) {
      featureReverseMap.add(e.getFirst());
      freqList.add(e.getSecond());
    }

    maxHeapSize = Integer.valueOf(params.get(PFPGrowth.MAX_HEAPSIZE, "50"));
    minSupport = Integer.valueOf(params.get(PFPGrowth.MIN_SUPPORT, "3"));

    maxPerGroup = params.getInt(PFPGrowth.MAX_PER_GROUP, 0);
    numFeatures = featureReverseMap.size();
    useFP2 = "true".equals(params.get(PFPGrowth.USE_FPG2));
  }