Search in sources :

Example 41 with Database

use of com.google.spanner.admin.database.v1.Database in project java-spanner by googleapis.

the class DatabaseAdminClient method dropDatabase.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be
 * retained according to their `expire_time`. Note: Cloud Spanner might continue to accept
 * requests for a few seconds after the database has been deleted.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
 *   DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
 *   databaseAdminClient.dropDatabase(database);
 * }
 * }</pre>
 *
 * @param database Required. The database to be dropped.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void dropDatabase(DatabaseName database) {
    DropDatabaseRequest request = DropDatabaseRequest.newBuilder().setDatabase(database == null ? null : database.toString()).build();
    dropDatabase(request);
}
Also used : DropDatabaseRequest(com.google.spanner.admin.database.v1.DropDatabaseRequest)

Example 42 with Database

use of com.google.spanner.admin.database.v1.Database in project java-spanner by googleapis.

the class DatabaseAdminClient method dropDatabase.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be
 * retained according to their `expire_time`. Note: Cloud Spanner might continue to accept
 * requests for a few seconds after the database has been deleted.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
 *   String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
 *   databaseAdminClient.dropDatabase(database);
 * }
 * }</pre>
 *
 * @param database Required. The database to be dropped.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void dropDatabase(String database) {
    DropDatabaseRequest request = DropDatabaseRequest.newBuilder().setDatabase(database).build();
    dropDatabase(request);
}
Also used : DropDatabaseRequest(com.google.spanner.admin.database.v1.DropDatabaseRequest)

Example 43 with Database

use of com.google.spanner.admin.database.v1.Database in project molgenis-emx2 by molgenis.

the class TestEmx2Roles method setup.

@BeforeClass
public static void setup() {
    Database database = TestDatabaseFactory.getTestDatabase();
    schema = database.dropCreateSchema(TestEmx2Roles.class.getSimpleName());
}
Also used : Database(org.molgenis.emx2.Database) BeforeClass(org.junit.BeforeClass)

Example 44 with Database

use of com.google.spanner.admin.database.v1.Database in project molgenis-emx2 by molgenis.

the class TestImportTableTask method setup.

@BeforeClass
public static void setup() {
    Database database = TestDatabaseFactory.getTestDatabase();
    schema = database.dropCreateSchema(TestImportTableTask.class.getSimpleName());
}
Also used : Database(org.molgenis.emx2.Database) BeforeClass(org.junit.BeforeClass)

Example 45 with Database

use of com.google.spanner.admin.database.v1.Database in project molgenis-emx2 by molgenis.

the class Benchmark method testCopyInAndOut.

public void testCopyInAndOut() {
    Database database = TestDatabaseFactory.getTestDatabase();
    Schema schema = database.dropCreateSchema(Benchmark.class.getSimpleName());
    int aSize = 50;
    int bSize = 100000;
    Table a = schema.create(table("TableA").add(column("ID").setPkey()));
    List<String> values = new ArrayList<>();
    Table b = schema.create(table("TableB").add(column("ID").setPkey()).add(column("ref").setType(REF_ARRAY).setRefTable("TableA")));
    // Table c =
    // schema.create(
    // table("TableC")
    // .add(column("ID").setPkey())
    // .add(column("ref").setType(MREF).setRefTable("TableA")));
    StopWatch.start("benchmark started");
    List<Row> aRows = new ArrayList<>();
    for (int i = 0; i < aSize; i++) {
        aRows.add(new Row().set("ID", "row" + i));
        values.add("row" + i);
    }
    StopWatch.start("benchmark1");
    a.insert(aRows);
    StopWatch.print("inserted primary", aSize);
    aRows.clear();
    List<Row> bRows = new ArrayList<>();
    for (int i = 0; i < bSize; i++) {
        bRows.add(new Row().set("ID", "row" + i).set("ref", values));
    }
    StopWatch.start("benchmark2 started");
    b.insert(bRows);
    StopWatch.print("inserted ref_array", bSize);
    bRows.clear();
// List<Row> cRows = new ArrayList<>();
// for (int i = 0; i < bSize; i++) {
// cRows.add(new Row().set("ID", "row" + i).set("ref", values));
// }
// StopWatch.start("benchmark3 started");
// c.insert(cRows);
// StopWatch.print("inserted mref", bSize);
// cRows.clear();
// StopWatch.print("inserted mref", bSize);
// ref_array
}
Also used : Table(org.molgenis.emx2.Table) Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database) ArrayList(java.util.ArrayList) Row(org.molgenis.emx2.Row)

Aggregations

Test (org.junit.Test)53 CreateDatabaseMetadata (com.google.spanner.admin.database.v1.CreateDatabaseMetadata)32 Database (com.google.cloud.spanner.Database)31 ArrayList (java.util.ArrayList)25 AbstractMessage (com.google.protobuf.AbstractMessage)24 ExecutionException (java.util.concurrent.ExecutionException)22 Database (com.google.spanner.admin.database.v1.Database)21 Operation (com.google.longrunning.Operation)18 ByteString (com.google.protobuf.ByteString)16 DatabaseAdminClient (com.google.cloud.spanner.DatabaseAdminClient)13 SpannerException (com.google.cloud.spanner.SpannerException)12 Database (org.molgenis.emx2.Database)12 CreateBackupMetadata (com.google.spanner.admin.database.v1.CreateBackupMetadata)11 DatabaseName (com.google.spanner.admin.database.v1.DatabaseName)10 RestoreDatabaseMetadata (com.google.spanner.admin.database.v1.RestoreDatabaseMetadata)9 Timestamp (com.google.cloud.Timestamp)8 Spanner (com.google.cloud.spanner.Spanner)8 RestoreDatabaseRequest (com.google.spanner.admin.database.v1.RestoreDatabaseRequest)7 UpdateDatabaseDdlMetadata (com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7