Datastax 中 pagingstate(作为字符串)的格式是什么
what is the format of pagingstate (as string) in 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)
分页状态对驱动程序有意义(source code),因此您需要提供有意义的值。
但是对于您的测试,您可以使用 Java driver tests:
中使用的相同值
PagingState emptyStatement = PagingState.fromString("00000000");;
对于我的单元测试,我需要创建一个虚拟 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)
分页状态对驱动程序有意义(source code),因此您需要提供有意义的值。
但是对于您的测试,您可以使用 Java driver tests:
中使用的相同值PagingState emptyStatement = PagingState.fromString("00000000");;