Skip to content

Commit

Permalink
Fix O(n^2) code (#26951)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Use a set so that we're not iterating over every partition key


before:

<img width="1435" alt="Screenshot 2025-01-08 at 2 43 54 PM"
src="https://github.com/user-attachments/assets/8e4b1244-79ab-4082-bd71-2971d9e31f7d"
/>


after:

![image](https://github.com/user-attachments/assets/0cd69efa-0d0d-4f12-86ba-092c5e2a304e)
  • Loading branch information
salazarm authored Jan 8, 2025
1 parent b6be0b5 commit db898e1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,15 @@ function addKeyIndexesToMaterializedRanges(
}
if (partitions.__typename === 'DefaultPartitionStatuses') {
const dim = dimensions[0]!;
const materializedPartitionKeys = new Set(partitions.materializedPartitions);
const materializingPartitionKeys = new Set(partitions.materializingPartitions);
const failedPartitionKeys = new Set(partitions.failedPartitions);
const spans = assembleIntoSpans(dim.partitionKeys, (key) =>
partitions.materializedPartitions.includes(key)
materializedPartitionKeys.has(key)
? AssetPartitionStatus.MATERIALIZED
: partitions.materializingPartitions.includes(key)
: materializingPartitionKeys.has(key)
? AssetPartitionStatus.MATERIALIZING
: partitions.failedPartitions.includes(key)
: failedPartitionKeys.has(key)
? AssetPartitionStatus.FAILED
: AssetPartitionStatus.MISSING,
);
Expand Down

1 comment on commit db898e1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-bc4bw1zc6-elementl.vercel.app

Built with commit db898e1.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.