@VisibleForTesting JoinEnumerationResult createJoinAccordingToPartitioning(LinkedHashSet<PlanNode> sources, List<Symbol> outputSymbols, Set<Integer> partitioning) { List<PlanNode> sourceList = ImmutableList.copyOf(sources); LinkedHashSet<PlanNode> leftSources = partitioning.stream() .map(sourceList::get) .collect(toCollection(LinkedHashSet::new)); LinkedHashSet<PlanNode> rightSources = sources.stream() .filter(source -> !leftSources.contains(source)) .collect(toCollection(LinkedHashSet::new)); return createJoin(leftSources, rightSources, outputSymbols); }
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"); }
public void testMapWithIndex_linkedHashSetSource() { testMapWithIndex(elems -> new LinkedHashSet<>(elems).stream()); }
private static Optional<Fix> fix(Tree target, Tree replace, VisitorState state) { return Optional.fromJavaUtil( FindIdentifiers.findAllIdents(state).stream() .filter( s -> isSubtype( s.type, state.getTypeFromString("com.google.errorprone.VisitorState"), state)) .findFirst() .map( s -> SuggestedFix.replace( replace, String.format( "%s.getSourceForNode(%s)", s, state.getSourceForNode(target))))); } }
private JoinEnumerationResult createJoin(LinkedHashSet<PlanNode> leftSources, LinkedHashSet<PlanNode> rightSources, List<Symbol> outputSymbols) Set<Symbol> leftSymbols = leftSources.stream() .flatMap(node -> node.getOutputSymbols().stream()) .collect(toImmutableSet()); Set<Symbol> rightSymbols = rightSources.stream() .flatMap(node -> node.getOutputSymbols().stream()) .collect(toImmutableSet());
originalUris.stream().forEach(originalUri -> {
private static <T> void dumpCycles(List<Node<T>> nodes, Stack<Node<T>> path, Function<T, String> toString) { path.peek().outEdges.stream().map(e -> e.to).forEach(node -> { if (nodes.contains(node)) { if (path.contains(node)) { System.out.println( "cycle: " + path.stream().map(n -> toString.apply(n.element)).collect(Collectors.toList())); } else { path.push(node); dumpCycles(nodes, path, toString); path.pop(); } } }); ; }
public List<String> getSentences( String word, int sentenceCount, int minTokenCount, int maxTokenCount) throws Exception { // load and eliminate duplicates. LinkedHashSet<String> sentences = new LinkedHashSet<>(searcher.search(word, 1000)); // filter and sort from smaller to larger sentences. List<String> filtered = sentences.stream() .filter(s -> { int k = s.split(" ").length; return k >= minTokenCount && k <= maxTokenCount; }) .filter(s -> !s.contains("\"")) .filter(s -> !s.contains(")")) .filter(s -> !s.contains("-")) //.sorted(Comparator.comparingInt(a -> a.split(" ").length)) .collect(Collectors.toList()); Collections.shuffle(filtered); int max = filtered.size() < sentenceCount ? filtered.size() : sentenceCount; return new ArrayList<>(filtered.subList(0, max)); }
all.stream().sorted(Turkish.STRING_COMPARATOR_ASC).forEach(pw::println);
candidates.stream().map(Candidate::new).collect(Collectors.toList()));
void deleteFilesForRecordsOfType(Type type) { records.stream() .filter(type::matches) .forEach(LogFile::deleteRecordFiles); records.clear(); }
void deleteFilesForRecordsOfType(Type type) { records.stream() .filter(type::matches) .forEach(LogFile::deleteRecordFiles); records.clear(); }
private static void writeServerFile(Path serverDir, int port, long pid, LinkedHashSet<Path> classpath, LinkedHashSet<Path> bootClasspath, List<String> javaArgs) throws Exception { Properties sp = new Properties(); sp.setProperty(Server.pKeyPort, String.valueOf(port)); sp.setProperty(Server.pKeyPID, String.valueOf(pid)); sp.setProperty(Server.pKeyJavaArgs, String.join(" ", javaArgs)); sp.setProperty(Server.pKeyBCP, bootClasspath.stream().map(ImageClassLoader::classpathToString).collect(Collectors.joining(" "))); sp.setProperty(Server.pKeyCP, classpath.stream().map(ImageClassLoader::classpathToString).collect(Collectors.joining(" "))); Path serverPropertiesPath = serverDir.resolve(Server.serverProperties); try (OutputStream os = Files.newOutputStream(serverPropertiesPath)) { sp.store(os, ""); } }
private boolean checkUnionTypeToJSONConvertibility(BUnionType type, BJSONType target) { // Check whether all the member types are convertible to JSON return type.memberTypes.stream() .anyMatch(memberType -> castVisitor.visit(memberType, target) == symTable.notFoundSymbol); }
private String createInsertSql(Set<String> additionalColumns) { String insertTemplate = "INSERT INTO %s (%s) VALUES (%s)"; LinkedHashSet<String> columnNamesForInsert = new LinkedHashSet<>(nonIdColumnNames); columnNamesForInsert.addAll(additionalColumns); String tableColumns = String.join(", ", columnNamesForInsert); String parameterNames = columnNamesForInsert.stream()// .map(n -> String.format(":%s", n))// .collect(Collectors.joining(", ")); return String.format(insertTemplate, entity.getTableName(), tableColumns, parameterNames); }
static Optional<String> findEnv(final Environment environment) { final Collection<String> activeProfiles = asList(environment.getActiveProfiles()); final Collection<String> envProfiles = newLinkedHashSet(activeProfiles).stream() // .filter(profile -> profile.endsWith(DOT_ENV)) // .map(profile -> profile.substring(0, profile.length() - 4)).collect(toList()); checkArgument(envProfiles.size() < 2, "only 1 env is allowed, there are %s", envProfiles); return Optional.ofNullable(!envProfiles.isEmpty() ? envProfiles.iterator().next() : null); }
private boolean isSafeNavigationAllowedBuiltinInvocation(BLangInvocation iExpr) { if (iExpr.builtInMethod == BLangBuiltInMethod.FREEZE) { if (iExpr.expr.type.tag == TypeTags.UNION && iExpr.expr.type.isNullable()) { BUnionType unionType = (BUnionType) iExpr.expr.type; return unionType.memberTypes.size() == 2 && unionType.memberTypes.stream() .noneMatch(type -> type.tag != TypeTags.NIL && types.isValueType(type)); } } else if (iExpr.builtInMethod == BLangBuiltInMethod.IS_FROZEN) { return false; } return true; }
public void saveOrCreateObjects() { dirtyResources.removeAll(newPersistentResources); // Delete has already been called on these objects dirtyResources.removeAll(deletedResources); newPersistentResources .stream() .map(PersistentResource::getObject) .forEach(s -> transaction.createObject(s, this)); dirtyResources.stream().map(PersistentResource::getObject).forEach(obj -> transaction.save(obj, this)); }
private List<Address> cleanUpSeedMembers(Collection<Address> seedMembers) { return new LinkedHashSet<>(seedMembers) .stream() .filter(address -> !address.equals(localMember.address())) .filter(address -> !address.equals(transport.address())) .collect(Collectors.toList()); }