Skip to content
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

Support Tap for SMB writes (addresses #5080) #5144

Merged
merged 9 commits into from
Jan 11, 2024
Merged

Conversation

clairemcginty
Copy link
Contributor

@clairemcginty clairemcginty commented Jan 8, 2024

addresses #5080

Simple implementation of Tap for SMB writes

todo:

  • Tap for SMB writes
  • Tap for SMB pre-keyed writes
  • Tap for SMB transforms

@@ -600,7 +600,7 @@ public abstract static class Write<K1, K2, V> extends PTransform<PCollection<V>,

abstract int getSorterMemoryMb();

abstract FileOperations<V> getFileOperations();
public abstract FileOperations<V> getFileOperations();
Copy link
Contributor Author

@clairemcginty clairemcginty Jan 8, 2024

Choose a reason for hiding this comment

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

We could get around the signature change by adding a new method to SortedBucketIO.Write like:

public Iterator<T> tapBucketFile(ResourceId resourceId) {
   return getFileOperations().open(resourceId);
}

but this seems overtly hacky to me - plus, we re-create a FileOperations instance for every bucket/shard combo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh it might be simplest to just make all these getters public 🤷‍♀️

val bucketFiles = self.context
.wrap(
writeResult
.get(new TupleTag("WrittenFiles"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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


ClosedTap(
bucketFiles.underlying
.flatMap(kv => fileOps.iterator(kv.getValue).asScala)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could keep the BucketShardId so the tap returns a mapping from Bucket ID --> records in that bucket - although we'd have to also find a way to implement this in test context (probably by making another SortedBucketIO.Write#getBucketMetadata public too and mapping the bucketing function over each elements)

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (54027fc) 63.42% compared to head (c3e7ca5) 63.55%.
Report is 2 commits behind head on main.

Files Patch % Lines
...cala/com/spotify/scio/smb/SortMergeTransform.scala 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5144      +/-   ##
==========================================
+ Coverage   63.42%   63.55%   +0.13%     
==========================================
  Files         291      291              
  Lines       10832    10845      +13     
  Branches      755      758       +3     
==========================================
+ Hits         6870     6893      +23     
+ Misses       3962     3952      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@clairemcginty clairemcginty marked this pull request as ready for review January 8, 2024 23:11
@clairemcginty clairemcginty merged commit dd5af6b into main Jan 11, 2024
11 checks passed
@clairemcginty clairemcginty deleted the smb-write-tap branch January 11, 2024 13:55
Comment on lines 199 to +201
sc.applyInternal(t)
ClosedTap[Nothing](EmptyTap)

val writeResult = sc.applyInternal(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Introduction of duplicated transform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants