absurdfarce commented on code in PR #1952:
URL:
https://github.com/apache/cassandra-java-driver/pull/1952#discussion_r1926063178
##########
core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java:
##########
@@ -196,7 +233,8 @@ public int hashCode() {
@Override
public String toString() {
- return Iterables.toString(this.list);
+ TypeCodec<T> subcodec = CodecRegistry.DEFAULT.codecFor(list.get(0));
Review Comment:
I mean, I... guess this is fine. But it seems to me like the current
implementation pretty much does... exactly what
[Iterables.toString()](https://javadoc.io/static/com.google.guava/guava/33.4.0-jre/com/google/common/collect/Iterables.html#toString(java.lang.Iterable))
does, right? Maybe I'm missing something there... but I don't think so. This
passes without issue:
```
$ git diff
diff --git
a/core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java
b/core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java
index 4e2fc77cf..69da04a9b 100644
--- a/core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java
+++ b/core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java
@@ -241,6 +241,8 @@ public class CqlVector<T> implements Iterable<T>,
Serializable {
.collect(Collectors.joining(", ", "[", "]"));
}
+ public String oldToString() { return Iterables.toString(this.list); }
+
/**
* Serialization proxy for CqlVector. Allows serialization regardless of
implementation of list
* field.
diff --git
a/core/src/test/java/com/datastax/oss/driver/api/core/data/CqlVectorTest.java
b/core/src/test/java/com/datastax/oss/driver/api/core/data/CqlVectorTest.java
index 3e0872cb9..208440d30 100644
---
a/core/src/test/java/com/datastax/oss/driver/api/core/data/CqlVectorTest.java
+++
b/core/src/test/java/com/datastax/oss/driver/api/core/data/CqlVectorTest.java
@@ -29,6 +29,7 @@ import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
+import java.time.LocalDate;
import java.time.LocalTime;
import java.util.AbstractList;
import java.util.ArrayList;
@@ -256,4 +257,15 @@ public class CqlVectorTest {
assertThat(e).isInstanceOf(ObjectStreamException.class);
}
}
+
+ @Test
+ public void compare_iterables_to_custom() {
+
+ CqlVector<String> stringVector = CqlVector.newInstance("abc", "def",
"ghi");
+
assertThat(stringVector.toString()).isEqualTo(stringVector.oldToString());
+ CqlVector<LocalTime> timeVector =
CqlVector.newInstance(LocalTime.now(), LocalTime.now(), LocalTime.now());
+ assertThat(timeVector.toString()).isEqualTo(timeVector.oldToString());
+ CqlVector<LocalDate> dateVector =
CqlVector.newInstance(LocalDate.now(), LocalDate.now(), LocalDate.now());
+ assertThat(dateVector.toString()).isEqualTo(dateVector.oldToString());
+ }
}
```
I guess I'd argue that unless our custom implementation gives us something
we don't get from the well-proven third-party lib I'd just as soon continue
using Iterables.toString()
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]