Java Code Examples for it.unimi.dsi.fastutil.longs.LongArrayList#clear()

The following examples show how to use it.unimi.dsi.fastutil.longs.LongArrayList#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrConditionTraverser.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public List<LongArrayList> calculateConditions(PositionListIndex partialUnique,
                                               PositionListIndex PLICondition,
                                               int frequency,
                                               List<LongArrayList> unsatisfiedClusters) {
  List<LongArrayList> result = new LinkedList<>();
  Long2LongOpenHashMap uniqueHashMap = partialUnique.asHashMap();
  LongArrayList touchedClusters = new LongArrayList();
  nextCluster:
  for (LongArrayList cluster : PLICondition.getClusters()) {
    int unsatisfactionCount = 0;
    touchedClusters.clear();
    for (long rowNumber : cluster) {
      if (uniqueHashMap.containsKey(rowNumber)) {
        if (touchedClusters.contains(uniqueHashMap.get(rowNumber))) {
          unsatisfactionCount++;
        } else {
          touchedClusters.add(uniqueHashMap.get(rowNumber));
        }
      }
    }
    if (unsatisfactionCount == 0) {
      result.add(cluster);
    } else {
      //if ((cluster.size() - unsatisfactionCount) >= frequency) {
      unsatisfiedClusters.add(cluster);
      //}
    }
  }
  return result;
}
 
Example 2
Source File: SimpleConditionTraverser.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public List<LongArrayList> calculateConditions(PositionListIndex partialUnique,
                                               PositionListIndex PLICondition,
                                               int frequency,
                                               List<LongArrayList> unsatisfiedClusters) {
  List<LongArrayList> result = new LinkedList<>();
  Long2LongOpenHashMap uniqueHashMap = partialUnique.asHashMap();
  LongArrayList touchedClusters = new LongArrayList();
  nextCluster:
  for (LongArrayList cluster : PLICondition.getClusters()) {
    if (cluster.size() < frequency) {
      continue;
    }
    int unsatisfactionCount = 0;
    touchedClusters.clear();
    for (long rowNumber : cluster) {
      if (uniqueHashMap.containsKey(rowNumber)) {
        if (touchedClusters.contains(uniqueHashMap.get(rowNumber))) {
          unsatisfactionCount++;
        } else {
          touchedClusters.add(uniqueHashMap.get(rowNumber));
        }
      }
    }
    if (unsatisfactionCount == 0) {
      result.add(cluster);
    } else {
      if ((cluster.size() - unsatisfactionCount) >= frequency) {
        unsatisfiedClusters.add(cluster);
      }
    }
  }
  return result;
}
 
Example 3
Source File: OrConditionTraverser.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
protected void combineClusterIntoResult(ColumnCombinationBitset partialUnique)
    throws AlgorithmExecutionException {
  LongArrayList touchedCluster = new LongArrayList();
  Long2LongOpenHashMap partialUniqueHash = this.algorithm.getPLI(partialUnique).asHashMap();
  Set<ColumnCombinationBitset> startPoints = this.getConditionStartPoints();
  for (ColumnCombinationBitset minimalConditionStartPoint : startPoints) {
    if (minimalConditionStartPoint.getSetBits().size() != 1) {
      minimalConditionStartPoint =
          minimalConditionStartPoint.getContainedOneColumnCombinations().get(0);
    }

    List<ConditionEntry> satisfiedCluster = new ArrayList<>();
    Long2ObjectOpenHashMap<LongArrayList> intersectingCluster = new Long2ObjectOpenHashMap<>();
    int clusterNumber = 0;
    //build intersecting cluster
    for (ConditionEntry singleCluster : this.singleConditions.get(minimalConditionStartPoint)) {
      satisfiedCluster.add(singleCluster.setClusterNumber(clusterNumber));
      touchedCluster.clear();
      for (long rowNumber : singleCluster.cluster) {
        if (partialUniqueHash.containsKey(rowNumber)) {
          touchedCluster.add(partialUniqueHash.get(rowNumber));
        }
      }
      for (long partialUniqueClusterNumber : touchedCluster) {
        if (intersectingCluster.containsKey(partialUniqueClusterNumber)) {
          intersectingCluster.get(partialUniqueClusterNumber).add(clusterNumber);
        } else {
          LongArrayList newConditionClusterNumbers = new LongArrayList();
          newConditionClusterNumbers.add(clusterNumber);
          intersectingCluster.put(partialUniqueClusterNumber, newConditionClusterNumbers);
        }
      }
      clusterNumber++;
    }
    intersectingCluster = purgeIntersectingClusterEntries(intersectingCluster);
    //convert into list
    List<LongArrayList> intersectingClusterList = new ArrayList<>();
    for (long partialUniqueCluster : intersectingCluster.keySet()) {
      intersectingClusterList.add(intersectingCluster.get(partialUniqueCluster));
    }

    Object2FloatArrayMap<List<ConditionEntry>>
        clustergroups =
        this.combineClusters(this.algorithm.frequency, satisfiedCluster,
                             intersectingClusterList);

    for (List<ConditionEntry> singleCondition : clustergroups.keySet()) {
      ResultSingleton.getInstance().addConditionToResult(partialUnique, singleCondition,
                                                         clustergroups.get(singleCondition));
    }
  }
}