Tabnine Logo
Stream.distinct
Code IndexAdd Tabnine to your IDE (free)

How to use
distinct
method
in
java.util.stream.Stream

Best Java code snippets using java.util.stream.Stream.distinct (Showing top 20 results out of 7,650)

Refine searchRefine arrow

  • Stream.collect
  • Stream.map
  • Collectors.toList
  • List.stream
  • Stream.filter
origin: prestodb/presto

public List<Symbol> getOriginalNonDistinctAggregateArgs()
{
  return aggregations.values().stream()
      .filter(aggregation -> !aggregation.getMask().isPresent())
      .map(Aggregation::getCall)
      .flatMap(function -> function.getArguments().stream())
      .distinct()
      .map(Symbol::from)
      .collect(Collectors.toList());
}
origin: prestodb/presto

private static Stream<Set<Expression>> extractArgumentSets(AggregationNode aggregation)
{
  return aggregation.getAggregations()
      .values().stream()
      .map(Aggregation::getCall)
      .filter(FunctionCall::isDistinct)
      .map(FunctionCall::getArguments)
      .<Set<Expression>>map(HashSet::new)
      .distinct();
}
origin: Vedenin/useful-java-links

private static void testDistinct() {
  System.out.println();
  System.out.println("Test distinct start");
  Collection<String> ordered = Arrays.asList("a1", "a2", "a2", "a3", "a1", "a2", "a2");
  Collection<String> nonOrdered = new HashSet<>(ordered);
  // Get collection without duplicate
  List<String> distinct = nonOrdered.stream().distinct().collect(Collectors.toList());
  System.out.println("distinct = " + distinct); // print  distinct = [a1, a2, a3] - порядок не гарантируется
  List<String> distinctOrdered = ordered.stream().distinct().collect(Collectors.toList());
  System.out.println("distinctOrdered = " + distinctOrdered); // print  distinct = [a1, a2, a3] - порядок гарантируется
}
origin: org.apache.ant/ant

  private <T> Stream<? extends T> streamResources(
    Function<? super Resource, ? extends T> mapper) {
    return getResourceCollections().stream()
      .flatMap(ResourceCollection::stream).map(mapper).distinct();
  }
}
origin: speedment/speedment

private void distinct() {
  Set<String> ratings = films.stream()
      .map(Film.RATING)
      .distinct()
      .collect(Collectors.toSet());
  System.out.println(ratings);
}
origin: fesh0r/fernflower

 public String getUniqueExceptionsString() {
  return exceptionTypes != null ? exceptionTypes.stream().distinct().collect(Collectors.joining(":")) : null;
 }
}
origin: AxonFramework/AxonFramework

@Override
public int[] fetchSegments(String processorName) {
  return tokens.keySet().stream()
         .filter(ps -> ps.processorName.equals(processorName))
         .map(ProcessAndSegment::getSegment)
         .distinct().mapToInt(Number::intValue).toArray();
}
origin: resilience4j/resilience4j

private Optional<Predicate<Throwable>> buildRecordExceptionsPredicate() {
  return Arrays.stream(recordExceptions)
      .distinct()
      .map(Builder::makePredicate)
      .reduce(Predicate::or);
}
origin: runelite/runelite

@Override
public GameObject[] result(Client client)
{
  return getGameObjects(client).stream()
    .filter(Objects::nonNull)
    .filter(predicate)
    .distinct()
    .toArray(GameObject[]::new);
}
origin: prestodb/presto

private static Map<Expression, Symbol> symbolsForExpressions(PlanBuilder builder, Iterable<? extends Expression> expressions)
{
  return stream(expressions)
      .distinct()
      .collect(toImmutableMap(expression -> expression, builder::translate));
}
origin: prestodb/presto

public List<Symbol> getOriginalDistinctAggregateArgs()
{
  return aggregations.values().stream()
      .filter(aggregation -> aggregation.getMask().isPresent())
      .map(Aggregation::getCall)
      .flatMap(function -> function.getArguments().stream())
      .distinct()
      .map(Symbol::from)
      .collect(Collectors.toList());
}
origin: prestodb/presto

@Test
public void testNonDeterministic()
{
  MaterializedResult materializedResult = computeActual("SELECT rand() FROM orders LIMIT 10");
  long distinctCount = materializedResult.getMaterializedRows().stream()
      .map(row -> row.getField(0))
      .distinct()
      .count();
  assertTrue(distinctCount >= 8, "rand() must produce different rows");
  materializedResult = computeActual("SELECT apply(1, x -> x + rand()) FROM orders LIMIT 10");
  distinctCount = materializedResult.getMaterializedRows().stream()
      .map(row -> row.getField(0))
      .distinct()
      .count();
  assertTrue(distinctCount >= 8, "rand() must produce different rows");
}
origin: prestodb/presto

@Override
public List<String> listSchemaNames(ConnectorSession session)
{
  return tables.listSystemTables(session).stream()
      .map(table -> table.getTableMetadata().getTable().getSchemaName())
      .distinct()
      .collect(toImmutableList());
}
origin: jtablesaw/tablesaw

  default StringColumn tokenizeAndRemoveDuplicates(String separator) {
    StringColumn newColumn = StringColumn.create(name() + "[without duplicates]", this.size());

    for (int r = 0; r < size(); r++) {
      String value = getString(r);

      Splitter splitter = Splitter.on(separator);
      splitter = splitter.trimResults();
      splitter = splitter.omitEmptyStrings();
      List<String> tokens = new ArrayList<>(splitter.splitToList(value));

      String result = tokens.stream().distinct().collect(Collectors.joining(separator));
      newColumn.set(r, result);
    }
    return newColumn;
  }
}
origin: prestodb/presto

private static boolean hasMultipleDistincts(AggregationNode aggregation)
{
  return aggregation.getAggregations()
      .values().stream()
      .filter(e -> e.getCall().isDistinct())
      .map(Aggregation::getCall)
      .map(FunctionCall::getArguments)
      .map(HashSet::new)
      .distinct()
      .count() > 1;
}
origin: spring-io/initializr

/**
 * Return all dependencies as a flat collection.
 * @return all dependencies
 */
public Collection<Dependency> getAll() {
  return Collections.unmodifiableCollection(this.indexedDependencies.values()
      .stream().distinct().collect(Collectors.toList()));
}
origin: resilience4j/resilience4j

private Optional<Predicate<Throwable>> buildRetryExceptionsPredicate() {
  return Arrays.stream(retryExceptions)
      .distinct()
      .map(Builder::makePredicate)
      .reduce(Predicate::or);
}
origin: runelite/runelite

@Override
public GroundObject[] result(Client client)
{
  return getGroundObjects(client).stream()
    .filter(Objects::nonNull)
    .filter(predicate)
    .distinct()
    .toArray(GroundObject[]::new);
}
origin: micronaut-projects/micronaut-core

/**
 * Set the allowed HTTP methods.
 *
 * @param methods The methods to specify in the Allowed HTTP header
 * @return This HTTP headers
 */
default MutableHttpHeaders allow(Collection<HttpMethod> methods) {
  String value = methods.stream().distinct().collect(Collectors.joining(","));
  return add(ALLOW, value);
}
origin: apache/incubator-druid

@Override
public List<String> getDataSourceNames()
{
 return rels.stream()
       .flatMap(rel -> ((DruidRel<?>) rel).getDataSourceNames().stream())
       .distinct()
       .collect(Collectors.toList());
}
java.util.streamStreamdistinct

Javadoc

Returns a stream consisting of the distinct elements (according to Object#equals(Object)) of this stream.

For ordered streams, the selection of distinct elements is stable (for duplicated elements, the element appearing first in the encounter order is preserved.) For unordered streams, no stability guarantees are made.

This is a stateful intermediate operation.

Popular methods of Stream

  • collect
  • map
  • filter
  • forEach
  • findFirst
  • of
  • anyMatch
  • flatMap
  • sorted
  • toArray
  • findAny
  • count
  • findAny,
  • count,
  • allMatch,
  • concat,
  • reduce,
  • mapToInt,
  • empty,
  • noneMatch,
  • iterator

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • setRequestProperty (URLConnection)
  • startActivity (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • BoxLayout (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now