public static double verifyAccuracy(double accuracy) { checkCondition(accuracy > 0 && accuracy < 1, INVALID_FUNCTION_ARGUMENT, "Percentile accuracy must be exclusively between 0 and 1, was %s", accuracy); return accuracy; }
/** * Returns a MethodHandle corresponding to the specified constructor. * <p> * Warning: The way Oracle JVM implements producing MethodHandle for a constructor involves * creating JNI global weak references. G1 processes such references serially. As a result, * calling this method in a tight loop can create significant GC pressure and significantly * increase application pause time. */ public static MethodHandle constructorMethodHandle(Class<?> clazz, Class<?>... parameterTypes) { return constructorMethodHandle(GENERIC_INTERNAL_ERROR, clazz, parameterTypes); }
@SuppressWarnings("unchecked") private static <T> Mergeable<T> mergeInfo(Mergeable<T> base, T other) { return (Mergeable<T>) base.mergeWith(other); }
/** * Returns a MethodHandle corresponding to the specified method. * <p> * Warning: The way Oracle JVM implements producing MethodHandle for a method involves creating * JNI global weak references. G1 processes such references serially. As a result, calling this * method in a tight loop can create significant GC pressure and significantly increase * application pause time. */ public static MethodHandle methodHandle(Method method) { return methodHandle(GENERIC_INTERNAL_ERROR, method); }
private T findInternal(T element) { Entry<T> value = map.get(element); if (value.getParent() == null) { return element; } else { T root = findInternal(value.getParent()); value.setParent(root); return root; } }
public T find(T element) { if (!map.containsKey(element)) { map.put(element, new Entry<>()); return element; } return findInternal(element); }
@PowerOfTwo public static Integer getConstrainedByPowerOfTwo() { return null; } }
@Override public RecordCursor cursor() { return new InMemoryRecordCursor(types, record); }
private static double simulate(int numberOfValues, int hashSize) { int collisions = 0; for (int i = 0; i < NUMBER_OF_PROBES; ++i) { collisions += simulationIteration(numberOfValues, hashSize); } return (double) collisions / NUMBER_OF_PROBES; }
public static AutoCloseableCloser create() { return new AutoCloseableCloser(); }
private static void checkMaxSize(long bytes, long count) { checkCondition( bytes <= (MAX_SIZE_IN_BYTES + count) / count, INVALID_FUNCTION_ARGUMENT, "result of repeat function must not take more than 1000000 bytes"); } }
@PowerOfTwo public int getConstrainedByPowerOfTwoUnboxed() { return value; }
public static double simulate(int numberOfValues, int hashSize, int iterations) { int collisions = 0; for (int i = 0; i < iterations; ++i) { collisions += simulationIteration(numberOfValues, hashSize); } return (double) collisions / iterations; }
private static void checkRadix(long radix) { checkCondition(radix >= MIN_RADIX && radix <= MAX_RADIX, INVALID_FUNCTION_ARGUMENT, "Radix must be between %d and %d", MIN_RADIX, MAX_RADIX); }
@PowerOfTwo public Integer getConstrainedByPowerOfTwoBoxed() { return value; } }
private static void checkValidStep(long start, long stop, long step) { checkCondition( step != 0, INVALID_FUNCTION_ARGUMENT, "step must not be zero"); checkCondition( step > 0 ? stop >= start : stop <= start, INVALID_FUNCTION_ARGUMENT, "sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start"); }
private static void checkMaxEntry(int length) { checkCondition( length <= MAX_RESULT_ENTRIES, INVALID_FUNCTION_ARGUMENT, "result of sequence function must not have more than 10000 entries"); } }
private static void checkWeight(long weight) { checkCondition(weight > 0, INVALID_FUNCTION_ARGUMENT, "percentile weight must be > 0"); } }
public static long verifyWeight(long weight) { checkCondition(weight > 0, INVALID_FUNCTION_ARGUMENT, "Percentile weight must be > 0, was %s", weight); return weight; } }