-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support for CQL3 Collections #10
Comments
You can have a look at the org.apache.cassandra.db.marshal package, it has a collection type. Haven't used the Collection type specifically, but I've already used the Decimal datatype successfully. I've already opened an issue to support implicits on those datatypes few weeks ago, you can easily use the example I posted with a Collection type. Open issue cassandra 2.0 datatypes: #8 Regards! |
@ra2085 Thanks! This ended up working flawlessly: import org.apache.cassandra.db.marshal.{UTF8Type, MapType}
implicit def ByteBuffer2MapSS(b: ByteBuffer): Map[String,String] =
MapType.getInstance(UTF8Type.instance, UTF8Type.instance).compose(b).toMap |
We should get the support for this in the next release RichByteBuffer Since we will be support CQL Auto Paging in next release and hence having DS driver as dependency, I was thinking of rewriting the RichByteBuffer using DataType. For this case it will look like - import com.datastax.driver.core.DataType
import scala.collection.JavaConverters._
implicit def MapSS2ByteBuffer(map: Map[String, String]): ByteBuffer = DataType.map(DataType.text(), DataType.text()).serialize(map.asJava)
implicit def ByteBuffer2MapSS(buffer: ByteBuffer): Map[String, String] = DataType.map(DataType.text(), DataType.text()).deserialize(buffer).asInstanceOf[java.util.Map[String, String]].asScala.toMap |
That looks much cleaner. |
Hi Rohit,
Is there any documentation regarding support for CQL3 collections?
Specifically, I'm trying to write a transformer for a table that looks like:
It seems there's no implicit converter inside
RichByteBuffer
forByteBuffer
toMap[String, String]
.Thanks,
--Abhinav
The text was updated successfully, but these errors were encountered: