Class ContinuousQueryOptions.Builder

java.lang.Object
org.apache.ignite.table.ContinuousQueryOptions.Builder
Enclosing class:
ContinuousQueryOptions

public static class ContinuousQueryOptions.Builder extends Object
Builder.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • pageSize

      public ContinuousQueryOptions.Builder pageSize(int pageSize)
      Sets the per-partition page size.

      Continuous Query polls every partition in a loop. This parameter controls the number of entries that will be requested from a single partition in one network call. Therefore, the maximum number of entries that the query may hold in memory at any given time is pageSize * partitions.

      Default value is 1000.

      Parameters:
      pageSize - Page size.
      Returns:
      This builder instance.
    • pollIntervalMs

      public ContinuousQueryOptions.Builder pollIntervalMs(int pollIntervalMs)
      Sets the poll interval in milliseconds.

      Default value is 1000 ms.

      Parameters:
      pollIntervalMs - Poll interval in milliseconds.
      Returns:
      This builder instance.
    • eventTypes

      public ContinuousQueryOptions.Builder eventTypes(EnumSet<TableRowEventType> eventTypes)
      Sets the included event types.

      By default, all event types are included.

      Parameters:
      eventTypes - Included event types.
      Returns:
      This builder instance.
    • eventTypes

      public ContinuousQueryOptions.Builder eventTypes(TableRowEventType... eventTypes)
      Sets the included event types.

      By default, all event types are included.

      Parameters:
      eventTypes - Included event types.
      Returns:
      This builder instance.
    • columnNames

      public ContinuousQueryOptions.Builder columnNames(@Nullable @Nullable Set<String> columnNames)
      Sets the column names to include in the result.

      By default, all columns are included. Excluding columns will reduce the amount of data transferred over the network.

      Excluded columns are still present in the resulting entries, but are set to null.

      Parameters:
      columnNames - Included column names. When null, all columns are included.
      Returns:
      This builder instance.
    • partitions

      public ContinuousQueryOptions.Builder partitions(@Nullable @Nullable Set<Partition> partitions)
      Sets the partitions to subscribe to. When null, all partitions are included.

      By default, all partitions are included.

      To obtain table partitions, use PartitionManager. For example, the following code starts a continuous query on a partition for the specific key:

           Table table = ignite().tables().table("my_table");
           Tuple key = Tuple.create().set("id", 1);
           Partition partition = table.partitionManager().partitionAsync(key).join();
           ContinuousQueryOptions opts = ContinuousQueryOptions.builder()
               .partitions(Set.of(partition))
               .build();
      
           table.recordView().queryContinuously(new MySubscriber(), opts);
       
      Parameters:
      partitions - Included partitions, or null for all partitions.
      Returns:
      This builder instance.
    • partitions

      public ContinuousQueryOptions.Builder partitions(Partition... partitions)
      Sets the partitions to subscribe to. When null, all partitions are included.

      By default, all partitions are included.

      To obtain table partitions, use PartitionManager. For example, the following code starts a continuous query on a partition for the specific key:

           Table table = ignite().tables().table("my_table");
           Tuple key = Tuple.create().set("id", 1);
           Partition partition = table.partitionManager().partitionAsync(key).join();
           ContinuousQueryOptions opts = ContinuousQueryOptions.builder()
               .partitions(partition)
               .build();
      
           table.recordView().queryContinuously(new MySubscriber(), opts);
       
      Parameters:
      partitions - Included partitions, or null for all partitions.
      Returns:
      This builder instance.
    • watermark

      public ContinuousQueryOptions.Builder watermark(@Nullable @Nullable ContinuousQueryWatermark watermark)
      Sets the starting watermark. When null, the query will start from the current time.

      Watermark can be obtained with ContinuousQueryWatermark.ofInstant(Instant), or from an event with TableRowEvent.watermark(). The latter allows resuming a query from a specific event (excluding said event, providing exactly-once semantics).

      Default value is null, meaning the query will start from the current time.

      Parameters:
      watermark - Watermark.
      Returns:
      This builder instance.
    • enableEmptyBatches

      public ContinuousQueryOptions.Builder enableEmptyBatches(boolean enableEmptyBatches)
      Sets the flag that indicates whether empty batches are enabled.

      When enabled, empty batches will be sent to the subscriber when there are no new events. This is useful for watermark updates (see TableRowEventBatch.watermark()).

      Default value is false, meaning empty batches are not sent to the subscriber.

      Parameters:
      enableEmptyBatches - True if empty batches are enabled, false otherwise.
      Returns:
      This builder instance.
    • executor

      public ContinuousQueryOptions.Builder executor(Executor executor)
      Sets the executor that is going to be used for async delivery and execution of subscriber methods.

      By default common pool is used - ForkJoinPool.commonPool().

      Parameters:
      executor - Executor to use for async delivery.
      Returns:
      This builder instance.
    • skipOldEntries

      public ContinuousQueryOptions.Builder skipOldEntries(boolean skipOldEntries)
      Sets the flag that indicates whether old entries should be skipped for TableRowEventType.UPDATED events. When true, TableRowEvent.oldEntry() will return null for TableRowEventType.UPDATED events. This reduces the amount of data transferred over the network.

      Default value is false, meaning old entries are not skipped.

      Parameters:
      skipOldEntries - True if old entries should be skipped, false otherwise.
      Returns:
      This builder instance.
    • build

      public ContinuousQueryOptions build()
      Builds the options.
      Returns:
      Continuous query options.