Class MongoSourceBuilder.Stream<T>

    • Method Detail

      • collection

        @Nonnull
        public MongoSourceBuilder.Stream<org.bson.Document> collection​(@Nonnull
                                                                       java.lang.String collectionName)
        Specifies from which collection connector will read documents. If not invoked, then connector will look at all collections in given database.

        Example usage:

        
          MongoSourceBuilder.stream(name, supplier)
              .collection("myCollection");
         
        This function is an equivalent of calling collection(String, Class) with Document as the second argument.
        Parameters:
        collectionName - Name of the collection that will be queried.
        Returns:
        this builder
      • collection

        @Nonnull
        public <T_NEW> MongoSourceBuilder.Stream<T_NEW> collection​(@Nonnull
                                                                   java.lang.String collectionName,
                                                                   @Nonnull
                                                                   java.lang.Class<T_NEW> mongoType)
        Specifies from which collection connector will read documents. If not invoked, then connector will look at all collections in given database. All documents read will be automatically parsed to user-defined type using MongoDB's standard codec registry with pojo support added.

        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));
         
        Parameters:
        collectionName - Name of the collection that will be queried.
        mongoType - user defined type to which the document will be parsed.
        Returns:
        this builder
      • mapFn

        @Nonnull
        public <T_NEW> MongoSourceBuilder.Stream<T_NEW> mapFn​(@Nonnull
                                                              BiFunctionEx<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>,​java.lang.Long,​T_NEW> mapFn)
        Type Parameters:
        T_NEW - type of the emitted object
        Parameters:
        mapFn - transforms the queried document to the desired output object. Second parameter will be the event timestamp.
        Returns:
        this builder
      • startAtOperationTime

        @Nonnull
        public MongoSourceBuilder.Stream<T> startAtOperationTime​(@Nonnull
                                                                 org.bson.BsonTimestamp startAtOperationTime)
        Specifies time from which MongoDB's events will be read.

        It is highly suggested to provide this argument, as it will reduce reading initial state of database.

        Parameters:
        startAtOperationTime - time from which events should be taken into consideration
        Returns:
        this builder
      • build

        @Nonnull
        public StreamSource<T> build()
        Creates and returns the MongoDB StreamSource which watches the given collection.