spotify/magnolify

BigtableType field names shortening

stormy-ua opened this issue · 4 comments

Bigtable column qualifiers are stored as data for each cell, so the best option is to keep column names as short as possible. At the same time, in a user case class field names are supposed to be long enough to convey field designation. It would be great to annotate case class fields with an attribute having a shortened field name e.g.:

case class MyClass(@btfieldname("f") superDescriptiveField: String)

I was thinking about adding implicit ClassTag to the BigtableType apply function and use reflection to traverse the type and build fields map once and cache it. Wondering if there are any other thoughts how to do this.

This you can do already by abusing CaseMapper?
https://github.com/spotify/magnolify/blob/master/docs/bigtable.md

Alternatively you can retrieve annotations in magnolia, see how AvroType handles @doc and how EntityType handles @key.

Yes :) I was thinking about renaming CaseMapper to FieldNameMapper. Oh nice, I didn't know magnolia supports annotations. Thanks for the hint!

You're right, CaseMapper is misleading since you can do whatever to the string 😭

Closing as won't fix.