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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chrisjstevo
Copy link
Contributor

No description provided.

Copy link

netlify bot commented Feb 21, 2024

Deploy Preview for papaya-valkyrie-395400 ready!

Name Link
🔨 Latest commit 80baace
🔍 Latest deploy log https://app.netlify.com/sites/papaya-valkyrie-395400/deploys/65f1c88498a9a10008fbc0e7
😎 Deploy Preview https://deploy-preview-1214--papaya-valkyrie-395400.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@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

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.

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.

None yet

3 participants