Simplify Java Stream Processing with JDFrame: A Semantic DataFrame Alternative
This article introduces JDFrame/SDFrame, a JVM‑level DataFrame‑style library that offers a more semantic and concise API for Java 8 streams, provides quick‑start instructions, detailed code examples, and a comprehensive overview of its SQL‑like operations such as filtering, aggregation, distinct, grouping, joining, and pagination.
Introduction: The author created a JVM-level DataFrame‑like tool to provide a more semantic and concise API for Java 8 streams, inspired by Spark and pandas.
Quick Start
Dependency
<dependency>
<groupId>io.github.burukeyou</groupId>
<artifactId>jdframe</artifactId>
<version>0.0.6</version>
</dependency>Example
Calculate the total score of schools where students are aged 9‑16, then list the top two schools.
static List<Student> studentList = new ArrayList<>();
// ... add Student objects ...
SDFrame<FI2<String, BigDecimal>> sdf2 = SDFrame.read(studentList)
.whereNotNull(Student::getAge)
.whereBetween(Student::getAge, 9, 16)
.groupBySum(Student::getSchool, Student::getScore)
.sortDesc(FI2::getC2)
.cutFirst(2);
sdf2.show();Output:
三中 10
二中 7API Overview
Matrix view
void show(int n);
List<String> columns();
List<R> col(Function<T,R> function);
T head();
List<T> head(int n);
T tail();
List<T> tail(int n);
List<T> page(int page, int pageSize);Filtering
whereBetween(...);
whereBetweenR(...);
whereBetweenL(...);
whereNotNull(...);
whereGt(...);
whereGe(...);
whereLt(...);
whereIn(...);
whereNotIn(...);
whereEq(...);
whereNotEq(...);
whereLike(...);
whereLikeLeft(...);
whereLikeRight(...);Aggregation
max(...);
maxValue(...);
min(...);
minValue(...);
avg(...);
sum(...);
maxMin(...);
maxMinValue(...);Distinct, Grouping, Joining, Pagination, etc.
Methods such as distinct(), groupBySum(), join(), cutFirst(), defaultScale() and others provide SQL‑like semantics for deduplication, grouping, joins, slicing and result formatting.
SDFrame vs JDFrame
SDFrame behaves like a lazy Java Stream—operations take effect only after a terminal call—while JDFrame applies changes immediately, allowing intermediate results to be inspected without re‑reading the data.
Author: 李白的手机 Source: juejin.cn/post/7356652717392740404
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
