use of it.unimi.dsi.fastutil.ints.IntSet in project elki by elki-project.
the class DeLiClu method reinsertExpanded.
private void reinsertExpanded(SpatialPrimitiveDistanceFunction<NV> distFunction, DeLiCluTree index, List<IndexTreePath<DeLiCluEntry>> path, int pos, DeLiCluEntry parentEntry, Relation<KNNList> knns) {
DeLiCluNode parentNode = index.getNode(parentEntry);
SpatialEntry entry2 = path.get(pos).getEntry();
if (entry2 instanceof LeafEntry) {
assert (pos == 0);
for (int i = 0; i < parentNode.getNumEntries(); i++) {
DeLiCluEntry entry1 = parentNode.getEntry(i);
if (entry1.hasHandled()) {
continue;
}
double distance = distFunction.minDist(entry1, entry2);
double reach = MathUtil.max(distance, knns.get(((LeafEntry) entry2).getDBID()).getKNNDistance());
SpatialObjectPair dataPair = new SpatialObjectPair(reach, entry1, entry2, false);
heap.add(dataPair);
}
return;
}
IntSet expanded = index.getExpanded(entry2);
for (int i = 0; i < parentNode.getNumEntries(); i++) {
DeLiCluDirectoryEntry entry1 = (DeLiCluDirectoryEntry) parentNode.getEntry(i);
// not yet expanded
if (!expanded.contains(entry1.getPageID())) {
double distance = distFunction.minDist(entry1, entry2);
SpatialObjectPair nodePair = new SpatialObjectPair(distance, entry1, entry2, true);
heap.add(nodePair);
} else // already expanded
{
reinsertExpanded(distFunction, index, path, pos - 1, entry1, knns);
}
}
}
use of it.unimi.dsi.fastutil.ints.IntSet in project gradle by gradle.
the class ClassSetAnalysis method findChangesSince.
/**
* Computes the types affected by the changes since some other class set, including transitively affected classes.
*/
public ClassSetDiff findChangesSince(ClassSetAnalysis other) {
DependentsSet directChanges = classAnalysis.getChangedClassesSince(other.classAnalysis);
if (directChanges.isDependencyToAll()) {
return new ClassSetDiff(directChanges, Collections.emptyMap());
}
DependentsSet transitiveChanges = other.findTransitiveDependents(directChanges.getAllDependentClasses(), Collections.emptyMap());
if (transitiveChanges.isDependencyToAll()) {
return new ClassSetDiff(transitiveChanges, Collections.emptyMap());
}
DependentsSet allChanges = DependentsSet.merge(Arrays.asList(directChanges, transitiveChanges));
Map<String, IntSet> changedConstants = findChangedConstants(other, allChanges);
return new ClassSetDiff(allChanges, changedConstants);
}
use of it.unimi.dsi.fastutil.ints.IntSet in project gradle by gradle.
the class ClassSetAnalysis method findTransitiveDependents.
/**
* Computes the transitive dependents of a set of changed classes. If the classes had any changes to inlineable constants, these need to be provided as the second parameter.
*
* If incremental annotation processing encountered issues in the previous compilation, a full recompilation is required.
* If any inlineable constants have changed and the compiler does not support exact constant dependency tracking, then a full recompilation is required.
* Otherwise follows the below rules for all of the given classes, as well as the classes that were marked as "always recompile" by annotation processing:
*
* Starts at this class and capture all classes that reference this class and all classes and resources that were generated from this class.
* Then does the same analysis for all classes that expose this class on their ABI recursively until no more new classes are discovered.
*/
public DependentsSet findTransitiveDependents(Collection<String> classes, Map<String, IntSet> changedConstantsByClass) {
if (classes.isEmpty()) {
return DependentsSet.empty();
}
String fullRebuildCause = annotationProcessingData.getFullRebuildCause();
if (fullRebuildCause != null) {
return DependentsSet.dependencyToAll(fullRebuildCause);
}
if (!compilerApiData.isSupportsConstantsMapping()) {
for (Map.Entry<String, IntSet> changedConstantsOfClass : changedConstantsByClass.entrySet()) {
if (!changedConstantsOfClass.getValue().isEmpty()) {
return DependentsSet.dependencyToAll("an inlineable constant in '" + changedConstantsOfClass.getKey() + "' has changed");
}
}
}
Set<String> privateDependents = new HashSet<>();
Set<String> accessibleDependents = new HashSet<>();
Set<GeneratedResource> dependentResources = new HashSet<>(annotationProcessingData.getGeneratedResourcesDependingOnAllOthers());
Set<String> visited = new HashSet<>();
Deque<String> remaining = new ArrayDeque<>(classes);
remaining.addAll(annotationProcessingData.getGeneratedTypesDependingOnAllOthers());
while (!remaining.isEmpty()) {
String current = remaining.pop();
if (!visited.add(current)) {
continue;
}
accessibleDependents.add(current);
DependentsSet dependents = findDirectDependents(current);
if (dependents.isDependencyToAll()) {
return dependents;
}
dependentResources.addAll(dependents.getDependentResources());
privateDependents.addAll(dependents.getPrivateDependentClasses());
remaining.addAll(dependents.getAccessibleDependentClasses());
}
privateDependents.removeAll(classes);
accessibleDependents.removeAll(classes);
return DependentsSet.dependents(privateDependents, accessibleDependents, dependentResources);
}
use of it.unimi.dsi.fastutil.ints.IntSet in project angel by Tencent.
the class ServerArbitraryIntRow method writeSparseTo.
public void writeSparseTo(DataOutputStream output) throws IOException {
try {
lock.readLock().lock();
super.writeTo(output);
output.writeUTF(RowType.T_INT_SPARSE.toString());
output.writeInt(nnz);
IntSet keys = sparseRep.keySet();
output.writeInt(keys.size());
for (int key : keys) {
output.writeInt(key);
output.writeInt(sparseRep.get(key));
}
} finally {
lock.readLock().unlock();
}
}
use of it.unimi.dsi.fastutil.ints.IntSet in project presto by prestodb.
the class TestDictionaryAwarePageFilter method testFilter.
private static void testFilter(DictionaryAwarePageFilter filter, Block block, boolean filterRange) {
IntSet actualSelectedPositions = toSet(filter.filter(null, new Page(block)));
block = block.getLoadedBlock();
IntSet expectedSelectedPositions = new IntArraySet(block.getPositionCount());
for (int position = 0; position < block.getPositionCount(); position++) {
if (isSelected(filterRange, block.getLong(position))) {
expectedSelectedPositions.add(position);
}
}
assertEquals(actualSelectedPositions, expectedSelectedPositions);
}
Aggregations