cassandra - 如何使用 datastax 驱动程序将一组元组存储到 cassandra
问题描述
我正在尝试使用 Micronaut 和 Cassandra(当前版本3.11.10
)运行我的服务,并将作为一组元组的列存储到 Cassandra 中。
示例代码:
QueryBuilder
.insertInto(table)
.value("column", QueryBuilder.literal(items.map { it.toTuple() }.toSet())))
该toTuple()
方法只是将项目转换为Term
对象的扩展方法
当我这样做时,我收到以下错误:
Internal Server Error: Could not inline literal of type java.util.Collections$SingletonSet. This happens because the driver doesn't know how to map it to a CQL type. Try passing a TypeCodec or CodecRegistry to literal().
我已经在多个来源中在线检查过,但找不到一种简单的方法来将一组元组存储到数据库中而不实现我的 custom TypeCodec
。我确信我不是第一个遇到这个问题的人,我可能做错了一些事情,但是我找不到任何关于什么是正确方法的文档。
解决方案
推荐阅读
- javascript - 传递事件和 $event 之间有区别吗?
- plex - NZBGet - 安装问题。nzbget:找不到命令
- node.js - Nodemon中的神秘参数-r
- python - TypeError: wrapper() 接受 1 个位置参数,但给出了 2 个
- elasticsearch - 使用输入数组进行 Elasticsearch 过滤,其中
- c - 如何将 2 个大数字乘以字符串(使用之前添加 2 个字符串的函数)?C
- http - Flutter http请求上传mp3文件
- java - Android Studio 布局没有响应
- c++ - 使用 IMFSinkWriter 编码的视频的播放速度根据宽度变化
- java - 切换到新的 Google Maps SDK 时出现迁移错误