Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Salesforce Functions (Java)で実装はどう変わるか
Search
CLB
July 01, 2022
Programming
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Salesforce Functions (Java)で 実装はどう変わるか
Salesforce Functions の実装を試しました。
・ライブラリーの使用方法
・並列実行
CLB
July 01, 2022
More Decks by CLB
See All by CLB
Salesforce 大規模開発で留意するトピック集
altyjp
0
1.3k
Other Decks in Programming
See All in Programming
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
Next.js: The final boss of Web Performance
guaca
0
260
Event is what happens
moro
2
840
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
570
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
ジョジョの世界をXRで再現する
mofurune
0
170
残高管理から台帳サービスへの進化
artoy
1
200
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
Jetpack Compose Mechanisms
skydoves
3
820
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
130
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
WENDY [Excerpt]
tessaabrams
14
40k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
The agentic SEO stack - context over prompts
schlessera
0
970
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Transcript
Salesforce functions (Java) で 実装はどう変わるか Sato Ryo
Hello! Sato Ryoです。(左はクレオです。) 仕事: ´ バックエンド( 業務処理の開発担当) です。 ´ Salesforce
歴 2.5 年くらいの初⼼者です。 趣味: • ネコ • キャンプ @altyjp
Salesforce functions GA 🎉 https://developer.salesforce.com/docs/platform/functions/overview
Java版の資料は少ない Node.js 版についてはいくつか資料がありますが、 Java版は資料が少ないように思います。 ´ クイックスタートガイド ´ https://developer.salesforce.com/docs/platform/functions/guide/create-function.html ´ しょっさん(Salesforce
の中の⼈)のブログ記事 ´ https://zenn.dev/sho7650/articles/f1b0c096847277 →Java 版を利⽤して気になった事を 検証していきたいと思います。
お品書き ´ ライブラリってどうなってるの︖ ´ 並列処理はできる︖効果ある︖ なお、実際のソースコードは以下にあります。 是⾮お試しください。 https://github.com/altyjp/Trying-SF-functions 注意事項︓ 問題により実際のFunctions
へのデプロイができなかったため、 本発表における実⾏時間などの値はローカル環境(MacBookAir 2018, Core i5, 8GB RAM)での実⾏結果を利⽤しております。 あくまで参考結果としてご覧ください。
ライブラリってどうなってるの︖ ´ Java で function を作成すると左記のようなファ イルが⽣成されます。 ´ Mavenを利⽤しているので、pom.xml に使いたい
ライブラリを記載することで利⽤する事ができます。
ライブラリが利⽤できるメリット ´ Apexではcsvなどを扱うライブラリ が無いため ⾃前で処理が必要になる。 ´ ライブラリを利⽤することで 安全かつ効率的にコーディング可 能。 //
opencsv で書き出す。 beanToCsv.write(accounts); // 出⼒ LOGGER.info(writer.toString()); // Account を Csv にする。 for(Account acc : accountList){ String accountId = acc.Id; String accountName = acc.Name; // ⾃前で組み⽴てが必要 String csvRow = '"' + accountId + '","' + accountName + '"'; csvStr.add(csvRow); } System.debug(csvStr); LibrarysampleFunction.java withoutLibrary.apex
並列実⾏は利⽤できる︖ 効果は︖
Apexでは並列処理を実装できないので ´ 重い処理でもforを利⽤しないといけない。 // 1000から5999までの素数を⾒つける for (Integer num : intList){
Boolean isPrime = true; for (Integer i = 2; i < num; i++) { if (Math.mod(num, i) == 0){ isPrime = false; break; } } // System.LimitException: Apex CPU time limit exceeded(10s以上) if (isPrime) { System.debug(num); } } processList.apex
Functions なら重い処理も爆速 ´ parallelStreamを利⽤して、複数のスレッドで処理を分散可能。 ´ 重い処理も⽐較にならない速度で実⾏できます。 ちなみに以下の処理、どのくらいの時間で終わると思いますか︖ // 1000から5999までの素数を⾒つける。 intList.parallelStream()
.filter(n -> isPrime(n)) .forEach(System.out::println); ParallelexecutionFunction.java
まとめ ´ ライブラリを利⽤することで安全かつ効率的に実装が⾏える。 ´ 特にCSVやyamlなどテキストデータを処理する場合。 ´ 他にはエクセル(.xlsx)などのこれまで対応できなかったバイナリファイルなども。 ´ 重い処理も並列実⾏で⾼速に実⾏できる。 ´
これにより、今までガバナ制限によって不可能だった処理も 1トランザクションで実⾏可能になるかもしれない。
Thank you!