Search in sources :

Example 1 with IntSet

use of it.unimi.dsi.fastutil.ints.IntSet in project gradle by gradle.

the class ClassChangeProcessor method processChange.

public void processChange(final InputFileDetails input, final RecompilationSpec spec) {
    if (input.isRemoved()) {
        // this is a really heavyweight way of getting the dependencies of a file which was removed
        // hopefully this is not going to happen too often
        String className = previousCompilation.getClassName(input.getFile().getAbsolutePath());
        update(input, spec, className, IntSets.EMPTY_SET);
        return;
    }
    final ClassReader classReader;
    try {
        classReader = new PatchedClassReader(Files.toByteArray(input.getFile()));
        String className = classReader.getClassName().replaceAll("/", ".");
        IntSet constants = ClassDependenciesVisitor.retrieveConstants(classReader);
        update(input, spec, className, constants);
    } catch (IOException e) {
        throw new IllegalArgumentException(String.format("Unable to read class file: '%s'", input.getFile()));
    }
}
Also used : IntSet(it.unimi.dsi.fastutil.ints.IntSet) PatchedClassReader(org.gradle.util.internal.PatchedClassReader) ClassReader(org.objectweb.asm.ClassReader) IOException(java.io.IOException) PatchedClassReader(org.gradle.util.internal.PatchedClassReader)

Example 2 with IntSet

use of it.unimi.dsi.fastutil.ints.IntSet in project gradle by gradle.

the class ClassDependenciesVisitor method retrieveConstants.

public static IntSet retrieveConstants(ClassReader reader) {
    IntSet constants = new IntOpenHashSet(2);
    ClassDependenciesVisitor visitor = new ClassDependenciesVisitor(constants);
    reader.accept(visitor, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
    return constants;
}
Also used : IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) IntSet(it.unimi.dsi.fastutil.ints.IntSet)

Example 3 with IntSet

use of it.unimi.dsi.fastutil.ints.IntSet in project LanternServer by LanternPowered.

the class EntityProtocol method postUpdate.

@Override
protected void postUpdate(EntityProtocolUpdateContext context) {
    final IntSet passengers = getPassengerIds(context);
    if (!passengers.equals(this.lastPassengers)) {
        this.lastPassengers = passengers;
        context.sendToAll(new MessagePlayOutSetEntityPassengers(getRootEntityId(), passengers.toIntArray()));
    }
}
Also used : MessagePlayOutSetEntityPassengers(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSetEntityPassengers) IntSet(it.unimi.dsi.fastutil.ints.IntSet)

Example 4 with IntSet

use of it.unimi.dsi.fastutil.ints.IntSet in project elki by elki-project.

the class DeLiCluTree method setExpanded.

/**
 * Marks the nodes with the specified ids as expanded.
 *
 * @param entry1 the first node
 * @param entry2 the second node
 */
public void setExpanded(SpatialEntry entry1, SpatialEntry entry2) {
    IntSet exp1 = expanded.get(getPageID(entry1));
    if (exp1 == null) {
        exp1 = new IntOpenHashSet();
        expanded.put(getPageID(entry1), exp1);
    }
    exp1.add(getPageID(entry2));
}
Also used : IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) IntSet(it.unimi.dsi.fastutil.ints.IntSet)

Example 5 with IntSet

use of it.unimi.dsi.fastutil.ints.IntSet in project presto by prestodb.

the class GroupedTopNBuilder method processPage.

private void processPage(Page newPage, GroupByIdBlock groupIds) {
    checkArgument(newPage != null);
    checkArgument(groupIds != null);
    int firstPositionToInsert = findFirstPositionToInsert(newPage, groupIds);
    if (firstPositionToInsert < 0) {
        // no insertions required
        return;
    }
    PageReference newPageReference = new PageReference(newPage);
    memorySizeInBytes += newPageReference.getEstimatedSizeInBytes();
    int newPageId;
    if (emptyPageReferenceSlots.isEmpty()) {
        // all the previous slots are full; create a new one
        pageReferences.ensureCapacity(currentPageCount + 1);
        newPageId = currentPageCount;
        currentPageCount++;
    } else {
        // reuse a previously removed page's slot
        newPageId = emptyPageReferenceSlots.dequeueInt();
    }
    verify(pageReferences.setIfNull(newPageId, newPageReference), "should not overwrite a non-empty slot");
    // ensure sufficient group capacity outside of the loop
    groupedRows.ensureCapacity(groupIds.getGroupCount());
    // update the affected heaps and record candidate pages that need compaction
    IntSet pagesToCompact = new IntOpenHashSet();
    for (int position = firstPositionToInsert; position < newPage.getPositionCount(); position++) {
        long groupId = groupIds.getGroupId(position);
        RowHeap rows = groupedRows.get(groupId);
        if (rows == null) {
            // a new group
            rows = new RowHeap(rowHeapComparator);
            groupedRows.set(groupId, rows);
        } else {
            // update an existing group;
            // remove the memory usage for this group for now; add it back after update
            memorySizeInBytes -= rows.getEstimatedSizeInBytes();
        }
        if (rows.size() < topN) {
            Row row = new Row(newPageId, position);
            newPageReference.reference(row);
            rows.enqueue(row);
        } else {
            // may compare with the topN-th element with in the heap to decide if update is necessary
            Row previousRow = rows.first();
            PageReference previousPageReference = pageReferences.get(previousRow.getPageId());
            if (pageWithPositionComparator.compareTo(newPage, position, previousPageReference.getPage(), previousRow.getPosition()) < 0) {
                // update reference and the heap
                rows.dequeue();
                previousPageReference.dereference(previousRow.getPosition());
                Row newRow = new Row(newPageId, position);
                newPageReference.reference(newRow);
                rows.enqueue(newRow);
                // compact a page if it is not the current input page and the reference count is below the threshold
                if (previousPageReference.getPage() != newPage && previousPageReference.getUsedPositionCount() * COMPACT_THRESHOLD < previousPageReference.getPage().getPositionCount()) {
                    pagesToCompact.add(previousRow.getPageId());
                }
            }
        }
        memorySizeInBytes += rows.getEstimatedSizeInBytes();
    }
    // may compact the new page as well
    if (newPageReference.getUsedPositionCount() * COMPACT_THRESHOLD < newPage.getPositionCount()) {
        verify(pagesToCompact.add(newPageId));
    }
    // compact pages
    IntIterator iterator = pagesToCompact.iterator();
    while (iterator.hasNext()) {
        int pageId = iterator.nextInt();
        PageReference pageReference = pageReferences.get(pageId);
        if (pageReference.getUsedPositionCount() == 0) {
            pageReferences.set(pageId, null);
            emptyPageReferenceSlots.enqueue(pageId);
            memorySizeInBytes -= pageReference.getEstimatedSizeInBytes();
        } else {
            memorySizeInBytes -= pageReference.getEstimatedSizeInBytes();
            pageReference.compact();
            memorySizeInBytes += pageReference.getEstimatedSizeInBytes();
        }
    }
}
Also used : IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) IntIterator(it.unimi.dsi.fastutil.ints.IntIterator) IntSet(it.unimi.dsi.fastutil.ints.IntSet)

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