private void checkNextLabelId( long[] labels ) { if ( labels.length > 0 && labels[0] != -1 ) { lowestLabelId = min( lowestLabelId, labels[0] ); } }
private long fractionOf( long length ) { if ( length < MAGIC_CHUNK_COUNT ) { return length; } return min( length / MAGIC_CHUNK_COUNT, MAX_ARRAY_SIZE ); }
public static long calculateMaxMemoryUsage( long numberOfDenseNodes, long numberOfRelationships ) { long maxDenseNodesForThisType = min( numberOfDenseNodes, numberOfRelationships * 2/*nodes/rel*/ ); return maxDenseNodesForThisType * NodeRelationshipCache.GROUP_ENTRY_SIZE; }
@Override public synchronized boolean next( InputChunk chunk ) { if ( id >= highId ) { return false; } long startId = id; id = min( highId, startId + batchSize ); ((StoreScanChunk)chunk).initialize( startId, id ); return true; } }
@Override public LongIterator nextBatch() { if ( startId >= highExcluded ) { return null; } long endId = min( highExcluded, findRoofId( startId ) ); final LongIterator result = range( startId, endId - 1 /*excluded*/ ); startId = endId; return result; }
@Override public Iterator<NodeLabelRange> iterator() { try { long lowestRange = Long.MAX_VALUE; closeCursors(); for ( int labelId = 0; labelId <= highestLabelId; labelId++ ) { RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException> cursor = seekProvider.apply( labelId ); // Bootstrap the cursor, which also provides a great opportunity to exclude if empty if ( cursor.next() ) { lowestRange = min( lowestRange, cursor.get().key().idRange ); cursors.add( cursor ); } } return new NodeLabelRangeIterator( lowestRange ); } catch ( IOException e ) { throw new RuntimeException( e ); } }
@Override public long getSystemFreeMemoryMb() throws IOException { long rootCgroupLimitFree = Long.MAX_VALUE; try { MemoryCore memRoot = (MemoryCore) rootCgroup.getCores().get(SubSystemType.memory); if (memRoot != null) { //For cgroups no limit is max long. long limit = memRoot.getPhysicalUsageLimit(); long used = memRoot.getMaxPhysicalUsage(); rootCgroupLimitFree = (limit - used) / 1024 / 1024; } } catch (FileNotFoundException e) { //Ignored if cgroups is not setup don't do anything with it } return Long.min(rootCgroupLimitFree, getMemInfoFreeMb()); } }
/** * A side-effect-free function that can calculate next {@link State} from current. * It determines time duration that you should wait for permission and reserves it for you, * if you'll be able to wait long enough. * * @param timeoutInNanos max time that caller can wait for permission in nanoseconds * @param activeState current state of {@link AtomicRateLimiter} * @return next {@link State} */ private State calculateNextState(final long timeoutInNanos, final State activeState) { long cyclePeriodInNanos = activeState.config.getLimitRefreshPeriodInNanos(); int permissionsPerCycle = activeState.config.getLimitForPeriod(); long currentNanos = currentNanoTime(); long currentCycle = currentNanos / cyclePeriodInNanos; long nextCycle = activeState.activeCycle; int nextPermissions = activeState.activePermissions; if (nextCycle != currentCycle) { long elapsedCycles = currentCycle - nextCycle; long accumulatedPermissions = elapsedCycles * permissionsPerCycle; nextCycle = currentCycle; nextPermissions = (int) min(nextPermissions + accumulatedPermissions, permissionsPerCycle); } long nextNanosToWait = nanosToWaitForPermission( cyclePeriodInNanos, permissionsPerCycle, nextPermissions, currentNanos, currentCycle ); State nextState = reservePermissions(activeState.config, timeoutInNanos, nextCycle, nextPermissions, nextNanosToWait); return nextState; }
public static long calculateMaxMemoryUsage( long numberOfDenseNodes, long numberOfRelationships ) { long maxDenseNodesForThisType = min( numberOfDenseNodes, numberOfRelationships * 2/*nodes/rel*/ ); return maxDenseNodesForThisType * NodeRelationshipCache.GROUP_ENTRY_SIZE; }
private void checkNextLabelId( long[] labels ) { if ( labels.length > 0 && labels[0] != -1 ) { lowestLabelId = min( lowestLabelId, labels[0] ); } }
private long fractionOf( long length ) { if ( length < MAGIC_CHUNK_COUNT ) { return length; } return min( length / MAGIC_CHUNK_COUNT, MAX_ARRAY_SIZE ); }
public Range uniteWith(Range r) { r.start = Long.min(this.start, r.start); r.end = Long.max(this.end, r.end); return r; }
@Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { long count = executeLargeUpdate(sql, columnIndexes); return (int) min(count, Integer.MAX_VALUE); }
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { long count = executeLargeUpdate(sql, autoGeneratedKeys); return (int) min(count, Integer.MAX_VALUE); }
@Override public long applyAsLong(long operand) { return Long.min(max,Long.max(min,operand)); } }
@Override public long applyAsLong(long operand) { return Long.min(max,Long.max(min,operand)); } }
protected int getLimit() { int ret = (int) getMinMaxPageSize(); if (ret == 0) { ret = (int) Long.min(getMaxResultWindow(), Integer.MAX_VALUE); } return ret; }
public IterativeNodeWorkList(Graph graph, boolean fill, int iterationLimitPerNode) { super(graph, fill); debug = graph.getDebug(); assert iterationLimitPerNode > 0; long limit = (long) iterationLimitPerNode * graph.getNodeCount(); iterationLimit = (int) Long.min(Integer.MAX_VALUE, limit); }