升级对 Datastax Java API 的调用,这些 API 在 3 中消失了
Upgrading calls to Datastax Java APIs that are gone in 3
Datastax 3.x 驱动程序中现在已删除许多 API。他们被用来做 'framework' 级别的驱动程序包装器 类 我有。
https://github.com/datastax/java-driver/tree/3.0/upgrade_guide
升级指南没有提供如何替换对已删除 API 的调用的示例(无论如何我都很关心)。这里有几个缺失,我正在尝试升级我的代码。 'replaced' 有什么想法吗?
DataType.serialize(Object value, ProtocolVersion protocolVersion)
DataType.deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
DataType.asJavaClass()
DataType.Name.asJavaClass()
任何关于现在应该调用对这些方法的 API 调用的帮助都将不胜感激。
项目 #2 引用了通过自定义编解码器对数据类型所做的更改。 TypeCodec
不再附加到 DataType
,因为在驱动程序的 3.0 版本中,您可以为数据类型定义自己的编解码器。因此这些方法不再直接通过 DataType
.
提供
Custom codecs (JAVA-721) introduce several breaking changes and also modify a few runtime behaviors.
Here is a detailed list of breaking API changes:
...
DataType has no more references to TypeCodec, so most methods that dealt with serialization and deserialization of data types have been removed:
ByteBuffer serialize(Object value, ProtocolVersion protocolVersion)
Object deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
Class asJavaClass()
Custom Codecs should provide the details you need to accomplish everything needed if you have the DataType
by resolving the TypeCodec
for it using CodecRegistry.codecFor
或 TypeCodec
解析默认编解码器的静态方法。 TypeCodec
提供了你需要的方法,即:
TypeCodec<Long> bigIntCodec = TypeCodec.bigint();
bigIntCodec.serialize(10L, protocolVersion);
bigIntCodec.deserialize(bytes, protocolVersion);
Class<?> clazz = bigIntCodec.getJavaType().getRawType();
Datastax 3.x 驱动程序中现在已删除许多 API。他们被用来做 'framework' 级别的驱动程序包装器 类 我有。
https://github.com/datastax/java-driver/tree/3.0/upgrade_guide
升级指南没有提供如何替换对已删除 API 的调用的示例(无论如何我都很关心)。这里有几个缺失,我正在尝试升级我的代码。 'replaced' 有什么想法吗?
DataType.serialize(Object value, ProtocolVersion protocolVersion)
DataType.deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
DataType.asJavaClass()
DataType.Name.asJavaClass()
任何关于现在应该调用对这些方法的 API 调用的帮助都将不胜感激。
项目 #2 引用了通过自定义编解码器对数据类型所做的更改。 TypeCodec
不再附加到 DataType
,因为在驱动程序的 3.0 版本中,您可以为数据类型定义自己的编解码器。因此这些方法不再直接通过 DataType
.
Custom codecs (JAVA-721) introduce several breaking changes and also modify a few runtime behaviors.
Here is a detailed list of breaking API changes:
...
DataType has no more references to TypeCodec, so most methods that dealt with serialization and deserialization of data types have been removed:
ByteBuffer serialize(Object value, ProtocolVersion protocolVersion)
Object deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
Class asJavaClass()
Custom Codecs should provide the details you need to accomplish everything needed if you have the DataType
by resolving the TypeCodec
for it using CodecRegistry.codecFor
或 TypeCodec
解析默认编解码器的静态方法。 TypeCodec
提供了你需要的方法,即:
TypeCodec<Long> bigIntCodec = TypeCodec.bigint();
bigIntCodec.serialize(10L, protocolVersion);
bigIntCodec.deserialize(bytes, protocolVersion);
Class<?> clazz = bigIntCodec.getJavaType().getRawType();