public static int totalLengthWithMvccVersion(final Iterable<? extends KeyValue> kvs, final boolean includeMvccVersion) { int length = 0; for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { length += lengthWithMvccVersion(kv, includeMvccVersion); } return length; }
public static ByteBuffer toByteBufferAndRewind(final Iterable<? extends KeyValue> kvs, boolean includeMemstoreTS) { int totalBytes = KeyValueUtil.totalLengthWithMvccVersion(kvs, includeMemstoreTS); ByteBuffer bb = ByteBuffer.allocate(totalBytes); for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { KeyValueUtil.appendToByteBuffer(bb, kv, includeMemstoreTS); } bb.rewind(); return bb; }
for (HStoreFile file : IterableUtils.emptyIfNull(compactedFiles)) { name2File.put(file.getFileInfo().getActiveFileName(), file);
public static int totalLengthWithMvccVersion(final Iterable<? extends KeyValue> kvs, final boolean includeMvccVersion) { int length = 0; for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { length += lengthWithMvccVersion(kv, includeMvccVersion); } return length; }
public static int totalLengthWithMvccVersion(final Iterable<? extends KeyValue> kvs, final boolean includeMvccVersion) { int length = 0; for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { length += lengthWithMvccVersion(kv, includeMvccVersion); } return length; }
public static ByteBuffer toByteBufferAndRewind(final Iterable<? extends KeyValue> kvs, boolean includeMemstoreTS) { int totalBytes = KeyValueUtil.totalLengthWithMvccVersion(kvs, includeMemstoreTS); ByteBuffer bb = ByteBuffer.allocate(totalBytes); for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { KeyValueUtil.appendToByteBuffer(bb, kv, includeMemstoreTS); } bb.rewind(); return bb; }
public static ByteBuffer toByteBufferAndRewind(final Iterable<? extends KeyValue> kvs, boolean includeMemstoreTS) { int totalBytes = KeyValueUtil.totalLengthWithMvccVersion(kvs, includeMemstoreTS); ByteBuffer bb = ByteBuffer.allocate(totalBytes); for (KeyValue kv : IterableUtils.emptyIfNull(kvs)) { KeyValueUtil.appendToByteBuffer(bb, kv, includeMemstoreTS); } bb.rewind(); return bb; }
/** * Counts the number of elements in the input iterable that match the predicate. * <p> * A <code>null</code> iterable matches no elements. * * @param <E> the type of object the {@link Iterable} contains * @param input the {@link Iterable} to get the input from, may be null * @param predicate the predicate to use, may not be null * @return the number of matches for the predicate in the collection * @throws NullPointerException if predicate is null */ public static <E> long countMatches(final Iterable<E> input, final Predicate<? super E> predicate) { if (predicate == null) { throw new NullPointerException("Predicate must not be null."); } return size(filteredIterable(emptyIfNull(input), predicate)); }
/** * Returns the number of occurrences of the provided object in the iterable. * * @param <E> the element type that the {@link Iterable} may contain * @param <T> the element type of the object to find * @param iterable the {@link Iterable} to search * @param obj the object to find the cardinality of * @return the the number of occurrences of obj in iterable */ public static <E, T extends E> int frequency(final Iterable<E> iterable, final T obj) { if (iterable instanceof Set<?>) { return ((Set<E>) iterable).contains(obj) ? 1 : 0; } if (iterable instanceof Bag<?>) { return ((Bag<E>) iterable).getCount(obj); } return size(filteredIterable(emptyIfNull(iterable), EqualPredicate.<E>equalPredicate(obj))); }