r/dataanalysis • • 21d ago

Data Tools Have you ever used Java for data analysis? I'm building CupOfTea, a fast, Pandas-like DataFrame library.

Sum Aggregation
Tablesaw : ■■■■■■■■■■ 0.48 ms
DFLib    : ■■■■■■■■■ 0.42 ms
Pandas   : ■■■■■■■ 0.35 ms
Polars   : ■■ 0.08 ms
CupOfTea : ■ 0.05 ms (9.6x faster than Tablesaw, 1.6x faster than Polars)

Here is a quick example reading from a Parquet file, aggregating by department, and exporting to CSV:

package com.example;

import com.cupoftea.CupOfTea;
import static com.cupoftea.aggregate.Aggregations.*;

public class ParquetToCsvReportExample {

    public static void main(String[] args) {
        String inputParquet = "sales.parquet";
        String outputCsv = "sales_summary_report.csv";

        CupOfTea df = CupOfTea.read().parquet(inputParquet);

        CupOfTea report = df.groupBy("department")
                            .agg(
                                sum("total_amount").as("total_revenue"),
                                mean("total_amount").as("average_ticket"),
                                count("order_id").as("order_count")
                            );

        report.write().csv(outputCsv);

    }
}

The project is open source: https://github.com/cupoftea-labs/cupoftea

I’d love to hear your thoughts:

  • What features or pain points make you reach for Python instead of doing data processing natively in Java?
  • Any specific workloads or benchmarks you’d like to see tested next?

All feedback, issues, and critique are welcome!

8 Upvotes

11 comments sorted by

4

u/SprinklesFresh5693 21d ago

Why java though?

2

u/virgilash 21d ago

Check duckdb against same data, op :-)

2

u/Aeronautical-You4917 20d ago

If this is a personal project, great! If this is something you want to use at work, etc. Just use DuckDB. Trust me.

3

u/justanothersnek 21d ago

Modern Java has come a long way, but analyzing data where everything has to be a class? No thank you.

1

u/AutoModerator 21d ago

Automod prevents all posts from being displayed until moderators have reviewed them. Do not delete your post or there will be nothing for the mods to review. Mods selectively choose what is permitted to be posted in r/DataAnalysis.

If your post involves Career-focused questions, including resume reviews, how to learn DA and how to get into a DA job, then the post does not belong here, but instead belongs in our sister-subreddit, r/DataAnalysisCareers.

Have you read the rules?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/[deleted] 21d ago

[deleted] — view deleted comment

2

u/IndependentIll8256 21d ago

While the high-level DataFrame APIs are similar, the difference lies underneath.

Tablesaw is single-threaded by default and can easily hit Out-Of-Memory (OOM) errors on large datasets due to memory overhead. CupOfTea is built for modern Java (Java 17+) with a high-throughput columnar engine, native multi-threading (.asParallel()), a lazy streaming mode for massive datasets, direct Java Record mapping, and native support for modern analytical formats like Apache Parquet and Apache Arrow.

1

u/[deleted] 21d ago

[removed] — view removed comment

1

u/IndependentIll8256 21d ago

Thank you for the feedback, I’ll definitely do that!

You're completely right—sub-millisecond in-memory micro-benchmarks don't tell the whole story of real-world reporting pipelines where disk I/O, parsing, and GC allocations usually dominate.

In development, we already track metrics like peak heap/RSS memory usage, allocation rates (via async-profiler), cold vs. warmed JVM runs, and high-cardinality grouping with null bitmasks.

Packaging this into a full end-to-end pipeline benchmark (Parquet read → Filter & Group-By → CSV export) with complete environment details, schemas, and memory profiles is a great idea. I'll add this to our benchmark suite and publish the full report soon.

Thanks for the input!