You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/01/19 17:26:48 UTC

[GitHub] [incubator-hudi] lamber-ken commented on issue #1245: [MINOR] Replace Collection.size > 0 with Collection.isEmpty()

lamber-ken commented on issue #1245: [MINOR] Replace Collection.size > 0 with Collection.isEmpty()
URL: https://github.com/apache/incubator-hudi/pull/1245#issuecomment-576026737
 
 
   hi @vinothchandar @smarthi thanks for review this pr.
   
   Here are my thoughts:
   1, It's right that some collections use `size()==0` inside their `isEmpty()` method, but that doesn't mean that they all do, for example `java.util.concurrent.ConcurrentSkipListSet`. 
   The [ConcurrentSkipListSet documentation](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html) says:
   ```
   Beware that, unlike in most collections, the size method is not a constant-time operation.
   ```
   It means that `.size()` can be O(1) or O(N), depending on the data structure; `.isEmpty()` is never O(N).
   
   <br>
   
   2, IDE always prompts me to make changes.
   
   ![image](https://user-images.githubusercontent.com/20113411/72685195-af0ccd00-3b22-11ea-8e11-24051be6e26f.png)
   
   <br>
   
   3, In hudi project, some codes use `isEmpty()`, some codes `size() > 0`
   
   ![image](https://user-images.githubusercontent.com/20113411/72685273-715c7400-3b23-11ea-9fb8-090c81f469d6.png)
   
   <br>
   
   4, `isEmpty()` is a clearer definition of what it is we actually care about, IMO, it's more understandable.
   
   
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services