40. TECHNOLOGY
DIVISION
40
Resources
• Eclipse Collections website
http://www.eclipse.org/collections
• JavaOne 2015 – Eclipse Collections by Example
https://published-rs.lanyonevents.com/published/oracleus2015/sessionsFiles/1528/CON10915_2015-10-
28%20JavaOne%20-%20EclipseCollectionsByExample.pdf
• Eclipse Collections on GitHub
https://github.com/eclipse/eclipse-collections
https://github.com/eclipse/eclipse-collections/wiki
https://github.com/eclipse/eclipse-collections-kata
• JJUG CCC - GS CollectionsとJava 8 実用的で流暢なAPIで楽しい開発を!
http://www.goldmansachs.com/gs-collections/presentations/2015-04-11_JJUG_CCC.pdf
• Parallel-lazy Performance: Java 8 vs Scala vs GS Collections
http://www.infoq.com/presentations/java-streams-scala-parallel-collections
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
#ccc_gh4
Eclipse Collections update
Goldman Sachs
Technology division Vice President
Hiroshi Ito
Engineering at Goldman Sachs
Engineering at Goldman Sachs
Engineering at Goldman Sachs
Goldman Sachs
A leading global investment banking, securities and investment management firm that provides a wide range of financial services to a substantial and diversified client base that includes corporations, financial institutions, governments and high-net-worth individuals. Founded in 1869, the firm is headquartered in New York and maintains offices in all major financial centers around the world.
Goldman Sachs Technology Division:
We build solutions to some of the most complex problems, creating transformational technologies and developing systems that drive business and financial markets worldwide.
From GS Collections to Eclipse Collections
Basics
Benefit of Eclipse Collections compared to Streams and JCF
Learning Eclipse Collections by solving problems
Future roadmap
GS Collections
Open source Java collections framework developed in Goldman Sachs
Inspired by Smalltalk Collections Framework
In development since 2004
Hosted on GitHub w/ Apache 2.0 License in January 2012
github.com/goldmansachs/gs-collections
GS Collections Kata
Internal training developed in 2007
Taught to > 2,000 GS Java developers
Hosted on GitHub w/ Apache 2.0 License in January 2012
github.com/goldmansachs/gs-collections-kata
Trending Positively
Spring Reactor includes GS Collections as a dependency
Monthly Maven central downloads have risen since JavaOne 2014
In the Top 300 Java GitHub projects based on number of stars
It’s been talked about in Japan
There have been blog/Twitter posts after Java Day Tokyo 2015 and JJUG CCC 2015 Spring.
[cites]
[1] yy_yank. (2015, April 15). Javaのコレクションフレームワークで物足りないならGS Collections使ったほうが良いかもしれない [Blog post]. Retrieved from http://yyyank.blogspot.jp/2015/04/javagscollections.html[2] mike_neck. (2015, Apr 16). GS-Collectionsはcode kataで練習すると面白い [Blog post]. Retrieved from http://mike-neck.hatenadiary.com/entry/2015/04/16/075014[3] tokuhirom. (2015, Apr 16). GS Collections Kata をひと通りやった [Blog post]. Retrieved from http://blog.64p.org/entry/2015/04/16/094947[4] opengl-8080. (2015, Apr 15). GS Collections 使い方メモ [Qiita post]. Retriefed from http://qiita.com/opengl-8080/items/a13773e0653800e23323
[5] 俺九番. (2015, Sep 12). Javaコレクション系のライブラリ、GS Collections使いやすくて好きなので大体のプロジェクトやるときはまずこれ入れてる [Twitter post]. Retrieved from https://twitter.com/orekyuu/status/642356311791767552[6] Kiyoshi SATOH. (2015, Jun 22). GS CollectionsというJavaのコレクションのライブラリ。メソッドチェインで書けて、Java8のラムダ使えばJavaで色々と関数型で書ける良い感じなライブラリ。 / “Java - GS Collections 使い方…” http://htn.to/utfBWD [Twitter post]. Retrieved from https://twitter.com/stealthinu/status/612816288226787328[7]よこな. (2015, Apr 15). 話題沸騰中やな〜 "Java - GS Collections 使い方メモ by @opengl_8080 on @Qiita http://qiita.com/opengl-8080/items/a13773e0653800e23323 …" [Twitter post]. Retrieved from https://twitter.com/ihcomega/status/588348537156411392[8] toshi_miura. (2015, Apr 11). JJUG CCCで一番心に刺さったこと。「GS Collections」使ってみっか・・・である。 [Twitter post]. Retrieved from https://twitter.com/toshi_miura/status/586879465537417217[9]eiryu@西新宿篇. (2015, Apr 10). GS Collectionsアツいな / 他43コメント http://b.hatena.ne.jp/entry/www.goldmansachs.com/gs-collections/presentations/2015-04-08_JavaDayTokyo.pdf#tw?u=eiryu9 … “[PDF] ゴールドマン・サックスの Javaへの取り組み” http://htn.to/v3CtWq [Twitter post]. Retrieved from https://twitter.com/eiryu/status/586316836729262080
JavaOne2015 – Eclipse Collections by Example
Eclipse Collections
Eclipse Collections
Project @ Eclipse Foundation
https://projects.eclipse.org/proposals/eclipse-collections
Project lead: Don Raab / Hiroshi Ito
7.0, public Released on Jan 20th!
Oct 2015: Proposal submitted
Nov 2015: Project proposal approved
Dec 2015: Repository migration completed
Jan 20th 2016: Release review approved
Eclipse Collections 7.0 feature set is the same as GS Collections 7.0
Dual license under EPL/EDL
Packages renamed
com.gs -> org.eclipse
Eclipse Collections - Open for contributions!
Java 8 Streams
Functional APIs
Lazy only
Single use
Serial & Parallel
Primitive streams (3 types)
Extensible Collectors
Eclipse Collections 7.0
Eager & Lazy, Serial & Parallel
Memory efficient containers
Primitive containers (all 8)
Immutable containers
More container types
More iteration patterns
“With” method patterns
“target” method patterns
Covariant return types
Java 5+ compatible
How to initialize
There are factory methods for all containers, such as List, Set, Bag, Map, Multimap etc. You can choose either methods of() or with().
There are factories for both Mutable and Immutable.
You can create empty collections by empty(), of(), with().
There are memory efficient fixed size factories for some containers like List, Set and Map etc.
There are factory methods for all primitive containers.
You can create ranged int collections with IntInterval.
Benefit of Eclipse Collections compared to Streams and JCF
You can write codes in more concise manner
You can leverage method references in more cases
You can write codes in better readability.
You can reuse the collection
More memory efficient (HashSet vs UnifiedSet)
More memory efficient (HashMap vs UnifiedMap)
More memory efficient (primitive collections)
You can write Exception handling in more concise manner.
Learning Eclipse Collections by solving problems
(please try to solve them with JDK Collections, Streams and compare yourself)
You want to implement a simple shopping cart. To make it easy, assume items are simple Strings. After executing each operation below, output the strings like below with the order of item string.
Operation1: Add “Item1” to the cart.
Operation2: Add “Item2” to the cart.
Operation3: Add “Item1” to the cart.
Operation4: Add “Item3” with 3 quantity to the cart.
Outputs:
“There are 2 Item1”
“There is 1 Item2”
“There are 3 Item3”
How would you implement?
(in Japanese, there is no difference between “are” and “is”, so the output is simpler)
You want to implement a simple shopping cart. To make it easy, assume items are simple Strings. After executing each operation below, output the strings like below with the order of item string.
Operation1: Add “Item1” to the cart.
Operation2: Add “Item2” to the cart.
Operation3: Add “Item1” to the cart.
Operation4: Add “Item3” with 3 quantity to the cart.
Outputs:
“There are 2 Item1”
“There is 1 Item2”
“There are 3 Item3”
How would you implement?
(in Japanese, there is no difference between “are” and “is”, so the output is simpler)
You want to implement a functionality to match a gift with each member at random. Given the strings below,
Member: "Hiroshi", "Yusuke", "Fumio", "Shotaro", "Tatsuya", "Sumire"
Gifts: "Smart Phone", "PC", "Video Game", "Guitar", "Robot", "Media Player“
match each member and gift at random, and output the strings such as below.
Output example:
Shotaro got Smart Phone!
Sumire got PC!
Hiroshi got Video Game!
Fumio got Guitar!
Tatsuya got Robot!
Yusuke got Media Player!
How would you implement?
You want to implement a functionality to match a gift with each member at random. Given the strings below,
Member: "Hiroshi", "Yusuke", "Fumio", "Shotaro", "Tatsuya", "Sumire"
Gifts: "Smart Phone", "PC", "Video Game", "Guitar", "Robot", "Media Player“
match each member and gift at random, and output the strings such as below.
Output example:
Shotaro got Smart Phone!
Sumire got PC!
Hiroshi got Video Game!
Fumio got Guitar!
Tatsuya got Robot!
Yusuke got Media Player!
How would you implement?
You want to implement a batching logic. Given a collections with 1,000,000 elements, you want to process 2,000 elements per batch.
How would you implement?
You want to implement a batching logic. Given a collections with 1,000,000 elements, you want to process 2,000 elements per batch.
How would you implement?
Given there are 2 sets of people below.
Band member: “Ken”, “Irene”, “Hiroshi”
Java community member: “Fumio”, “Sumire”, “Yusuke”, “Hiroshi”
Write a program that outputs strings such like below based on the 2 sets.
Output example:
Belongs to both band and Java community: Hiroshi
Belongs to either band or Java community: Fumio, Sumire, Ken, Hiroshi, Irene, Yusuke
Belongs to band only: Ken, Irene
Belongs to Java community only: Fumio, Sumire, Yusuke
How would you implement?
Given there are 2 sets of people below.
Band member: “Ken”, “Irene”, “Hiroshi”
Java community member: “Fumio”, “Sumire”, “Yusuke”, “Hiroshi”
Write a program that outputs strings such like below based on the 2 sets.
Output example:
Belongs to both band and Java community: Hiroshi
Belongs to either band or Java community: Fumio, Sumire, Ken, Hiroshi, Irene, Yusuke
Belongs to band only: Ken, Irene
Belongs to Java community only: Fumio, Sumire, Yusuke
How would you implement?
You have a string collection like below. You want to extract the digit parts only, and create a new string collection.
["[A12345]", "[A99234]", "[A43156]", "[A55324]“]
Output example
[12345, 99234, 43156, 55324]
How would you implement?
You have a string collection like below. You want to extract the digit parts only, and create a new string collection.
["[A12345]", "[A99234]", "[A43156]", "[A55324]“]
Output example
[12345, 99234, 43156, 55324]
How would you implement?
* This is a new feature introduced in version 7.0
* There is also CodePointAdapter which can handle surrogate pairs, too
Learning Eclipse Collections by solving problems.
If you want to learn more about Eclipse Collections, try solving Kata, too.
GS Collections Kata
Training material by passing unit test one by one
It’s the best material to learn Eclipse Collections/GS Collections
It’s used in Goldman Sachs trainings
You can also learn Streams and Lambda with Kata
Eclipse Collections Roadmap
Eclipse Collections 7.1 – 2016 Q1
Minor updates and brush up OSS characteristics
Migrate GS Collections Kata to Eclipse Collections Kata
Feature enhancements and performance improvement
Enrich documentation and tutorials
Increase contributors, committers
Eclipse Collections 8.0 – 2016 Q2/Q3
Make Eclipse Collections functional interfaces extend Java 8 functional interfaces
Create our own Streams and override the stream() method for better performance
Add new API methods that return Optional
Use default methods to reduce lines of code and jar size
Eclipse Collections accepts contributions
Please let us know if you’re interested in contributing!!
How To Contribute: https://github.com/eclipse/eclipse-collections/blob/master/CONTRIBUTING.md
Summary: Sign Eclipse Foundation CLA and submit pull-requests
Developer mailing list: https://dev.eclipse.org/mailman/listinfo/collections-dev
Issues: https://github.com/eclipse/eclipse-collections/issues
Contribution examples:
Sign up to the issues you’re interested in, and implement
Write documentation/tutorial, and/or translate to Japanese
Translate Kata to Japanese