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

DRAFT #1213 added example of rowbuilder interface #1214

Merged
merged 6 commits into from
Dec 13, 2024

Conversation

chrisjstevo
Copy link
Contributor

No description provided.

Copy link

netlify bot commented Feb 21, 2024

Deploy Preview for papaya-valkyrie-395400 canceled.

Name Link
🔨 Latest commit 1346cb3
🔍 Latest deploy log https://app.netlify.com/sites/papaya-valkyrie-395400/deploys/675c4a0fa287e800080d6c98

@rumakt
Copy link
Contributor

rumakt commented Feb 21, 2024

Looking good.

Copy link
Contributor

@junaidzm13 junaidzm13 left a comment

Choose a reason for hiding this comment

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

Looks good! Left a couple of comments, let me know what you think

}
override def setKey(key: String): RowBuilder = {
this.key = key
this
Copy link
Contributor

@junaidzm13 junaidzm13 Feb 21, 2024

Choose a reason for hiding this comment

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

Not sure if it applies here but would be worthwhile to think about:

It uses the same instance of the row builder so if somewhere we instantiate a row builder and share the same builder with other functions there is a chance that we might mutate the data in multiple places resulting in unexpected data changes and hard to find bugs.

For example:

def main() = {
  ...
  val rowBuilder = InMemMapRowBuilder().setKey("key")
  function1(rowBuilder)
  function2(rowBuilder)
}

def function1(rowBuilder: RowBuilder, ...) = {
  ...
  rowBuilder.setLong(col1, 50).asRow()
  ...
}

def function2(rowBuilder: RowBuilder) = {
  ...
  // key will be "" here
  rowBuilder.setString(col2, "ABC").asRow()
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is very true. Each caller should getetter own I think, but I think it's fair to assume different call sites shouldn't pass them across threads.
Will update and add notthreadsafe annotation

private val mutableMap = new mutable.HashMap[String, Any]()
private var key: String = ""
override def setLong(column: Column, v: Long): RowBuilder = {
mutableMap.put(column.name, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

For the future: might be able to check for type consistency by matching the type i.e. Long with column.dataType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was indeed my goal. So checking datatype of column matches call signature.
I will add that.

@chrisjstevo chrisjstevo force-pushed the issue_1213_rowbuilder branch from 80baace to ae9a2c0 Compare December 13, 2024 12:13
Copy link

linux-foundation-easycla bot commented Dec 13, 2024

CLA Missing ID CLA Not Signed

@chrisjstevo chrisjstevo merged commit 508676f into main Dec 13, 2024
14 of 15 checks passed
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.

3 participants