Refine search
public Set<String> getAllTables(String schema) throws SchemaNotFoundException { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); builder.addAll(ImmutableList.copyOf(client.getDatabase(schema).listCollectionNames()).stream() .filter(name -> !name.equals(schemaCollection)) .filter(name -> !SYSTEM_TABLES.contains(name)) .collect(toSet())); builder.addAll(getTableMetadataNames(schema)); return builder.build(); }
public static TypeParameterNamingClassification classify(String name) { if (SINGLE_PLUS_MAYBE_DIGIT.matcher(name).matches()) { return LETTER_WITH_MAYBE_NUMERAL; } if (!name.endsWith("T")) { return UNCLASSIFIED; } ImmutableList<String> tokens = NamingConventions.splitToLowercaseTerms(name); // Combine the tokens back into UpperCamelTokens and make sure it matches the identifier String reassembled = tokens.stream().map(TypeParameterNaming::upperCamelToken).collect(Collectors.joining()); return name.equals(reassembled) ? CLASS_NAME_WITH_T : NON_CLASS_NAME_WITH_T_SUFFIX; }
private static <T extends Expression> List<T> extractExpressions( Iterable<? extends Node> nodes, Class<T> clazz, Predicate<T> predicate) { requireNonNull(nodes, "nodes is null"); requireNonNull(clazz, "clazz is null"); requireNonNull(predicate, "predicate is null"); return ImmutableList.copyOf(nodes).stream() .flatMap(node -> linearizeNodes(node).stream()) .filter(clazz::isInstance) .map(clazz::cast) .filter(predicate) .collect(toImmutableList()); }
/** * Constructs a stream for every element of formals paired with every element of actuals (cross * product). Each item contains the formal and the actual, which in turn contain their index into * the cost matrix. Elements whose cost is Inf in the cost matrix are filtered out so only viable * pairings remain. */ Stream<ParameterPair> viablePairs() { return formals.stream() .flatMap(f -> actuals.stream().map(a -> ParameterPair.create(f, a))) .filter( p -> costMatrix[p.formal().index()][p.actual().index()] != Double.POSITIVE_INFINITY); }
/** * Concatenates {@link InputStream}s to multiple configuration files on the classpath into a * single {@link InputStream}. */ public static InputStream getCombinedInputStream(ImmutableList<String> settingsFiles) { return settingsFiles.stream() .map(file -> ConfigUtils.class.getClassLoader().getResourceAsStream(file)) .reduce(null, (in1, in2) -> combineStreams(in1, in2)); }
private synchronized boolean allAssignmentsHavePropagated(Iterable<QueryExecution> queries) { if (nodes.isEmpty()) { // Assignments can't have propagated, if there are no visible nodes. return false; } long newestAssignment = ImmutableList.copyOf(queries).stream() .map(QueryExecution::getMemoryPool) .mapToLong(VersionedMemoryPoolId::getVersion) .min() .orElse(-1); long mostOutOfDateNode = nodes.values().stream() .mapToLong(RemoteNodeMemory::getCurrentAssignmentVersion) .min() .orElse(Long.MAX_VALUE); return newestAssignment <= mostOutOfDateNode; }
sourceTerms.stream() .map(s -> targetTerms.stream().mapToDouble(t -> editDistanceFn.apply(s, t)).toArray()) .toArray(double[][]::new); sourceTerms.stream() .map(s -> s.length()) .map( s -> targetTerms.stream() .map(t -> t.length()) .mapToDouble(t -> maxDistanceFn.apply(s, t)) sourceTerms.stream().mapToDouble(s -> maxDistanceFn.apply(s.length(), 0)).toArray(); targetTerms.stream().mapToDouble(s -> maxDistanceFn.apply(0, s.length())).toArray();
@VisibleForTesting static TransferExtension findTransferExtension( ImmutableList<TransferExtension> transferExtensions, String service) { try { return transferExtensions .stream() .filter(ext -> ext.getServiceId().toLowerCase().equals(service.toLowerCase())) .collect(onlyElement()); } catch (IllegalArgumentException e) { throw new IllegalStateException( "Found multiple transfer extensions for service " + service, e); } catch (NoSuchElementException e) { throw new IllegalStateException( "Did not find a valid transfer extension for service " + service, e); } }
static String logback(final Config conf) { // Avoid warning message from logback when multiples files are present String logback; if (conf.hasPath("logback.configurationFile")) { logback = conf.getString("logback.configurationFile"); } else { String env = conf.hasPath("application.env") ? conf.getString("application.env") : null; ImmutableList.Builder<File> files = ImmutableList.builder(); // TODO: sanitization of arguments File userdir = new File(System.getProperty("user.dir")); File confdir = new File(userdir, "conf"); if (env != null) { files.add(new File(userdir, "logback." + env + ".xml")); files.add(new File(confdir, "logback." + env + ".xml")); } files.add(new File(userdir, "logback.xml")); files.add(new File(confdir, "logback.xml")); logback = files.build() .stream() .filter(File::exists) .map(File::getAbsolutePath) .findFirst() .orElseGet(() -> { return Optional.ofNullable(Jooby.class.getResource("/logback." + env + ".xml")) .map(Objects::toString) .orElse("logback.xml"); }); } return logback; }
private static Optional<String> getCommonImmutableTypeForAllReturnStatementsTypes( ImmutableSet<ClassType> returnStatementsTypes) { checkState(!returnStatementsTypes.isEmpty()); ClassType arbitraryClassType = returnStatementsTypes.asList().get(0); ImmutableList<String> superTypes = getImmutableSuperTypesForClassType(arbitraryClassType); return superTypes.stream() .filter(areAllReturnStatementsAssignable(returnStatementsTypes)) .findFirst(); }
@SuppressWarnings("ResultOfMethodCallIgnored") public void setupKotlinHome(String kotlinVersion) { this.kotlinHomeEnabled = true; this.kotlinVersion = kotlinVersion; Configuration kotlinConfig = project.getConfigurations().maybeCreate(KOTLIN_DEPS_CONFIG); DependencyHandler handler = project.getDependencies(); kotlinModules .stream() .map(module -> String.format("%s:%s:%s", KOTLIN_GROUP, module, kotlinVersion)) .forEach(dependency -> handler.add(KOTLIN_DEPS_CONFIG, dependency)); dependencies = new DependencyCache(project, ProjectUtil.getDependencyManager(project)).build(kotlinConfig); }
/** * Get the region functions of all zones which are siblings of the given zone (including the given zone). * * Sibling zones are zones that have the same parent. * * @param zone the zone to find the siblings of * @return the region functions of the given zone's siblings */ static List<ZoneRegionFunction> getSiblingRegionFunctions(Zone zone) { return zone.getParent().getChildZones().stream() .map(Zone::getRegionFunction) .collect(Collectors.toList()); }
@VisibleForTesting Collection<Message> decodeV9(InetSocketAddress sender, ByteBuf buffer) throws InvalidProtocolBufferException { final List<NetFlowV9Packet> netFlowV9Packets = decodeV9Packets(buffer); return netFlowV9Packets.stream().map(netFlowV9Packet -> netFlowV9Packet.records().stream() .filter(record -> record instanceof NetFlowV9Record) .map(record -> NetFlowFormatter.toMessage(netFlowV9Packet.header(), record, sender)) .collect(Collectors.toList()) ).flatMap(Collection::stream) .collect(Collectors.toList()); }
private void deleteSeleniumContainers() { logger.info("About to clean up any left over DockerSelenium containers created by Zalenium"); String image = DockeredSeleniumStarter.getDockerSeleniumImageName(); String zaleniumContainerName = DockeredSeleniumStarter.getContainerName(); try { List<Container> containerList = dockerClient.listContainers(withStatusRunning(), withStatusCreated()) .stream().filter(container -> container.image().contains(image) && container.names().stream().anyMatch(name -> name.contains(zaleniumContainerName))) .collect(Collectors.toList()); containerList.stream() .parallel() .forEach(container -> stopContainer(container.id())); } catch (Exception e) { logger.warn(nodeId + " Error while deleting existing DockerSelenium containers", e); ga.trackException(e); } }
private void resolveNativeEntityGrokPattern(EntityDescriptor entityDescriptor, InputWithExtractors inputWithExtractors, MutableGraph<EntityDescriptor> mutableGraph) { inputWithExtractors.extractors().stream() .filter(e -> e.getType().equals(Extractor.Type.GROK)) .map(e -> (String) e.getExtractorConfig().get(GrokExtractor.CONFIG_GROK_PATTERN)) .map(GrokPatternService::extractPatternNames) .flatMap(Collection::stream) .forEach(patternName -> { grokPatternService.loadByName(patternName).ifPresent(depPattern -> { final EntityDescriptor depEntityDescriptor = EntityDescriptor.create( depPattern.id(), ModelTypes.GROK_PATTERN_V1); mutableGraph.putEdge(entityDescriptor, depEntityDescriptor); }); }); }