Comments (11)
May be I can try this!
from presto.
find . -type f -name '*java' -exec grep -nHI -e "ImmutableList.of()" \{\} + | wc -l
2078
from presto.
I don't think that will work since you didn't include the parentheses. Only no-args ImmutableList.of() can be replaced by Collections.emptyList().
from presto.
@elharo understood that and corrected myself.
from presto.
@elharo what's the motivation for this change?
from presto.
tldr; JDK > 3rd party library
https://stackoverflow.com/questions/43291202/collections-emptylist-vs-guavas-immutablelist-of
from presto.
@elharo from the SO post, I see one answer that lists two reasons:
- Why introduce a third party dependency when you can use whatever is already built-in to the JDK?
- The JDK factory uses a dedicated implementation for the empty list, vs. Guava uses an immutable list with no elements.
For point 1, I don't understand what the benefit is, unless we have some sort of overarching goal to remove our Guava dependency. We already have this dependency because we prefer immutability, so I don't understand why we would want to differentiate empty vs. non-empty immutable collections.
For point 2, I simply don't understand what sort of practical benefit this has. Can you attempt to explain it?
from presto.
I don't understand or care about #2 either. I do think #1 is important though for a number of reasons:
- It's more familiar to new developers. No third party library is going to be as well known as what's already in the JDK. The code is simply clearer to more people when it uses the standard libraries.
- The JDK has been far more stable over time than any third party library, Guava included. I've seen Guava go through cycles of well supported and not so well supported over the years. I've also watched compatibility promises change over the years (generally for the better). And of course it's far from out of the question that Google loses interest in Guava, lays off or reassigns the team, and ignores it for multiple years.
- Standard libraries are much more likely to be optimized in VMs than third party libraries.
- In this specific case, "emptyList" is a better name that makes the code clearer than "of". It more obviously expresses the intent
Bottom line: ImmutableList.of()
is a relic of quite old JDKs. Now that Presto is on JDK 8, it's long past the point where this was useful.
from presto.
I think arguments 1 and 2 would make more sense to me if there were suitable immutable alternatives for collections in the JDK. Such alternatives don't exist. Which leaves us with one way of doing things for empty lists, and a different way of doing things for non-empty lists. We still have the problem you mention of relying on Guava, because our non-empty lists will still use it. And in terms of familiarity, to me this just seems really hard to quantify in a codebase which already has so many quirks not found in many other Java projects. In short, I just view this as having a cost (two ways of creating immutable lists instead of one), and I'm not really convinced of the benefits.
For point 3, I would want to see something that proves we get some sort of non-negligible improvement, otherwise it just risks being a micro-optimization.
from presto.
I'm going to remove the good first issue
tag to allow time for alignment around this, we can add it back later.
from presto.
It doesn't help that the class hierarchy for lists has been borked since Java 1.1. The Liskov Substitution Principle requires that MutableList be the subtype and List not have any methods that ever throw UnsupportedOperationException, but I'm afraid that ship sailed long ago. :-(
from presto.
Related Issues (20)
- Timestamp logical type annotation not being stored when written from presto hive HOT 1
- Refactor queueing-related classes in presto-main module to a new presto-dispatcher module
- `prestodb/presto-native` on Docker Hub lacks self-documentation
- Fork existing presto-elasticsearch connector and create a presto-elasticsearch-6 version in preparation for moving to Elasticsearch 7.x support. HOT 1
- Distinguish between partitioning for join vs agg
- Add Exchange before GroupId to improve Partial Aggregation
- Add a new scheduler + exchange rules to support multiple table scans in a single stage
- Add support for streaming TopN rank HOT 1
- Confusing (B) in UI in console HOT 3
- Wrong results for timestamp cast of out of range timestamps in the year 292278994 HOT 4
- Iceberg REST configurable OAuth Endpoint
- Segmentation fault when exchange.http-client.enable-connection-pool=true in Presto C++ worker HOT 2
- Oracle not using BaseJdbcConfigs for user and password
- Is there any continuously updated grafana plugin for presto like grafana-trino? HOT 1
- SSL Enablement for Cassandra Connector
- Dropping of Iceberg tables, whose metadata is deleted from its S3 storage, taking too much time than expected.
- Function to split an IP prefix into subnets HOT 1
- Issue with druid selecting empty columns HOT 6
- Add SQL Support for ALTER VIEW In Presto
- Pushdown semijoin below agg if keys are subset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from presto.