private void addToPendingNanos(final long amount) { long currentValue; long newValue; do { currentValue = pendingNanos.get(); newValue = MathUtil.clampAdd(currentValue, amount); } while (!pendingNanos.compareAndSet(currentValue, newValue)); }
public static long gcd(List<Long> numbers) { if (numbers == null) { throw new IllegalArgumentException("Null list provided"); } if (numbers.size() == 0) { throw new IllegalArgumentException("List of size 0 provided"); } long result = numbers.get(0); for (int i = 1; i < numbers.size(); i++) { result = gcd(result, numbers.get(i)); } return result; }
public static long gcd(List<Long> numbers) { if (numbers == null) { throw new IllegalArgumentException("Null list provided"); } if (numbers.size() == 0) { throw new IllegalArgumentException("List of size 0 provided"); } long result = numbers.get(0); for (int i = 1; i < numbers.size(); i++) { result = gcd(result, numbers.get(i)); } return result; }
private void addToPendingNanos(final long amount) { long currentValue; long newValue; do { currentValue = pendingNanos.get(); newValue = MathUtil.clampAdd(currentValue, amount); } while (!pendingNanos.compareAndSet(currentValue, newValue)); }
public static long gcd(List<Long> numbers) { if (numbers == null) { throw new IllegalArgumentException("Null list provided"); } if (numbers.size() == 0) { throw new IllegalArgumentException("List of size 0 provided"); } long result = numbers.get(0); for (int i = 1; i < numbers.size(); i++) { result = gcd(result, numbers.get(i)); } return result; }
private void addToPendingNanos(final long amount) { long currentValue; long newValue; do { currentValue = pendingNanos.get(); newValue = MathUtil.clampAdd(currentValue, amount); } while (!pendingNanos.compareAndSet(currentValue, newValue)); }
public static long gcd(List<Long> numbers) { if (numbers == null) { throw new IllegalArgumentException("Null list provided"); } if (numbers.size() == 0) { throw new IllegalArgumentException("List of size 0 provided"); } long result = numbers.get(0); for (int i = 1; i < numbers.size(); i++) { result = gcd(result, numbers.get(i)); } return result; }
private void addToPendingNanos(final long amount) { long currentValue; long newValue; do { currentValue = pendingNanos.get(); newValue = MathUtil.clampAdd(currentValue, amount); } while (!pendingNanos.compareAndSet(currentValue, newValue)); }
public static long gcd(List<Long> numbers) { if (numbers == null) { throw new IllegalArgumentException("Null list provided"); } if (numbers.size() == 0) { throw new IllegalArgumentException("List of size 0 provided"); } long result = numbers.get(0); for (int i = 1; i < numbers.size(); i++) { result = gcd(result, numbers.get(i)); } return result; }
private void addToPendingNanos(final long amount) { long currentValue; long newValue; do { currentValue = pendingNanos.get(); newValue = MathUtil.clampAdd(currentValue, amount); } while (!pendingNanos.compareAndSet(currentValue, newValue)); }
/** * Computes the triggering interval to use during the execution of this {@link JobNode} */ private long computeTriggerInterval(Collection<OperatorSpec> reachableOperators) { List<Long> windowTimerIntervals = reachableOperators.stream() .filter(spec -> spec.getOpCode() == OperatorSpec.OpCode.WINDOW) .map(spec -> ((WindowOperatorSpec) spec).getDefaultTriggerMs()) .collect(Collectors.toList()); // Filter out the join operators, and obtain a list of their ttl values List<Long> joinTtlIntervals = reachableOperators.stream() .filter(spec -> spec instanceof JoinOperatorSpec) .map(spec -> ((JoinOperatorSpec) spec).getTtlMs()) .collect(Collectors.toList()); // Combine both the above lists List<Long> candidateTimerIntervals = new ArrayList<>(joinTtlIntervals); candidateTimerIntervals.addAll(windowTimerIntervals); if (candidateTimerIntervals.isEmpty()) { return -1; } // Compute the gcd of the resultant list return MathUtil.gcd(candidateTimerIntervals); }
/** * Sleeps for a period of time that approximates the requested number of nanoseconds. Actual sleep * time can vary significantly based on the JVM implementation and platform. This function returns * the measured error between expected and actual sleep time. * * @param nanos the number of nanoseconds to sleep. * @throws InterruptedException if the current thread is interrupted while blocked in this method. */ long sleep(long nanos) throws InterruptedException { if (nanos <= 0) { return nanos; } final long start = System.nanoTime(); TimeUnit.NANOSECONDS.sleep(nanos); return MathUtil.clampAdd(nanos, -(System.nanoTime() - start)); } }
/** * Computes the triggering interval to use during the execution of this {@link JobNode} */ private long computeTriggerInterval(Collection<OperatorSpec> reachableOperators) { List<Long> windowTimerIntervals = reachableOperators.stream() .filter(spec -> spec.getOpCode() == OperatorSpec.OpCode.WINDOW) .map(spec -> ((WindowOperatorSpec) spec).getDefaultTriggerMs()) .collect(Collectors.toList()); // Filter out the join operators, and obtain a list of their ttl values List<Long> joinTtlIntervals = reachableOperators.stream() .filter(spec -> spec instanceof JoinOperatorSpec) .map(spec -> ((JoinOperatorSpec) spec).getTtlMs()) .collect(Collectors.toList()); // Combine both the above lists List<Long> candidateTimerIntervals = new ArrayList<>(joinTtlIntervals); candidateTimerIntervals.addAll(windowTimerIntervals); if (candidateTimerIntervals.isEmpty()) { return -1; } // Compute the gcd of the resultant list return MathUtil.gcd(candidateTimerIntervals); }
/** * Sleeps for a period of time that approximates the requested number of nanoseconds. Actual sleep * time can vary significantly based on the JVM implementation and platform. This function returns * the measured error between expected and actual sleep time. * * @param nanos the number of nanoseconds to sleep. * @throws InterruptedException if the current thread is interrupted while blocked in this method. */ long sleep(long nanos) throws InterruptedException { if (nanos <= 0) { return nanos; } final long start = System.nanoTime(); TimeUnit.NANOSECONDS.sleep(nanos); return MathUtil.clampAdd(nanos, -(System.nanoTime() - start)); } }
/** * Computes the triggering interval to use during the execution of this {@link JobNode} */ private long computeTriggerInterval(Collection<OperatorSpec> reachableOperators) { List<Long> windowTimerIntervals = reachableOperators.stream() .filter(spec -> spec.getOpCode() == OperatorSpec.OpCode.WINDOW) .map(spec -> ((WindowOperatorSpec) spec).getDefaultTriggerMs()) .collect(Collectors.toList()); // Filter out the join operators, and obtain a list of their ttl values List<Long> joinTtlIntervals = reachableOperators.stream() .filter(spec -> spec instanceof JoinOperatorSpec) .map(spec -> ((JoinOperatorSpec) spec).getTtlMs()) .collect(Collectors.toList()); // Combine both the above lists List<Long> candidateTimerIntervals = new ArrayList<>(joinTtlIntervals); candidateTimerIntervals.addAll(windowTimerIntervals); if (candidateTimerIntervals.isEmpty()) { return -1; } // Compute the gcd of the resultant list return MathUtil.gcd(candidateTimerIntervals); }
/** * Sleeps for a period of time that approximates the requested number of nanoseconds. Actual sleep * time can vary significantly based on the JVM implementation and platform. This function returns * the measured error between expected and actual sleep time. * * @param nanos the number of nanoseconds to sleep. * @throws InterruptedException if the current thread is interrupted while blocked in this method. */ long sleep(long nanos) throws InterruptedException { if (nanos <= 0) { return nanos; } final long start = System.nanoTime(); TimeUnit.NANOSECONDS.sleep(nanos); return MathUtil.clampAdd(nanos, -(System.nanoTime() - start)); } }
/** * Computes the triggering interval to use during the execution of this {@link JobNode} */ private long computeTriggerInterval(Collection<OperatorSpec> reachableOperators) { List<Long> windowTimerIntervals = reachableOperators.stream() .filter(spec -> spec.getOpCode() == OperatorSpec.OpCode.WINDOW) .map(spec -> ((WindowOperatorSpec) spec).getDefaultTriggerMs()) .collect(Collectors.toList()); // Filter out the join operators, and obtain a list of their ttl values List<Long> joinTtlIntervals = reachableOperators.stream() .filter(spec -> spec instanceof JoinOperatorSpec) .map(spec -> ((JoinOperatorSpec) spec).getTtlMs()) .collect(Collectors.toList()); // Combine both the above lists List<Long> candidateTimerIntervals = new ArrayList<>(joinTtlIntervals); candidateTimerIntervals.addAll(windowTimerIntervals); if (candidateTimerIntervals.isEmpty()) { return -1; } // Compute the gcd of the resultant list return MathUtil.gcd(candidateTimerIntervals); }
/** * Sleeps for a period of time that approximates the requested number of nanoseconds. Actual sleep * time can vary significantly based on the JVM implementation and platform. This function returns * the measured error between expected and actual sleep time. * * @param nanos the number of nanoseconds to sleep. * @throws InterruptedException if the current thread is interrupted while blocked in this method. */ long sleep(long nanos) throws InterruptedException { if (nanos <= 0) { return nanos; } final long start = System.nanoTime(); TimeUnit.NANOSECONDS.sleep(nanos); return MathUtil.clampAdd(nanos, -(System.nanoTime() - start)); } }
/** * Computes the triggering interval to use during the execution of this {@link JobNode} */ private long computeTriggerInterval(Collection<OperatorSpec> reachableOperators) { List<Long> windowTimerIntervals = reachableOperators.stream() .filter(spec -> spec.getOpCode() == OperatorSpec.OpCode.WINDOW) .map(spec -> ((WindowOperatorSpec) spec).getDefaultTriggerMs()) .collect(Collectors.toList()); // Filter out the join operators, and obtain a list of their ttl values List<Long> joinTtlIntervals = reachableOperators.stream() .filter(spec -> spec instanceof JoinOperatorSpec) .map(spec -> ((JoinOperatorSpec) spec).getTtlMs()) .collect(Collectors.toList()); // Combine both the above lists List<Long> candidateTimerIntervals = new ArrayList<>(joinTtlIntervals); candidateTimerIntervals.addAll(windowTimerIntervals); if (candidateTimerIntervals.isEmpty()) { return -1; } // Compute the gcd of the resultant list return MathUtil.gcd(candidateTimerIntervals); }
/** * Sleeps for a period of time that approximates the requested number of nanoseconds. Actual sleep * time can vary significantly based on the JVM implementation and platform. This function returns * the measured error between expected and actual sleep time. * * @param nanos the number of nanoseconds to sleep. * @throws InterruptedException if the current thread is interrupted while blocked in this method. */ long sleep(long nanos) throws InterruptedException { if (nanos <= 0) { return nanos; } final long start = System.nanoTime(); TimeUnit.NANOSECONDS.sleep(nanos); return MathUtil.clampAdd(nanos, -(System.nanoTime() - start)); } }