-
Notifications
You must be signed in to change notification settings - Fork 702
Allow constructing a PailSource from a PailSpec #1424
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
Open
amazari
wants to merge
6
commits into
twitter:develop
Choose a base branch
from
amazari:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b684787
Add a PailSource ctor taking a PailSpec arg
6b43239
Merge remote-tracking branch 'upstream/develop' into develop
5eeb0bc
Merge remote-tracking branch 'upstream/develop' into develop
66f8f00
Use an empty array as default value for subpath
a246e83
Merge remote-tracking branch 'upstream/develop' into develop
2144b29
Make PailSource a TypeSink
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 |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ package com.twitter.scalding.commons.source | |
| import scala.reflect.ClassTag | ||
|
|
||
| import com.backtype.cascading.tap.PailTap | ||
| import com.backtype.hadoop.pail.PailStructure | ||
| import com.backtype.hadoop.pail.{ PailStructure, PailSpec } | ||
| import cascading.tap.Tap | ||
| import com.twitter.bijection.Injection | ||
| import com.twitter.scalding._ | ||
|
|
@@ -79,9 +79,16 @@ object PailSource { | |
|
|
||
| /** | ||
| * Generic version of Pail sink accepts a PailStructure. | ||
| * Prefer the override taking a PailSpec as it gives you finer control over pail configuration (compression for ex) | ||
| */ | ||
| def sink[T](rootPath: String, structure: PailStructure[T]): PailSource[T] = | ||
| new PailSource(rootPath, structure) | ||
| sink(rootPath, PailTap.makeSpec(null, structure)) | ||
|
|
||
| /** | ||
| * Generic version of Pail sink accepts a PailSpec. | ||
| */ | ||
| def sink[T](rootPath: String, spec: PailSpec): PailSource[T] = | ||
| new PailSource[T](rootPath, spec) | ||
|
|
||
| /** | ||
| * A Pail sink can also build its structure on the fly from a | ||
|
|
@@ -113,10 +120,19 @@ object PailSource { | |
|
|
||
| /** | ||
| * Generic version of Pail source accepts a PailStructure. | ||
| * Prefer the override taking a PailSpec as it gives you finer control over pail configuration (compression for ex) | ||
| */ | ||
| def source[T](rootPath: String, structure: PailStructure[T], subPaths: Array[List[String]]): PailSource[T] = { | ||
| assert(subPaths != null && subPaths.size > 0) | ||
| new PailSource(rootPath, structure, subPaths) | ||
| new PailSource[T](rootPath, PailTap.makeSpec(null, structure), subPaths) | ||
| } | ||
|
|
||
| /** | ||
| * Generic version of Pail source accepts a PailSpec. | ||
| */ | ||
| def source[T](rootPath: String, spec: PailSpec, subPaths: Array[List[String]]): PailSource[T] = { | ||
| assert(subPaths != null && subPaths.size > 0) | ||
| new PailSource[T](rootPath, spec, subPaths) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -145,15 +161,14 @@ 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]] = null)(implicit conv: TupleConverter[T]) | ||
| extends Source with Mappable[T] { | ||
| import Dsl._ | ||
|
|
||
| override def converter[U >: T] = TupleConverter.asSuperConverter[T, U](conv) | ||
| 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 } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| val opts = new PailTap.PailTapOptions(spec, fieldName, javaSubPath, null) | ||
| new PailTap(rootPath, opts) | ||
|
|
||
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.
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?