Package com.google.cloud.spanner.watcher
Class SpannerUtils
- java.lang.Object
-
- com.google.cloud.spanner.watcher.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 ObjectUtils for getting commonly needed schema information from a Spanner database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSpannerUtils.LogRecordBuilder
-
Field Summary
Fields Modifier and Type Field Description static StringFIND_COMMIT_TIMESTAMP_COLUMN_QUERYQuery for getting the column of a table that holds the commit timestamp.
-
Constructor Summary
Constructors Constructor Description SpannerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.cloud.spanner.KeybuildKey(Iterable<String> pkColumns, com.google.cloud.spanner.ResultSet rs)Creates aKeyinstance from anIterableof primary key columns and aResultSetcontaining the data to use for the key.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.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.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.
-
-
-
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
-
-
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 bySpannerTableChangeWatchers that do not use anyShardProviders, 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.
-
-