Search in sources :

Example 16 with IntSet

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);
        }
    }
}
Also used : DeLiCluEntry(de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluEntry) LeafEntry(de.lmu.ifi.dbs.elki.index.tree.LeafEntry) IntSet(it.unimi.dsi.fastutil.ints.IntSet) DeLiCluDirectoryEntry(de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluDirectoryEntry) DeLiCluNode(de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluNode) SpatialEntry(de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialEntry)

Example 17 with IntSet

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);
}
Also used : DependentsSet(org.gradle.api.internal.tasks.compile.incremental.compilerapi.deps.DependentsSet) IntSet(it.unimi.dsi.fastutil.ints.IntSet)

Example 18 with IntSet

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);
}
Also used : DependentsSet(org.gradle.api.internal.tasks.compile.incremental.compilerapi.deps.DependentsSet) IntSet(it.unimi.dsi.fastutil.ints.IntSet) GeneratedResource(org.gradle.api.internal.tasks.compile.incremental.compilerapi.deps.GeneratedResource) HashMap(java.util.HashMap) Map(java.util.Map) ArrayDeque(java.util.ArrayDeque) HashSet(java.util.HashSet) IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet)

Example 19 with IntSet

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();
    }
}
Also used : IntSet(it.unimi.dsi.fastutil.ints.IntSet)

Example 20 with IntSet

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);
}
Also used : IntSet(it.unimi.dsi.fastutil.ints.IntSet) Page(com.facebook.presto.common.Page) IntArraySet(it.unimi.dsi.fastutil.ints.IntArraySet)

Aggregations

IntSet (it.unimi.dsi.fastutil.ints.IntSet)20 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)12 HashMap (java.util.HashMap)3 DependentsSet (org.gradle.api.internal.tasks.compile.incremental.compilerapi.deps.DependentsSet)3 ArrayDeque (java.util.ArrayDeque)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ClassAnalysis (org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)2 Page (com.facebook.presto.common.Page)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 LeafEntry (de.lmu.ifi.dbs.elki.index.tree.LeafEntry)1 SpatialEntry (de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialEntry)1 DeLiCluDirectoryEntry (de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluDirectoryEntry)1 DeLiCluEntry (de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluEntry)1 DeLiCluNode (de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.deliclu.DeLiCluNode)1 IntArraySet (it.unimi.dsi.fastutil.ints.IntArraySet)1 IntIterator (it.unimi.dsi.fastutil.ints.IntIterator)1 IOException (java.io.IOException)1 ConciseBitmapFactory (org.apache.druid.collections.bitmap.ConciseBitmapFactory)1 MutableBitmap (org.apache.druid.collections.bitmap.MutableBitmap)1