T
- type of the emitted objectspublic static final class MongoSourceBuilder.Batch<T> extends Object
Modifier and Type | Method and Description |
---|---|
BatchSource<T> |
build()
Creates and returns the MongoDB
BatchSource . |
MongoSourceBuilder.Batch<org.bson.Document> |
collection(String collectionName)
Specifies from which collection connector will read documents.
|
<T_NEW> MongoSourceBuilder.Batch<T_NEW> |
collection(String collectionName,
Class<T_NEW> mongoType)
Specifies from which collection connector will read documents.
|
MongoSourceBuilder.Batch<T> |
database(String database)
Specifies which database will be queried.
|
MongoSourceBuilder.Batch<T> |
filter(org.bson.conversions.Bson filter)
Adds filter aggregate to this builder, which allows to filter documents in MongoDB, without
the need to download all documents.
|
<T_NEW> MongoSourceBuilder.Batch<T_NEW> |
mapFn(FunctionEx<org.bson.Document,T_NEW> mapFn) |
MongoSourceBuilder.Batch<T> |
project(org.bson.conversions.Bson projection)
Adds a projection aggregate.
|
MongoSourceBuilder.Batch<T> |
sort(org.bson.conversions.Bson sort)
Adds sort aggregate to this builder.
|
@Nonnull public MongoSourceBuilder.Batch<T> project(@Nonnull org.bson.conversions.Bson projection)
import static com.mongodb.client.model.Projections.include;
MongoSourceBuilder.stream(name, supplier)
.projection(include("fieldName"));
projection
- Bson form of projection;
use Projections
to create projection.@Nonnull public MongoSourceBuilder.Batch<T> sort(@Nonnull org.bson.conversions.Bson sort)
Example usage:
import static com.mongodb.client.model.Sorts.ascending;
MongoSourceBuilder.stream(name, supplier)
.sort(ascending("fieldName"));
sort
- Bson form of sort. Use Sorts
to create sort.@Nonnull public MongoSourceBuilder.Batch<T> filter(@Nonnull org.bson.conversions.Bson filter)
Example usage:
import static com.mongodb.client.model.Filters.eq;
MongoSourceBuilder.stream(name, supplier)
.filter(eq("fieldName", 10));
filter
- Bson form of filter. Use Filters
to create sort.@Nonnull public <T_NEW> MongoSourceBuilder.Batch<T_NEW> mapFn(@Nonnull FunctionEx<org.bson.Document,T_NEW> mapFn)
T_NEW
- type of the emitted objectmapFn
- transforms the queried document to the desired output
object@Nonnull public MongoSourceBuilder.Batch<T> database(@Nullable String database)
database
- database name to query.@Nonnull public MongoSourceBuilder.Batch<org.bson.Document> collection(@Nullable String collectionName)
Example usage:
MongoSourceBuilder.stream(name, supplier)
.collection("myCollection");
This function is an equivalent of calling collection(String, Class) with Document
as the second argument.collectionName
- Name of the collection that will be queried.@Nonnull public <T_NEW> MongoSourceBuilder.Batch<T_NEW> collection(String collectionName, @Nonnull Class<T_NEW> mongoType)
Example usage:
MongoSourceBuilder.stream(name, supplier)
.collection("myCollection", MyDocumentPojo.class);
This function is an equivalent for calling:
import static com.hazelcast.jet.mongodb.impl.Mappers.toClass;
MongoSourceBuilder.stream(name, supplier)
.collection("myCollection")
.mapFn(toClass(MyuDocumentPojo.class));
collectionName
- Name of the collection that will be queried.mongoType
- user defined type to which the document will be parsed.@Nonnull public BatchSource<T> build()
BatchSource
.Copyright © 2023 Hazelcast, Inc.. All rights reserved.