Java Code Examples for it.unimi.dsi.fastutil.ints.IntArrayList#getInt()

The following examples show how to use it.unimi.dsi.fastutil.ints.IntArrayList#getInt() . 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: HyFD.java    From winter with Apache License 2.0 6 votes vote down vote up
private void fetchNonFdsWindowingOverClusters(Set<OpenBitSet> negCover, int[][] compressedRecords, List<PositionListIndex> plis) {
	System.out.println("\tMoving window over small clusters ...");
	for (PositionListIndex pli : plis) {
		boolean selectSmallClustersOnly = pli.getClusters().size() < this.attributeThreshold; 	// If there are too few clusters, then the clusters are large and we have already executed sufficient comparisons between the records of these clusters
		
		for (IntArrayList cluster : pli.getClusters()) {
			if (selectSmallClustersOnly && (cluster.size() > this.windowSize))					// But if the current cluster is very small, we should still use it for comparisons (the other cluster(s) must be very large)
				continue;
			
			for (int recordIndex = 0; recordIndex < cluster.size(); recordIndex++) {
				int recordId = cluster.getInt(recordIndex);
				
				for (int partnerRecordIndex = recordIndex + 1; partnerRecordIndex < Math.min(recordIndex + this.windowSize, cluster.size()); partnerRecordIndex++) {
					int partnerRecordId = cluster.getInt(partnerRecordIndex);
					
					negCover.add(this.getViolatedFds(compressedRecords[recordId], compressedRecords[partnerRecordId]));
				}
			}
		}
	}
}
 
Example 2
Source File: HyFD.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void fetchNonFdsFromClustersTopsAndBottoms(Set<BitSet> negCover, int[][] compressedRecords, List<PositionListIndex> plis) {
	System.out.println("\tComparing window on clusters tops and bottoms ...");
	for (PositionListIndex pli : plis) {
		for (IntArrayList cluster : pli.getClusters()) {
			if (cluster.size() < this.windowSize)
				continue;
			
			for (int recordIndex = 0; recordIndex < this.windowSize; recordIndex++) {
				int recordId = cluster.getInt(recordIndex);
				
				for (int partnerRecordIndex = cluster.size() - 1; partnerRecordIndex > cluster.size() - this.windowSize; partnerRecordIndex--) {
					int partnerRecordId = cluster.getInt(partnerRecordIndex);
					
					if (recordId == partnerRecordId)
						continue;
					
					negCover.add(this.getViolatedFds(compressedRecords[recordId], compressedRecords[partnerRecordId]));
				}
			}
		}
	}
}
 
Example 3
Source File: HyFD.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void fetchNonFdsWindowingOverClusters(Set<BitSet> negCover, int[][] compressedRecords, List<PositionListIndex> plis) {
	System.out.println("\tMoving window over small clusters ...");
	for (PositionListIndex pli : plis) {
		boolean selectSmallClustersOnly = pli.getClusters().size() < this.attributeThreshold; 	// If there are too few clusters, then the clusters are large and we have already executed sufficient comparisons between the records of these clusters
		
		for (IntArrayList cluster : pli.getClusters()) {
			if (selectSmallClustersOnly && (cluster.size() > this.windowSize))					// But if the current cluster is very small, we should still use it for comparisons (the other cluster(s) must be very large)
				continue;
			
			for (int recordIndex = 0; recordIndex < cluster.size(); recordIndex++) {
				int recordId = cluster.getInt(recordIndex);
				
				for (int partnerRecordIndex = recordIndex + 1; partnerRecordIndex < Math.min(recordIndex + this.windowSize, cluster.size()); partnerRecordIndex++) {
					int partnerRecordId = cluster.getInt(partnerRecordIndex);
					
					negCover.add(this.getViolatedFds(compressedRecords[recordId], compressedRecords[partnerRecordId]));
				}
			}
		}
	}
}
 
Example 4
Source File: HyFD.java    From winter with Apache License 2.0 6 votes vote down vote up
private void fetchNonFdsFromClustersTopsAndBottoms(Set<OpenBitSet> negCover, int[][] compressedRecords, List<PositionListIndex> plis) {
	System.out.println("\tComparing window on clusters tops and bottoms ...");
	for (PositionListIndex pli : plis) {
		for (IntArrayList cluster : pli.getClusters()) {
			if (cluster.size() < this.windowSize)
				continue;
			
			for (int recordIndex = 0; recordIndex < this.windowSize; recordIndex++) {
				int recordId = cluster.getInt(recordIndex);
				
				for (int partnerRecordIndex = cluster.size() - 1; partnerRecordIndex > cluster.size() - this.windowSize; partnerRecordIndex--) {
					int partnerRecordId = cluster.getInt(partnerRecordIndex);
					
					if (recordId == partnerRecordId)
						continue;
					
					negCover.add(this.getViolatedFds(compressedRecords[recordId], compressedRecords[partnerRecordId]));
				}
			}
		}
	}
}
 
Example 5
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[] rhsInvertedPli, IntArrayList cluster) {
	int rhsClusterId = rhsInvertedPli[cluster.getInt(0)];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (rhsInvertedPli[recordId] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 6
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[] rhsInvertedPli, IntArrayList cluster) {
	int rhsClusterId = rhsInvertedPli[cluster.getInt(0)];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (rhsInvertedPli[recordId] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 7
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[][] compressedRecords, int rhsAttr, IntArrayList cluster) {
	int rhsClusterId = compressedRecords[cluster.getInt(0)][rhsAttr];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (compressedRecords[recordId][rhsAttr] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 8
Source File: Sampler.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public void runNext(FDList newNonFds, int[][] compressedRecords) {
	this.windowDistance++;
	int numNewNonFds = 0;
	int numComparisons = 0;
	BitSet equalAttrs = new BitSet(this.posCover.getNumAttributes());
	
	int previousNegCoverSize = newNonFds.size();
	Iterator<IntArrayList> clusterIterator = this.clusters.iterator();
	while (clusterIterator.hasNext()) {
		IntArrayList cluster = clusterIterator.next();
		
		if (cluster.size() <= this.windowDistance) {
			clusterIterator.remove();
			continue;
		}
		
		for (int recordIndex = 0; recordIndex < (cluster.size() - this.windowDistance); recordIndex++) {
			int recordId = cluster.getInt(recordIndex);
			int partnerRecordId = cluster.getInt(recordIndex + this.windowDistance);
			
			this.sampler.match(equalAttrs, compressedRecords[recordId], compressedRecords[partnerRecordId]);
			
			if (!this.negCover.contains(equalAttrs)) {
				BitSet equalAttrsCopy = (BitSet) equalAttrs.clone();
				this.negCover.add(equalAttrsCopy);
				newNonFds.add(equalAttrsCopy);
				
				this.memoryGuardian.memoryChanged(1);
				this.memoryGuardian.match(this.negCover, this.posCover, newNonFds);
			}
			numComparisons++;
		}
	}
	numNewNonFds = newNonFds.size() - previousNegCoverSize;
	
	this.numNewNonFds.add(numNewNonFds);
	this.numComparisons.add(numComparisons);
}
 
Example 9
Source File: HyFD.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public boolean runNext(Set<BitSet> negCover, int[][] compressedRecords) {
	this.windowDistance++;
	int numNewNonFds = 0;
	int numComparisons = 0;
	
	int previousNegCoverSize = negCover.size();
	Iterator<IntArrayList> clusterIterator = this.clusters.iterator();
	while (clusterIterator.hasNext()) {
		IntArrayList cluster = clusterIterator.next();
		
		if (cluster.size() <= this.windowDistance) {
			clusterIterator.remove();
			continue;
		}
		
		for (int recordIndex = 0; recordIndex < (cluster.size() - this.windowDistance); recordIndex++) {
			int recordId = cluster.getInt(recordIndex);
			int partnerRecordId = cluster.getInt(recordIndex + this.windowDistance);
			negCover.add(this.getViolatedFds(compressedRecords[recordId], compressedRecords[partnerRecordId]));
			numComparisons++;
		}
	}
	numNewNonFds = negCover.size() - previousNegCoverSize;
	
	this.numNewNonFds.add(numNewNonFds);
	this.numComparisons.add(numComparisons);
	
	if (numComparisons == 0)
		return false;
	return true;
}
 
Example 10
Source File: MToNChain.java    From twister2 with Apache License 2.0 5 votes vote down vote up
private boolean sendToGroup() {
  boolean sent = false;
  IntArrayList sendingGroup = sendingGroupsWorkers.get(sendGroupIndex);
  for (int j = 0; j < sendingGroup.size(); j++) {
    int worker = sendingGroup.getInt(j);
    IntArrayList workerTargets = workerToTargets.get(worker);
    int targetIndex = sendWorkerTaskIndex.get(worker);

    for (int i = targetIndex; i < workerTargets.size(); i++) {
      int target = workerTargets.get(i);
      Queue<AggregatedObjects<Object>> queue = merged.get(target);

      AggregatedObjects<Object> data = queue.peek();
      if (data == null) {
        data = empty;
      }
      RoutingParameters parameters = targetRoutes.get(target);
      // even if we have 0 tuples, we need to send at this point
      if (!delegate.sendMessage(representSource, data, target, 0, parameters)) {
        return false;
      } else {
        queue.poll();
        sent = true;
        // we are going to decrease the amount of messages in memory
        mergedInMemoryMessages -= data.size();
        // advance the index
        targetIndex++;
        sendWorkerTaskIndex.put(worker, targetIndex);
      }
    }
  }

  if (sent) {
    finishedSendGroups.add(sendGroupIndex);
  }
  return true;
}
 
Example 11
Source File: TestDictionaryAwarePageFilter.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public SelectedPositions filter(ConnectorSession session, Page page)
{
    assertEquals(page.getChannelCount(), 1);
    Block block = page.getBlock(0);

    boolean sequential = true;
    IntArrayList selectedPositions = new IntArrayList();
    for (int position = 0; position < block.getPositionCount(); position++) {
        long value = block.getLong(position, 0);
        verifyPositive(value);

        boolean selected = isSelected(filterRange, value);
        if (selected) {
            if (sequential && !selectedPositions.isEmpty()) {
                sequential = (position == selectedPositions.getInt(selectedPositions.size() - 1) + 1);
            }
            selectedPositions.add(position);
        }
    }
    if (selectedPositions.isEmpty()) {
        return SelectedPositions.positionsRange(0, 0);
    }
    if (sequential) {
        return SelectedPositions.positionsRange(selectedPositions.getInt(0), selectedPositions.size());
    }
    // add 3 invalid elements to the head and tail
    for (int i = 0; i < 3; i++) {
        selectedPositions.add(0, -1);
        selectedPositions.add(-1);
    }

    // verify the input block is the expected type (this is to assure that
    // dictionary processing enabled and disabled as expected)
    // this check is performed last so that dictionary processing that fails
    // is not checked (only the fall back processing is checked)
    assertTrue(expectedType.isInstance(block));

    return SelectedPositions.positionsList(selectedPositions.elements(), 3, selectedPositions.size() - 6);
}
 
Example 12
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[][] compressedRecords, int rhsAttr, IntArrayList cluster) {
	int rhsClusterId = compressedRecords[cluster.getInt(0)][rhsAttr];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (compressedRecords[recordId][rhsAttr] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 13
Source File: Sampler.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public void runNext(UCCList newNonUCCs, int[][] compressedRecords) {
	this.windowDistance++;
	int numNewNonFds = 0;
	int numComparisons = 0;
	BitSet equalAttrs = new BitSet(this.posCover.getNumAttributes());
	
	int previousNewNonFdsSize = newNonUCCs.size();
	Iterator<IntArrayList> clusterIterator = this.clusters.iterator();
	while (clusterIterator.hasNext()) {
		IntArrayList cluster = clusterIterator.next();
		
		if (cluster.size() <= this.windowDistance) {
			clusterIterator.remove();
			continue;
		}
		
		for (int recordIndex = 0; recordIndex < (cluster.size() - this.windowDistance); recordIndex++) {
			int recordId = cluster.getInt(recordIndex);
			int partnerRecordId = cluster.getInt(recordIndex + this.windowDistance);
			
			this.sampler.match(equalAttrs, compressedRecords[recordId], compressedRecords[partnerRecordId]);
			
			if (!this.negCover.contains(equalAttrs)) {
				BitSet equalAttrsCopy = (BitSet) equalAttrs.clone();
				this.negCover.add(equalAttrsCopy);
				newNonUCCs.add(equalAttrsCopy);
				
				this.memoryGuardian.memoryChanged(1);
				this.memoryGuardian.match(this.negCover, this.posCover, newNonUCCs);
			}
			numComparisons++;
		}
	}
	numNewNonFds = newNonUCCs.size() - previousNewNonFdsSize;
	
	this.numNewNonFds.add(numNewNonFds);
	this.numComparisons.add(numComparisons);
}
 
Example 14
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[] rhsInvertedPli, IntArrayList cluster) {
	int rhsClusterId = rhsInvertedPli[cluster.getInt(0)];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (rhsInvertedPli[recordId] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 15
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[][] compressedRecords, int rhsAttr, IntArrayList cluster) {
	int rhsClusterId = compressedRecords[cluster.getInt(0)][rhsAttr];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (compressedRecords[recordId][rhsAttr] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 16
Source File: PositionListIndex.java    From winter with Apache License 2.0 5 votes vote down vote up
protected boolean probe(int[][] compressedRecords, int rhsAttr, IntArrayList cluster) {
	int rhsClusterId = compressedRecords[cluster.getInt(0)][rhsAttr];
	
	// If otherClusterId < 0, then this cluster must point into more than one other clusters
	if (rhsClusterId == -1)
		return false;
	
	// Check if all records of this cluster point into the same other cluster
	for (int recordId : cluster)
		if (compressedRecords[recordId][rhsAttr] != rhsClusterId)
			return false;
	
	return true;
}
 
Example 17
Source File: CFDFinder.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private List<IntArrayList> determineCover(final Pattern c, final Pattern currentPattern, final int[][] values) {
 List<IntArrayList> result = new LinkedList<>();
 for (IntArrayList cluster : currentPattern.getCover()) {
     int[] tuple = values[cluster.getInt(0)];
     if (c.matches(tuple)) {
         result.add(cluster.clone());
        }
    }
 return result;
}
 
Example 18
Source File: HyFD.java    From winter with Apache License 2.0 5 votes vote down vote up
private void fetchNonFdsSPIDER(Set<OpenBitSet> negCover, int[][] compressedRecords, List<PositionListIndex> plis) {
	System.out.println("\tSPIDERing over clusters ...");
	for (PositionListIndex pli : plis) {
		for (IntArrayList cluster : pli.getClusters()) {
			int pivotRecord = cluster.getInt(0);
			
			IntArrayList[] clusters = new IntArrayList[this.numAttributes];
			for (int i = 0; i < this.numAttributes; i++)
				if (compressedRecords[pivotRecord][i] >= 0) // Maybe the record has no duplicate value in some attributes
					clusters[i] = plis.get(i).getClusters().get(compressedRecords[pivotRecord][i]);
			
			this.spider(clusters, pivotRecord, negCover);
		}
	}
}
 
Example 19
Source File: ConstantPatternExpansionStrategy.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private List<Pattern> getChildPatterns(Pattern pattern, IntArrayList cluster) {
    List<Pattern> results = new LinkedList<>();
    for (int i = 0; i < pattern.getIds().length; i+= 1) {
        int id = pattern.getIds()[i];
        PatternEntry entry = pattern.getPatternEntries()[i];
        if (entry instanceof VariablePatternEntry) {
            int value = values[cluster.getInt(0)][id];
            results.addAll(specializeVariablePatternEntry(pattern, id, value));
        }
    }
    return results;
}
 
Example 20
Source File: MToNChain.java    From twister2 with Apache License 2.0 5 votes vote down vote up
private boolean sendSyncs() {
  boolean sent = false;
  IntArrayList sendingGroup = sendingGroupsWorkers.get(sendGroupIndex);
  for (int j = 0; j < sendingGroup.size(); j++) {
    int worker = sendingGroup.getInt(j);
    IntArrayList workerTargets = workerToTargets.get(worker);
    int targetIndex = sendWorkerTaskIndex.get(worker);

    for (int i = targetIndex; i < workerTargets.size(); i++) {
      int target = workerTargets.getInt(i);
      RoutingParameters parameters = targetRoutes.get(target);
      byte[] message = new byte[1];
      int flags = MessageFlags.SYNC_EMPTY;
      if (delegate.sendMessage(representSource, message, target, flags, parameters)) {
        sent = true;
        // advance the index
        targetIndex++;
        syncSent.add(target);
        sendWorkerTaskIndex.put(worker, targetIndex);
      } else {
        // no point in going further
        return false;
      }
    }
  }


  if (sent) {
    if (syncSent.size() == targetsArray.length) {
      for (int source : thisWorkerSources) {
        sourceStates.put(source, ReceiverState.SYNCED);
      }
    }
    finishedSendGroups.add(sendGroupIndex);
  }
  return true;
}