datastax-java-driver - Datastax中分页状态(作为字符串)的格式是什么
问题描述
对于我的单元测试,我需要创建一个虚拟PagingState
值。
https://docs.datastax.com/en/latest-java-driver-api/com/datastax/driver/core/PagingState.html
我可以看到有一种fromString
方法可以PagingState
为我创建对象。但我需要以正确的格式提供字符串。
的格式是PagingState
什么?
我读到了The paging state is a array of 16 bytes
。我尝试执行以下操作
val pagingStateByteArray = Array[Byte](1.toByte,2.toByte,3.toByte,4.toByte,5.toByte,6.toByte,7.toByte,8.toByte,9.toByte,10.toByte,11.toByte,12.toByte,13.toByte,14.toByte,15.toByte,16.toByte)
val pagingState = PagingState.fromBytes(pagingStateByteArray) //make this more accurate. instance of PagingState
但有错误
Cannot deserialize paging state, invalid format. The serialized form was corrupted, or not initially generated from a PagingState object.
com.datastax.driver.core.exceptions.PagingStateException: Cannot deserialize paging state, invalid format. The serialized form was corrupted, or not initially generated from a PagingState object.
at com.datastax.driver.core.PagingState.<init>(PagingState.java:60)
at com.datastax.driver.core.PagingState.fromBytes(PagingState.java:170)
解决方案
分页状态对驱动程序(源代码)有意义,因此您需要提供有意义的值。
但是对于您的测试,您可以使用Java 驱动程序测试中使用的相同值:
PagingState emptyStatement = PagingState.fromString("00000000");;
推荐阅读
- javascript - Gatsby GraphQL 自定义日期格式字符串
- c# - 如何使用 C# iTextSharp 检测 PDF 中的矩形和框
- javascript - Woocommerce:如何将产品从 iframe 添加到购物车?
- java - 只有在重构包名称之后,才考虑在您的配置中定义一个 * 类型的 bean
- c# - VS2019 C# OleDB 在路径中使用“AppDomain.CurrentDomain.BaseDirectory”导致VS安装目录而不是项目目录
- google-docs - 如何将当前文件的位置插入googl docs?
- javascript - 我如何只用传单显示一个县?还是重建这张地图?
- symfony - ApiFilter - Altername 参数名称
- c++ - 是否允许使用偏移量将内存复制到普通的可复制类型?
- vba - 使用 VBA 在 3DExperience 2018 中发布元素