Example #1
0
  @Override
  public void check(final Node node) {

    // Store snapshot from last check
    if (stateMachine.getLastNode() != null) {
      history.store(
          stateMachine.getLastNode(), currentGroupify, stateMachine.getLastTransition().snapshot);
    }

    // Transition
    final Transition transition = stateMachine.transition(node);

    // Switch groupifies
    final IHashGroupify temp = lastGroupify;
    lastGroupify = currentGroupify;
    currentGroupify = temp;
    currentGroupify.clear();

    // Apply transition
    switch (transition.type) {
      case UNOPTIMIZED:
        currentGroupify =
            transformer.apply(transition.projection, node.getTransformation(), currentGroupify);
        break;
      case ROLLUP:
        currentGroupify =
            transformer.applyRollup(
                transition.projection, node.getTransformation(), lastGroupify, currentGroupify);
        break;
      case SNAPSHOT:
        currentGroupify =
            transformer.applySnapshot(
                transition.projection,
                node.getTransformation(),
                currentGroupify,
                transition.snapshot);
        break;
    }

    // Mark as checked
    node.setChecked();

    // Propagate k-anonymity
    node.setKAnonymous(currentGroupify.isKAnonymous());

    // Propagate anonymity and information loss
    if (currentGroupify.isAnonymous()) {
      node.setAnonymous(true);
      metric.evaluate(node, currentGroupify);
    } else {
      node.setInformationLoss(null);
      node.setAnonymous(false);
    }
  }
Example #2
0
  @Override
  @Deprecated
  public Data transform(final Node node) {

    // Apply transition and groupify
    currentGroupify.clear();
    currentGroupify = transformer.apply(0L, node.getTransformation(), currentGroupify);

    // Determine outliers and set infoloss
    if (!node.isChecked()) {
      node.setChecked();
      node.setAnonymous(currentGroupify.isAnonymous());
      metric.evaluate(node, currentGroupify);
      node.setTagged();
    }

    return getBuffer();
  }
Example #3
0
  @Override
  protected InformationLossWithBound<InformationLossDefault> getInformationLossInternal(
      final Node node, final HashGroupify g) {

    if (node.getLowerBound() != null) {
      return new InformationLossWithBound<InformationLossDefault>(
          (InformationLossDefault) node.getLowerBound(),
          (InformationLossDefault) node.getLowerBound());
    }

    // Init
    double result = 0;

    // For each column
    for (int column = 0; column < hierarchies.length; column++) {

      // Check for cached value
      final int state = node.getTransformation()[column];
      double value = cache[column][state];
      if (value == NA) {
        value = 0d;
        final int[][] cardinality = cardinalities[column];
        final int[][] hierarchy = hierarchies[column];
        for (int in = 0; in < hierarchy.length; in++) {
          final int out = hierarchy[in][state];
          final double a = cardinality[in][0];
          final double b = cardinality[out][state];
          if (a != 0d) {
            value += a * log2(a / b);
          }
        }
        cache[column][state] = value;
      }
      result += value;
    }
    result = round(result == 0.0d ? result : -result);
    return new InformationLossDefaultWithBound(result, result);
  }
Example #4
0
  @Override
  public Data transformAndMarkOutliers(final Node node) {

    // Apply transition and groupify
    currentGroupify.clear();
    currentGroupify = transformer.apply(0L, node.getTransformation(), currentGroupify);

    // Determine outliers and set infoloss
    node.setAnonymous(currentGroupify.isAnonymous());
    if (!node.isChecked()) {
      node.setChecked();
      metric.evaluate(node, currentGroupify);
      node.setTagged();
    }

    // Find outliers
    if (config.getAbsoluteMaxOutliers() != 0) {
      currentGroupify.markOutliers(transformer.getBuffer());
    }

    // Return the buffer
    return getBuffer();
  }