Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Salesforce Functions (Java)で実装はどう変わるか
Search
CLB
July 01, 2022
Programming
0
500
Salesforce Functions (Java)で 実装はどう変わるか
Salesforce Functions の実装を試しました。
・ライブラリーの使用方法
・並列実行
CLB
July 01, 2022
Tweet
Share
More Decks by CLB
See All by CLB
Salesforce 大規模開発で留意するトピック集
altyjp
0
1.2k
Other Decks in Programming
See All in Programming
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
160
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
410
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
技術同人誌をMCP Serverにしてみた
74th
1
450
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
710
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
48
32k
エラーって何種類あるの?
kajitack
5
320
PipeCDのプラグイン化で目指すところ
warashi
1
220
Create a website using Spatial Web
akkeylab
0
310
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
670
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
330
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
450
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1031
460k
The Invisible Side of Design
smashingmag
300
51k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
A designer walks into a library…
pauljervisheath
207
24k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
Six Lessons from altMBA
skipperchong
28
3.9k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
5
230
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Speed Design
sergeychernyshev
32
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!