public static List<byte[]> getUtf8ByteArrays(List<String> strings) { if (CollectionUtils.isEmpty(strings)) { return Collections.emptyList(); } List<byte[]> byteArrays = new ArrayList<>(strings.size()); strings.forEach(s -> byteArrays.add(Bytes.toBytes(s))); return byteArrays; }
public static boolean isSorted(Collection<byte[]> arrays) { if (!CollectionUtils.isEmpty(arrays)) { byte[] previous = new byte[0]; for (byte[] array : arrays) { if (Bytes.compareTo(previous, array) > 0) { return false; } previous = array; } } return true; }
@VisibleForTesting static Set<byte[]> collectFamilies(List<Cell> cells) { if (CollectionUtils.isEmpty(cells)) { return Collections.emptySet(); } else { return cells.stream() .filter(v -> !CellUtil.matchingFamily(v, WALEdit.METAFAMILY)) .collect(toCollection(() -> new TreeSet<>(CellComparator.getInstance()::compareFamilies))) .stream() .map(CellUtil::cloneFamily) .collect(toCollection(() -> new TreeSet<>(Bytes.BYTES_COMPARATOR))); } }
/** * Create a {@link RowMutations} with the specified mutations. * @param mutations the mutations to send * @return RowMutations * @throws IOException if any row in mutations is different to another */ public static RowMutations of(List<? extends Mutation> mutations) throws IOException { if (CollectionUtils.isEmpty(mutations)) { throw new IllegalArgumentException("Cannot instantiate a RowMutations by empty list"); } return new RowMutations(mutations.get(0).getRow(), mutations.size()) .add(mutations); }
/** Adds the files to compacting files. filesCompacting must be locked. */ private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) { if (CollectionUtils.isEmpty(filesToAdd)) { return; } // Check that we do not try to compact the same StoreFile twice. if (!Collections.disjoint(filesCompacting, filesToAdd)) { Preconditions.checkArgument(false, "%s overlaps with %s", filesToAdd, filesCompacting); } filesCompacting.addAll(filesToAdd); Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator()); }
@Override public void updateReaders(List<HStoreFile> sfs, List<KeyValueScanner> memStoreScanners) throws IOException { if (CollectionUtils.isEmpty(sfs) && CollectionUtils.isEmpty(memStoreScanners)) { return; } flushLock.lock(); try { flushed = true; final boolean isCompaction = false; boolean usePread = get || scanUsePread; // SEE HBASE-19468 where the flushed files are getting compacted even before a scanner // calls next(). So its better we create scanners here rather than next() call. Ensure // these scanners are properly closed() whether or not the scan is completed successfully // Eagerly creating scanners so that we have the ref counting ticking on the newly created // store files. In case of stream scanners this eager creation does not induce performance // penalty because in scans (that uses stream scanners) the next() call is bound to happen. List<KeyValueScanner> scanners = store.getScanners(sfs, cacheBlocks, get, usePread, isCompaction, matcher, scan.getStartRow(), scan.getStopRow(), this.readPt, false); flushedstoreFileScanners.addAll(scanners); if (!CollectionUtils.isEmpty(memStoreScanners)) { clearAndClose(memStoreScannersAfterFlush); memStoreScannersAfterFlush.addAll(memStoreScanners); } } finally { flushLock.unlock(); } // Let the next() call handle re-creating and seeking }
if (CollectionUtils.isEmpty(levelOneDirs)) { return;
private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files) throws IOException { if (CollectionUtils.isEmpty(files)) { return Collections.emptyList();
@Override public boolean commit(MonitoredTask status) throws IOException { if (CollectionUtils.isEmpty(this.tempFiles)) { return false;
if (CollectionUtils.isEmpty(delSfs)) { return;
String oldQueueNode = getQueueNode(sourceServerName, queueId); List<String> wals = ZKUtil.listChildrenNoWatch(zookeeper, oldQueueNode); if (CollectionUtils.isEmpty(wals)) { ZKUtil.deleteNodeFailSilent(zookeeper, oldQueueNode); LOG.info("Removed empty {}/{}", sourceServerName, queueId);
private static Cell reckonDelta(final Cell delta, final Cell currentCell, final byte[] columnFamily, final long now, Mutation mutation, Function<Cell, byte[]> supplier) throws IOException { // Forward any tags found on the delta. List<Tag> tags = TagUtil.carryForwardTags(delta); tags = TagUtil.carryForwardTTLTag(tags, mutation.getTTL()); if (currentCell != null) { tags = TagUtil.carryForwardTags(tags, currentCell); byte[] newValue = supplier.apply(currentCell); return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(mutation.getRow(), 0, mutation.getRow().length) .setFamily(columnFamily, 0, columnFamily.length) // copy the qualifier if the cell is located in shared memory. .setQualifier(CellUtil.cloneQualifier(delta)) .setTimestamp(Math.max(currentCell.getTimestamp() + 1, now)) .setType(KeyValue.Type.Put.getCode()) .setValue(newValue, 0, newValue.length) .setTags(TagUtil.fromList(tags)) .build(); } else { PrivateCellUtil.updateLatestStamp(delta, now); return CollectionUtils.isEmpty(tags) ? delta : PrivateCellUtil.createCell(delta, tags); } }
if (!CollectionUtils.isEmpty(mutations)) { doNonAtomicBatchOp(builder, region, quota, mutations, cellScanner, spaceQuotaEnforcement);
/** * Create a {@link RowMutations} with the specified mutations. * @param mutations the mutations to send * @return RowMutations * @throws IOException if any row in mutations is different to another */ public static RowMutations of(List<? extends Mutation> mutations) throws IOException { if (CollectionUtils.isEmpty(mutations)) { throw new IllegalArgumentException("Cannot instantiate a RowMutations by empty list"); } return new RowMutations(mutations.get(0).getRow(), mutations.size()) .add(mutations); }
/** * Null-safe check if the specified collection is not empty. * <p> * Null returns false. * * @param coll the collection to check, may be null * @return true if non-null and non-empty * @since 3.2 */ public static boolean isNotEmpty(final Collection<?> coll) { return !isEmpty(coll); }
public static List<byte[]> getUtf8ByteArrays(List<String> strings) { if (CollectionUtils.isEmpty(strings)) { return Collections.emptyList(); } List<byte[]> byteArrays = new ArrayList<>(strings.size()); strings.forEach(s -> byteArrays.add(Bytes.toBytes(s))); return byteArrays; }
public static List<byte[]> getUtf8ByteArrays(List<String> strings) { if (CollectionUtils.isEmpty(strings)) { return Collections.emptyList(); } List<byte[]> byteArrays = new ArrayList<>(strings.size()); strings.forEach(s -> byteArrays.add(Bytes.toBytes(s))); return byteArrays; }
public static boolean isSorted(Collection<byte[]> arrays) { if (!CollectionUtils.isEmpty(arrays)) { byte[] previous = new byte[0]; for (byte[] array : arrays) { if (Bytes.compareTo(previous, array) > 0) { return false; } previous = array; } } return true; }
public static boolean isSorted(Collection<byte[]> arrays) { if (!CollectionUtils.isEmpty(arrays)) { byte[] previous = new byte[0]; for (byte[] array : arrays) { if (Bytes.compareTo(previous, array) > 0) { return false; } previous = array; } } return true; }
if (CollectionUtils.isEmpty(levelOneDirs)) { return;