Class SpannerUtils


  • @InternalApi("Public visibility for re-use by other spanner-change-watcher libraries. API-breaking changes without prior notice is possible.")
    public class SpannerUtils
    extends Object
    Utils for getting commonly needed schema information from a Spanner database.
    • Field Detail

      • FIND_COMMIT_TIMESTAMP_COLUMN_QUERY

        public static final String FIND_COMMIT_TIMESTAMP_COLUMN_QUERY
        Query for getting the column of a table that holds the commit timestamp.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SpannerUtils

        public SpannerUtils()
    • Method Detail

      • getTimestampColumn

        @InternalApi
        public static com.google.api.core.ApiFuture<String> getTimestampColumn​(com.google.cloud.spanner.DatabaseClient client,
                                                                               TableId table)
        Returns the name of the commit timestamp column of the given table.
      • getPrimaryKeyColumns

        @InternalApi
        public static com.google.api.core.ApiFuture<List<String>> getPrimaryKeyColumns​(com.google.cloud.spanner.DatabaseClient client,
                                                                                       TableId table)
        Returns the primary key columns of a table.
      • getIndexOnColumn

        @InternalApi
        public static com.google.api.core.ApiFuture<String> getIndexOnColumn​(com.google.cloud.spanner.DatabaseClient client,
                                                                             TableId table,
                                                                             String column)
        Returns any (secondary) index that is defined on only the given column. Any such index can be used by SpannerTableChangeWatchers that do not use any ShardProviders, and therefore only search for changes by filtering directly on the commit timestamp column. These indexes can cause write hotspots in a Cloud Spanner database, but for tables that do not receive a large number of writes, this does not necessarily need to be a problem. This function will prefer null-filtered indexes over non-null-filtered indexes. Other than that, the index that is returned by this function when there are multiple indexes defined on only this column is undefined.
      • buildKey

        @InternalApi
        public static com.google.cloud.spanner.Key buildKey​(Iterable<String> pkColumns,
                                                            com.google.cloud.spanner.ResultSet rs)
        Creates a Key instance from an Iterable of primary key columns and a ResultSet containing the data to use for the key.