You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "jberragan (via GitHub)" <gi...@apache.org> on 2024/09/03 22:18:40 UTC
Re: [PR] CASSANDRA-19815: Decouple Cassandra types from Spark types so Cassandra types can be u… [cassandra-analytics]
jberragan commented on code in PR #71:
URL: https://github.com/apache/cassandra-analytics/pull/71#discussion_r1742768323
##########
cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/DataTypeSerializationTests.java:
##########
@@ -152,151 +153,153 @@ public void testUUID()
public void testLong()
{
qt().forAll(TestUtils.bridges()).checkAssert(bridge -> {
- assertTrue(bridge.bigint().deserialize(bridge.bigint().serialize(Long.MAX_VALUE)) instanceof Long);
- assertEquals(Long.MAX_VALUE, bridge.bigint().deserialize(
- ByteBuffer.allocate(8).putLong(0, Long.MAX_VALUE)));
+ assertTrue(bridge.bigint().deserializeToType(bridge.typeConverter(), bridge.bigint().serialize(Long.MAX_VALUE)) instanceof Long);
+ assertEquals(Long.MAX_VALUE, bridge.bigint().deserializeToType(bridge.typeConverter(),
+ ByteBuffer.allocate(8).putLong(0, Long.MAX_VALUE)));
qt().forAll(integers().all())
- .checkAssert(integer -> assertEquals((long) integer, bridge.bigint().deserialize(
- bridge.bigint().serialize((long) integer))));
- assertEquals(Long.MAX_VALUE, bridge.bigint().deserialize(bridge.bigint().serialize(Long.MAX_VALUE)));
- assertEquals(Long.MIN_VALUE, bridge.bigint().deserialize(bridge.bigint().serialize(Long.MIN_VALUE)));
+ .checkAssert(integer -> assertEquals((long) integer, bridge.bigint().deserializeToType(bridge.typeConverter(),
+ bridge.bigint().serialize((long) integer))));
+ assertEquals(Long.MAX_VALUE, bridge.bigint().deserializeToJavaType(bridge.bigint().serialize(Long.MAX_VALUE)));
+ assertEquals(Long.MIN_VALUE, bridge.bigint().deserializeToJavaType(bridge.bigint().serialize(Long.MIN_VALUE)));
qt().withExamples(MAX_TESTS)
.forAll(longs().all())
- .checkAssert(aLong -> assertEquals(aLong, bridge.bigint().deserialize(
- bridge.bigint().serialize(aLong))));
+ .checkAssert(aLong -> assertEquals(aLong, bridge.bigint().deserializeToType(bridge.typeConverter(),
+ bridge.bigint().serialize(aLong))));
});
}
@Test
public void testDecimal()
{
qt().forAll(TestUtils.bridges()).checkAssert(bridge -> {
- assertTrue(bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(500L))) instanceof Decimal);
- assertEquals(Decimal.apply(500), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(500L))));
- assertNotSame(Decimal.apply(501), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(500L))));
- assertEquals(Decimal.apply(-1), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(-1L))));
- assertEquals(Decimal.apply(Long.MAX_VALUE), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(Long.MAX_VALUE))));
- assertEquals(Decimal.apply(Long.MIN_VALUE), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(Long.MIN_VALUE))));
- assertEquals(Decimal.apply(Integer.MAX_VALUE), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(Integer.MAX_VALUE))));
- assertEquals(Decimal.apply(Integer.MIN_VALUE), bridge.decimal().deserialize(
- bridge.decimal().serialize(BigDecimal.valueOf(Integer.MIN_VALUE))));
+ assertTrue(bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(500L))) instanceof Decimal);
+ assertEquals(Decimal.apply(500), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(500L))));
+ assertNotSame(Decimal.apply(501), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(500L))));
+ assertEquals(Decimal.apply(-1), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(-1L))));
+ assertEquals(Decimal.apply(Long.MAX_VALUE), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(Long.MAX_VALUE))));
+ assertEquals(Decimal.apply(Long.MIN_VALUE), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal().serialize(BigDecimal.valueOf(Long.MIN_VALUE))));
+ assertEquals(Decimal.apply(Integer.MAX_VALUE), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal()
+ .serialize(BigDecimal.valueOf(Integer.MAX_VALUE))));
+ assertEquals(Decimal.apply(Integer.MIN_VALUE), bridge.decimal().deserializeToType(bridge.typeConverter(),
+ bridge.decimal()
+ .serialize(BigDecimal.valueOf(Integer.MIN_VALUE))));
Review Comment:
I made the update here: https://github.com/apache/cassandra-analytics/pull/71/commits/b47f6fe3d4d04a1b77a5a6f2635c9d599a70c488
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org