Stream<SegmentWithState> getAppendingSegments(Collection<String> sequenceNames) { synchronized (segments) { return sequenceNames .stream() .map(segments::get) .filter(Objects::nonNull) .flatMap(segmentsForSequence -> segmentsForSequence.intervalToSegmentStates.values().stream()) .map(segmentsOfInterval -> segmentsOfInterval.appendingSegment) .filter(Objects::nonNull); } }
/** * Gets a stream of values from a collection of range resources. */ public static LongStream rangeValues(Collection<Protos.Resource> resources) { checkNotNull(resources); return resources.stream() .filter(Protos.Resource::hasRanges) .flatMap(r -> r.getRanges().getRangeList().stream()) .flatMapToLong(Utils::rangeValues); }
@Override public void validate(PlanNode plan, Session session, Metadata metadata, SqlParser sqlParser, TypeProvider types, WarningCollector warningCollector) { searchFrom(plan) .where(AggregationNode.class::isInstance) .<AggregationNode>findAll() .stream() .flatMap(node -> node.getAggregations().values().stream()) .filter(aggregation -> aggregation.getCall().getFilter().isPresent()) .forEach(ignored -> { throw new IllegalStateException("Generated plan contains unimplemented filtered aggregations"); }); } }
/** * Create a new {@link MockMultipartHttpServletRequest} based on the * supplied {@code ServletContext} and the {@code MockMultipartFiles} * added to this builder. */ @Override protected final MockHttpServletRequest createServletRequest(ServletContext servletContext) { MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(servletContext); this.files.stream().forEach(request::addFile); this.parts.values().stream().flatMap(Collection::stream).forEach(request::addPart); if (!this.parts.isEmpty()) { new StandardMultipartHttpServletRequest(request) .getMultiFileMap().values().stream().flatMap(Collection::stream) .forEach(request::addFile); } return request; }
public MultiJoinNode(LinkedHashSet<PlanNode> sources, Expression filter, List<Symbol> outputSymbols) { requireNonNull(sources, "sources is null"); checkArgument(sources.size() > 1, "sources size is <= 1"); requireNonNull(filter, "filter is null"); requireNonNull(outputSymbols, "outputSymbols is null"); this.sources = sources; this.filter = filter; this.outputSymbols = ImmutableList.copyOf(outputSymbols); List<Symbol> inputSymbols = sources.stream().flatMap(source -> source.getOutputSymbols().stream()).collect(toImmutableList()); checkArgument(inputSymbols.containsAll(outputSymbols), "inputs do not contain all output symbols"); }
/** * Returns initial {@link Method} as well as all matching ones found in interfaces. * This allows to introspect metadata for a method which is both declared in parent class and in implemented * interface(s). <code>interfaces</code> typically is obtained by {@link ClassUtils#getAllInterfacesAsSet} */ Collection<Method> getMethodAndInterfaceDeclarations(Method method, Collection<Class> interfaces) { final List<Method> methods = new ArrayList<>(); methods.add(method); // we search for matching method by iteration and comparison vs getMethod to avoid repeated NoSuchMethodException // being thrown, while interface typically only define a few set of methods to check. interfaces.stream() .map(Class::getMethods) .flatMap(Arrays::stream) .filter(m -> m.getName().equals(method.getName()) && Arrays.equals(m.getParameterTypes(), method.getParameterTypes())) .findFirst() .ifPresent(methods::add); return methods; }
@Override public void upgrade() { this.indexSetService.findAll() .stream() .map(mongoIndexSetFactory::create) .flatMap(indexSet -> getReopenedIndices(indexSet).stream()) .map(indexName -> { LOG.debug("Marking index {} to be reopened using alias.", indexName); return indexName; }) .forEach(indices::markIndexReopened); }