OUT - The output type of the source.@PublicEvolving public class MongoSourceBuilder<OUT> extends Object
MongoSource to make it easier for the users to construct a MongoSource.| Modifier and Type | Method and Description |
|---|---|
MongoSource<OUT> |
build()
Build the
MongoSource. |
MongoSourceBuilder<OUT> |
setCollection(String collection)
Sets the collection to sink of MongoDB.
|
MongoSourceBuilder<OUT> |
setDatabase(String database)
Sets the database to sink of MongoDB.
|
MongoSourceBuilder<OUT> |
setDeserializationSchema(MongoDeserializationSchema<OUT> deserializationSchema)
Sets the deserialization schema for MongoDB
BsonDocument. |
MongoSourceBuilder<OUT> |
setFetchSize(int fetchSize)
Sets the number of documents should be fetched per round-trip when reading.
|
MongoSourceBuilder<OUT> |
setFilter(org.bson.conversions.Bson filter)
Sets the filter of documents to read.
|
MongoSourceBuilder<OUT> |
setLimit(int limit)
Sets the limit of documents to read.
|
MongoSourceBuilder<OUT> |
setNoCursorTimeout(boolean noCursorTimeout)
The MongoDB server normally times out idle cursors after an inactivity period (10 minutes) to
prevent excess memory use.
|
MongoSourceBuilder<OUT> |
setPartitionSize(org.apache.flink.configuration.MemorySize partitionSize)
Sets the partition memory size of MongoDB split.
|
MongoSourceBuilder<OUT> |
setPartitionStrategy(PartitionStrategy partitionStrategy)
Sets the partition strategy.
|
MongoSourceBuilder<OUT> |
setProjectedFields(List<String> projectedFields)
Sets the projection fields of documents to read.
|
MongoSourceBuilder<OUT> |
setProjectedFields(String... projectedFields)
Sets the projection fields of documents to read.
|
MongoSourceBuilder<OUT> |
setSamplesPerPartition(int samplesPerPartition)
Sets the number of samples to take per partition which is only used for the sample partition
strategy
PartitionStrategy.SAMPLE. |
MongoSourceBuilder<OUT> |
setUri(String uri)
Sets the connection string of MongoDB.
|
public MongoSourceBuilder<OUT> setUri(String uri)
uri - connection string of MongoDBpublic MongoSourceBuilder<OUT> setDatabase(String database)
database - the database to read from MongoDB.public MongoSourceBuilder<OUT> setCollection(String collection)
collection - the collection to read from MongoDB.public MongoSourceBuilder<OUT> setFetchSize(int fetchSize)
fetchSize - the number of documents should be fetched per round-trip when reading.public MongoSourceBuilder<OUT> setNoCursorTimeout(boolean noCursorTimeout)
noCursorTimeout() or a maxTimeMS() greater than 30 minutes.noCursorTimeout - Set this option to true to prevent cursor timeout (10 minutes)public MongoSourceBuilder<OUT> setPartitionStrategy(PartitionStrategy partitionStrategy)
PartitionStrategy for detail.partitionStrategy - the strategy of a partition.public MongoSourceBuilder<OUT> setPartitionSize(org.apache.flink.configuration.MemorySize partitionSize)
MongoScanSourceSplitReader to speed up the overall read time.partitionSize - the memory size of a partition.public MongoSourceBuilder<OUT> setSamplesPerPartition(int samplesPerPartition)
PartitionStrategy.SAMPLE. The sample partitioner samples the collection,
projects and sorts by the partition fields. Then uses every samplesPerPartition as
the value to use to calculate the partition boundaries. The total number of samples taken is:
samples per partition * ( count of documents / number of documents per partition).samplesPerPartition - number of samples per partition.public MongoSourceBuilder<OUT> setLimit(int limit)
limit - the limit of documents to read.public MongoSourceBuilder<OUT> setFilter(org.bson.conversions.Bson filter)
filter - the filter of documents to read.public MongoSourceBuilder<OUT> setProjectedFields(String... projectedFields)
projectedFields - the projection fields of documents to read.public MongoSourceBuilder<OUT> setProjectedFields(List<String> projectedFields)
projectedFields - the projection fields of documents to read.public MongoSourceBuilder<OUT> setDeserializationSchema(MongoDeserializationSchema<OUT> deserializationSchema)
BsonDocument.deserializationSchema - the deserialization schema to deserialize BsonDocument.public MongoSource<OUT> build()
MongoSource.Copyright © 2022–2025 The Apache Software Foundation. All rights reserved.