Skip to content

Commit 898af58

Browse files
authored
Merge branch 'main' into JAVA-4586_bulk-write
2 parents 397cd1d + bdd4af2 commit 898af58

File tree

87 files changed

+6279
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+6279
-678
lines changed

.evergreen/run-kotlin-tests.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
3131
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
3232
fi
3333

34-
echo "Running Kotlin tests"
35-
3634
./gradlew -version
37-
./gradlew kotlinCheck -Dorg.mongodb.test.uri=${MONGODB_URI} ${MULTI_MONGOS_URI_SYSTEM_PROPERTY}
35+
36+
echo "Running Kotlin Unit Tests"
37+
./gradlew :bson-kotlin:test :bson-kotlinx:test :driver-kotlin-sync:test :driver-kotlin-coroutine:test :driver-kotlin-extensions:test
38+
39+
echo "Running Kotlin Integration Tests"
40+
./gradlew :driver-kotlin-sync:integrationTest :driver-kotlin-coroutine:integrationTest -Dorg.mongodb.test.uri=${MONGODB_URI} ${MULTI_MONGOS_URI_SYSTEM_PROPERTY}

.evergreen/ssdlc-report.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ printf "\nCreating SpotBugs SARIF reports\n"
6565
set +e
6666
# This `gradlew` command is expected to exit with a non-zero exit status,
6767
# because it reports all the findings that we normally explicitly exclude as "No Fix Needed"/"False Positive".
68-
./gradlew -PssdlcReport.enabled=true --continue -x test -x integrationTest -x spotlessApply check scalaCheck kotlinCheck
68+
./gradlew -PssdlcReport.enabled=true --continue -x test -x integrationTest -x spotlessApply check scalaCheck
6969
set -e
7070
printf "\nSpotBugs created the following SARIF reports\n"
7171
IFS=$'\n'

.evergreen/static-checks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE[0]:-$0}")"
1212
echo "Compiling JVM drivers"
1313

1414
./gradlew -version
15-
./gradlew -PxmlReports.enabled=true --info -x test -x integrationTest -x spotlessApply clean check scalaCheck kotlinCheck jar testClasses docs
15+
./gradlew -PxmlReports.enabled=true --info -x test -x integrationTest -x spotlessApply clean check scalaCheck jar testClasses docs

THIRD-PARTY-NOTICES

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,26 @@ https://github.com/mongodb/mongo-java-driver.
161161
See the License for the specific language governing permissions and
162162
limitations under the License.
163163

164+
8) The following files (originally from https://github.com/Litote/kmongo):
165+
166+
Filters.kt
167+
Properties.kt
168+
KPropertyPath.kt
169+
FiltersTest.kt
170+
KPropertiesTest.kt
171+
172+
Copyright 2008-present MongoDB, Inc.
173+
Copyright (C) 2016/2022 Litote
174+
175+
Licensed under the Apache License, Version 2.0 (the "License");
176+
you may not use this file except in compliance with the License.
177+
You may obtain a copy of the License at
178+
179+
http://www.apache.org/licenses/LICENSE-2.0
180+
181+
Unless required by applicable law or agreed to in writing, software
182+
distributed under the License is distributed on an "AS IS" BASIS,
183+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184+
See the License for the specific language governing permissions and
185+
limitations under the License.
186+

bson-kotlin/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ spotbugs { showProgress.set(true) }
111111
// ===========================
112112
// Test Configuration
113113
// ===========================
114-
tasks.create("kotlinCheck") {
115-
description = "Runs all the kotlin checks"
116-
group = "verification"
117-
118-
dependsOn("clean", "check")
119-
tasks.findByName("check")?.mustRunAfter("clean")
120-
}
121114

122115
tasks.test { useJUnitPlatform() }
123116

bson-kotlinx/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ spotbugs { showProgress.set(true) }
128128
// ===========================
129129
// Test Configuration
130130
// ===========================
131-
tasks.create("kotlinCheck") {
132-
description = "Runs all the kotlin checks"
133-
group = "verification"
134-
135-
dependsOn("clean", "check")
136-
tasks.findByName("check")?.mustRunAfter("clean")
137-
}
138131

139132
tasks.test { useJUnitPlatform() }
140133

bson/src/main/org/bson/Vector.java renamed to bson/src/main/org/bson/BinaryVector.java

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,19 @@
2020
import static org.bson.assertions.Assertions.notNull;
2121

2222
/**
23-
* Represents a vector that is stored and retrieved using the BSON Binary Subtype 9 format.
24-
* This class supports multiple vector {@link DataType}'s and provides static methods to create
25-
* vectors.
26-
* <p>
27-
* Vectors are densely packed arrays of numbers, all the same type, which are stored efficiently
28-
* in BSON using a binary format.
23+
* Binary Vectors are densely packed arrays of numbers, all the same type, which are stored and retrieved efficiently using the BSON Binary
24+
* Subtype 9 format. This class supports multiple vector {@link DataType}'s and provides static methods to create vectors.
2925
* <p>
3026
* <b>NOTE:</b> This class should be treated as <b>sealed</b>: it must not be extended or implemented by consumers of the library.
3127
*
3228
* @mongodb.server.release 6.0
3329
* @see BsonBinary
3430
* @since 5.3
3531
*/
36-
public abstract class Vector {
32+
public abstract class BinaryVector {
3733
private final DataType dataType;
3834

39-
Vector(final DataType dataType) {
35+
BinaryVector(final DataType dataType) {
4036
this.dataType = dataType;
4137
}
4238

@@ -56,18 +52,18 @@ public abstract class Vector {
5652
* </pre>
5753
* <p>
5854
* NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
59-
* in the created {@link PackedBitVector} instance.
55+
* in the created {@link PackedBitBinaryVector} instance.
6056
*
6157
* @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
6258
* @param padding The number of least-significant bits (0 to 7) to ignore in the final byte of the vector data.
63-
* @return A {@link PackedBitVector} instance with the {@link DataType#PACKED_BIT} data type.
59+
* @return A {@link PackedBitBinaryVector} instance with the {@link DataType#PACKED_BIT} data type.
6460
* @throws IllegalArgumentException If the padding value is greater than 7.
6561
*/
66-
public static PackedBitVector packedBitVector(final byte[] data, final byte padding) {
62+
public static PackedBitBinaryVector packedBitVector(final byte[] data, final byte padding) {
6763
notNull("data", data);
6864
isTrueArgument("Padding must be between 0 and 7 bits. Provided padding: " + padding, padding >= 0 && padding <= 7);
6965
isTrueArgument("Padding must be 0 if vector is empty. Provided padding: " + padding, padding == 0 || data.length > 0);
70-
return new PackedBitVector(data, padding);
66+
return new PackedBitBinaryVector(data, padding);
7167
}
7268

7369
/**
@@ -77,14 +73,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
7773
* with values in the range [-128, 127].</p>
7874
* <p>
7975
* NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
80-
* in the created {@link Int8Vector} instance.
76+
* in the created {@link Int8BinaryVector} instance.
8177
*
8278
* @param data The byte array representing the {@link DataType#INT8} vector data.
83-
* @return A {@link Int8Vector} instance with the {@link DataType#INT8} data type.
79+
* @return A {@link Int8BinaryVector} instance with the {@link DataType#INT8} data type.
8480
*/
85-
public static Int8Vector int8Vector(final byte[] data) {
81+
public static Int8BinaryVector int8Vector(final byte[] data) {
8682
notNull("data", data);
87-
return new Int8Vector(data);
83+
return new Int8BinaryVector(data);
8884
}
8985

9086
/**
@@ -93,50 +89,50 @@ public static Int8Vector int8Vector(final byte[] data) {
9389
* A {@link DataType#FLOAT32} vector is a vector of floating-point numbers, where each element in the vector is a float.</p>
9490
* <p>
9591
* NOTE: The float array `data` is not copied; changes to the provided array will be reflected
96-
* in the created {@link Float32Vector} instance.
92+
* in the created {@link Float32BinaryVector} instance.
9793
*
9894
* @param data The float array representing the {@link DataType#FLOAT32} vector data.
99-
* @return A {@link Float32Vector} instance with the {@link DataType#FLOAT32} data type.
95+
* @return A {@link Float32BinaryVector} instance with the {@link DataType#FLOAT32} data type.
10096
*/
101-
public static Float32Vector floatVector(final float[] data) {
97+
public static Float32BinaryVector floatVector(final float[] data) {
10298
notNull("data", data);
103-
return new Float32Vector(data);
99+
return new Float32BinaryVector(data);
104100
}
105101

106102
/**
107-
* Returns the {@link PackedBitVector}.
103+
* Returns the {@link PackedBitBinaryVector}.
108104
*
109-
* @return {@link PackedBitVector}.
105+
* @return {@link PackedBitBinaryVector}.
110106
* @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
111107
* type before calling this method.
112108
*/
113-
public PackedBitVector asPackedBitVector() {
109+
public PackedBitBinaryVector asPackedBitVector() {
114110
ensureType(DataType.PACKED_BIT);
115-
return (PackedBitVector) this;
111+
return (PackedBitBinaryVector) this;
116112
}
117113

118114
/**
119-
* Returns the {@link Int8Vector}.
115+
* Returns the {@link Int8BinaryVector}.
120116
*
121-
* @return {@link Int8Vector}.
117+
* @return {@link Int8BinaryVector}.
122118
* @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
123119
* type before calling this method.
124120
*/
125-
public Int8Vector asInt8Vector() {
121+
public Int8BinaryVector asInt8Vector() {
126122
ensureType(DataType.INT8);
127-
return (Int8Vector) this;
123+
return (Int8BinaryVector) this;
128124
}
129125

130126
/**
131-
* Returns the {@link Float32Vector}.
127+
* Returns the {@link Float32BinaryVector}.
132128
*
133-
* @return {@link Float32Vector}.
129+
* @return {@link Float32BinaryVector}.
134130
* @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
135131
* type before calling this method.
136132
*/
137-
public Float32Vector asFloat32Vector() {
133+
public Float32BinaryVector asFloat32Vector() {
138134
ensureType(DataType.FLOAT32);
139-
return (Float32Vector) this;
135+
return (Float32BinaryVector) this;
140136
}
141137

142138
/**

bson/src/main/org/bson/BsonBinary.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import org.bson.assertions.Assertions;
2020
import org.bson.internal.UuidHelper;
21-
import org.bson.internal.vector.VectorHelper;
21+
import org.bson.internal.vector.BinaryVectorHelper;
2222

2323
import java.util.Arrays;
2424
import java.util.UUID;
2525

26-
import static org.bson.internal.vector.VectorHelper.encodeVectorToBinary;
26+
import static org.bson.internal.vector.BinaryVectorHelper.encodeVectorToBinary;
2727

2828
/**
2929
* A representation of the BSON Binary type. Note that for performance reasons instances of this class are not immutable,
@@ -93,12 +93,12 @@ public BsonBinary(final UUID uuid) {
9393
}
9494

9595
/**
96-
* Constructs a {@linkplain BsonBinarySubType#VECTOR subtype 9} {@link BsonBinary} from the given {@link Vector}.
96+
* Constructs a {@linkplain BsonBinarySubType#VECTOR subtype 9} {@link BsonBinary} from the given {@link BinaryVector}.
9797
*
98-
* @param vector the {@link Vector}
98+
* @param vector the {@link BinaryVector}
9999
* @since 5.3
100100
*/
101-
public BsonBinary(final Vector vector) {
101+
public BsonBinary(final BinaryVector vector) {
102102
if (vector == null) {
103103
throw new IllegalArgumentException("Vector must not be null");
104104
}
@@ -145,18 +145,18 @@ public UUID asUuid() {
145145
}
146146

147147
/**
148-
* Returns the binary as a {@link Vector}. The {@linkplain #getType() subtype} must be {@linkplain BsonBinarySubType#VECTOR 9}.
148+
* Returns the binary as a {@link BinaryVector}. The {@linkplain #getType() subtype} must be {@linkplain BsonBinarySubType#VECTOR 9}.
149149
*
150150
* @return the vector
151151
* @throws BsonInvalidOperationException if the binary subtype is not {@link BsonBinarySubType#VECTOR}.
152152
* @since 5.3
153153
*/
154-
public Vector asVector() {
154+
public BinaryVector asVector() {
155155
if (type != BsonBinarySubType.VECTOR.getValue()) {
156156
throw new BsonInvalidOperationException("type must be a Vector subtype.");
157157
}
158158

159-
return VectorHelper.decodeBinaryToVector(this.data);
159+
return BinaryVectorHelper.decodeBinaryToVector(this.data);
160160
}
161161

162162
/**

bson/src/main/org/bson/BsonBinarySubType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public enum BsonBinarySubType {
7878
*
7979
* @mongodb.server.release 6.0
8080
* @since 5.3
81-
* @see Vector
81+
* @see BinaryVector
8282
*/
8383
VECTOR((byte) 0x09),
8484

bson/src/main/org/bson/Float32Vector.java renamed to bson/src/main/org/bson/Float32BinaryVector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@
2323
/**
2424
* Represents a vector of 32-bit floating-point numbers, where each element in the vector is a float.
2525
* <p>
26-
* The {@link Float32Vector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
26+
* The {@link Float32BinaryVector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
2727
*
2828
* @mongodb.server.release 6.0
29-
* @see Vector#floatVector(float[])
30-
* @see BsonBinary#BsonBinary(Vector)
29+
* @see BinaryVector#floatVector(float[])
30+
* @see BsonBinary#BsonBinary(BinaryVector)
3131
* @see BsonBinary#asVector()
3232
* @since 5.3
3333
*/
34-
public final class Float32Vector extends Vector {
34+
public final class Float32BinaryVector extends BinaryVector {
3535

3636
private final float[] data;
3737

38-
Float32Vector(final float[] vectorData) {
38+
Float32BinaryVector(final float[] vectorData) {
3939
super(DataType.FLOAT32);
4040
this.data = assertNotNull(vectorData);
4141
}
4242

4343
/**
44-
* Retrieve the underlying float array representing this {@link Float32Vector}, where each float
44+
* Retrieve the underlying float array representing this {@link Float32BinaryVector}, where each float
4545
* represents an element of a vector.
4646
* <p>
4747
* NOTE: The underlying float array is not copied; changes to the returned array will be reflected in this instance.
4848
*
49-
* @return the underlying float array representing this {@link Float32Vector} vector.
49+
* @return the underlying float array representing this {@link Float32BinaryVector} vector.
5050
*/
5151
public float[] getData() {
5252
return assertNotNull(data);
@@ -60,7 +60,7 @@ public boolean equals(final Object o) {
6060
if (o == null || getClass() != o.getClass()) {
6161
return false;
6262
}
63-
Float32Vector that = (Float32Vector) o;
63+
Float32BinaryVector that = (Float32BinaryVector) o;
6464
return Arrays.equals(data, that.data);
6565
}
6666

bson/src/main/org/bson/Int8Vector.java renamed to bson/src/main/org/bson/Int8BinaryVector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@
2424
/**
2525
* Represents a vector of 8-bit signed integers, where each element in the vector is a byte.
2626
* <p>
27-
* The {@link Int8Vector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
27+
* The {@link Int8BinaryVector} is used to store and retrieve data efficiently using the BSON Binary Subtype 9 format.
2828
*
2929
* @mongodb.server.release 6.0
30-
* @see Vector#int8Vector(byte[])
31-
* @see BsonBinary#BsonBinary(Vector)
30+
* @see BinaryVector#int8Vector(byte[])
31+
* @see BsonBinary#BsonBinary(BinaryVector)
3232
* @see BsonBinary#asVector()
3333
* @since 5.3
3434
*/
35-
public final class Int8Vector extends Vector {
35+
public final class Int8BinaryVector extends BinaryVector {
3636

3737
private byte[] data;
3838

39-
Int8Vector(final byte[] data) {
39+
Int8BinaryVector(final byte[] data) {
4040
super(DataType.INT8);
4141
this.data = assertNotNull(data);
4242
}
4343

4444
/**
45-
* Retrieve the underlying byte array representing this {@link Int8Vector} vector, where each byte represents
45+
* Retrieve the underlying byte array representing this {@link Int8BinaryVector} vector, where each byte represents
4646
* an element of a vector.
4747
* <p>
4848
* NOTE: The underlying byte array is not copied; changes to the returned array will be reflected in this instance.
4949
*
50-
* @return the underlying byte array representing this {@link Int8Vector} vector.
50+
* @return the underlying byte array representing this {@link Int8BinaryVector} vector.
5151
*/
5252
public byte[] getData() {
5353
return assertNotNull(data);
@@ -61,7 +61,7 @@ public boolean equals(final Object o) {
6161
if (o == null || getClass() != o.getClass()) {
6262
return false;
6363
}
64-
Int8Vector that = (Int8Vector) o;
64+
Int8BinaryVector that = (Int8BinaryVector) o;
6565
return Objects.deepEquals(data, that.data);
6666
}
6767

0 commit comments

Comments
 (0)