Skip to content

Conversation

@wuchong
Copy link
Member

@wuchong wuchong commented Feb 6, 2017

Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the How To Contribute guide.
In addition to going through the list, please provide a meaningful description of your changes.

  • General

    • The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
    • The pull request addresses only one issue
    • Each commit in the PR has a meaningful commit message (including the JIRA id)
  • Documentation

    • Documentation has been added for new functionality
    • Old documentation affected by the pull request has been updated
    • JavaDoc for public methods has been added
  • Tests & Build

    • Functionality added by the pull request is covered by tests
    • mvn clean verify has been executed successfully locally or a Travis build has passed

Add a builder to create CsvTableSource. And I have also updated the documentation.

@wuchong wuchong force-pushed the CsvTableSource-builder-FLINK-5714 branch from 10ffca1 to 751e7a7 Compare February 7, 2017 02:07
- `fieldDelimiter(String delim)` Sets the field delimiter, `","` by default.
- `lineDelimiter(String delim)` Sets the line delimiter, `"\n"` by default.
- `quoteCharacter(Character quote)` Sets the quote character for String values, `null` by default.
- `commentPrefix(String prefix)` Sets a prefix to indicate comments, null by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we change to null to null to keep consistency

- `lineDelimiter(String delim)` Sets the line delimiter, `"\n"` by default.
- `quoteCharacter(Character quote)` Sets the quote character for String values, `null` by default.
- `commentPrefix(String prefix)` Sets a prefix to indicate comments, null by default.
- `ignoreFirstLine()` Ignore the first line. Not skip the first line by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

disabled by default?

* For example:
*
* {{{
* val source: CsvTableSource = new CsvTableSourceBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

CsvTableSourceBuilder should be CsvTableSource.builder()
and does this comment a little duplicated with method builder ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, new CsvTableSourceBuilder() should be new CsvTableSource.Builder(). The comment is a little duplicate. But I think it is reasonable to let user create a builder by the constructor, not only the static builder method.

*/
class Builder {

private val fieldNames: ListBuffer[String] = ListBuffer[String]()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we bind the name and type to a MutableMap and do some check when we adding fields? Like can not have duplicated filed names?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point!

ignoreFirstLine: Boolean = false,
ignoreComments: String = null,
lenient: Boolean = false)
private val path: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these two forms are identical

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I want to access these fields in the equals(Object) by that.path. The private val modifier will create getter/setter implicitly.

* @return a newly-created [[CsvTableSource]].
*/
def build: CsvTableSource = {
Preconditions.checkNotNull(path, "Path must not be null.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fields can not be empty too?

Copy link
Contributor

@KurtYoung KurtYoung left a comment

Choose a reason for hiding this comment

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

Thanks for the work, looks good to me, i only have some minor comments

@wuchong
Copy link
Member Author

wuchong commented Feb 10, 2017

Thank you for your advice. I will update the PR soon.

@wuchong
Copy link
Member Author

wuchong commented Feb 10, 2017

updated!

def build: CsvTableSource = {
Preconditions.checkNotNull(path, "Path must not be null.")
if (path == null) {
throw new IllegalArgumentException("Path must be defined.")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can still use Preconditions.checkArgument though.

Copy link
Contributor

@KurtYoung KurtYoung left a comment

Choose a reason for hiding this comment

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

LGTM

@twalthr
Copy link
Contributor

twalthr commented Feb 15, 2017

Looks good to merge. Merging...

@twalthr
Copy link
Contributor

twalthr commented Feb 15, 2017

I found another issue: We should use a LinkedHashMap otherwise the order of fields and types is not guaranteed. I fixed it and will merge this now.

@asfgit asfgit closed this in 6c310a7 Feb 15, 2017
@wuchong wuchong deleted the CsvTableSource-builder-FLINK-5714 branch May 15, 2017 02:12
hequn8128 pushed a commit to hequn8128/flink that referenced this pull request Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants