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()));
}
}
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;
}
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()));
}
}
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));
}
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();
}
}
}
Aggregations