Class SpannerTableTailer.Builder

    • Method Detail

      • setTableHint

        public SpannerTableTailer.Builder setTableHint​(String tableHint)
        Sets an optional table hint to use for the poll query. This could for example be a `@{FORCE_INDEX=Idx_SecondaryIndex}` hint to force the usage of a specific secondary index.
      • setLimit

        public SpannerTableTailer.Builder setLimit​(long limit)
        Sets the maximum number of changes to fetch for each poll query. Default is 10,000. If limit number of changes are found during a poll, a new poll will be scheduled directly instead of after setPollInterval(Duration).

        Setting this limit to a lower value instructs the SpannerTableTailer to execute more poll queries more quickly if it is not able to keep up with the modifications in the table that it is watching. Setting it too low can limit the overall throughput of the SpannerTableTailer as it cannot fetch enough rows in each poll.

        Recommended values are between 1,000 and 10,000.

      • setFallbackToWithQuerySeconds

        public SpannerTableTailer.Builder setFallbackToWithQuerySeconds​(int seconds)
        A SpannerTableTailer that uses a FixedShardProvider with an array of values will by default execute a simple poll query that looks like this:
        
         SELECT *
         FROM Table
         WHERE LastModified > @lastSeenCommitTimestamp AND ShardId IS NOT NULL AND ShardId IN UNNEST(@shardIds)
         ORDER BY LastModified, PrimaryKeyCol1, PrimaryKeyCol2, ...
         LIMIT @limit
         

        In some specific cases these queries can also automatically be re-written to a query that creates a WITH clause for each shard id. This can be more efficient, especially if there are many old mutations that have not yet been reported by the SpannerTableTailer. Using such a query comes with the expense of a higher memory footprint on Cloud Spanner. This query is therefore only used if the SpannerTableTailer is more than 60 seconds behind. This default limit of 60 seconds can be increased or decreased with this setting.

        Recommended values are between 10 seconds and 24 hours. Setting the limit to multiple hours means that the WITH query should only be used when the SpannerTableTailer is started after having been stopped for a while, while modifications to the watched table continued to be applied.

      • setPollInterval

        public SpannerTableTailer.Builder setPollInterval​(org.threeten.bp.Duration interval)
        Sets the poll interval for the table. Defaults to 1 second.
      • setCommitTimestampColumn

        public SpannerTableTailer.Builder setCommitTimestampColumn​(String column)
        This should only be set if your table contains more than one commit timestamp column.

        Sets the commit timestamp column to use. It is only necessary to set this property if the table contains more than one column with the allow_commit_timestamp=true option. If the table only contains one column that can hold a commit timestamp, the SpannerTableTailer will find the column automatically.