private Collection<String> referencedRules(String pipelineSource) { final Pipeline pipeline = pipelineRuleParser.parsePipeline("dummy", pipelineSource); return pipeline.stages().stream() .map(Stage::ruleReferences) .flatMap(Collection::stream) .map(ruleService::findByName) .filter(Optional::isPresent) .map(Optional::get) .map(RuleDao::id) .collect(Collectors.toSet()); } }
@Override public Iterable<Vertex> getNeighbors(final int value) { return outEdges.stream() .filter(edge -> (Integer) edge.getProperty("number") == value) .map(Edge::getEnd) .collect(Collectors.toSet()); }
public Map<String, QualityProfile> getProfilesByKey() { return profiles.stream().collect(uniqueIndex(QualityProfile::getQpKey, identity())); }
@Override public Iterable<Vertex> getNeighbors(final int value) { // SortedSet<ByteEntry> set = (SortedSet<ByteEntry>) tx.get(id); return set.stream() .filter(entry -> entry.value.getInt(0) == value) .map(entry -> new ByteVertex(entry.key.getLong(8), tx)) .collect(Collectors.toSet()); } }
/** * Find the patterns matching the given lookup path. Invoking this method should * yield results equivalent to those of calling * {@link #getMatchingCondition(ServerWebExchange)}. * This method is provided as an alternative to be used if no request is available * (e.g. introspection, tooling, etc). * @param exchange the current exchange * @return a sorted set of matching patterns sorted with the closest match first */ private SortedSet<PathPattern> getMatchingPatterns(ServerWebExchange exchange) { PathContainer lookupPath = exchange.getRequest().getPath().pathWithinApplication(); return this.patterns.stream() .filter(pattern -> pattern.matches(lookupPath)) .collect(Collectors.toCollection(TreeSet::new)); }
public Collection<Frequency> getFrequencies (String trip_id) { // IntelliJ tells me all these casts are unnecessary, and that's also my feeling, but the code won't compile // without them return (List<Frequency>) frequencies.subSet(new Fun.Tuple2(trip_id, null), new Fun.Tuple2(trip_id, Fun.HI)).stream() .map(t2 -> ((Tuple2<String, Frequency>) t2).b) .collect(Collectors.toList()); }
deadWorkerDirs.stream().map(File::getName).collect(joining(",")));
.stream() .noneMatch( prop ->
/** * Get brokers that the rebalance process will go over to apply balancing actions to rep licas they contain. * * @param clusterModel The state of the cluster. * @return A collection of brokers that the rebalance process will go over to apply balancing actions to replicas * they contain. */ @Override protected SortedSet<Broker> brokersToBalance(ClusterModel clusterModel) { if (!clusterModel.deadBrokers().isEmpty()) { return clusterModel.deadBrokers(); } if (_currentRebalanceTopic == null) { return Collections.emptySortedSet(); } // Brokers having over minimum number of replicas per broker for the current rebalance topic are eligible for balancing. SortedSet<Broker> brokersToBalance = new TreeSet<>(); int minNumReplicasPerBroker = _replicaDistributionTargetByTopic.get(_currentRebalanceTopic).minNumReplicasPerBroker(); brokersToBalance.addAll(clusterModel.brokers().stream() .filter(broker -> broker.replicasOfTopicInBroker(_currentRebalanceTopic).size() > minNumReplicasPerBroker) .collect(Collectors.toList())); return brokersToBalance; }
List<String> reorderedFilesStr = logFiles.stream() .map(WorkerLogs::getTopologyPortWorkerLog) .filter(fileStr -> !StringUtils.equals(fileName, fileStr))
final Set<String> indexRangesWithoutStreams = indexRangeService.findAll().stream() .filter(indexRange -> defaultIndexSet.isManagedIndex(indexRange.indexName())) .filter(indexRange -> indexRange.streamIds() == null)
private Settings.Builder getMinimumNonSgNodeSettingsBuilder(final int nodenum, final boolean masterNode, final boolean dataNode, final boolean tribeNode, int nodeCount, int masterCount, SortedSet<Integer> tcpPorts, int tcpPort, int httpPort) { return Settings.builder() .put("node.name", "node_"+clustername+ "_num" + nodenum) .put("node.data", dataNode) .put("node.master", masterNode) .put("cluster.name", clustername) .put("path.data", "data/"+clustername+"/data") .put("path.logs", "data/"+clustername+"/logs") .put("node.max_local_storage_nodes", nodeCount) .put("discovery.zen.minimum_master_nodes", minMasterNodes(masterCount)) .put("discovery.zen.no_master_block", "all") .put("discovery.zen.fd.ping_timeout", "5s") .put("discovery.initial_state_timeout","8s") .putList("discovery.zen.ping.unicast.hosts", tcpPorts.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList())) .put("transport.tcp.port", tcpPort) .put("http.port", httpPort) .put("http.enabled", true) .put("cluster.routing.allocation.disk.threshold_enabled", false) .put("http.cors.enabled", true) .put("path.home", "."); } // @formatter:on
private void initNewDuplicated(Component component, Set<Integer> changedLines) { DuplicationCounters duplicationCounters = new DuplicationCounters(changedLines); Iterable<Duplication> duplications = duplicationRepository.getDuplications(component); for (Duplication duplication : duplications) { duplicationCounters.addBlock(duplication.getOriginal()); duplication.getDuplicates().stream() .filter(InnerDuplicate.class::isInstance) .map(duplicate -> (InnerDuplicate) duplicate) .forEach(duplicate -> duplicationCounters.addBlock(duplicate.getTextBlock())); } newDuplicatedLines.increment(duplicationCounters.getNewLinesDuplicated()); newDuplicatedBlocks.increment(duplicationCounters.getNewBlocksDuplicated()); } }
eligibleBrokers(replica, clusterModel).stream().map(BrokerReplicaCount::broker).collect(Collectors.toList());
assert freePorts.size() == internalNodeSettings.size()*2; final SortedSet<Integer> tcpPorts = new TreeSet<Integer>(); freePorts.stream().limit(internalNodeSettings.size()).forEach(el->tcpPorts.add(el)); final Iterator<Integer> tcpPortsIt = tcpPorts.iterator(); freePorts.stream().skip(internalNodeSettings.size()).limit(internalNodeSettings.size()).forEach(el->httpPorts.add(el)); final Iterator<Integer> httpPortsIt = httpPorts.iterator();
@Test public void elixirModule() throws IOException, OtpErlangDecodeException { Beam beam = beam("Elixir.Kernel"); assertNotNull(beam); Atoms atoms = beam.atoms(); assertNotNull(atoms); assertEquals("Elixir.Kernel", atoms.moduleName()); long callDefinitionCount = beam.callDefinitionsList(atoms).stream().mapToInt(CallDefinitions::size).sum(); assertTrue("There are no callDefinitions", callDefinitionCount > 0); SortedSet<MacroNameArity> macroNameAritySortedSet = CallDefinitions.macroNameAritySortedSet(beam, atoms); assertEquals("There are nameless callDefinitions", callDefinitionCount, macroNameAritySortedSet.size()); Stream<MacroNameArity> macroNameArityStream = macroNameAritySortedSet.stream().filter( macroNameArity -> "node".equals(macroNameArity.name) ); MacroNameArity[] macroNameArities = macroNameArityStream.toArray(MacroNameArity[]::new); assertEquals(2, macroNameArities.length); assertEquals(0, (int) macroNameArities[0].arity); assertEquals(1, (int) macroNameArities[1].arity); }
public static PipelineSource fromDao(PipelineRuleParser parser, PipelineDao dao) { Set<ParseError> errors = null; Pipeline pipeline = null; try { pipeline = parser.parsePipeline(dao.id(), dao.source()); } catch (ParseException e) { errors = e.getErrors(); } final List<StageSource> stageSources = (pipeline == null) ? Collections.emptyList() : pipeline.stages().stream() .map(stage -> StageSource.builder() .matchAll(stage.matchAll()) .rules(stage.ruleReferences()) .stage(stage.stage()) .build()) .collect(Collectors.toList()); return builder() .id(dao.id()) .title(dao.title()) .description(dao.description()) .source(dao.source()) .createdAt(dao.createdAt()) .modifiedAt(dao.modifiedAt()) .stages(stageSources) .errors(errors) .build(); }
@Procedure @Description("apoc.spatial.sortPathsByDistance(List<Path>) sort the given paths based on the geo informations (lat/long) in ascending order") public Stream<DistancePathResult> sortByDistance(@Name("paths")List<Path> paths) { return paths.size() > 0 ? sortPaths(paths).stream() : Stream.empty(); }