热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

reactor.core.publisher.Flux.mergeOrdered()方法的使用及代码示例

本文整理了Java中reactor.core.publisher.Flux.mergeOrdered()方法的一些代码示例,展示了Flux.mergeOrd

本文整理了Java中reactor.core.publisher.Flux.mergeOrdered()方法的一些代码示例,展示了Flux.mergeOrdered()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.mergeOrdered()方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:mergeOrdered

Flux.mergeOrdered介绍

[英]Merge data from provided Publisher sequences into an ordered merged sequence, by picking the smallest values from each source (as defined by the provided Comparator). This is not a #sort(Comparator), as it doesn't consider the whole of each sequences.

Instead, this operator considers only one value from each source and picks the smallest of all these values, then replenishes the slot for that picked source.
[中]通过从每个源(由提供的比较器定义)中选取最小值,将提供的发布者序列中的数据合并到有序的合并序列中。这不是一个γ类(比较器),因为它不考虑整个序列。
相反,该运算符只考虑每个源中的一个值,并从所有这些值中选取最小值,然后为该选取的源补充插槽。

代码示例

代码示例来源:origin: reactor/reactor-core

/**
* Merge data from provided {@link Publisher} sequences into an ordered merged sequence,
* by picking the smallest values from each source (as defined by the provided
* {@link Comparator}). This is not a {@link #sort(Comparator)}, as it doesn't consider
* the whole of each sequences.
*


* Instead, this operator considers only one value from each source and picks the
* smallest of all these values, then replenishes the slot for that picked source.
*


*
*
* @param comparator the {@link Comparator} to use to find the smallest value
* @param sources {@link Publisher} sources to merge
* @param the merged type
* @return a merged {@link Flux} that , subscribing early but keeping the original ordering
*/
@SafeVarargs
public static Flux mergeOrdered(Comparator comparator, Publisher... sources) {
return mergeOrdered(Queues.SMALL_BUFFER_SIZE, comparator, sources);
}

代码示例来源:origin: reactor/reactor-core

/**
* Merge data from provided {@link Publisher} sequences into an ordered merged sequence,
* by picking the smallest values from each source (as defined by their natural order).
* This is not a {@link #sort()}, as it doesn't consider the whole of each sequences.
*


* Instead, this operator considers only one value from each source and picks the
* smallest of all these values, then replenishes the slot for that picked source.
*


*
*
* @param sources {@link Publisher} sources of {@link Comparable} to merge
* @param a {@link Comparable} merged type that has a {@link Comparator#naturalOrder() natural order}
* @return a merged {@link Flux} that , subscribing early but keeping the original ordering
*/
@SafeVarargs
public static > Flux mergeOrdered(Publisher... sources) {
return mergeOrdered(Queues.SMALL_BUFFER_SIZE, Comparator.naturalOrder(), sources);
}

代码示例来源:origin: reactor/reactor-core

/**
* Merge data from this {@link Flux} and a {@link Publisher} into a reordered merge
* sequence, by picking the smallest value from each sequence as defined by a provided
* {@link Comparator}. Note that subsequent calls are combined, and their comparators are
* in lexicographic order as defined by {@link Comparator#thenComparing(Comparator)}.
*


* The combination step is avoided if the two {@link Comparator Comparators} are
* {@link Comparator#equals(Object) equal} (which can easily be achieved by using the
* same reference, and is also always true of {@link Comparator#naturalOrder()}).
*


* Note that merge is tailored to work with asynchronous sources or finite sources. When dealing with
* an infinite source that doesn't already publish on a dedicated Scheduler, you must isolate that source
* in its own Scheduler, as merge would otherwise attempt to drain it before subscribing to
* another source.
*


*
*
* @param other the {@link Publisher} to merge with
* @param otherComparator the {@link Comparator} to use for merging
*
* @return a new {@link Flux}
*/
public final Flux mergeOrderedWith(Publisher other,
Comparator otherComparator) {
if (this instanceof FluxMergeOrdered) {
FluxMergeOrdered fluxMerge = (FluxMergeOrdered) this;
return fluxMerge.mergeAdditionalSource(other, otherComparator);
}
return mergeOrdered(otherComparator, this, other);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPIZeroOrOneSource() {
Flux expectedZero = Flux.empty();
Flux testZero = Flux.mergeOrdered(Comparator.naturalOrder());
Flux expectedOne= Flux.just(1, 2, 3);
Flux testOne= Flux.mergeOrdered(Comparator.naturalOrder(), expectedOne);
assertThat(testZero).isSameAs(expectedZero);
assertThat(testOne).isSameAs(expectedOne);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPIWithDefaultPrefetch() {
Flux test = Flux.mergeOrdered(Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8, 10));
assertThat(test.getPrefetch()).isEqualTo(Queues.SMALL_BUFFER_SIZE);
StepVerifier.create(test)
.expectNext(1, 2, 3, 4, 5, 6, 7, 8, 10)
.verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPINaturalOrder() {
Flux test = Flux.mergeOrdered(Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8, 10));
assertThat(test.getPrefetch()).isEqualTo(Queues.SMALL_BUFFER_SIZE);
StepVerifier.create(test)
.expectNext(1, 2, 3, 4, 5, 6, 7, 8, 10)
.verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPI() {
Flux test = Flux.mergeOrdered(Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7),
Flux.just(2, 4, 6, 8, 10));
StepVerifier.create(test)
.expectNext(1, 2, 3, 4, 5, 6, 7, 8, 10)
.verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPISmallRequest() {
Flux test = Flux.mergeOrdered(Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7),
Flux.just(2, 4, 6, 8, 10));
StepVerifier.create(test, 5)
.expectNext(1, 2, 3, 4)
.expectNoEvent(Duration.ofMillis(50))
.thenRequest(5)
.expectNext(5, 6, 7, 8, 10)
.verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void considersOnlyLatestElementInEachSource() {
final Flux flux = Flux.mergeOrdered(Comparator.comparingInt(String::length),
Flux.just("AAAAA", "BBBB"),
Flux.just("DD", "CCC"),
Flux.just("E"));
StepVerifier.create(flux)
.expectNext("E") // between E, DD and AAAAA => E, 3rd slot done
.expectNext("DD") // between DD and AAAAA => DD, replenish 2nd slot to CCC
.expectNext("CCC") // between CCC and AAAAA => CCC, 2nd slot done
.expectNext("AAAAA", "BBBB") // rest of first flux in 1st slot => AAAAA then BBBB
.verifyComplete();
}

代码示例来源:origin: io.projectreactor/reactor-core

/**
* Merge data from provided {@link Publisher} sequences into an ordered merged sequence,
* by picking the smallest values from each source (as defined by the provided
* {@link Comparator}). This is not a {@link #sort(Comparator)}, as it doesn't consider
* the whole of each sequences.
*


* Instead, this operator considers only one value from each source and picks the
* smallest of all these values, then replenishes the slot for that picked source.
*


*
*
* @param comparator the {@link Comparator} to use to find the smallest value
* @param sources {@link Publisher} sources to merge
* @param the merged type
* @return a merged {@link Flux} that , subscribing early but keeping the original ordering
*/
@SafeVarargs
public static Flux mergeOrdered(Comparator comparator, Publisher... sources) {
return mergeOrdered(Queues.SMALL_BUFFER_SIZE, comparator, sources);
}

代码示例来源:origin: io.projectreactor/reactor-core

/**
* Merge data from provided {@link Publisher} sequences into an ordered merged sequence,
* by picking the smallest values from each source (as defined by their natural order).
* This is not a {@link #sort()}, as it doesn't consider the whole of each sequences.
*


* Instead, this operator considers only one value from each source and picks the
* smallest of all these values, then replenishes the slot for that picked source.
*


*
*
* @param sources {@link Publisher} sources of {@link Comparable} to merge
* @param a {@link Comparable} merged type that has a {@link Comparator#naturalOrder() natural order}
* @return a merged {@link Flux} that , subscribing early but keeping the original ordering
*/
@SafeVarargs
public static > Flux mergeOrdered(Publisher... sources) {
return mergeOrdered(Queues.SMALL_BUFFER_SIZE, Comparator.naturalOrder(), sources);
}

代码示例来源:origin: io.projectreactor/reactor-core

/**
* Merge data from this {@link Flux} and a {@link Publisher} into a reordered merge
* sequence, by picking the smallest value from each sequence as defined by a provided
* {@link Comparator}. Note that subsequent calls are combined, and their comparators are
* in lexicographic order as defined by {@link Comparator#thenComparing(Comparator)}.
*


* The combination step is avoided if the two {@link Comparator Comparators} are
* {@link Comparator#equals(Object) equal} (which can easily be achieved by using the
* same reference, and is also always true of {@link Comparator#naturalOrder()}).
*


* Note that merge is tailored to work with asynchronous sources or finite sources. When dealing with
* an infinite source that doesn't already publish on a dedicated Scheduler, you must isolate that source
* in its own Scheduler, as merge would otherwise attempt to drain it before subscribing to
* another source.
*


*
*
* @param other the {@link Publisher} to merge with
* @param otherComparator the {@link Comparator} to use for merging
*
* @return a new {@link Flux}
*/
public final Flux mergeOrderedWith(Publisher other,
Comparator otherComparator) {
if (this instanceof FluxMergeOrdered) {
FluxMergeOrdered fluxMerge = (FluxMergeOrdered) this;
return fluxMerge.mergeAdditionalSource(other, otherComparator);
}
return mergeOrdered(otherComparator, this, other);
}

推荐阅读
  • 本文介绍了iOS数据库Sqlite的SQL语句分类和常见约束关键字。SQL语句分为DDL、DML和DQL三种类型,其中DDL语句用于定义、删除和修改数据表,关键字包括create、drop和alter。常见约束关键字包括if not exists、if exists、primary key、autoincrement、not null和default。此外,还介绍了常见的数据库数据类型,包括integer、text和real。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • Week04面向对象设计与继承学习总结及作业要求
    本文总结了Week04面向对象设计与继承的重要知识点,包括对象、类、封装性、静态属性、静态方法、重载、继承和多态等。同时,还介绍了私有构造函数在类外部无法被调用、static不能访问非静态属性以及该类实例可以共享类里的static属性等内容。此外,还提到了作业要求,包括讲述一个在网上商城购物或在班级博客进行学习的故事,并使用Markdown的加粗标记和语句块标记标注关键名词和动词。最后,还提到了参考资料中关于UML类图如何绘制的范例。 ... [详细]
  • SpringBoot uri统一权限管理的实现方法及步骤详解
    本文详细介绍了SpringBoot中实现uri统一权限管理的方法,包括表结构定义、自动统计URI并自动删除脏数据、程序启动加载等步骤。通过该方法可以提高系统的安全性,实现对系统任意接口的权限拦截验证。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • Java中包装类的设计原因以及操作方法
    本文主要介绍了Java中设计包装类的原因以及操作方法。在Java中,除了对象类型,还有八大基本类型,为了将基本类型转换成对象,Java引入了包装类。文章通过介绍包装类的定义和实现,解答了为什么需要包装类的问题,并提供了简单易用的操作方法。通过本文的学习,读者可以更好地理解和应用Java中的包装类。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
  • Oracle seg,V$TEMPSEG_USAGE与Oracle排序的关系及使用方法
    本文介绍了Oracle seg,V$TEMPSEG_USAGE与Oracle排序之间的关系,V$TEMPSEG_USAGE是V_$SORT_USAGE的同义词,通过查询dba_objects和dba_synonyms视图可以了解到它们的详细信息。同时,还探讨了V$TEMPSEG_USAGE的使用方法。 ... [详细]
author-avatar
我是来工作的程_586
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有