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

HBase typeclass #841

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

HBase typeclass #841

wants to merge 3 commits into from

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.

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