private List<Instruction> sortInstructions(Collection<Instruction> instructions, BasicBlock block) { ObjectIntMap<Instruction> indexes = new ObjectIntHashMap<>(); int index = 0; for (Instruction instruction : block) { indexes.put(instruction, index++); } List<Instruction> sortedInstructions = new ArrayList<>(instructions); sortedInstructions.sort(Comparator.comparing(insn -> indexes.getOrDefault(insn, -1))); return sortedInstructions; }
private ObjectIntMap<Instruction> getInstructionIndexes(BasicBlock block) { ObjectIntMap<Instruction> indexes = new ObjectIntHashMap<>(); for (Instruction instruction : block) { indexes.put(instruction, indexes.size()); } return indexes; }
private ObjectIntMap<String> generatePackageMetadata(List<ClassNode> classes, Set<String> classesRequiringName) throws IOException { PackageNode root = new PackageNode(null); for (ClassNode classNode : classes) { String className = classNode.getName(); if (!classesRequiringName.contains(className)) { continue; } int dotIndex = className.lastIndexOf('.'); if (dotIndex < 0) { continue; } addPackageName(root, className.substring(0, dotIndex)); } ObjectIntMap<String> indexes = new ObjectIntHashMap<>(); writePackageStructure(root, -1, "", indexes); writer.softNewLine(); return indexes; }
private void printStats(Renderer renderer, int totalSize) { if (!Boolean.parseBoolean(System.getProperty("teavm.js.stats", "false"))) { return; } System.out.println("Total output size: " + STATS_NUM_FORMAT.format(totalSize)); System.out.println("Metadata size: " + getSizeWithPercentage(renderer.getMetadataSize(), totalSize)); System.out.println("String pool size: " + getSizeWithPercentage(renderer.getStringPoolSize(), totalSize)); ObjectIntMap<String> packageSizeMap = new ObjectIntHashMap<>(); for (String className : renderer.getClassesInStats()) { String packageName = className.substring(0, className.lastIndexOf('.') + 1); int classSize = renderer.getClassSize(className); packageSizeMap.put(packageName, packageSizeMap.getOrDefault(packageName, 0) + classSize); } String[] packageNames = packageSizeMap.keys().toArray(String.class); Arrays.sort(packageNames, Comparator.comparing(p -> -packageSizeMap.getOrDefault(p, 0))); for (String packageName : packageNames) { System.out.println("Package '" + packageName + "' size: " + getSizeWithPercentage(packageSizeMap.get(packageName), totalSize)); } }
CombinedDeletionPolicy(Logger logger, TranslogDeletionPolicy translogDeletionPolicy, SoftDeletesPolicy softDeletesPolicy, LongSupplier globalCheckpointSupplier) { this.logger = logger; this.translogDeletionPolicy = translogDeletionPolicy; this.softDeletesPolicy = softDeletesPolicy; this.globalCheckpointSupplier = globalCheckpointSupplier; this.snapshottedCommits = new ObjectIntHashMap<>(); }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static <KType> ObjectIntHashMap<KType> from(KType[] keys, int[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } ObjectIntHashMap<KType> map = new ObjectIntHashMap<>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) { ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName); if (nodesPerAttributesCounts != null) { return nodesPerAttributesCounts; } nodesPerAttributesCounts = new ObjectIntHashMap<>(); for (RoutingNode routingNode : this) { String attrValue = routingNode.node().getAttributes().get(attributeName); nodesPerAttributesCounts.addTo(attrValue, 1); } nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts); return nodesPerAttributesCounts; }
CombinedDeletionPolicy(Logger logger, TranslogDeletionPolicy translogDeletionPolicy, SoftDeletesPolicy softDeletesPolicy, LongSupplier globalCheckpointSupplier) { this.logger = logger; this.translogDeletionPolicy = translogDeletionPolicy; this.softDeletesPolicy = softDeletesPolicy; this.globalCheckpointSupplier = globalCheckpointSupplier; this.snapshottedCommits = new ObjectIntHashMap<>(); }
JvmStats() { versions = new ObjectIntHashMap<>(); threads = 0; maxUptime = 0; heapMax = 0; heapUsed = 0; }
CombinedDeletionPolicy(Logger logger, TranslogDeletionPolicy translogDeletionPolicy, LongSupplier globalCheckpointSupplier) { this.logger = logger; this.translogDeletionPolicy = translogDeletionPolicy; this.globalCheckpointSupplier = globalCheckpointSupplier; this.snapshottedCommits = new ObjectIntHashMap<>(); }
this.versions = new ObjectIntHashMap<>(); long threads = 0; long maxUptime = 0;
this.names = new ObjectIntHashMap<>(); this.prettyNames = new ObjectIntHashMap<>(); int availableProcessors = 0; int allocatedProcessors = 0;
ObjectIntHashMap<String> shardPerAttribute = new ObjectIntHashMap<>(); for (ShardRouting assignedShard : allocation.routingNodes().assignedShards(shardRouting.shardId())) { if (assignedShard.started() || assignedShard.initializing()) {
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { List<ObjectIntPair<T>> list = (List<ObjectIntPair<T>>)in.readObject(); g_map = new com.carrotsearch.hppc.ObjectIntHashMap<T>(list.size()); put(list); }
@Override public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) { super.setup(keys, fillFactor, oneFailureOutOf); m_map = new ObjectIntHashMap<>( keys.length, fillFactor ); for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key+1 : key), key ); }
public ObjectIntHashMap<String> nodesPerAttributesCounts(String attributeName) { ObjectIntHashMap<String> nodesPerAttributesCounts = nodesPerAttributeNames.get(attributeName); if (nodesPerAttributesCounts != null) { return nodesPerAttributesCounts; } nodesPerAttributesCounts = new ObjectIntHashMap<>(); for (RoutingNode routingNode : this) { String attrValue = routingNode.node().getAttributes().get(attributeName); nodesPerAttributesCounts.addTo(attrValue, 1); } nodesPerAttributeNames.put(attributeName, nodesPerAttributesCounts); return nodesPerAttributesCounts; }
@Override public int test() { final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length, m_fillFactor ); for ( int i = 0; i < m_keys.length; ++i ) m_map.put( m_keys[ i ], i ); for ( int i = 0; i < m_keys2.length; ++i ) m_map.put( m_keys2[ i ], i ); return m_map.size(); } }
@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void check() { int color = DEFAULT_COLOR; ObjectIntMap<AbstractStage> colors = new ObjectIntHashMap<AbstractStage>(); ThreadPainter threadPainter = new ThreadPainter(); Traverser traverser = new Traverser(threadPainter); for (AbstractStage threadableStage : threadableStages) { color++; colors.put(threadableStage, color); threadPainter.reset(colors, color, threadableStages); traverser.traverse(threadableStage); } }
@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void check() { int color = DEFAULT_COLOR; ObjectIntMap<AbstractStage> colors = new ObjectIntHashMap<AbstractStage>(); ThreadPainter threadPainter = new ThreadPainter(); Traverser traverser = new Traverser(threadPainter); for (AbstractStage threadableStage : threadableStages) { color++; colors.put(threadableStage, color); threadPainter.reset(colors, color, threadableStages); traverser.traverse(threadableStage); } }
@Override public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); versions = new ObjectIntHashMap<>(size); for (; size > 0; size--) { versions.addTo(JvmVersion.readJvmVersion(in), in.readVInt()); } threads = in.readVLong(); maxUptime = in.readVLong(); heapUsed = in.readVLong(); heapMax = in.readVLong(); }