Efficiently pack a list of Longs in Scodec representation

168 Views Asked by At

I have a case class with a List[Long] attribute that I am converting into a token using the Scodec library. Right now, it is not efficient (space-wise) because I am using this codec:

listOfN(uint16, int64)

This is using all 64 bits even though my Longs are never more than a few thousand (as of now). Is there a built-in way in Scodec library to use only as many bits as absolutely needed?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

If your long values are non-negative, try using the vpbcd codec:

listOfN(uint16, vpbcd)

This encodes using variable length packed binary-coded decimal format.