Skip to content

Commit

Permalink
Feedback from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
absurdfarce committed Jun 26, 2023
1 parent 8f7cb9c commit 88a01b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public static DataType custom(@NonNull String className) {
DefaultVectorType.VECTOR_CLASS_NAME.length() + 1, className.length() - 1));
DataType subType = classNameParser.parse(params.get(0), AttachmentPoint.NONE);
int dimensions = Integer.parseInt(params.get(1));
if (dimensions <= 0) {
throw new IllegalArgumentException(
String.format(
"Request to create vector of size %d, size must be positive", dimensions));
}
return new DefaultVectorType(subType, dimensions);
}
return new DefaultCustomType(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DefaultVectorType(DataType subtype, int dimensions) {
this.subtype = subtype;
}

/* ============== SequenceType interface ============== */
/* ============== ContainerType interface ============== */
@Override
public DataType getElementType() {
return this.subtype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import com.datastax.oss.driver.shaded.guava.common.base.Splitter;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
import com.datastax.oss.driver.shaded.guava.common.collect.Iterables;
import com.datastax.oss.driver.shaded.guava.common.collect.Streams;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand All @@ -30,6 +29,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

public class VectorCodec<SubtypeT> implements TypeCodec<List<SubtypeT>> {

Expand Down Expand Up @@ -134,6 +134,6 @@ private List<SubtypeT> from(@Nullable String value) {

return Streams.stream(Splitter.on(", ").split(value.substring(1, value.length() - 1)))
.map(subtypeCodec::parse)
.collect(ImmutableList.toImmutableList());
.collect(Collectors.toCollection(ArrayList::new));
}
}

0 comments on commit 88a01b7

Please sign in to comment.