T
- type of the queried documentspublic static final class MongoSourceBuilder.Stream<T> extends Object
Modifier and Type | Method and Description |
---|---|
StreamSource<T> |
build()
Creates and returns the MongoDB
StreamSource which watches
the given collection. |
MongoSourceBuilder.Stream<org.bson.Document> |
collection(String collectionName)
Specifies from which collection connector will read documents.
|
<T_NEW> MongoSourceBuilder.Stream<T_NEW> |
collection(String collectionName,
Class<T_NEW> mongoType)
Specifies from which collection connector will read documents.
|
MongoSourceBuilder.Stream<T> |
database(String database)
Specifies which database will be queried.
|
MongoSourceBuilder.Stream<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.Stream<T_NEW> |
mapFn(BiFunctionEx<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>,Long,T_NEW> mapFn) |
MongoSourceBuilder.Stream<T> |
project(org.bson.conversions.Bson projection)
Adds a projection aggregate.
|
MongoSourceBuilder.Stream<T> |
startAtOperationTime(org.bson.BsonTimestamp startAtOperationTime)
Specifies time from which MongoDB's events will be read.
|
MongoSourceBuilder.Stream<T> |
throwOnNonExisting(boolean throwOnNonExisting)
If
true , the lack of database or collection will cause an error. |
@Nonnull public MongoSourceBuilder.Stream<T> throwOnNonExisting(boolean throwOnNonExisting)
true
, the lack of database or collection will cause an error.
If false
, database and collection will be automatically created.
Default value is true
.throwOnNonExisting
- if exception should be thrown when database or collection does not exist.@Nonnull public MongoSourceBuilder.Stream<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.Stream<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 MongoSourceBuilder.Stream<T> database(@Nonnull String database)
database
- database name to query.@Nonnull public MongoSourceBuilder.Stream<org.bson.Document> collection(@Nonnull 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.Stream<T_NEW> collection(@Nonnull 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 <T_NEW> MongoSourceBuilder.Stream<T_NEW> mapFn(@Nonnull BiFunctionEx<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>,Long,T_NEW> mapFn)
T_NEW
- type of the emitted objectmapFn
- transforms the queried document to the desired output
object. Second parameter will be the event timestamp.@Nonnull public MongoSourceBuilder.Stream<T> startAtOperationTime(@Nonnull org.bson.BsonTimestamp startAtOperationTime)
It is highly suggested to provide this argument, as it will reduce reading initial state of database.
startAtOperationTime
- time from which events should be taken into consideration@Nonnull public StreamSource<T> build()
StreamSource
which watches
the given collection.Copyright © 2024 Hazelcast, Inc.. All rights reserved.