Skip to content

Conversation

SariNusier
Copy link

@SariNusier SariNusier commented Nov 26, 2020

  • If ttl.column is set, the connector will use the value in that column to set the ttl of the record.
  • The ttl column will not be included in the fields of the record.

Sari Nusier added 4 commits November 26, 2020 10:26
- If ttl.column is set, the connector will use the value in that column to set the ttl of the record.
- The ttl column will not be included in the fields of the record.
- The ability to use a constant ttl is still there, but ttl.column takes precedence when both are set.
Copy link
Contributor

@fe2s fe2s left a comment

Choose a reason for hiding this comment

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

Hi @SariNusier
Thank you for the PR! It looks good in general.
Could you please also update documentation and tests?

override def encodeRow(keyName: String, value: Row): Array[Byte] = {
override def encodeRow(keyName: String, value: Row, ttlColumn: Option[String] = None): Array[Byte] = {
val fields = value.schema.fields.map(_.name)
val valuesArray = fields.map(f => value.getAs[Any](f))
Copy link
Contributor

Choose a reason for hiding this comment

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

should we exclude TTL column here as well?

}
.filter { case (k, _) =>
// don't store TTLs
ttlColumn match {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably more efficient in terms of the performance to check if ttlColumn is specified only once rather than for every field.

val encodedRow = persistence.encodeRow(keyName, row)
persistence.save(pipeline, key, encodedRow, ttl)
val encodedRow = persistence.encodeRow(keyName, row, ttlColumn)
val recordTTL = if (ttlColumn.isEmpty) ttl else row.getAs[Int](ttlColumn.get)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can rewrite it with val recordTTL = ttlColumn.map(v => row.getAs[Int](v)).getOrElse(ttl). It looks to be more idiomatic approach.

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.

2 participants