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
540
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
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
100
AHC070解法紹介
eijirou
0
120
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
140
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
1.1k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
400
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.2k
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
190
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
120
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
370
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.3k
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
990
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
600
Ruling the World: When Life Gets Gamed
codingconduct
0
330
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Code Review Best Practice
trishagee
74
20k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Chasing Engaging Ingredients in Design
codingconduct
0
310
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
Crafting Experiences
bethany
1
340
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!