public class SpannerDatabaseAdminTemplate extends Object
| Constructor and Description |
|---|
SpannerDatabaseAdminTemplate(DatabaseAdminClient databaseAdminClient,
Supplier<DatabaseClient> databaseClientProvider,
Supplier<DatabaseId> databaseIdProvider)
Constructor that takes in the database admin client used to perform operations and the
DatabaseId object holding the project, instance, and database IDs used for all
operations. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
databaseExists()
Returns true if the configured database ID refers to an existing database.
|
void |
executeDdlStrings(Iterable<String> ddlStrings,
boolean createDatabase)
Execute the given DDL strings in order and creates the database if it does not
exist.
|
Map<String,String> |
getChildParentTablesMap()
Return a map where key is the table name and the value is the parent table name.
|
String |
getDatabase()
Get the database ID used to perform database operations.
|
String |
getInstanceId()
Get the instance ID used to perform database operations.
|
Map<String,Set<String>> |
getParentChildTablesMap()
Return a map of parent and child table relationships in the database at the
moment.
|
Set<String> |
getTables()
Return a set of the tables that currently exist in the database.
|
boolean |
isInterleaved(String ancestor,
String descendant)
Return true if the given table names are interleaved as ancestor and descendant.
|
boolean |
tableExists(String table)
Returns true if the given table name exists in the database currently.
|
public SpannerDatabaseAdminTemplate(DatabaseAdminClient databaseAdminClient, Supplier<DatabaseClient> databaseClientProvider, Supplier<DatabaseId> databaseIdProvider)
DatabaseId object holding the project, instance, and database IDs used for all
operations. While operations can be optionally performed for a database that does not
yet exist, the project and instance IDs must already exist for Spanner.databaseAdminClient - the client used to create databases and execute DDL
statements.databaseClientProvider - the client used to access schema information tables.databaseIdProvider - the combination of Cloud Spanner Instance Id and Database Id.
While databases can be created automatically by this template, instances determine
billing and are not created automatically.public void executeDdlStrings(Iterable<String> ddlStrings, boolean createDatabase)
ddlStrings - the DDL stringscreateDatabase - if true, then the database is created at the same
time as the tables using the DDL strings. if false, then the database must
already exist.public String getInstanceId()
public String getDatabase()
public boolean databaseExists()
public Map<String,String> getChildParentTablesMap()
public boolean isInterleaved(String ancestor, String descendant)
ancestor - the name of the ancestor tabledescendant - the name of the descendant table. this may be a direct child or
further down in the family tree.public Map<String,Set<String>> getParentChildTablesMap()
public Set<String> getTables()
public boolean tableExists(String table)
table - the name of the table.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.