Skip to content

Commit 4e9b7db

Browse files
authored
Merge branch 'mongodb:main' into main
2 parents 51aa520 + 5e377bc commit 4e9b7db

File tree

314 files changed

+22899
-2615
lines changed

Some content is hidden

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

314 files changed

+22899
-2615
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ declare -r EVERGREEN_BUILD_URL_PREFIX="https://spruce.mongodb.com/version"
4040
declare -r GIT_TAG="r${PRODUCT_VERSION}"
4141
GIT_COMMIT_HASH="$(git rev-list --ignore-missing -n 1 "${GIT_TAG}")"
4242
set +e
43-
GIT_BRANCH_MASTER="$(git branch -a --contains "${GIT_TAG}" | grep 'master$')"
43+
GIT_BRANCH_DEFAULT="$(git branch -a --contains "${GIT_TAG}" | grep 'main$')"
4444
GIT_BRANCH_PATCH="$(git branch -a --contains "${GIT_TAG}" | grep '\.x$')"
4545
set -e
46-
if [ -n "${GIT_BRANCH_MASTER}" ]; then
46+
if [ -n "${GIT_BRANCH_DEFAULT}" ]; then
4747
declare -r EVERGREEN_BUILD_URL="${EVERGREEN_BUILD_URL_PREFIX}/${EVERGREEN_PROJECT_NAME_PREFIX}_${GIT_COMMIT_HASH}"
4848
elif [ -n "${GIT_BRANCH_PATCH}" ]; then
4949
# strip out the patch version
@@ -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/AbstractBsonWriter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,15 @@ protected void throwInvalidState(final String methodName, final State... validSt
748748
methodName, validStatesString, state));
749749
}
750750

751+
/**
752+
* {@inheritDoc}
753+
* <p>
754+
* The {@link #flush()} method of {@link AbstractBsonWriter} does nothing.</p>
755+
*/
756+
@Override
757+
public void flush() {
758+
}
759+
751760
@Override
752761
public void close() {
753762
closed = true;

bson/src/main/org/bson/BSONCallbackAdapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ protected BSONCallbackAdapter(final BsonWriterSettings settings, final BSONCallb
3939
this.bsonCallback = bsonCallback;
4040
}
4141

42-
@Override
43-
public void flush() {
44-
//Looks like should be no-op?
45-
}
46-
4742
@Override
4843
public void doWriteStartDocument() {
4944
BsonContextType contextType = getState() == State.SCOPE_DOCUMENT
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,26 @@
1616

1717
package org.bson;
1818

19+
import org.bson.annotations.Beta;
20+
import org.bson.annotations.Reason;
21+
1922
import static org.bson.assertions.Assertions.isTrueArgument;
2023
import static org.bson.assertions.Assertions.notNull;
2124

2225
/**
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.
26+
* Binary Vectors are densely packed arrays of numbers, all the same type, which are stored and retrieved efficiently using the BSON Binary
27+
* Subtype 9 format. This class supports multiple vector {@link DataType}'s and provides static methods to create vectors.
2928
* <p>
3029
* <b>NOTE:</b> This class should be treated as <b>sealed</b>: it must not be extended or implemented by consumers of the library.
3130
*
3231
* @mongodb.server.release 6.0
3332
* @see BsonBinary
3433
* @since 5.3
3534
*/
36-
public abstract class Vector {
35+
public abstract class BinaryVector {
3736
private final DataType dataType;
3837

39-
Vector(final DataType dataType) {
38+
BinaryVector(final DataType dataType) {
4039
this.dataType = dataType;
4140
}
4241

@@ -56,18 +55,19 @@ public abstract class Vector {
5655
* </pre>
5756
* <p>
5857
* NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
59-
* in the created {@link PackedBitVector} instance.
58+
* in the created {@link PackedBitBinaryVector} instance.
6059
*
6160
* @param data The byte array representing the packed bit vector data. Each byte can store 8 bits.
6261
* @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.
62+
* @return A {@link PackedBitBinaryVector} instance with the {@link DataType#PACKED_BIT} data type.
6463
* @throws IllegalArgumentException If the padding value is greater than 7.
6564
*/
66-
public static PackedBitVector packedBitVector(final byte[] data, final byte padding) {
65+
@Beta(Reason.SERVER)
66+
public static PackedBitBinaryVector packedBitVector(final byte[] data, final byte padding) {
6767
notNull("data", data);
6868
isTrueArgument("Padding must be between 0 and 7 bits. Provided padding: " + padding, padding >= 0 && padding <= 7);
6969
isTrueArgument("Padding must be 0 if vector is empty. Provided padding: " + padding, padding == 0 || data.length > 0);
70-
return new PackedBitVector(data, padding);
70+
return new PackedBitBinaryVector(data, padding);
7171
}
7272

7373
/**
@@ -77,14 +77,14 @@ public static PackedBitVector packedBitVector(final byte[] data, final byte padd
7777
* with values in the range [-128, 127].</p>
7878
* <p>
7979
* NOTE: The byte array `data` is not copied; changes to the provided array will be reflected
80-
* in the created {@link Int8Vector} instance.
80+
* in the created {@link Int8BinaryVector} instance.
8181
*
8282
* @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.
83+
* @return A {@link Int8BinaryVector} instance with the {@link DataType#INT8} data type.
8484
*/
85-
public static Int8Vector int8Vector(final byte[] data) {
85+
public static Int8BinaryVector int8Vector(final byte[] data) {
8686
notNull("data", data);
87-
return new Int8Vector(data);
87+
return new Int8BinaryVector(data);
8888
}
8989

9090
/**
@@ -93,50 +93,50 @@ public static Int8Vector int8Vector(final byte[] data) {
9393
* A {@link DataType#FLOAT32} vector is a vector of floating-point numbers, where each element in the vector is a float.</p>
9494
* <p>
9595
* NOTE: The float array `data` is not copied; changes to the provided array will be reflected
96-
* in the created {@link Float32Vector} instance.
96+
* in the created {@link Float32BinaryVector} instance.
9797
*
9898
* @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.
99+
* @return A {@link Float32BinaryVector} instance with the {@link DataType#FLOAT32} data type.
100100
*/
101-
public static Float32Vector floatVector(final float[] data) {
101+
public static Float32BinaryVector floatVector(final float[] data) {
102102
notNull("data", data);
103-
return new Float32Vector(data);
103+
return new Float32BinaryVector(data);
104104
}
105105

106106
/**
107-
* Returns the {@link PackedBitVector}.
107+
* Returns the {@link PackedBitBinaryVector}.
108108
*
109-
* @return {@link PackedBitVector}.
109+
* @return {@link PackedBitBinaryVector}.
110110
* @throws IllegalStateException if this vector is not of type {@link DataType#PACKED_BIT}. Use {@link #getDataType()} to check the vector
111111
* type before calling this method.
112112
*/
113-
public PackedBitVector asPackedBitVector() {
113+
public PackedBitBinaryVector asPackedBitVector() {
114114
ensureType(DataType.PACKED_BIT);
115-
return (PackedBitVector) this;
115+
return (PackedBitBinaryVector) this;
116116
}
117117

118118
/**
119-
* Returns the {@link Int8Vector}.
119+
* Returns the {@link Int8BinaryVector}.
120120
*
121-
* @return {@link Int8Vector}.
121+
* @return {@link Int8BinaryVector}.
122122
* @throws IllegalStateException if this vector is not of type {@link DataType#INT8}. Use {@link #getDataType()} to check the vector
123123
* type before calling this method.
124124
*/
125-
public Int8Vector asInt8Vector() {
125+
public Int8BinaryVector asInt8Vector() {
126126
ensureType(DataType.INT8);
127-
return (Int8Vector) this;
127+
return (Int8BinaryVector) this;
128128
}
129129

130130
/**
131-
* Returns the {@link Float32Vector}.
131+
* Returns the {@link Float32BinaryVector}.
132132
*
133-
* @return {@link Float32Vector}.
133+
* @return {@link Float32BinaryVector}.
134134
* @throws IllegalStateException if this vector is not of type {@link DataType#FLOAT32}. Use {@link #getDataType()} to check the vector
135135
* type before calling this method.
136136
*/
137-
public Float32Vector asFloat32Vector() {
137+
public Float32BinaryVector asFloat32Vector() {
138138
ensureType(DataType.FLOAT32);
139-
return (Float32Vector) this;
139+
return (Float32BinaryVector) this;
140140
}
141141

142142
/**

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
/**

0 commit comments

Comments
 (0)