Refine search
/** * Constructor for the class. * * @param initialCapacity Initial capacity for the priority queue * @param minHeap Min order, ie smallest element on top. */ public IntObjectIndexedPriorityQueue(int initialCapacity, boolean minHeap) { super(initialCapacity, minHeap); _values = new ObjectArrayList<>(initialCapacity); _reusablePair = new IntObjectPair<>(0, null); }
public void addPage(Page page) { // ignore empty pages if (page.getPositionCount() == 0) { return; } positionCount += page.getPositionCount(); int pageIndex = (channels.length > 0) ? channels[0].size() : 0; for (int i = 0; i < channels.length; i++) { Block block = page.getBlock(i); if (eagerCompact) { block = block.copyRegion(0, block.getPositionCount()); } channels[i].add(block); pagesMemorySize += block.getRetainedSizeInBytes(); } for (int position = 0; position < page.getPositionCount(); position++) { long sliceAddress = encodeSyntheticAddress(pageIndex, position); valueAddresses.add(sliceAddress); } estimatedSize = calculateEstimatedSize(); }
public void appendTo(int channel, int position, BlockBuilder output) { long pageAddress = valueAddresses.getLong(position); Type type = types.get(channel); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); type.appendTo(block, blockPosition, output); }
public void compact() { if (eagerCompact) { return; } for (int channel = 0; channel < types.size(); channel++) { ObjectArrayList<Block> blocks = channels[channel]; for (int i = nextBlockToCompact; i < blocks.size(); i++) { Block block = blocks.get(i); // Copy the block to compact its size Block compactedBlock = block.copyRegion(0, block.getPositionCount()); blocks.set(i, compactedBlock); pagesMemorySize -= block.getRetainedSizeInBytes(); pagesMemorySize += compactedBlock.getRetainedSizeInBytes(); } } nextBlockToCompact = channels[0].size(); estimatedSize = calculateEstimatedSize(); }
@Override public String[] performanceMetrics() { ObjectArrayList<String> metrics = new ObjectArrayList<>(); metrics.add("validationScore"); metrics.addAll(helper.getMetricNames()); return metrics.toArray(new String[metrics.size()]); }
@Override public Collection<Integer> getIncidentVertices(final Long e) { final int x = (int)(e.longValue() >>> 32); final int y = e.intValue(); if (x == y) return ObjectLists.singleton(Integer.valueOf(x)); final ObjectArrayList<Integer> res = new ObjectArrayList<>(); res.add(Integer.valueOf(x)); res.add(Integer.valueOf(y)); return res; }
private PagesIndex( OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FunctionRegistry functionRegistry, boolean groupByUsesEqualTo, List<Type> types, int expectedPositions, boolean eagerCompact) { this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null"); this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null"); this.functionRegistry = requireNonNull(functionRegistry, "functionRegistry is null"); this.groupByUsesEqualTo = groupByUsesEqualTo; this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.valueAddresses = new LongArrayList(expectedPositions); this.eagerCompact = eagerCompact; //noinspection rawtypes channels = (ObjectArrayList<Block>[]) new ObjectArrayList[types.size()]; for (int i = 0; i < channels.length; i++) { channels[i] = ObjectArrayList.wrap(new Block[1024], 0); } estimatedSize = calculateEstimatedSize(); }
ObjectArrayList<int[]> list = new ObjectArrayList<>(); list.add(new int[] { Integer.parseInt(p[0]),Integer.parseInt(p[1]), Integer.parseInt(p[2]) }); final ArcLabelledImmutableGraph g = new IntegerTriplesArcLabelledImmutableGraph(list.toArray(new int[0][])); BVGraph.store(g, basename + ArcLabelledImmutableGraph.UNDERLYINGGRAPH_SUFFIX); BitStreamArcLabelledImmutableGraph.store(g, basename, basename + ArcLabelledImmutableGraph.UNDERLYINGGRAPH_SUFFIX);
public boolean getBoolean(int channel, int position) { long pageAddress = valueAddresses.getLong(position); Block block = channels[channel].get(decodeSliceIndex(pageAddress)); int blockPosition = decodePosition(pageAddress); return types.get(channel).getBoolean(block, blockPosition); }
/** * Puts the element into the priority queue. * <ul> * <li> If key does not exist, it is added to the priority queue. </li> * <li> If key exists, then the value is updated, and the priority queue ordering is maintained. </li> * <li> Runtime complexity of {@code O(log(n)}). </li> * </ul> * @param key Integer key for the value * @param value Value of the key */ @SuppressWarnings("unchecked") public void put(int key, T value) { if (!_keyToIndexMap.containsKey(key)) { _values.add(value); int last = _values.size() - 1; updateKeyIndexMap(key, last); siftUp(last); } else { int index = _keyToIndexMap.get(key); _values.set(index, value); // Sift the value up or down, as the case may be. if (!siftDown(index)) { siftUp(index); } } }
@Override protected String[] createOutputHeader() { initializeStats(""); ObjectArrayList<String> values = new ObjectArrayList<>(); values.addAll(it.unimi.dsi.fastutil.objects.ObjectArrayList.wrap(orderStats)); values.add("AUC"); values.add("[AUC95"); values.add("AUC95]"); return values.toArray(new String[0]); }
@Override protected Class<?>[] getSignatureTypes(final Method method) { Class<?>[] signatureTypes = super.getSignatureTypes(method); if (this.needsInstance(method)) { final ObjectArrayList<Class<?>> paramList = ObjectArrayList.wrap(signatureTypes); paramList.ensureCapacity(paramList.size() + 1); paramList.add(0, method.getDeclaringClass()); signatureTypes = paramList.elements(); } return signatureTypes; }