Compacts all compactable segments.
483875
private void compactSegments() {
    // Create a compact segment with a newer version to which to rewrite the segment entries.
    Segment compactSegment = manager.createSegment(SegmentDescriptor.builder()
      .withId(segment.descriptor().id())
      .withVersion(segment.descriptor().version() + 1)
      .withIndex(segment.descriptor().index())
      .withMaxSegmentSize(segment.descriptor().maxSegmentSize())
      .withMaxEntries(segment.descriptor().maxEntries())
      .build());

    compactEntries(segment, compactSegment);

    // Replace the old segment with the compact segment.
    manager.replaceSegments(Collections.singletonList(segment), compactSegment);

    // Update the new segment with offsets that were released during compaction.
    mergeReleasedEntries(segment, compactSegment);

    // Delete the old segment.
    segment.close();
    segment.delete();
  }
560464
public void compact(ServerStoreProxy.ChainEntry entry) {
    ChainBuilder builder = new ChainBuilder();
    for (PutOperation<K, V> operation : resolveAll(entry).values()) {
      builder = builder.add(codec.encode(operation));
    }
    Chain compacted = builder.build();
    if (compacted.length() < entry.length()) {
      entry.replaceAtHead(compacted);
    }
  }
1220286
private void compactPartition(int partitionNumber) throws IOException {
		// stop if no garbage exists
		if(this.partitions.get(partitionNumber).isCompacted()) {
			return;
		}
		// release all segments owned by compaction partition
		this.compactionMemory.clearAllMemory(availableMemory);
		this.compactionMemory.allocateSegments(1);
		T tempHolder = this.buildSideSerializer.createInstance();
		InMemoryPartition<T> partition = this.partitions.remove(partitionNumber);
		final int numPartitions = this.partitions.size() + 1; // dropped one earlier
		long pointer = 0L;
		int pointerOffset = 0;
		int bucketOffset = 0;
		final int bucketsPerSegment = this.bucketsPerSegmentMask + 1;
		for (int i = 0, bucket = partitionNumber; i < this.buckets.length && bucket < this.numBuckets; i++) {
			MemorySegment segment = this.buckets[i];
			// go over all buckets in the segment belonging to the partition
			for (int k = bucket % bucketsPerSegment; k < bucketsPerSegment && bucket < this.numBuckets; k += numPartitions, bucket += numPartitions) {
				bucketOffset = k * HASH_BUCKET_SIZE;
				if((int)segment.get(bucketOffset + HEADER_PARTITION_OFFSET) != partitionNumber) {
					throw new IOException("Accessed wrong bucket! ");
				}
				int count = segment.getInt(bucketOffset + HEADER_COUNT_OFFSET);
				for (int j = 0; j < NUM_ENTRIES_PER_BUCKET && j < count; j++) {
					pointerOffset = bucketOffset + BUCKET_POINTER_START_OFFSET + (j * POINTER_LEN);
					pointer = segment.getLong(pointerOffset);
					partition.readRecordAt(pointer, tempHolder);
					pointer = this.compactionMemory.appendRecord(tempHolder);
					segment.putLong(pointerOffset, pointer);
				}
				long overflowPointer = segment.getLong(bucketOffset + HEADER_FORWARD_OFFSET);
				if(overflowPointer != BUCKET_FORWARD_POINTER_NOT_SET) {
					// scan overflow buckets
					int current = NUM_ENTRIES_PER_BUCKET;
					bucketOffset = (int) (overflowPointer & 0xffffffff);
					pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
					int overflowSegNum = (int) (overflowPointer >>> 32);
					count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
					while(current < count) {
						pointer = partition.overflowSegments[overflowSegNum].getLong(pointerOffset);
						partition.readRecordAt(pointer, tempHolder);
						pointer = this.compactionMemory.appendRecord(tempHolder);
						partition.overflowSegments[overflowSegNum].putLong(pointerOffset, pointer);
						current++;
						if(current % NUM_ENTRIES_PER_BUCKET == 0) {
							count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
							overflowPointer = partition.overflowSegments[overflowSegNum].getLong(bucketOffset + HEADER_FORWARD_OFFSET);
							if(overflowPointer == BUCKET_FORWARD_POINTER_NOT_SET) {
								break;
							}
							overflowSegNum = (int) (overflowPointer >>> 32);
							bucketOffset = (int) (overflowPointer & 0xffffffff);
							pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
						} else {
							pointerOffset += POINTER_LEN;
						}
					}
				}
			}
		}
		// swap partition with compaction partition
		this.compactionMemory.setPartitionNumber(partitionNumber);
		this.partitions.add(partitionNumber, compactionMemory);
		this.compactionMemory = partition;
		this.partitions.get(partitionNumber).overflowSegments = this.compactionMemory.overflowSegments;
		this.partitions.get(partitionNumber).numOverflowSegments = this.compactionMemory.numOverflowSegments;
		this.partitions.get(partitionNumber).nextOverflowBucket = this.compactionMemory.nextOverflowBucket;
		this.partitions.get(partitionNumber).setCompaction(true);
		this.compactionMemory.resetRecordCounter();
		this.compactionMemory.setPartitionNumber(-1);
		// try to allocate maximum segment count
		int maxSegmentNumber = 0;
		for (InMemoryPartition<T> e : this.partitions) {
			if(e.getBlockCount() > maxSegmentNumber) {
				maxSegmentNumber = e.getBlockCount();
			}
		}
		this.compactionMemory.allocateSegments(maxSegmentNumber);
		if(this.compactionMemory.getBlockCount() > maxSegmentNumber) {
			this.compactionMemory.releaseSegments(maxSegmentNumber, availableMemory);
		}
	}
686175
@GuardedBy("lock")
    protected void _compact() {
        // This is the range we need to copy into the new matrix (including from and to)
        int from=computeRow(low), to=computeRow(hr);
        int range=to - from +1;  // e.g. from=3, to=5, new_size has to be [3 .. 5] (=3)

        int new_size=(int)Math.max( (double)range * resize_factor, (double) range +1 );
        new_size=Math.max(new_size, num_rows); // don't fall below the initial size defined
        if(new_size < matrix.length) {
            T[][] new_matrix=(T[][])new Object[new_size][];
            System.arraycopy(matrix, from, new_matrix, 0, range);
            matrix=new_matrix;
            offset+=from * elements_per_row;
            num_compactions++;
        }
    }
605249
public void compact() {
        // Bare-bones iterator: no filter, don't bother with package strings
        for (NodeIterator<T> i = this.getNodeIterator(); i.hasNext();) {
            NodeIndex<T> n = i.next();
            if (n.node.exactKids != null)
                n.node.exactKids.trimToSize();
        }
    }
38925
def resizeAllSections(header, sectionSize):
    
    for idx in range(header.length()):
        header.resizeSection(idx, sectionSize)
257865
private void mergeReleasedEntries(Segment segment, OffsetPredicate predicate, Segment compactSegment) {
    for (long i = segment.firstIndex(); i <= segment.lastIndex(); i++) {
      long offset = segment.offset(i);
      if (offset != -1 && !predicate.test(offset)) {
        compactSegment.release(i);
      }
    }
  }
159512
public void sync(boolean syncAllSegments)
    {
        CommitLogSegment current = allocator.allocatingFrom();
        for (CommitLogSegment segment : allocator.getActiveSegments())
        {
            if (!syncAllSegments && segment.id > current.id)
                return;
            segment.sync();
        }
    }
1304619
function compact(array) {
  const aResult = [];
  for (let idx = 0, len = array.length; idx < len; idx++) {
    if (array[idx]) { aResult.push(array[idx]); }
  }
  return aResult;
}
413478
def compact(self, include=None):
        
        return self._get(self._build_url(self.endpoint.compact(include=include)))
1274855
protected void syncCompactor() {
        ConcurrentLinkedQueue<Segment> queue = _compactor.getCompactedQueue();
        while(!queue.isEmpty()) {
            Segment seg = queue.remove();
            consumeCompactionBatches();
            _compactor.getFreeQueue().offer(seg);
        }
        
        consumeCompactionBatches();
    }
1050474
final KeyValue compact(final ArrayList<KeyValue> row,
      List<Annotation> annotations,
      List<HistogramDataPoint> histograms) {
    return compactionq.compact(row, annotations, histograms);
  }
738115
public List<List<Segment>> getCompactableGroups(Storage storage, SegmentManager manager) {
    List<List<Segment>> compact = new ArrayList<>();
    List<Segment> segments = null;
    for (Segment segment : getCompactableSegments(manager)) {
      // If this is the first segment in a segments list, add the segment.
      if (segments == null) {
        segments = new ArrayList<>();
        segments.add(segment);
      }
      // If the total size of all segments is less than the maximum size of any segment, add the segment to the segments list.
      else if (segments.stream().mapToLong(Segment::size).sum() + segment.size() <= storage.maxSegmentSize()
        && segments.stream().mapToLong(Segment::count).sum() + segment.count() <= storage.maxEntriesPerSegment()) {
        segments.add(segment);
      }
      // If there's not enough room to combine segments, reset the segments list.
      else {
        compact.add(segments);
        segments = new ArrayList<>();
        segments.add(segment);
      }
    }

    // Ensure all compactable segments have been added to the compact segments list.
    if (segments != null) {
      compact.add(segments);
    }
    return compact;
  }
794139
public void compact() {
        final int idealCapacity = (int) Math.round(size() * (1.0d / loadFactor));
        rehash(QuickMath.nextPowerOfTwo(idealCapacity));
    }
724137
public void allocateSegments(int numberOfSegments) {
		while (getBlockCount() < numberOfSegments) {
			MemorySegment next = this.availableMemory.nextSegment();
			if (next != null) {
				this.partitionPages.add(next);
			} else {
				return;
			}
		}
	}
591565
def compact(paths):
    """"""

    sep = os.path.sep
    short_paths = set()
    for path in sorted(paths, key=len):
        should_skip = any(
            path.startswith(shortpath.rstrip("*")) and
            path[len(shortpath.rstrip("*").rstrip(sep))] == sep
            for shortpath in short_paths
        )
        if not should_skip:
            short_paths.add(path)
    return short_paths
1152273
def partition(partition):
    """"""
    nodes = set()
    for part in partition:
        for node in part:
            if node in nodes:
                raise ValueError(
                    'Micro-element {} may not be partitioned into multiple '
                    'macro-elements'.format(node))
            nodes.add(node)