Hisoka-X commented on code in PR #7586:
URL: https://github.com/apache/seatunnel/pull/7586#discussion_r1744749925
##########
seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/source/split/SamplingSplitStrategy.java:
##########
@@ -108,7 +109,22 @@ private ImmutablePair<Long, Long>
getDocumentNumAndAvgSize() {
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 -> {
+ if (v instanceof Integer) {
+ return ((Integer) v).longValue();
+ } else if (v instanceof Long) {
+ return (Long) v;
+ } else {
+ throw CommonError.unsupportedDataType(
+ "Mongodb",
count.getClass().getTypeName(), "count");
+ }
+ })
Review Comment:
```suggestion
Long.parseLong(v.toString());
```
how about this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]