Class MongoSourceBuilder.Batch<T>

java.lang.Object
com.hazelcast.jet.mongodb.MongoSourceBuilder.Batch<T>
Type Parameters:
T - type of the emitted objects
Enclosing class:
MongoSourceBuilder

public static final class MongoSourceBuilder.Batch<T> extends Object
  • Field Details

    • params

      protected com.hazelcast.jet.mongodb.impl.ReadMongoParams<T> params
    • existenceChecks

      protected ResourceChecks existenceChecks
    • name

      protected String name
    • forceReadTotalParallelismOne

      protected boolean forceReadTotalParallelismOne
  • Method Details

    • mapFn

      @Nonnull public <T_NEW> MongoSourceBuilder.Batch<T_NEW> mapFn(@Nonnull FunctionEx<org.bson.Document,T_NEW> mapFn)
      Type Parameters:
      T_NEW - type of the emitted object
      Parameters:
      mapFn - transforms the queried document to the desired output object
    • collection

      @Nonnull public MongoSourceBuilder.Batch<org.bson.Document> collection(@Nullable 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.Batch<T_NEW> collection(String collectionName, @Nonnull 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
    • build

      @Nonnull public BatchSource<T> build()
      Creates and returns the MongoDB BatchSource.
    • database

      @Nonnull public MongoSourceBuilder.Batch<T> database(String database)
    • forceReadTotalParallelismOne

      @Nonnull public MongoSourceBuilder.Batch<T> forceReadTotalParallelismOne(boolean forceReadTotalParallelismOne)
      If set to true, reading will be done in only one thread.
      Parameters:
      forceReadTotalParallelismOne - if true, reading will be done in only one thread.
    • checkResourceExistence

      @Nonnull public MongoSourceBuilder.Batch<T> checkResourceExistence(ResourceChecks checkResourceExistence)
      If ResourceChecks.NEVER, the database and collection will be automatically created on the first usage. Otherwise, querying for a database or collection that don't exist will cause an error. Default value is ResourceChecks.ONCE_PER_JOB.
      Parameters:
      checkResourceExistence - mode of resource existence checks; whether exception should be thrown when database or collection does not exist and when the check will be performed.
      Since:
      5.4
    • project

      @Nonnull public MongoSourceBuilder.Batch<T> project(@Nonnull org.bson.conversions.Bson projection)
      Adds a projection aggregate. Example use:
      
       import static com.mongodb.client.model.Projections.include;
      
        MongoSourceBuilder.stream(name, supplier)
            .projection(include("fieldName"));
       
      Parameters:
      projection - Bson form of projection; use Projections to create projection.
      Returns:
      this builder with projection added
    • sort

      @Nonnull public MongoSourceBuilder.Batch<T> sort(@Nonnull org.bson.conversions.Bson sort)
      Adds sort aggregate to this builder.

      Example usage:

      
        import static com.mongodb.client.model.Sorts.ascending;
      
        MongoSourceBuilder.stream(name, supplier)
            .sort(ascending("fieldName"));
       
      Parameters:
      sort - Bson form of sort. Use Sorts to create sort.
      Returns:
      this builder with aggregate added
    • filter

      @Nonnull public MongoSourceBuilder.Batch<T> filter(@Nonnull 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.

      Example usage:

      
        import static com.mongodb.client.model.Filters.eq;
      
        MongoSourceBuilder.stream(name, supplier)
            .filter(eq("fieldName", 10));
       
      Parameters:
      filter - Bson form of filter. Use Filters to create sort.
      Returns:
      this builder with aggregate added