-
Notifications
You must be signed in to change notification settings - Fork 708
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
Allow constructing a PailSource from a PailSpec #1424
base: develop
Are you sure you want to change the base?
Conversation
Exposing a PailSpec-taking ctor give more flexibility in PailSource construction. For example, compression and/or sizing policy can be set.
@@ -153,7 +169,6 @@ class PailSource[T] private (rootPath: String, structure: PailStructure[T], subP | |||
val fieldName = "pailItem" | |||
|
|||
lazy val getTap = { | |||
val spec = PailTap.makeSpec(null, structure) | |||
val javaSubPath = if ((subPaths == null) || (subPaths.size == 0)) null else subPaths map { _.asJava } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the constructor setting up the null for the list is private, and we only seem to care if the path is empty or not. Can we just default subPaths to an empty list and not need to do null checking?
Assertions in factory functions and sane default value for the subPath field of PailSource remove the need for null-checking the val when creating a Tap.
@@ -145,7 +161,7 @@ object PailSource { | |||
} | |||
} | |||
|
|||
class PailSource[T] private (rootPath: String, structure: PailStructure[T], subPaths: Array[List[String]] = null)(implicit conv: TupleConverter[T]) | |||
class PailSource[T] private (rootPath: String, spec: PailSpec, subPaths: Array[List[String]] = Array.empty)(implicit conv: TupleConverter[T]) | |||
extends Source with Mappable[T] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add with TypedSink[T]
? Is there any reason why you can't write to this?
Alexandre Mazari seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
By allowing a PailSource to be constructed from a PailSpec, this patch gives more flexibility to client code. For example, it is is now possible to set compression and/or sizing policy.
For backward compatibility sake, it is still possible to construct a source from a PailStructure. In that case, a PailSpec is materialized using PailTap.makeSpec facility in the same manner it was previously done.