- Apache Spark 2.x for Java Developers
- Sourav Gulati Sumit Kumar
- 103字
- 2021-07-02 19:01:59
Partitioning
Partitioning is a special condition of grouping where the elements of the streams are partitioned based on the logic of the predicate function being passed to the Collectors. The predicate function based on a Boolean logic evaluates each element of the stream to either be true or false. The resultant output of the partitioningBy() method is a Map having two keys, true and false, and a list of values of streams associated with each Boolean value depending on the output of the predicate function:
//Partition Collectors
Map<Boolean,List<String>>partitionExample=streamSupplier.get().collect(Collectors.partitioningBy( x->x.toString().length() > 5 ));
System.out.println("Patitioning of elements on the basis of its length :: "+partitionExample);
推薦閱讀
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- Android開發(fā)精要
- 微服務(wù)與事件驅(qū)動(dòng)架構(gòu)
- Python從入門到精通(精粹版)
- Instant 960 Grid System
- Python Geospatial Development(Second Edition)
- C語(yǔ)言程序設(shè)計(jì)
- C#程序設(shè)計(jì)
- 數(shù)據(jù)結(jié)構(gòu)案例教程(C/C++版)
- Swift語(yǔ)言實(shí)戰(zhàn)精講
- Mastering Akka
- Practical GIS
- 黑莓(BlackBerry)開發(fā)從入門到精通
- Java并發(fā)實(shí)現(xiàn)原理:JDK源碼剖析
- 深入理解Kafka:核心設(shè)計(jì)與實(shí)踐原理