Skip to content

Conversation

@RustedBones
Copy link
Contributor

Add hbase module to support conversion fromResult ant to Put mutation

@RustedBones RustedBones changed the title Hbase typeclass HBase typeclass Oct 4, 2023
import java.util.UUID
import scala.annotation.implicitNotFound
import scala.jdk.CollectionConverters.*
sealed trait HBaseType[T] extends Converter[T, Map[String, Array[Byte]], Map[String, Array[Byte]]] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sealed trait HBaseType[T] extends Converter[T, Map[String, Array[Byte]], Map[String, Array[Byte]]] {
sealed trait HBaseType[T] extends Converter[T, Map[String, Array[Byte]], Map[String, Array[Byte]]] {

Map(k -> toBytes(v))
}

// ////////////////////////////////////////////////
Copy link
Contributor

Choose a reason for hiding this comment

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

missing a comment here or is it just intended as a linebreak?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

linebreak as in the other modules

}
v.getOrElse(p.default)
}
// result is default if all fields are default
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm misunderstanding the construct lambda, it looks like result defaults if even one field is default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from the bigtable module. I don't get either why we use the Value wrapper. I'd see If I can clean that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #847

primitive[Double](java.lang.Double.BYTES)(_.getDouble)(_.putDouble(_))
implicit val hbfBoolean: Primitive[Boolean] =
from[Byte](_ == 1)(if (_) 1 else 0)
implicit val hbfUUID: Primitive[UUID] =
Copy link
Contributor

Choose a reason for hiding this comment

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

nice! should we include support for java.time classes as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe in an unsafe package. As there could be several way to store dates (string bytes, ms long bytes, ...), we should not arbitrarily prick one here.

@kellen
Copy link
Contributor

kellen commented Jan 31, 2025

See spotify/scio#5010 (comment)

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.

4 participants