You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by wa...@apache.org on 2024/09/05 04:50:36 UTC
(seatunnel) branch dev updated: [Hotfix][Connector-v2] Fix the ClassCastException for connector-mongodb (#7586)
This is an automated email from the ASF dual-hosted git repository.
wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new dc43370e8c [Hotfix][Connector-v2] Fix the ClassCastException for connector-mongodb (#7586)
dc43370e8c is described below
commit dc43370e8c887b7e9cdf44ffd6407c90021125d0
Author: dailai <da...@chinatelecom.cn>
AuthorDate: Thu Sep 5 12:50:31 2024 +0800
[Hotfix][Connector-v2] Fix the ClassCastException for connector-mongodb (#7586)
---
.../seatunnel/mongodb/source/split/SamplingSplitStrategy.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/split/SamplingSplitStrategy.java b/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/split/SamplingSplitStrategy.java
index 6ce9596daa..4ef08c5398 100644
--- a/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/split/SamplingSplitStrategy.java
+++ b/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/split/SamplingSplitStrategy.java
@@ -108,7 +108,12 @@ public class SamplingSplitStrategy implements MongoSplitStrategy, Serializable {
clientProvider.getDefaultCollection().getNamespace().getCollectionName();
BsonDocument statsCmd = new BsonDocument("collStats", new BsonString(collectionName));
Document res = clientProvider.getDefaultDatabase().runCommand(statsCmd);
- long total = res.getInteger("count");
+ Object count = res.get("count");
+ // fix issue https://github.com/apache/seatunnel/issues/7575
+ long total =
+ Optional.ofNullable(count)
+ .map(v -> Long.parseLong(String.valueOf(count)))
+ .orElse(0L);
Object avgDocumentBytes = res.get("avgObjSize");
long avgObjSize =
Optional.ofNullable(avgDocumentBytes)