Skip to content

Commit 3f7d404

Browse files
committed
Merge commit '40a9a49d50fac6abed2a5bb2cc2627e4085a399b' of https://github.com/apache/cassandra-java-driver into pull-upstream-4.18.1-v3
2 parents 845b897 + 40a9a49 commit 3f7d404

File tree

1 file changed

+8
-6
lines changed
  • core/src/main/java/com/datastax/oss/driver/internal/core/type/codec

1 file changed

+8
-6
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/VectorCodec.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,19 @@ Elements should at least precede themselves with their size (along the lines of
127127
cqlType.getDimensions(), bytes.remaining()));
128128
}
129129

130+
ByteBuffer slice = bytes.slice();
130131
List<SubtypeT> rv = new ArrayList<SubtypeT>(cqlType.getDimensions());
131132
for (int i = 0; i < cqlType.getDimensions(); ++i) {
132-
ByteBuffer slice = bytes.slice();
133-
slice.limit(elementSize);
133+
// Set the limit for the current element
134+
int originalPosition = slice.position();
135+
slice.limit(originalPosition + elementSize);
134136
rv.add(this.subtypeCodec.decode(slice, protocolVersion));
135-
bytes.position(bytes.position() + elementSize);
137+
// Move to the start of the next element
138+
slice.position(originalPosition + elementSize);
139+
// Reset the limit to the end of the buffer
140+
slice.limit(slice.capacity());
136141
}
137142

138-
/* Restore the input ByteBuffer to its original state */
139-
bytes.rewind();
140-
141143
return CqlVector.newInstance(rv);
142144
}
143145

0 commit comments

Comments
 (0)