File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
core/src/main/java/com/datastax/oss/driver/internal/core/type/codec
integration-tests/src/test/java/com/datastax/oss/driver/core/data Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 3333import java .util .Iterator ;
3434import java .util .List ;
3535import java .util .NoSuchElementException ;
36+ import java .util .stream .Collectors ;
3637
3738public class VectorCodec <SubtypeT > implements TypeCodec <CqlVector <SubtypeT >> {
3839
@@ -95,8 +96,17 @@ public CqlVector<SubtypeT> decode(
9596
9697 @ NonNull
9798 @ Override
98- public String format (@ Nullable CqlVector <SubtypeT > value ) {
99- return value == null ? "NULL" : Iterables .toString (value );
99+ public String format (CqlVector <SubtypeT > value ) {
100+ if (value == null ) return "NULL" ;
101+
102+ // if the subtype is a string, double quote
103+ if (!value .isEmpty () && value .iterator ().next () instanceof String )
104+ return value .stream ()
105+ .map (s -> (String ) s )
106+ .map (s -> "\" " + s + "\" " )
107+ .collect (Collectors .joining (", " , "[" , "]" ));
108+
109+ return Iterables .toString (value );
100110 }
101111
102112 @ Nullable
Original file line number Diff line number Diff line change 4646import com .datastax .oss .driver .api .core .type .TupleType ;
4747import com .datastax .oss .driver .api .core .type .UserDefinedType ;
4848import com .datastax .oss .driver .api .core .type .codec .TypeCodec ;
49+ import com .datastax .oss .driver .api .core .type .reflect .GenericType ;
4950import com .datastax .oss .driver .api .testinfra .ccm .CcmRule ;
5051import com .datastax .oss .driver .api .testinfra .session .SessionRule ;
5152import com .datastax .oss .driver .categories .ParallelizableTests ;
@@ -266,8 +267,8 @@ public static Object[][] typeSamples() {
266267
267268 // change the vector subtype into arbitrary type
268269 if (o [0 ] == DataTypes .INT ) {
269- CqlVector <Float > vector = CqlVector .newInstance (1.1f , 2.2f , 3.3f );
270- samples .add (new Object [] {DataTypes .vectorOf (DataTypes .FLOAT , 3 ), vector });
270+ CqlVector <Byte > vector = CqlVector .newInstance (( byte ) 1 , ( byte ) 2 , ( byte ) 3 );
271+ samples .add (new Object [] {DataTypes .vectorOf (DataTypes .TINYINT , 3 ), vector });
271272 }
272273 return samples .stream ();
273274 })
You can’t perform that action at this time.
0 commit comments