@Override public Histogram histogram(String name) { return (Histogram) CollectionUtils.computeIfAbsent(metrics, name, this::createHistogram); }
/************************ first/last **************************/ public static <T> T getFirst(Collection<T> collection) { if (CollectionUtils.isEmpty(collection)) { return null; } for (T t : collection) { return t; } return null; }
public static <A, B> boolean nullSafeSameSize(Collection<A> a, Collection<B> b) { return nullSafeSize(a) == nullSafeSize(b); }
AdminService.Interface getAdminStub(ServerName serverName) throws IOException { return CollectionUtils.computeIfAbsentEx(adminSubs, getStubKey(AdminService.Interface.class.getSimpleName(), serverName, hostnameCanChange), () -> createAdminServerStub(serverName)); }
@Override public void addToSortedRanges() { sortedRanges.addAll(CollectionUtils.nullSafe(uniqueIndexByUniqueRange.keySet())); }
public boolean isNub() { return CollectionUtils.notEmpty(children) && hasOccurrences(); }
/** * @param list * @param index the index in question * @return true if it is the last index or if list is empty and -1 is passed for the index param */ public static boolean isLastIndex(List<?> list, int index){ return index == getLastIndex(list); }
public void incrementNumOccurrencesOfLatestValue(){ CollectionUtils.getLast(nodes).incrementNumOccurrences(1); }
public LongEncoder compile() { int numUnique = uniqueValues.size(); if (numUnique == 1) { min = CollectionUtils.getFirst(uniqueValues); sortedUniqueValues = new long[] { min }; return this; } sortedUniqueValues = new long[numUnique]; int lastIndex = -1; for (long value : uniqueValues) { sortedUniqueValues[++lastIndex] = value; } Arrays.sort(sortedUniqueValues); min = ArrayUtils.getFirst(sortedUniqueValues); max = ArrayUtils.getLast(sortedUniqueValues); maxDelta = max - min; if (maxDelta > 0) { bytesPerDelta = UFIntTool.numBytes(maxDelta); } else { bytesPerDelta = 0; } int maxIndex = numUnique - 1; bytesPerIndex = UFIntTool.numBytes(maxIndex); totalCompressedBytes = numUnique * bytesPerDelta; return this; }
/************************ first/last **************************/ public static <T> T getFirst(Collection<T> collection) { if (CollectionUtils.isEmpty(collection)) { return null; } for (T t : collection) { return t; } return null; }
public static <A, B> boolean nullSafeSameSize(Collection<A> a, Collection<B> b) { return nullSafeSize(a) == nullSafeSize(b); }
ClientService.Interface getRegionServerStub(ServerName serverName) throws IOException { return CollectionUtils.computeIfAbsentEx(rsStubs, getStubKey(ClientService.Interface.class.getSimpleName(), serverName, hostnameCanChange), () -> createRegionServerStub(serverName)); }
@Override public void addToSortedRanges() { sortedRanges.addAll(CollectionUtils.nullSafe(uniqueIndexByUniqueRange.keySet())); Collections.sort(sortedRanges); }
public boolean isNub() { return CollectionUtils.notEmpty(children) && hasOccurrences(); }