-
Notifications
You must be signed in to change notification settings - Fork 0
Changes Provider and Direct Comparison functionality #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
e772f24
init commit
CalebGerman 4fb6e47
Merge remote-tracking branch 'origin/master' into cgerman/secret-fron…
CalebGerman ac08bf7
WIP working on RPC
CalebGerman 60f371f
Frontend to backend comms
CalebGerman 8ed3041
Changeset downloaded
CalebGerman f59683a
Got Affans code working
CalebGerman 22e2410
Frontend has change elements from backend
CalebGerman 7ee0ffd
pushing new changed elements into manager
CalebGerman 716af60
Working all the way
CalebGerman 42bf6b8
Updated group helper
CalebGerman 74b777d
WIP
CalebGerman a61ca9f
WIP
CalebGerman a8fb1f3
WIP direct comparison result
CalebGerman 2ce1529
Added optimizations
CalebGerman 8a8f434
Adding timings
CalebGerman 1df5903
Merge remote-tracking branch 'origin/master' into cgerman/secret-fron…
CalebGerman e2bd4a3
Fixed merged files
CalebGerman 3dece23
Added more logging for timing
CalebGerman ee65f18
Added experiment.md
CalebGerman 0eda6d0
Updated experiment markdown
CalebGerman d7e3d7f
Updated table
CalebGerman a5257eb
updated table
CalebGerman f3ac4d3
Got new results
CalebGerman 488ad21
Initial pass at domain comparison processors. Allow options to contro…
diegopinate 983db29
Move transformation to changed elements to frontend, and keep the bac…
diegopinate 9a78eb4
Add driven property filter, ability to maintain driven element inform…
diegopinate 59e47d1
Initial handling for selecting driven elements from widget
diegopinate 0793515
Generalize Rpc interface naming and helpers. Track relationships that…
diegopinate 7ca29e7
Merge branch 'master' of https://github.com/iTwin/changed-elements-re…
diegopinate fc7d708
Fix visualization after merge conflicts
diegopinate dc1d9c0
Remove hacked-in driven type logic in favor of using customizable cal…
diegopinate 22b2166
Merge branch 'master' of https://github.com/iTwin/changed-elements-re…
diegopinate 0654647
Revert env file, add environment variable to use direct comparison vi…
diegopinate 7daf85f
Add changeset
diegopinate bf27bad
Add approved builds, fix build
diegopinate aba2bba
Update node and pnpm in workflows
diegopinate e110079
Fix linter and linting problems. Add interfaces for comparison metadata.
diegopinate 8f48a13
Add object-storage-azure to backend deps
diegopinate d8f56bb
Fix comment
diegopinate 32737f4
Comment clean-up.
diegopinate 582a2a2
Remove unused comment
diegopinate e877de2
Add docs to ChangedECInstanceCache
diegopinate 181fd51
Move checks above starting logic
diegopinate 097837f
Remove useless try block
diegopinate 2d0e1ab
Add appropriate null checks and remove comment
diegopinate 767831b
Add void
diegopinate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
"@itwin/changed-elements-react": minor | ||
--- | ||
|
||
_Frontend Enhancements:_ | ||
|
||
1. Provide consumers a way to inject their own changes and skip using the changed elements service altogether | ||
2. Provide colorization overrides for any special customization logic | ||
3. Provide a callback when changed instances are selected in the UI | ||
|
||
_Backend Enhancements:_ | ||
1. Initial ChangesRpcInterface and ChangesRpcImpl which aim to allow using the Partial EC Change Unifier in a simplified way | ||
2. The Rpc interface allows the app to provide relationships that they care about and marks any related changed ec instance with what relationships were affected that may drive the element for changes | ||
|
||
See VersionCompare initialization options (`changesProvider`, `colorOverrideProvider` and `onInstancesSelected`) for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"singleQuote": false, | ||
"trailingComma": "all", | ||
"printWidth": 150, | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Changed Elements React Experiment - Direct Comparison Workflow | ||
|
||
### HYPOTHESIS: | ||
If we use changeset group processing without processing the changed elements, then the result of the direct processing will be produced faster and will resemble GitHub's diff functionality by displaying a flat list of changes. | ||
|
||
### REASON FOR EXPERIMENT | ||
Changed elements undergo extensive processing to ensure a presentation-based summary of changes in an iModel. We aim to understand how a feature like Version Comparison would operate using raw changeset group results instead of presentation ruleset-based property path traversal. We expect faster loading times for Direct Comparison due to reduced processing, while still providing valuable output to the user. | ||
|
||
### EXPERIMENT | ||
We conducted multiple experiments to confirm our hypothesis. The steps were: | ||
|
||
1. Run the Version Compare V2 workflow (Post/Get/Display) for an iModel with an unprocessed job range. Record the time until the user can interact with the job-related information on the UI. | ||
2. Run the experimental Direct Comparison on the same unprocessed job version. Record the time until the user can interact with the job-related information on the UI. | ||
|
||
#### Results Table | ||
We tested across three different iModels of varying sizes in the DEV region to draw better conclusions. | ||
|
||
| Itwin | IModel | Number Of Changeset Processed (V2 / Direct Comparison) | V2 Processing Time till interaction in UI (ms) | V2 Number of Changed Elements Found | Direct Comparison Processing Time till interaction in UI (ms) | Direct Comparison Number of Changed Elements Found | % diff between V2 and Direct Processing | | ||
| -- | -- | -- | -- | -- | -- | -- | -- | | ||
| 1036c64d-7fbe-47fd-b03c-4ed7ad7fc829 | c87854bc-1197-4ed9-8d3d-ad9cb5fd1347 | 12 | 22133 | 5342 | 6536 | 28039 | 108.807% | | ||
| 1036c64d-7fbe-47fd-b03c-4ed7ad7fc829 | e657e0d6-fad1-4971-9c22-459bd400534b | 524 | 185067 | 109474 | 71375 | 314907 | 88.6688% | | ||
| 1036c64d-7fbe-47fd-b03c-4ed7ad7fc829 | b8571aeb-dc0b-405f-bf6b-42401af40dd1 | 23 | 109007 | 128803 | 26017 | 22348 | 122.926% | | ||
|
||
### RESULTS SUMMARY | ||
The most salient findings of our testing: | ||
|
||
1. On iModels with a vast amount of data to process, Direct Comparison is on average 106.8 % faster than V2 Comparison. | ||
2. The UI has more elements to process with the Direct Comparison workflow than with the V2 workflow. | ||
3. The larger the IModel/changeset range. The v2 processing is faster due to multiple agents used for processing. | ||
|
||
### CONCLUSION | ||
This experiment proved that the Direct Comparison workflow is viable and may be preferable in some situations for larger iModels due to its processing speed. Direct Comparison may be an efficacious solution to long waiting times if the user does not require the full information provided by property traversal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
packages/changed-elements-react/src/api/ChangedECInstanceCache.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { Id64String } from "@itwin/core-bentley"; | ||
import { ChangedECInstance } from "./VersionCompare.js"; | ||
import { ChangedElementEntry } from "./ChangedElementEntryCache.js"; | ||
|
||
/** | ||
* Used to maintain the ChangedECInstances when using a custom changesProvider | ||
* Useful to correlate the ChangedElementEntry with the ChangedECInstance | ||
*/ | ||
export class ChangedECInstanceCache { | ||
private readonly _cache: Map<Id64String, ChangedECInstance>; | ||
|
||
constructor() { | ||
this._cache = new Map<Id64String, ChangedECInstance>(); | ||
} | ||
|
||
/** | ||
* Creates a key for the ChangedECInstance based on its Id and Class Id | ||
* @param instance ChangedECInstance to create a key for | ||
* @returns Key string for the ChangedECInstance in the cache, formatted as "instanceId:classId" | ||
*/ | ||
private _getKey(instance: ChangedECInstance): string { | ||
return `${instance.ECInstanceId}:${instance.ECClassId}`; | ||
} | ||
|
||
/** | ||
* Initializes the cache with the given ChangedECInstances | ||
* The cache will be cleared before adding the instances | ||
* @param instances | ||
*/ | ||
public initialize(instances: ChangedECInstance[]): void { | ||
this._cache.clear(); | ||
for (const instance of instances) { | ||
this._cache.set(this._getKey(instance), instance); | ||
} | ||
} | ||
|
||
/** | ||
* Add instance to the cache | ||
* @param instance ChangedECInstance to add to the cache | ||
*/ | ||
public add(instance: ChangedECInstance): void { | ||
this._cache.set(this._getKey(instance), instance); | ||
} | ||
|
||
/** | ||
* Gets the ChangedECInstance from the cache based on the instanceId and classId | ||
* @param instanceId Id of the instance to get | ||
* @param classId Class Id of the instance to get | ||
* @returns ChangedECInstance if found, undefined otherwise | ||
*/ | ||
public get(instanceId: Id64String, classId: Id64String): ChangedECInstance | undefined { | ||
const key = `${instanceId}:${classId}`; | ||
return this._cache.get(key); | ||
} | ||
|
||
/** | ||
* Returns whether the cache contains the ChangedECInstance with the given instanceId and classId | ||
* @param instanceId Id of the instance to check | ||
* @param classId Class Id of the instance to check | ||
* @returns true if the cache contains the instance, false otherwise | ||
*/ | ||
public has(instanceId: Id64String, classId: Id64String): boolean { | ||
const key = `${instanceId}:${classId}`; | ||
return this._cache.has(key); | ||
} | ||
|
||
/** | ||
* Similar to get, but uses the ChangedElementEntry to find the instance | ||
* @param entry ChangedElementEntry to use for finding the instance | ||
* @returns ChangedECInstance if found, undefined otherwise | ||
*/ | ||
public getFromEntry(entry: ChangedElementEntry): ChangedECInstance | undefined { | ||
return this.get(entry.id, entry.classId); | ||
} | ||
|
||
/** | ||
* Returns all ChangedECInstances that are present in the cache that match the entries | ||
* @param entries | ||
* @returns | ||
*/ | ||
public mapFromEntries(entries: ChangedElementEntry[]): ChangedECInstance[] { | ||
const instances: ChangedECInstance[] = []; | ||
for (const entry of entries) { | ||
const instance = this.get(entry.id, entry.classId); | ||
if (instance) { | ||
instances.push(instance); | ||
} | ||
} | ||
return instances; | ||
} | ||
|
||
/** | ||
* Clears the cache of all ChangedECInstances | ||
*/ | ||
public clear(): void { | ||
this._cache.clear(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.